| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.contributor.dart.keyword; | 5 library services.completion.contributor.dart.keyword; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // then the user is probably finishing that | 117 // then the user is probably finishing that |
| 118 _addImportDirectiveKeywords(previousMember); | 118 _addImportDirectiveKeywords(previousMember); |
| 119 return; | 119 return; |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 if (previousMember == null || previousMember is Directive) { | 122 if (previousMember == null || previousMember is Directive) { |
| 123 if (previousMember == null && | 123 if (previousMember == null && |
| 124 !node.directives.any((d) => d is LibraryDirective)) { | 124 !node.directives.any((d) => d is LibraryDirective)) { |
| 125 _addSuggestions([Keyword.LIBRARY], DART_RELEVANCE_HIGH); | 125 _addSuggestions([Keyword.LIBRARY], DART_RELEVANCE_HIGH); |
| 126 } | 126 } |
| 127 _addSuggestions([Keyword.EXPORT, Keyword.PART], DART_RELEVANCE_HIGH); | 127 _addSuggestions([Keyword.IMPORT, Keyword.EXPORT, Keyword.PART], DART_RELEV
ANCE_HIGH); |
| 128 _addSuggestion2("import '';", | |
| 129 offset: 8, relevance: DART_RELEVANCE_HIGH + 1); | |
| 130 _addSuggestion2("import '' as ;", | |
| 131 offset: 8, relevance: DART_RELEVANCE_HIGH); | |
| 132 _addSuggestion2("import '' hide ;", | |
| 133 offset: 8, relevance: DART_RELEVANCE_HIGH); | |
| 134 _addSuggestion2("import '' show ;", | |
| 135 offset: 8, relevance: DART_RELEVANCE_HIGH); | |
| 136 } | 128 } |
| 137 if (entity == null || entity is Declaration) { | 129 if (entity == null || entity is Declaration) { |
| 138 if (previousMember is FunctionDeclaration && | 130 if (previousMember is FunctionDeclaration && |
| 139 previousMember.functionExpression is FunctionExpression && | 131 previousMember.functionExpression is FunctionExpression && |
| 140 previousMember.functionExpression.body is EmptyFunctionBody) { | 132 previousMember.functionExpression.body is EmptyFunctionBody) { |
| 141 _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH); | 133 _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH); |
| 142 } | 134 } |
| 143 _addCompilationUnitKeywords(); | 135 _addCompilationUnitKeywords(); |
| 144 } | 136 } |
| 145 } | 137 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 _addSuggestions([Keyword.SUPER, Keyword.THIS,]); | 377 _addSuggestions([Keyword.SUPER, Keyword.THIS,]); |
| 386 } | 378 } |
| 387 if (_inAsyncMethodOrFunction(node)) { | 379 if (_inAsyncMethodOrFunction(node)) { |
| 388 _addSuggestion2(AWAIT); | 380 _addSuggestion2(AWAIT); |
| 389 } | 381 } |
| 390 _addSuggestions([ | 382 _addSuggestions([ |
| 391 Keyword.ASSERT, | 383 Keyword.ASSERT, |
| 392 Keyword.CONTINUE, | 384 Keyword.CONTINUE, |
| 393 Keyword.DO, | 385 Keyword.DO, |
| 394 Keyword.FINAL, | 386 Keyword.FINAL, |
| 395 //Keyword.FOR, | 387 Keyword.FOR, |
| 396 Keyword.IF, | 388 Keyword.IF, |
| 397 Keyword.NEW, | 389 Keyword.NEW, |
| 398 Keyword.RETURN, | 390 Keyword.RETURN, |
| 399 Keyword.SWITCH, | 391 Keyword.SWITCH, |
| 400 Keyword.THROW, | 392 Keyword.THROW, |
| 401 Keyword.TRY, | 393 Keyword.TRY, |
| 402 Keyword.VAR, | 394 Keyword.VAR, |
| 403 Keyword.VOID, | 395 Keyword.VOID, |
| 404 Keyword.WHILE | 396 Keyword.WHILE |
| 405 ]); | 397 ]); |
| 406 _addSuggestion2('for ()', offset: 5); | |
| 407 _addSuggestion(Keyword.RETHROW, DART_RELEVANCE_KEYWORD - 1); | 398 _addSuggestion(Keyword.RETHROW, DART_RELEVANCE_KEYWORD - 1); |
| 408 } | 399 } |
| 409 | 400 |
| 410 void _addSuggestion(Keyword keyword, | 401 void _addSuggestion(Keyword keyword, |
| 411 [int relevance = DART_RELEVANCE_KEYWORD]) { | 402 [int relevance = DART_RELEVANCE_KEYWORD]) { |
| 412 _addSuggestion2(keyword.syntax, relevance: relevance); | 403 _addSuggestion2(keyword.syntax, relevance: relevance); |
| 413 } | 404 } |
| 414 | 405 |
| 415 void _addSuggestion2(String completion, | 406 void _addSuggestion2(String completion, |
| 416 {int offset, int relevance: DART_RELEVANCE_KEYWORD}) { | 407 {int offset, int relevance: DART_RELEVANCE_KEYWORD}) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 441 return false; | 432 return false; |
| 442 } | 433 } |
| 443 AstNode parent = body.parent; | 434 AstNode parent = body.parent; |
| 444 if (parent is ConstructorDeclaration || parent is MethodDeclaration) { | 435 if (parent is ConstructorDeclaration || parent is MethodDeclaration) { |
| 445 return true; | 436 return true; |
| 446 } | 437 } |
| 447 node = parent; | 438 node = parent; |
| 448 } | 439 } |
| 449 } | 440 } |
| 450 } | 441 } |
| OLD | NEW |