| 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, | 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, |
| 10 ElementKind; | 10 ElementKind; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 101 } |
| 102 | 102 |
| 103 @override | 103 @override |
| 104 void declaredField(FieldDeclaration fieldDecl, VariableDeclaration varDecl) { | 104 void declaredField(FieldDeclaration fieldDecl, VariableDeclaration varDecl) { |
| 105 if (typesOnly) { | 105 if (typesOnly) { |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 bool isDeprecated = _isDeprecated(fieldDecl) || _isDeprecated(varDecl); | 108 bool isDeprecated = _isDeprecated(fieldDecl) || _isDeprecated(varDecl); |
| 109 CompletionSuggestion suggestion = _addSuggestion( | 109 CompletionSuggestion suggestion = _addSuggestion( |
| 110 varDecl.name, | 110 varDecl.name, |
| 111 fieldDecl.fields.type, | 111 null, |
| 112 fieldDecl.parent, | 112 fieldDecl.parent, |
| 113 isDeprecated); | 113 isDeprecated); |
| 114 if (suggestion != null) { | 114 if (suggestion != null) { |
| 115 suggestion.element = _createElement( | 115 suggestion.element = _createElement( |
| 116 protocol.ElementKind.GETTER, | 116 protocol.ElementKind.FIELD, |
| 117 varDecl.name, | 117 varDecl.name, |
| 118 null, | 118 null, |
| 119 fieldDecl.fields.type, | 119 null, |
| 120 false, | 120 false, |
| 121 isDeprecated); | 121 isDeprecated); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 @override | 125 @override |
| 126 void declaredFunction(FunctionDeclaration declaration) { | 126 void declaredFunction(FunctionDeclaration declaration) { |
| 127 if (typesOnly) { | 127 if (typesOnly) { |
| 128 return; | 128 return; |
| 129 } | 129 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 suggestion.element = _createElement( | 258 suggestion.element = _createElement( |
| 259 protocol.ElementKind.TOP_LEVEL_VARIABLE, | 259 protocol.ElementKind.TOP_LEVEL_VARIABLE, |
| 260 varDecl.name, | 260 varDecl.name, |
| 261 null, | 261 null, |
| 262 varList.type, | 262 varList.type, |
| 263 false, | 263 false, |
| 264 isDeprecated); | 264 isDeprecated); |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 | 267 |
| 268 CompletionSuggestion _addSuggestion(SimpleIdentifier id, TypeName typeName, | 268 CompletionSuggestion _addSuggestion(SimpleIdentifier id, TypeName returnType, |
| 269 ClassDeclaration classDecl, bool isDeprecated) { | 269 ClassDeclaration classDecl, bool isDeprecated) { |
| 270 if (id != null) { | 270 if (id != null) { |
| 271 String completion = id.name; | 271 String completion = id.name; |
| 272 if (completion != null && completion.length > 0 && completion != '_') { | 272 if (completion != null && completion.length > 0 && completion != '_') { |
| 273 CompletionSuggestion suggestion = new CompletionSuggestion( | 273 CompletionSuggestion suggestion = new CompletionSuggestion( |
| 274 CompletionSuggestionKind.INVOCATION, | 274 CompletionSuggestionKind.INVOCATION, |
| 275 isDeprecated ? CompletionRelevance.LOW : CompletionRelevance.DEFAULT
, | 275 isDeprecated ? CompletionRelevance.LOW : CompletionRelevance.DEFAULT
, |
| 276 completion, | 276 completion, |
| 277 completion.length, | 277 completion.length, |
| 278 0, | 278 0, |
| 279 false, | 279 false, |
| 280 false); | 280 false); |
| 281 if (classDecl != null) { | 281 if (classDecl != null) { |
| 282 SimpleIdentifier identifier = classDecl.name; | 282 SimpleIdentifier identifier = classDecl.name; |
| 283 if (identifier != null) { | 283 if (identifier != null) { |
| 284 String name = identifier.name; | 284 String name = identifier.name; |
| 285 if (name != null && name.length > 0) { | 285 if (name != null && name.length > 0) { |
| 286 suggestion.declaringType = name; | 286 suggestion.declaringType = name; |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 if (typeName != null) { | 290 if (returnType != null) { |
| 291 Identifier identifier = typeName.name; | 291 Identifier identifier = returnType.name; |
| 292 if (identifier != null) { | 292 if (identifier != null) { |
| 293 String name = identifier.name; | 293 String name = identifier.name; |
| 294 if (name != null && name.length > 0) { | 294 if (name != null && name.length > 0) { |
| 295 suggestion.returnType = name; | 295 suggestion.returnType = name; |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 request.suggestions.add(suggestion); | 299 request.suggestions.add(suggestion); |
| 300 return suggestion; | 300 return suggestion; |
| 301 } | 301 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 if (name == null || name.length <= 0) { | 376 if (name == null || name.length <= 0) { |
| 377 return DYNAMIC; | 377 return DYNAMIC; |
| 378 } | 378 } |
| 379 TypeArgumentList typeArgs = type.typeArguments; | 379 TypeArgumentList typeArgs = type.typeArguments; |
| 380 if (typeArgs != null) { | 380 if (typeArgs != null) { |
| 381 //TODO (danrubel) include type arguments | 381 //TODO (danrubel) include type arguments |
| 382 } | 382 } |
| 383 return name; | 383 return name; |
| 384 } | 384 } |
| 385 } | 385 } |
| OLD | NEW |