| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.
dart'; | |
| 8 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 9 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 11 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| 11 import 'package:analyzer/file_system/file_system.dart'; |
| 12 import 'package:analyzer_plugin/protocol/protocol_common.dart' hide Element; | 12 import 'package:analyzer_plugin/protocol/protocol_common.dart' hide Element; |
| 13 import 'package:analyzer_plugin/src/utilities/completion/completion_target.dart'
; | 13 import 'package:analyzer_plugin/src/utilities/completion/completion_target.dart'
; |
| 14 import 'package:analyzer_plugin/src/utilities/completion/element_suggestion_buil
der.dart'; |
| 14 import 'package:analyzer_plugin/src/utilities/completion/optype.dart'; | 15 import 'package:analyzer_plugin/src/utilities/completion/optype.dart'; |
| 15 import 'package:analyzer_plugin/utilities/completion/completion_core.dart'; | 16 import 'package:analyzer_plugin/utilities/completion/completion_core.dart'; |
| 16 | 17 |
| 17 /** | 18 /** |
| 18 * A contributor for calculating suggestions for inherited references. | 19 * A contributor for calculating suggestions for inherited references. |
| 19 */ | 20 */ |
| 20 class InheritedReferenceContributor extends Object | 21 class InheritedReferenceContributor extends Object |
| 21 with ElementSuggestionBuilder | 22 with ElementSuggestionBuilder |
| 22 implements CompletionContributor { | 23 implements CompletionContributor { |
| 23 @override | 24 @override |
| 24 LibraryElement containingLibrary; | 25 LibraryElement containingLibrary; |
| 25 | 26 |
| 26 @override | 27 @override |
| 27 CompletionSuggestionKind kind; | 28 CompletionSuggestionKind kind; |
| 28 | 29 |
| 29 @override | 30 @override |
| 31 ResourceProvider resourceProvider; |
| 32 |
| 33 @override |
| 30 Future<Null> computeSuggestions( | 34 Future<Null> computeSuggestions( |
| 31 CompletionRequest request, CompletionCollector collector) async { | 35 CompletionRequest request, CompletionCollector collector) async { |
| 32 CompletionTarget target = | 36 CompletionTarget target = |
| 33 new CompletionTarget.forOffset(request.result.unit, request.offset); | 37 new CompletionTarget.forOffset(request.result.unit, request.offset); |
| 34 OpType optype = new OpType.forCompletion(target, request.offset); | 38 OpType optype = new OpType.forCompletion(target, request.offset); |
| 35 if (!optype.includeIdentifiers) { | 39 if (!optype.includeIdentifiers) { |
| 36 return; | 40 return; |
| 37 } | 41 } |
| 38 ClassDeclaration classDecl = _enclosingClass(target); | 42 ClassDeclaration classDecl = _enclosingClass(target); |
| 39 if (classDecl == null || classDecl.element == null) { | 43 if (classDecl == null || classDecl.element == null) { |
| 40 return; | 44 return; |
| 41 } | 45 } |
| 42 containingLibrary = request.result.libraryElement; | 46 containingLibrary = request.result.libraryElement; |
| 43 _computeSuggestionsForClass2( | 47 _computeSuggestionsForClass2( |
| 44 collector, | 48 collector, |
| 45 target, | 49 target, |
| 46 resolutionMap.elementDeclaredByClassDeclaration(classDecl), | 50 resolutionMap.elementDeclaredByClassDeclaration(classDecl), |
| 47 request, | 51 request, |
| 48 optype); | 52 optype); |
| 49 } | 53 } |
| 50 | 54 |
| 51 List<CompletionSuggestion> computeSuggestionsForClass( | |
| 52 CompletionCollector collector, | |
| 53 ClassElement classElement, | |
| 54 CompletionRequest request, | |
| 55 {bool skipChildClass: true}) { | |
| 56 // if (!request.includeIdentifiers) { | |
| 57 // return const <CompletionSuggestion>[]; | |
| 58 // } | |
| 59 // containingLibrary = request.result.libraryElement; | |
| 60 // | |
| 61 // return _computeSuggestionsForClass2(collector, classElement, request, | |
| 62 // skipChildClass: skipChildClass); | |
| 63 throw new StateError('Unexpected invocation of computeSuggestionsForClass'); | |
| 64 } | |
| 65 | |
| 66 _addSuggestionsForType(InterfaceType type, OpType optype, | 55 _addSuggestionsForType(InterfaceType type, OpType optype, |
| 67 {bool isFunctionalArgument: false}) { | 56 {bool isFunctionalArgument: false}) { |
| 68 if (!isFunctionalArgument) { | 57 if (!isFunctionalArgument) { |
| 69 for (PropertyAccessorElement elem in type.accessors) { | 58 for (PropertyAccessorElement elem in type.accessors) { |
| 70 if (elem.isGetter) { | 59 if (elem.isGetter) { |
| 71 if (optype.includeReturnValueSuggestions) { | 60 if (optype.includeReturnValueSuggestions) { |
| 72 addSuggestion(elem); | 61 addSuggestion(elem); |
| 73 } | 62 } |
| 74 } else { | 63 } else { |
| 75 if (optype.includeVoidReturnSuggestions) { | 64 if (optype.includeVoidReturnSuggestions) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 if (node is FieldDeclaration) { | 127 if (node is FieldDeclaration) { |
| 139 if (node.isStatic) { | 128 if (node.isStatic) { |
| 140 return null; | 129 return null; |
| 141 } | 130 } |
| 142 } | 131 } |
| 143 node = node.parent; | 132 node = node.parent; |
| 144 } | 133 } |
| 145 return null; | 134 return null; |
| 146 } | 135 } |
| 147 } | 136 } |
| OLD | NEW |