@@ -9,7 +9,6 @@ import 'package:analysis_server/src/services/completion/dart/completion_state.da
99import 'package:analysis_server/src/services/completion/dart/suggestion_collector.dart' ;
1010import 'package:analyzer/dart/element/element.dart' ;
1111import 'package:analyzer/source/source_range.dart' ;
12- import 'package:analyzer/src/dart/element/inheritance_manager3.dart' ;
1312
1413/// A helper class that produces candidate suggestions for overrides of
1514/// inherited methods.
@@ -20,43 +19,34 @@ class OverrideHelper {
2019 /// The suggestion collector to which suggestions will be added.
2120 final SuggestionCollector collector;
2221
23- /// The inheritance manager used to compute the set of methods that can be
24- /// overridden.
25- final InheritanceManager3 inheritanceManager;
26-
2722 /// Initialize a newly created helper to add suggestions to the [collector] .
28- OverrideHelper ({required this .state, required this .collector})
29- : inheritanceManager = state.request.inheritanceManager;
23+ OverrideHelper ({required this .state, required this .collector});
3024
3125 void computeOverridesFor ({
3226 required InterfaceElement interfaceElement,
3327 required SourceRange replacementRange,
3428 required bool skipAt,
3529 }) {
36- var interface = inheritanceManager.getInterface2 (interfaceElement);
37- var interfaceMap = interface .map2;
38- var namesToOverride = _namesToOverride (
39- interfaceElement.library2.uri,
40- interface ,
41- );
30+ var namesToOverride = _namesToOverride (interfaceElement);
4231
43- // Build suggestions
32+ // Build suggestions.
4433 for (var name in namesToOverride) {
45- var element = interfaceMap [name];
34+ var element = interfaceElement.interfaceMembers [name];
4635 // Gracefully degrade if the overridden element has not been resolved.
4736 if (element != null ) {
4837 if (_hasNonVirtualAnnotation (element)) {
4938 continue ;
5039 }
5140
52- var invokeSuper = interface .isSuperImplemented (name);
5341 var matcherScore = math.max (
5442 math.max (
5543 state.matcher.score ('override' ),
5644 state.matcher.score ('operator' ),
5745 ),
5846 state.matcher.score (element.displayName),
5947 );
48+ var invokeSuper =
49+ interfaceElement.getInheritedConcreteMember (name) != null ;
6050 if (matcherScore != - 1 ) {
6151 collector.addSuggestion (
6252 OverrideSuggestion (
@@ -83,19 +73,26 @@ class OverrideHelper {
8373 return element.metadata2.hasNonVirtual;
8474 }
8575
86- /// Return the list of names that belong to the [interface] of a class , but
87- /// are not yet declared in the class.
88- List <Name > _namesToOverride (Uri libraryUri, Interface interface ) {
76+ /// Returns the list of names that belong to [interfaceElement] , but are not
77+ /// yet declared in the class.
78+ List <Name > _namesToOverride (InterfaceElement interfaceElement ) {
8979 var namesToOverride = < Name > [];
90- for (var name in interface .map2.keys) {
80+ var libraryUri = interfaceElement.library2.uri;
81+ var memberNames = interfaceElement.interfaceMembers.keys;
82+ for (var name in memberNames) {
9183 if (name.isAccessibleFor (libraryUri)) {
9284 // TODO(brianwilkerson): When the user is typing the name of an
9385 // inherited member, the map will contain a key matching the current
9486 // prefix. If the name is the only thing typed (that is, the field
9587 // declaration consists of a single identifier), and that identifier
9688 // matches the name of an overridden member, then the override should
9789 // still be suggested.
98- if (! interface .declared2.containsKey (name)) {
90+ var declaredElement =
91+ interfaceElement.getGetter (name.name) ??
92+ interfaceElement.getMethod (name.name) ??
93+ // `getSetter` accepts names without trailing `=` characters.
94+ interfaceElement.getSetter (name.forGetter.name);
95+ if (declaredElement == null ) {
9996 namesToOverride.add (name);
10097 }
10198 }
0 commit comments