OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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/ide_options.dart'; | |
8 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 7 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
9 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; | 8 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; |
10 import 'package:analysis_server/src/services/completion/dart/optype.dart'; | 9 import 'package:analysis_server/src/services/completion/dart/optype.dart'; |
11 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.
dart'; | 10 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.
dart'; |
12 import 'package:analyzer/dart/ast/ast.dart'; | 11 import 'package:analyzer/dart/ast/ast.dart'; |
13 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 12 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
14 import 'package:analyzer/dart/element/element.dart'; | 13 import 'package:analyzer/dart/element/element.dart'; |
15 import 'package:analyzer/dart/element/type.dart'; | 14 import 'package:analyzer/dart/element/type.dart'; |
16 | 15 |
17 import '../../../protocol_server.dart' | 16 import '../../../protocol_server.dart' |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 {bool skipChildClass: true}) { | 74 {bool skipChildClass: true}) { |
76 if (!request.includeIdentifiers) { | 75 if (!request.includeIdentifiers) { |
77 return EMPTY_LIST; | 76 return EMPTY_LIST; |
78 } | 77 } |
79 containingLibrary = request.libraryElement; | 78 containingLibrary = request.libraryElement; |
80 | 79 |
81 return _computeSuggestionsForClass2(classElement, request, | 80 return _computeSuggestionsForClass2(classElement, request, |
82 skipChildClass: skipChildClass); | 81 skipChildClass: skipChildClass); |
83 } | 82 } |
84 | 83 |
85 _addSuggestionsForType( | 84 _addSuggestionsForType(InterfaceType type, OpType optype, |
86 InterfaceType type, OpType optype, IdeOptions ideOptions, | |
87 {bool isFunctionalArgument: false}) { | 85 {bool isFunctionalArgument: false}) { |
88 if (!isFunctionalArgument) { | 86 if (!isFunctionalArgument) { |
89 for (PropertyAccessorElement elem in type.accessors) { | 87 for (PropertyAccessorElement elem in type.accessors) { |
90 if (elem.isGetter) { | 88 if (elem.isGetter) { |
91 if (optype.includeReturnValueSuggestions) { | 89 if (optype.includeReturnValueSuggestions) { |
92 addSuggestion(elem, ideOptions); | 90 addSuggestion(elem); |
93 } | 91 } |
94 } else { | 92 } else { |
95 if (optype.includeVoidReturnSuggestions) { | 93 if (optype.includeVoidReturnSuggestions) { |
96 addSuggestion(elem, ideOptions); | 94 addSuggestion(elem); |
97 } | 95 } |
98 } | 96 } |
99 } | 97 } |
100 } | 98 } |
101 for (MethodElement elem in type.methods) { | 99 for (MethodElement elem in type.methods) { |
102 if (elem.returnType == null) { | 100 if (elem.returnType == null) { |
103 addSuggestion(elem, ideOptions); | 101 addSuggestion(elem); |
104 } else if (!elem.returnType.isVoid) { | 102 } else if (!elem.returnType.isVoid) { |
105 if (optype.includeReturnValueSuggestions) { | 103 if (optype.includeReturnValueSuggestions) { |
106 addSuggestion(elem, ideOptions); | 104 addSuggestion(elem); |
107 } | 105 } |
108 } else { | 106 } else { |
109 if (optype.includeVoidReturnSuggestions) { | 107 if (optype.includeVoidReturnSuggestions) { |
110 addSuggestion(elem, ideOptions); | 108 addSuggestion(elem); |
111 } | 109 } |
112 } | 110 } |
113 } | 111 } |
114 } | 112 } |
115 | 113 |
116 List<CompletionSuggestion> _computeSuggestionsForClass2( | 114 List<CompletionSuggestion> _computeSuggestionsForClass2( |
117 ClassElement classElement, DartCompletionRequest request, | 115 ClassElement classElement, DartCompletionRequest request, |
118 {bool skipChildClass: true}) { | 116 {bool skipChildClass: true}) { |
119 bool isFunctionalArgument = request.target.isFunctionalArgument(); | 117 bool isFunctionalArgument = request.target.isFunctionalArgument(); |
120 kind = isFunctionalArgument | 118 kind = isFunctionalArgument |
121 ? CompletionSuggestionKind.IDENTIFIER | 119 ? CompletionSuggestionKind.IDENTIFIER |
122 : CompletionSuggestionKind.INVOCATION; | 120 : CompletionSuggestionKind.INVOCATION; |
123 OpType optype = request.opType; | 121 OpType optype = request.opType; |
124 | 122 |
125 if (!skipChildClass) { | 123 if (!skipChildClass) { |
126 _addSuggestionsForType(classElement.type, optype, request.ideOptions, | 124 _addSuggestionsForType(classElement.type, optype, |
127 isFunctionalArgument: isFunctionalArgument); | 125 isFunctionalArgument: isFunctionalArgument); |
128 } | 126 } |
129 | 127 |
130 for (InterfaceType type in classElement.allSupertypes) { | 128 for (InterfaceType type in classElement.allSupertypes) { |
131 _addSuggestionsForType(type, optype, request.ideOptions, | 129 _addSuggestionsForType(type, optype, |
132 isFunctionalArgument: isFunctionalArgument); | 130 isFunctionalArgument: isFunctionalArgument); |
133 } | 131 } |
134 return suggestions; | 132 return suggestions; |
135 } | 133 } |
136 } | 134 } |
OLD | NEW |