Skip to content

Commit 381508a

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Use shard ManifestItem.match()
As discussed in https://dart-review.googlesource.com/c/sdk/+/420461, this allows having single code to match metadata. Change-Id: I495b93dead88aa63451ae7679965cb60c7bd9bae Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420521 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent b45827c commit 381508a

File tree

4 files changed

+102
-149
lines changed

4 files changed

+102
-149
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ This is part of the old analyzer element model. Please see
6464
https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/doc/element_model_migration_guide.md
6565
for information about how to migrate to the new element model.''';
6666

67+
abstract class AnnotatableElement implements Element2, Annotatable {
68+
@override
69+
MetadataImpl get metadata2;
70+
}
71+
6772
@Deprecated('This is an internal class, do not use it')
6873
// TODO(scheglov): remove it when DartDoc stops using it
6974
// https://github.com/dart-lang/dartdoc/issues/4015
@@ -3605,16 +3610,14 @@ class EnumElementImpl2 extends InterfaceElementImpl2 implements EnumElement2 {
36053610

36063611
/// Common base class for all analyzer-internal classes that implement
36073612
/// `ExecutableElement2`.
3608-
abstract class ExecutableElement2OrMember implements ExecutableElement2 {
3613+
abstract class ExecutableElement2OrMember
3614+
implements ExecutableElement2, AnnotatableElement {
36093615
@override
36103616
ExecutableElementImpl2 get baseElement;
36113617

36123618
@override
36133619
List<FormalParameterElementMixin> get formalParameters;
36143620

3615-
@override
3616-
MetadataImpl get metadata2;
3617-
36183621
@override
36193622
TypeImpl get returnType;
36203623

@@ -5724,7 +5727,7 @@ abstract class InstanceElementImpl extends _ExistingElementImpl
57245727
}
57255728

57265729
abstract class InstanceElementImpl2 extends ElementImpl2
5727-
implements InstanceElement2, TypeParameterizedElement2 {
5730+
implements InstanceElement2, TypeParameterizedElement2, AnnotatableElement {
57285731
@override
57295732
InstanceElement2 get baseElement => this;
57305733

pkg/analyzer/lib/src/fine/library_manifest.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,8 @@ class _LibraryMatch {
642642
return false;
643643
}
644644

645-
var matchContext = item.match(element);
646-
if (matchContext == null) {
645+
var matchContext = MatchContext(parent: null);
646+
if (!item.match(matchContext, element)) {
647647
return false;
648648
}
649649

@@ -685,8 +685,8 @@ class _LibraryMatch {
685685
return false;
686686
}
687687

688-
var matchContext = item.match(interfaceMatchContext, executable);
689-
if (matchContext == null) {
688+
var matchContext = MatchContext(parent: interfaceMatchContext);
689+
if (!item.match(matchContext, executable)) {
690690
return false;
691691
}
692692

@@ -699,8 +699,8 @@ class _LibraryMatch {
699699
return false;
700700
}
701701

702-
var matchContext = item.match(interfaceMatchContext, executable);
703-
if (matchContext == null) {
702+
var matchContext = MatchContext(parent: interfaceMatchContext);
703+
if (!item.match(matchContext, executable)) {
704704
return false;
705705
}
706706

@@ -752,8 +752,8 @@ class _LibraryMatch {
752752
return false;
753753
}
754754

755-
var matchContext = item.match(interfaceMatchContext, element);
756-
if (matchContext == null) {
755+
var matchContext = MatchContext(parent: interfaceMatchContext);
756+
if (!item.match(matchContext, element)) {
757757
return false;
758758
}
759759

@@ -828,8 +828,8 @@ class _LibraryMatch {
828828
return false;
829829
}
830830

831-
var matchContext = item.match(element);
832-
if (matchContext == null) {
831+
var matchContext = MatchContext(parent: null);
832+
if (!item.match(matchContext, element)) {
833833
return false;
834834
}
835835

@@ -849,8 +849,8 @@ class _LibraryMatch {
849849
return false;
850850
}
851851

852-
var matchContext = item.match(element);
853-
if (matchContext == null) {
852+
var matchContext = MatchContext(parent: null);
853+
if (!item.match(matchContext, element)) {
854854
return false;
855855
}
856856

@@ -869,8 +869,8 @@ class _LibraryMatch {
869869
return false;
870870
}
871871

872-
var matchContext = item.match(element);
873-
if (matchContext == null) {
872+
var matchContext = MatchContext(parent: null);
873+
if (!item.match(matchContext, element)) {
874874
return false;
875875
}
876876

0 commit comments

Comments
 (0)