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' |
11 show CompletionContributor, CompletionRequest; | 11 show CompletionContributor, CompletionRequest; |
12 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 12 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
13 import 'package:analysis_server/src/provisional/completion/dart/completion_plugi
n.dart'; | 13 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'; | 14 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; |
15 import 'package:analysis_server/src/services/completion/completion_core.dart'; | 15 import 'package:analysis_server/src/services/completion/completion_core.dart'; |
16 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; | 16 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; |
17 import 'package:analysis_server/src/services/completion/dart/common_usage_sorter
.dart'; | 17 import 'package:analysis_server/src/services/completion/dart/common_usage_sorter
.dart'; |
18 import 'package:analysis_server/src/services/completion/dart/contribution_sorter
.dart'; | 18 import 'package:analysis_server/src/services/completion/dart/contribution_sorter
.dart'; |
19 import 'package:analysis_server/src/services/completion/dart/optype.dart'; | 19 import 'package:analysis_server/src/services/completion/dart/optype.dart'; |
20 import 'package:analysis_server/src/services/search/search_engine.dart'; | 20 import 'package:analysis_server/src/services/search/search_engine.dart'; |
21 import 'package:analyzer/dart/ast/ast.dart'; | 21 import 'package:analyzer/dart/ast/ast.dart'; |
| 22 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
22 import 'package:analyzer/dart/ast/token.dart'; | 23 import 'package:analyzer/dart/ast/token.dart'; |
23 import 'package:analyzer/dart/element/element.dart'; | 24 import 'package:analyzer/dart/element/element.dart'; |
24 import 'package:analyzer/dart/element/type.dart'; | 25 import 'package:analyzer/dart/element/type.dart'; |
25 import 'package:analyzer/exception/exception.dart'; | 26 import 'package:analyzer/exception/exception.dart'; |
26 import 'package:analyzer/file_system/file_system.dart'; | 27 import 'package:analyzer/file_system/file_system.dart'; |
27 import 'package:analyzer/src/context/context.dart' show AnalysisFutureHelper; | 28 import 'package:analyzer/src/context/context.dart' show AnalysisFutureHelper; |
28 import 'package:analyzer/src/dart/analysis/driver.dart'; | 29 import 'package:analyzer/src/dart/analysis/driver.dart'; |
29 import 'package:analyzer/src/dart/ast/token.dart'; | 30 import 'package:analyzer/src/dart/ast/token.dart'; |
30 import 'package:analyzer/src/generated/engine.dart' hide AnalysisResult; | 31 import 'package:analyzer/src/generated/engine.dart' hide AnalysisResult; |
31 import 'package:analyzer/src/generated/source.dart'; | 32 import 'package:analyzer/src/generated/source.dart'; |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 // then check the previous token to see if it should be replaced | 510 // then check the previous token to see if it should be replaced |
510 token = token.previous; | 511 token = token.previous; |
511 } | 512 } |
512 if (token != null && isKeywordOrIdentifier(token)) { | 513 if (token != null && isKeywordOrIdentifier(token)) { |
513 if (token.offset <= requestOffset && requestOffset <= token.end) { | 514 if (token.offset <= requestOffset && requestOffset <= token.end) { |
514 // Replacement range for typical identifier completion | 515 // Replacement range for typical identifier completion |
515 return new ReplacementRange(token.offset, token.length); | 516 return new ReplacementRange(token.offset, token.length); |
516 } | 517 } |
517 } | 518 } |
518 if (token is StringToken) { | 519 if (token is StringToken) { |
519 SimpleStringLiteral uri = new SimpleStringLiteral(token, token.lexeme); | 520 SimpleStringLiteral uri = |
| 521 astFactory.simpleStringLiteral(token, token.lexeme); |
520 Keyword keyword = token.previous?.keyword; | 522 Keyword keyword = token.previous?.keyword; |
521 if (keyword == Keyword.IMPORT || | 523 if (keyword == Keyword.IMPORT || |
522 keyword == Keyword.EXPORT || | 524 keyword == Keyword.EXPORT || |
523 keyword == Keyword.PART) { | 525 keyword == Keyword.PART) { |
524 int start = uri.contentsOffset; | 526 int start = uri.contentsOffset; |
525 var end = uri.contentsEnd; | 527 var end = uri.contentsEnd; |
526 if (start <= requestOffset && requestOffset <= end) { | 528 if (start <= requestOffset && requestOffset <= end) { |
527 // Replacement range for import URI | 529 // Replacement range for import URI |
528 return new ReplacementRange(start, end - start); | 530 return new ReplacementRange(start, end - start); |
529 } | 531 } |
530 } | 532 } |
531 } | 533 } |
532 } | 534 } |
533 return new ReplacementRange(requestOffset, 0); | 535 return new ReplacementRange(requestOffset, 0); |
534 } | 536 } |
535 } | 537 } |
OLD | NEW |