| 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.computer.dart.local; | 5 library services.completion.computer.dart.local; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, Ele
mentKind; | 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, Ele
mentKind; |
| 10 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind; | 10 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 _addFieldSuggestions(node, classMbr); | 97 _addFieldSuggestions(node, classMbr); |
| 98 } else if (classMbr is MethodDeclaration) { | 98 } else if (classMbr is MethodDeclaration) { |
| 99 _addMethodSuggestion(node, classMbr); | 99 _addMethodSuggestion(node, classMbr); |
| 100 } | 100 } |
| 101 }); | 101 }); |
| 102 visitNode(node); | 102 visitNode(node); |
| 103 } | 103 } |
| 104 | 104 |
| 105 @override | 105 @override |
| 106 visitCompilationUnit(CompilationUnit node) { | 106 visitCompilationUnit(CompilationUnit node) { |
| 107 node.directives.forEach((Directive directive) { | |
| 108 if (directive is ImportDirective) { | |
| 109 _addLibraryPrefixSuggestion(directive); | |
| 110 } | |
| 111 }); | |
| 112 node.declarations.forEach((Declaration declaration) { | 107 node.declarations.forEach((Declaration declaration) { |
| 113 if (declaration is ClassDeclaration) { | 108 if (declaration is ClassDeclaration) { |
| 114 _addClassSuggestion(declaration); | 109 _addClassSuggestion(declaration); |
| 115 } else if (declaration is EnumDeclaration) { | 110 } else if (declaration is EnumDeclaration) { |
| 116 // _addSuggestion(d.name, CompletionSuggestionKind.ENUM); | 111 // _addSuggestion(d.name, CompletionSuggestionKind.ENUM); |
| 117 } else if (declaration is FunctionDeclaration) { | 112 } else if (declaration is FunctionDeclaration) { |
| 118 _addFunctionSuggestion(declaration); | 113 _addFunctionSuggestion(declaration); |
| 119 } else if (declaration is TopLevelVariableDeclaration) { | 114 } else if (declaration is TopLevelVariableDeclaration) { |
| 120 _addTopLevelVarSuggestions(declaration.variables); | 115 _addTopLevelVarSuggestions(declaration.variables); |
| 121 } else if (declaration is ClassTypeAlias) { | 116 } else if (declaration is ClassTypeAlias) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 if (suggestion != null) { | 245 if (suggestion != null) { |
| 251 suggestion.element = _createElement( | 246 suggestion.element = _createElement( |
| 252 protocol.ElementKind.FUNCTION, | 247 protocol.ElementKind.FUNCTION, |
| 253 declaration.name, | 248 declaration.name, |
| 254 declaration.returnType, | 249 declaration.returnType, |
| 255 false, | 250 false, |
| 256 _isDeprecated(declaration.metadata)); | 251 _isDeprecated(declaration.metadata)); |
| 257 } | 252 } |
| 258 } | 253 } |
| 259 | 254 |
| 260 void _addLibraryPrefixSuggestion(ImportDirective directive) { | |
| 261 CompletionSuggestion suggestion = _addSuggestion( | |
| 262 directive.prefix, | |
| 263 CompletionSuggestionKind.LIBRARY_PREFIX, | |
| 264 null, | |
| 265 null); | |
| 266 if (suggestion != null) { | |
| 267 suggestion.element = _createElement( | |
| 268 protocol.ElementKind.LIBRARY, | |
| 269 directive.prefix, | |
| 270 NO_RETURN_TYPE, | |
| 271 false, | |
| 272 false); | |
| 273 } | |
| 274 } | |
| 275 | |
| 276 void _addLocalVarSuggestion(SimpleIdentifier id, TypeName returnType) { | 255 void _addLocalVarSuggestion(SimpleIdentifier id, TypeName returnType) { |
| 277 CompletionSuggestion suggestion = | 256 CompletionSuggestion suggestion = |
| 278 _addSuggestion(id, CompletionSuggestionKind.LOCAL_VARIABLE, returnType,
null); | 257 _addSuggestion(id, CompletionSuggestionKind.LOCAL_VARIABLE, returnType,
null); |
| 279 if (suggestion != null) { | 258 if (suggestion != null) { |
| 280 suggestion.element = _createElement( | 259 suggestion.element = _createElement( |
| 281 protocol.ElementKind.LOCAL_VARIABLE, | 260 protocol.ElementKind.LOCAL_VARIABLE, |
| 282 id, | 261 id, |
| 283 returnType, | 262 returnType, |
| 284 false, | 263 false, |
| 285 false); | 264 false); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 if (name == null || name.length <= 0) { | 423 if (name == null || name.length <= 0) { |
| 445 return DYNAMIC; | 424 return DYNAMIC; |
| 446 } | 425 } |
| 447 TypeArgumentList typeArgs = type.typeArguments; | 426 TypeArgumentList typeArgs = type.typeArguments; |
| 448 if (typeArgs != null) { | 427 if (typeArgs != null) { |
| 449 //TODO (danrubel) include type arguments | 428 //TODO (danrubel) include type arguments |
| 450 } | 429 } |
| 451 return name; | 430 return name; |
| 452 } | 431 } |
| 453 } | 432 } |
| OLD | NEW |