| 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/ide_options.dart'; |
| 10 import 'package:analysis_server/src/provisional/completion/completion_core.dart' | 11 import 'package:analysis_server/src/provisional/completion/completion_core.dart' |
| 11 show CompletionContributor, CompletionRequest; | 12 show CompletionContributor, CompletionRequest; |
| 12 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 13 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
| 13 import 'package:analysis_server/src/provisional/completion/dart/completion_plugi
n.dart'; | 14 import 'package:analysis_server/src/provisional/completion/dart/completion_plugi
n.dart'; |
| 14 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; | 15 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; |
| 15 import 'package:analysis_server/src/services/completion/completion_core.dart'; | 16 import 'package:analysis_server/src/services/completion/completion_core.dart'; |
| 16 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; | 17 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; |
| 17 import 'package:analysis_server/src/services/completion/dart/common_usage_sorter
.dart'; | 18 import 'package:analysis_server/src/services/completion/dart/common_usage_sorter
.dart'; |
| 18 import 'package:analysis_server/src/services/completion/dart/contribution_sorter
.dart'; | 19 import 'package:analysis_server/src/services/completion/dart/contribution_sorter
.dart'; |
| 19 import 'package:analysis_server/src/services/completion/dart/optype.dart'; | 20 import 'package:analysis_server/src/services/completion/dart/optype.dart'; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 * The information about a requested list of completions within a Dart file. | 109 * The information about a requested list of completions within a Dart file. |
| 109 */ | 110 */ |
| 110 class DartCompletionRequestImpl implements DartCompletionRequest { | 111 class DartCompletionRequestImpl implements DartCompletionRequest { |
| 111 @override | 112 @override |
| 112 final AnalysisResult result; | 113 final AnalysisResult result; |
| 113 | 114 |
| 114 @override | 115 @override |
| 115 final AnalysisContext context; | 116 final AnalysisContext context; |
| 116 | 117 |
| 117 @override | 118 @override |
| 119 IdeOptions ideOptions; |
| 120 |
| 121 @override |
| 118 final Source source; | 122 final Source source; |
| 119 | 123 |
| 120 @override | 124 @override |
| 121 final int offset; | 125 final int offset; |
| 122 | 126 |
| 123 @override | 127 @override |
| 124 Expression dotTarget; | 128 Expression dotTarget; |
| 125 | 129 |
| 126 @override | 130 @override |
| 127 Source librarySource; | 131 Source librarySource; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 DartCompletionRequestImpl._( | 170 DartCompletionRequestImpl._( |
| 167 this.result, | 171 this.result, |
| 168 this.context, | 172 this.context, |
| 169 this.resourceProvider, | 173 this.resourceProvider, |
| 170 this.searchEngine, | 174 this.searchEngine, |
| 171 this.librarySource, | 175 this.librarySource, |
| 172 this.source, | 176 this.source, |
| 173 this.offset, | 177 this.offset, |
| 174 CompilationUnit unit, | 178 CompilationUnit unit, |
| 175 this._originalRequest, | 179 this._originalRequest, |
| 176 this.performance) { | 180 this.performance, |
| 181 this.ideOptions) { |
| 177 _updateTargets(unit); | 182 _updateTargets(unit); |
| 178 } | 183 } |
| 179 | 184 |
| 180 @override | 185 @override |
| 181 LibraryElement get coreLib { | 186 LibraryElement get coreLib { |
| 182 if (result != null) { | 187 if (result != null) { |
| 183 AnalysisContext context = | 188 AnalysisContext context = |
| 184 resolutionMap.elementDeclaredByCompilationUnit(result.unit).context; | 189 resolutionMap.elementDeclaredByCompilationUnit(result.unit).context; |
| 185 _coreLib = context.typeProvider.objectType.element.library; | 190 _coreLib = context.typeProvider.objectType.element.library; |
| 186 } else { | 191 } else { |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 DartCompletionRequestImpl dartRequest = new DartCompletionRequestImpl._( | 444 DartCompletionRequestImpl dartRequest = new DartCompletionRequestImpl._( |
| 440 request.result, | 445 request.result, |
| 441 request.context, | 446 request.context, |
| 442 request.resourceProvider, | 447 request.resourceProvider, |
| 443 request.searchEngine, | 448 request.searchEngine, |
| 444 libSource, | 449 libSource, |
| 445 request.source, | 450 request.source, |
| 446 request.offset, | 451 request.offset, |
| 447 unit, | 452 unit, |
| 448 request, | 453 request, |
| 449 performance); | 454 performance, |
| 455 request.ideOptions); |
| 450 | 456 |
| 451 // Resolve the expression in which the completion occurs | 457 // Resolve the expression in which the completion occurs |
| 452 // to properly determine if identifiers should be suggested | 458 // to properly determine if identifiers should be suggested |
| 453 // rather than invocations. | 459 // rather than invocations. |
| 454 if (dartRequest.target.maybeFunctionalArgument()) { | 460 if (dartRequest.target.maybeFunctionalArgument()) { |
| 455 AstNode node = dartRequest.target.containingNode.parent; | 461 AstNode node = dartRequest.target.containingNode.parent; |
| 456 if (node is Expression) { | 462 if (node is Expression) { |
| 457 const FUNCTIONAL_ARG_TAG = 'resolve expression for isFunctionalArg'; | 463 const FUNCTIONAL_ARG_TAG = 'resolve expression for isFunctionalArg'; |
| 458 performance.logStartTime(FUNCTIONAL_ARG_TAG); | 464 performance.logStartTime(FUNCTIONAL_ARG_TAG); |
| 459 await dartRequest.resolveContainingExpression(node); | 465 await dartRequest.resolveContainingExpression(node); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 if (start <= requestOffset && requestOffset <= end) { | 544 if (start <= requestOffset && requestOffset <= end) { |
| 539 // Replacement range for import URI | 545 // Replacement range for import URI |
| 540 return new ReplacementRange(start, end - start); | 546 return new ReplacementRange(start, end - start); |
| 541 } | 547 } |
| 542 } | 548 } |
| 543 } | 549 } |
| 544 } | 550 } |
| 545 return new ReplacementRange(requestOffset, 0); | 551 return new ReplacementRange(requestOffset, 0); |
| 546 } | 552 } |
| 547 } | 553 } |
| OLD | NEW |