| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return suggestions; | 54 return suggestions; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * The information about a requested list of completions within a Dart file. | 59 * The information about a requested list of completions within a Dart file. |
| 60 */ | 60 */ |
| 61 class DartCompletionRequestImpl extends CompletionRequestImpl | 61 class DartCompletionRequestImpl extends CompletionRequestImpl |
| 62 implements DartCompletionRequest { | 62 implements DartCompletionRequest { |
| 63 /** | 63 /** |
| 64 * The [LibraryElement] representing dart:core |
| 65 */ |
| 66 LibraryElement _coreLib; |
| 67 |
| 68 /** |
| 64 * The [DartType] for Object in dart:core | 69 * The [DartType] for Object in dart:core |
| 65 */ | 70 */ |
| 66 InterfaceType _objectType; | 71 InterfaceType _objectType; |
| 67 | 72 |
| 68 @override | 73 @override |
| 69 Expression dotTarget; | 74 Expression dotTarget; |
| 70 | 75 |
| 71 @override | 76 @override |
| 72 Source librarySource; | 77 Source librarySource; |
| 73 | 78 |
| 74 OpType _opType; | 79 OpType _opType; |
| 75 | 80 |
| 76 @override | 81 @override |
| 77 CompletionTarget target; | 82 CompletionTarget target; |
| 78 | 83 |
| 79 DartCompletionRequestImpl._( | 84 DartCompletionRequestImpl._( |
| 80 AnalysisContext context, | 85 AnalysisContext context, |
| 81 ResourceProvider resourceProvider, | 86 ResourceProvider resourceProvider, |
| 82 SearchEngine searchEngine, | 87 SearchEngine searchEngine, |
| 83 this.librarySource, | 88 this.librarySource, |
| 84 Source source, | 89 Source source, |
| 85 int offset, | 90 int offset, |
| 86 CompilationUnit unit) | 91 CompilationUnit unit) |
| 87 : super(context, resourceProvider, searchEngine, source, offset) { | 92 : super(context, resourceProvider, searchEngine, source, offset) { |
| 88 _updateTargets(unit); | 93 _updateTargets(unit); |
| 89 } | 94 } |
| 90 | 95 |
| 91 @override | 96 @override |
| 97 LibraryElement get coreLib { |
| 98 if (_coreLib == null) { |
| 99 Source coreUri = context.sourceFactory.forUri('dart:core'); |
| 100 _coreLib = context.computeLibraryElement(coreUri); |
| 101 } |
| 102 return _coreLib; |
| 103 } |
| 104 |
| 105 @override |
| 92 bool get includeIdentifiers { | 106 bool get includeIdentifiers { |
| 93 opType; // <<< ensure _opType is initialized | 107 opType; // <<< ensure _opType is initialized |
| 94 return !_opType.isPrefixed && | 108 return !_opType.isPrefixed && |
| 95 (_opType.includeReturnValueSuggestions || | 109 (_opType.includeReturnValueSuggestions || |
| 96 _opType.includeTypeNameSuggestions || | 110 _opType.includeTypeNameSuggestions || |
| 97 _opType.includeVoidReturnSuggestions || | 111 _opType.includeVoidReturnSuggestions || |
| 98 _opType.includeConstructorSuggestions); | 112 _opType.includeConstructorSuggestions); |
| 99 } | 113 } |
| 100 | 114 |
| 101 @override | 115 @override |
| 102 LibraryElement get libraryElement { | 116 LibraryElement get libraryElement { |
| 103 //TODO(danrubel) build the library element rather than all the declarations | 117 //TODO(danrubel) build the library element rather than all the declarations |
| 104 CompilationUnit unit = target.unit; | 118 CompilationUnit unit = target.unit; |
| 105 if (unit != null) { | 119 if (unit != null) { |
| 106 CompilationUnitElement elem = unit.element; | 120 CompilationUnitElement elem = unit.element; |
| 107 if (elem != null) { | 121 if (elem != null) { |
| 108 return elem.library; | 122 return elem.library; |
| 109 } | 123 } |
| 110 } | 124 } |
| 111 return null; | 125 return null; |
| 112 } | 126 } |
| 113 | 127 |
| 114 @override | 128 @override |
| 115 InterfaceType get objectType { | 129 InterfaceType get objectType { |
| 116 if (_objectType == null) { | 130 if (_objectType == null) { |
| 117 Source coreUri = context.sourceFactory.forUri('dart:core'); | |
| 118 LibraryElement coreLib = context.computeLibraryElement(coreUri); | |
| 119 _objectType = coreLib.getType('Object').type; | 131 _objectType = coreLib.getType('Object').type; |
| 120 } | 132 } |
| 121 return _objectType; | 133 return _objectType; |
| 122 } | 134 } |
| 123 | 135 |
| 124 OpType get opType { | 136 OpType get opType { |
| 125 if (_opType == null) { | 137 if (_opType == null) { |
| 126 _opType = new OpType.forCompletion(target, offset); | 138 _opType = new OpType.forCompletion(target, offset); |
| 127 } | 139 } |
| 128 return _opType; | 140 return _opType; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 if (dartRequest.target.maybeFunctionalArgument()) { | 261 if (dartRequest.target.maybeFunctionalArgument()) { |
| 250 AstNode node = dartRequest.target.containingNode.parent; | 262 AstNode node = dartRequest.target.containingNode.parent; |
| 251 if (node is Expression) { | 263 if (node is Expression) { |
| 252 await dartRequest.resolveExpression(node); | 264 await dartRequest.resolveExpression(node); |
| 253 } | 265 } |
| 254 } | 266 } |
| 255 | 267 |
| 256 return dartRequest; | 268 return dartRequest; |
| 257 } | 269 } |
| 258 } | 270 } |
| OLD | NEW |