| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 if (previousMember is ClassDeclaration) { | 100 if (previousMember is ClassDeclaration) { |
| 101 if (previousMember.leftBracket == null || | 101 if (previousMember.leftBracket == null || |
| 102 previousMember.leftBracket.isSynthetic) { | 102 previousMember.leftBracket.isSynthetic) { |
| 103 // If the prior member is an unfinished class declaration | 103 // If the prior member is an unfinished class declaration |
| 104 // then the user is probably finishing that | 104 // then the user is probably finishing that |
| 105 _addClassDeclarationKeywords(previousMember); | 105 _addClassDeclarationKeywords(previousMember); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 if (previousMember is ImportDirective) { | 109 if (previousMember is ImportDirective) { |
| 110 if (previousMember.semicolon == null || previousMember.semicolon.isSynthet
ic) { | 110 if (previousMember.semicolon == null || |
| 111 previousMember.semicolon.isSynthetic) { |
| 111 // If the prior member is an unfinished import directive | 112 // If the prior member is an unfinished import directive |
| 112 // then the user is probably finishing that | 113 // then the user is probably finishing that |
| 113 _addImportDirectiveKeywords(previousMember); | 114 _addImportDirectiveKeywords(previousMember); |
| 114 return; | 115 return; |
| 115 } | 116 } |
| 116 } | 117 } |
| 117 if (previousMember == null || previousMember is Directive) { | 118 if (previousMember == null || previousMember is Directive) { |
| 118 if (previousMember == null && | 119 if (previousMember == null && |
| 119 !node.directives.any((d) => d is LibraryDirective)) { | 120 !node.directives.any((d) => d is LibraryDirective)) { |
| 120 _addSuggestions([Keyword.LIBRARY], DART_RELEVANCE_HIGH); | 121 _addSuggestions([Keyword.LIBRARY], DART_RELEVANCE_HIGH); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 136 } | 137 } |
| 137 } | 138 } |
| 138 | 139 |
| 139 @override | 140 @override |
| 140 visitImportDirective(ImportDirective node) { | 141 visitImportDirective(ImportDirective node) { |
| 141 if (entity == node.asKeyword) { | 142 if (entity == node.asKeyword) { |
| 142 if (node.deferredKeyword == null) { | 143 if (node.deferredKeyword == null) { |
| 143 _addSuggestion(Keyword.DEFERRED, DART_RELEVANCE_HIGH); | 144 _addSuggestion(Keyword.DEFERRED, DART_RELEVANCE_HIGH); |
| 144 } | 145 } |
| 145 } | 146 } |
| 146 if (entity == node.semicolon) { | 147 if (entity == node.semicolon || node.combinators.contains(entity)) { |
| 147 _addImportDirectiveKeywords(node); | 148 _addImportDirectiveKeywords(node); |
| 148 } | 149 } |
| 149 } | 150 } |
| 150 | 151 |
| 151 void _addImportDirectiveKeywords(ImportDirective node) { | 152 void _addImportDirectiveKeywords(ImportDirective node) { |
| 152 if (node.asKeyword == null) { | 153 if (node.asKeyword == null) { |
| 153 _addSuggestion(Keyword.AS, DART_RELEVANCE_HIGH); | 154 _addSuggestion(Keyword.AS, DART_RELEVANCE_HIGH); |
| 154 if (node.deferredKeyword == null) { | 155 if (node.deferredKeyword == null) { |
| 155 _addSuggestion(Keyword.DEFERRED, DART_RELEVANCE_HIGH); | 156 _addSuggestion(Keyword.DEFERRED, DART_RELEVANCE_HIGH); |
| 156 } | 157 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 return false; | 193 return false; |
| 193 } | 194 } |
| 194 AstNode parent = body.parent; | 195 AstNode parent = body.parent; |
| 195 if (parent is ConstructorDeclaration || parent is MethodDeclaration) { | 196 if (parent is ConstructorDeclaration || parent is MethodDeclaration) { |
| 196 return true; | 197 return true; |
| 197 } | 198 } |
| 198 node = parent; | 199 node = parent; |
| 199 } | 200 } |
| 200 } | 201 } |
| 201 } | 202 } |
| OLD | NEW |