OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library services.completion.dart.manager; | 5 library services.completion.dart.manager; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
10 import 'package:analysis_server/src/provisional/completion/completion_core.dart' | 10 import 'package:analysis_server/src/provisional/completion/completion_core.dart' |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 @override | 112 @override |
113 Source librarySource; | 113 Source librarySource; |
114 | 114 |
115 OpType _opType; | 115 OpType _opType; |
116 | 116 |
117 @override | 117 @override |
118 CompletionTarget target; | 118 CompletionTarget target; |
119 | 119 |
120 @override | 120 @override |
121 bool get includeIdentifiers { | 121 bool get includeIdentifiers { |
122 if (_opType == null) { | 122 opType; // <<< ensure _opType is initialized |
123 _opType = new OpType.forCompletion(target, offset); | |
124 } | |
125 return !_opType.isPrefixed && | 123 return !_opType.isPrefixed && |
126 (_opType.includeReturnValueSuggestions || | 124 (_opType.includeReturnValueSuggestions || |
127 _opType.includeTypeNameSuggestions || | 125 _opType.includeTypeNameSuggestions || |
128 _opType.includeVoidReturnSuggestions || | 126 _opType.includeVoidReturnSuggestions || |
129 _opType.includeConstructorSuggestions); | 127 _opType.includeConstructorSuggestions); |
130 } | 128 } |
131 | 129 |
132 @override | 130 @override |
133 LibraryElement get libraryElement { | 131 LibraryElement get libraryElement { |
134 //TODO(danrubel) build the library element rather than all the declarations | 132 //TODO(danrubel) build the library element rather than all the declarations |
(...skipping 10 matching lines...) Expand all Loading... |
145 @override | 143 @override |
146 InterfaceType get objectType { | 144 InterfaceType get objectType { |
147 if (_objectType == null) { | 145 if (_objectType == null) { |
148 Source coreUri = context.sourceFactory.forUri('dart:core'); | 146 Source coreUri = context.sourceFactory.forUri('dart:core'); |
149 LibraryElement coreLib = context.getLibraryElement(coreUri); | 147 LibraryElement coreLib = context.getLibraryElement(coreUri); |
150 _objectType = coreLib.getType('Object').type; | 148 _objectType = coreLib.getType('Object').type; |
151 } | 149 } |
152 return _objectType; | 150 return _objectType; |
153 } | 151 } |
154 | 152 |
| 153 // For internal use only |
| 154 OpType get opType { |
| 155 if (_opType == null) { |
| 156 _opType = new OpType.forCompletion(target, offset); |
| 157 } |
| 158 return _opType; |
| 159 } |
| 160 |
155 @override | 161 @override |
156 Future<List<Directive>> resolveDirectives() async { | 162 Future<List<Directive>> resolveDirectives() async { |
157 CompilationUnit libUnit; | 163 CompilationUnit libUnit; |
158 if (librarySource == source) { | 164 if (librarySource == source) { |
159 libUnit = target.unit; | 165 libUnit = target.unit; |
160 } else if (librarySource != null) { | 166 } else if (librarySource != null) { |
161 // TODO(danrubel) only resolve the directives | 167 // TODO(danrubel) only resolve the directives |
162 libUnit = await new AnalysisFutureHelper<CompilationUnit>( | 168 libUnit = await new AnalysisFutureHelper<CompilationUnit>( |
163 context, | 169 context, |
164 new LibrarySpecificUnit(librarySource, librarySource), | 170 new LibrarySpecificUnit(librarySource, librarySource), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 dotTarget = node.realTarget; | 229 dotTarget = node.realTarget; |
224 } | 230 } |
225 } | 231 } |
226 if (node is PrefixedIdentifier) { | 232 if (node is PrefixedIdentifier) { |
227 if (identical(node.identifier, target.entity)) { | 233 if (identical(node.identifier, target.entity)) { |
228 dotTarget = node.prefix; | 234 dotTarget = node.prefix; |
229 } | 235 } |
230 } | 236 } |
231 } | 237 } |
232 } | 238 } |
OLD | NEW |