Skip to content

Commit c6722fc

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Rename / deprecate ClassElement.isXyzIn
Change-Id: I5ebc171cd8de04526cdde35f4140635f6bea7edd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428845 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 0da8837 commit c6722fc

File tree

6 files changed

+49
-12
lines changed

6 files changed

+49
-12
lines changed

pkg/analysis_server/lib/src/cider/local_library_contributor.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ class LibraryElementSuggestionBuilder
6262
void visitClassElement(ClassElement element) {
6363
AstNode node = request.target.containingNode;
6464
var libraryElement = request.libraryElement;
65-
if (node is ExtendsClause && !element.isExtendableIn2(libraryElement)) {
65+
if (node is ExtendsClause && !element.isExtendableIn(libraryElement)) {
6666
return;
6767
} else if (node is ImplementsClause &&
68-
!element.isImplementableIn2(libraryElement)) {
68+
!element.isImplementableIn(libraryElement)) {
6969
return;
70-
} else if (node is WithClause && !element.isMixableIn2(libraryElement)) {
70+
} else if (node is WithClause && !element.isMixableIn(libraryElement)) {
7171
return;
7272
}
7373
_visitInterfaceElement(element);

pkg/analysis_server/lib/src/services/completion/dart/declaration_helper.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,10 +1672,10 @@ class DeclarationHelper {
16721672
void _suggestClass(ClassElement element, ImportData? importData) {
16731673
if (visibilityTracker.isVisible(element: element, importData: importData)) {
16741674
if ((mustBeExtendable &&
1675-
!element.isExtendableIn2(request.libraryElement)) ||
1675+
!element.isExtendableIn(request.libraryElement)) ||
16761676
(mustBeImplementable &&
1677-
!element.isImplementableIn2(request.libraryElement)) ||
1678-
(mustBeMixable && !element.isMixableIn2(request.libraryElement))) {
1677+
!element.isImplementableIn(request.libraryElement)) ||
1678+
(mustBeMixable && !element.isMixableIn(request.libraryElement))) {
16791679
return;
16801680
}
16811681
if (!(mustBeConstant && !objectPatternAllowed) && !excludeTypeNames) {

pkg/analyzer/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
This allows the analyzer to have an internal implementation
1818
class corresponding to `ElementDirective`.
1919
* Deprecate `NamedType.name2`, use `name` instead.
20+
* Deprecate `ClassElement.isXyzIn2`, use `isXyzIn` instead.
2021

2122
## 7.4.1
2223
* Restore `InstanceElement.augmented` getter.

pkg/analyzer/api.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,9 +2999,12 @@ package:analyzer/dart/element/element.dart:
29992999
isMixinClass (getter: bool)
30003000
isSealed (getter: bool)
30013001
isValidMixin (getter: bool)
3002-
isExtendableIn2 (method: bool Function(LibraryElement))
3003-
isImplementableIn2 (method: bool Function(LibraryElement))
3004-
isMixableIn2 (method: bool Function(LibraryElement))
3002+
isExtendableIn (method: bool Function(LibraryElement))
3003+
isExtendableIn2 (method: bool Function(LibraryElement), deprecated)
3004+
isImplementableIn (method: bool Function(LibraryElement))
3005+
isImplementableIn2 (method: bool Function(LibraryElement), deprecated)
3006+
isMixableIn (method: bool Function(LibraryElement))
3007+
isMixableIn2 (method: bool Function(LibraryElement), deprecated)
30053008
ClassFragment (class extends Object implements InterfaceFragment):
30063009
new (constructor: ClassFragment Function())
30073010
element (getter: ClassElement)

pkg/analyzer/lib/dart/element/element.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,29 @@ abstract class ClassElement implements InterfaceElement {
309309

310310
/// Whether the class, assuming that it is within scope, can be extended by
311311
/// classes in the given [library].
312+
bool isExtendableIn(LibraryElement library);
313+
314+
/// Whether the class, assuming that it is within scope, can be extended by
315+
/// classes in the given [library].
316+
@Deprecated('Use isExtendableIn instead')
312317
bool isExtendableIn2(LibraryElement library);
313318

314319
/// Whether the class, assuming that it is within scope, can be implemented by
315320
/// classes, mixins, and enums in the given [library].
321+
bool isImplementableIn(LibraryElement library);
322+
323+
/// Whether the class, assuming that it is within scope, can be implemented by
324+
/// classes, mixins, and enums in the given [library].
325+
@Deprecated('Use isImplementableIn instead')
316326
bool isImplementableIn2(LibraryElement library);
317327

318328
/// Whether the class, assuming that it is within scope, can be mixed-in by
319329
/// classes and enums in the given [library].
330+
bool isMixableIn(LibraryElement library);
331+
332+
/// Whether the class, assuming that it is within scope, can be mixed-in by
333+
/// classes and enums in the given [library].
334+
@Deprecated('Use isMixableIn instead')
320335
bool isMixableIn2(LibraryElement library);
321336
}
322337

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,32 +360,50 @@ class ClassElementImpl2 extends InterfaceElementImpl2 implements ClassElement {
360360

361361
@override
362362
@trackedIndirectly
363-
bool isExtendableIn2(LibraryElement library) {
363+
bool isExtendableIn(LibraryElement library) {
364364
if (library == library2) {
365365
return true;
366366
}
367367
return !isInterface && !isFinal && !isSealed;
368368
}
369369

370+
@Deprecated('Use isExtendableIn instead')
371+
@override
372+
bool isExtendableIn2(LibraryElement library) {
373+
return isExtendableIn(library);
374+
}
375+
370376
@override
371377
@trackedIndirectly
372-
bool isImplementableIn2(LibraryElement library) {
378+
bool isImplementableIn(LibraryElement library) {
373379
if (library == library2) {
374380
return true;
375381
}
376382
return !isBase && !isFinal && !isSealed;
377383
}
378384

385+
@Deprecated('Use isImplementableIn instead')
386+
@override
387+
bool isImplementableIn2(LibraryElement library) {
388+
return isImplementableIn(library);
389+
}
390+
379391
@override
380392
@trackedIndirectly
381-
bool isMixableIn2(LibraryElement library) {
393+
bool isMixableIn(LibraryElement library) {
382394
if (library == library2) {
383395
return true;
384396
} else if (library2.featureSet.isEnabled(Feature.class_modifiers)) {
385397
return isMixinClass && !isInterface && !isFinal && !isSealed;
386398
}
387399
return true;
388400
}
401+
402+
@Deprecated('Use isMixableIn instead')
403+
@override
404+
bool isMixableIn2(LibraryElement library) {
405+
return isMixableIn(library);
406+
}
389407
}
390408

391409
/// An [InterfaceFragmentImpl] which is a class.

0 commit comments

Comments
 (0)