| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 this.source, | 170 this.source, |
| 171 this.offset, | 171 this.offset, |
| 172 CompilationUnit unit, | 172 CompilationUnit unit, |
| 173 this._originalRequest, | 173 this._originalRequest, |
| 174 this.performance) { | 174 this.performance) { |
| 175 _updateTargets(unit); | 175 _updateTargets(unit); |
| 176 } | 176 } |
| 177 | 177 |
| 178 @override | 178 @override |
| 179 LibraryElement get coreLib { | 179 LibraryElement get coreLib { |
| 180 if (_coreLib == null) { | 180 if (result != null) { |
| 181 Source coreUri = context.sourceFactory.forUri('dart:core'); | 181 AnalysisContext context = result.unit.element.context; |
| 182 _coreLib = context.typeProvider.objectType.element.library; |
| 183 } else { |
| 184 Source coreUri = sourceFactory.forUri('dart:core'); |
| 182 _coreLib = context.computeLibraryElement(coreUri); | 185 _coreLib = context.computeLibraryElement(coreUri); |
| 183 } | 186 } |
| 184 return _coreLib; | 187 return _coreLib; |
| 185 } | 188 } |
| 186 | 189 |
| 187 @override | 190 @override |
| 188 bool get includeIdentifiers { | 191 bool get includeIdentifiers { |
| 189 opType; // <<< ensure _opType is initialized | 192 opType; // <<< ensure _opType is initialized |
| 190 return !_opType.isPrefixed && | 193 return !_opType.isPrefixed && |
| 191 (_opType.includeReturnValueSuggestions || | 194 (_opType.includeReturnValueSuggestions || |
| (...skipping 23 matching lines...) Expand all Loading... |
| 215 return _objectType; | 218 return _objectType; |
| 216 } | 219 } |
| 217 | 220 |
| 218 OpType get opType { | 221 OpType get opType { |
| 219 if (_opType == null) { | 222 if (_opType == null) { |
| 220 _opType = new OpType.forCompletion(target, offset); | 223 _opType = new OpType.forCompletion(target, offset); |
| 221 } | 224 } |
| 222 return _opType; | 225 return _opType; |
| 223 } | 226 } |
| 224 | 227 |
| 228 @override |
| 229 SourceFactory get sourceFactory { |
| 230 return context?.sourceFactory ?? result.sourceFactory; |
| 231 } |
| 232 |
| 225 /** | 233 /** |
| 226 * Throw [AbortCompletion] if the completion request has been aborted. | 234 * Throw [AbortCompletion] if the completion request has been aborted. |
| 227 */ | 235 */ |
| 228 void checkAborted() { | 236 void checkAborted() { |
| 229 _originalRequest.checkAborted(); | 237 _originalRequest.checkAborted(); |
| 230 } | 238 } |
| 231 | 239 |
| 232 @override | 240 @override |
| 233 Future resolveContainingExpression(AstNode node) async { | 241 Future resolveContainingExpression(AstNode node) async { |
| 234 // TODO When an Expression can be resolved instead of just an entire unit, | 242 // TODO When an Expression can be resolved instead of just an entire unit, |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 if (start <= requestOffset && requestOffset <= end) { | 523 if (start <= requestOffset && requestOffset <= end) { |
| 516 // Replacement range for import URI | 524 // Replacement range for import URI |
| 517 return new ReplacementRange(start, end - start); | 525 return new ReplacementRange(start, end - start); |
| 518 } | 526 } |
| 519 } | 527 } |
| 520 } | 528 } |
| 521 } | 529 } |
| 522 return new ReplacementRange(requestOffset, 0); | 530 return new ReplacementRange(requestOffset, 0); |
| 523 } | 531 } |
| 524 } | 532 } |
| OLD | NEW |