| 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.suggestion.builder; | 5 library services.completion.suggestion.builder; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 7 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
| 8 import 'package:analysis_server/src/protocol_server.dart' hide Element, | 8 import 'package:analysis_server/src/protocol_server.dart' hide Element, |
| 9 ElementKind; | 9 ElementKind; |
| 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 if (elementLibrary != unitLibrary) { | 276 if (elementLibrary != unitLibrary) { |
| 277 return; | 277 return; |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 String completion = element.displayName; | 280 String completion = element.displayName; |
| 281 if (completion == null || | 281 if (completion == null || |
| 282 completion.length <= 0 || | 282 completion.length <= 0 || |
| 283 !_completions.add(completion)) { | 283 !_completions.add(completion)) { |
| 284 return; | 284 return; |
| 285 } | 285 } |
| 286 bool isDeprecated = element.isDeprecated; |
| 286 CompletionSuggestion suggestion = new CompletionSuggestion( | 287 CompletionSuggestion suggestion = new CompletionSuggestion( |
| 287 kind, | 288 kind, |
| 288 CompletionRelevance.DEFAULT, | 289 isDeprecated ? CompletionRelevance.LOW : CompletionRelevance.DEFAULT, |
| 289 completion, | 290 completion, |
| 290 completion.length, | 291 completion.length, |
| 291 0, | 292 0, |
| 292 element.isDeprecated, | 293 isDeprecated, |
| 293 false); | 294 false); |
| 294 suggestion.element = protocol.newElement_fromEngine(element); | 295 suggestion.element = protocol.newElement_fromEngine(element); |
| 295 if (suggestion.element != null) { | 296 if (suggestion.element != null) { |
| 296 if (element is FieldElement) { | 297 if (element is FieldElement) { |
| 297 suggestion.element.kind = protocol.ElementKind.GETTER; | 298 suggestion.element.kind = protocol.ElementKind.GETTER; |
| 298 suggestion.element.returnType = | 299 suggestion.element.returnType = |
| 299 element.type != null ? element.type.displayName : 'dynamic'; | 300 element.type != null ? element.type.displayName : 'dynamic'; |
| 300 } | 301 } |
| 301 } | 302 } |
| 302 if (enclosingElement != null) { | 303 if (enclosingElement != null) { |
| 303 suggestion.declaringType = enclosingElement.displayName; | 304 suggestion.declaringType = enclosingElement.displayName; |
| 304 } | 305 } |
| 305 if (type != null) { | 306 if (type != null) { |
| 306 String typeName = type.displayName; | 307 String typeName = type.displayName; |
| 307 if (typeName != null && typeName.length > 0 && typeName != 'dynamic') { | 308 if (typeName != null && typeName.length > 0 && typeName != 'dynamic') { |
| 308 suggestion.returnType = typeName; | 309 suggestion.returnType = typeName; |
| 309 } | 310 } |
| 310 } | 311 } |
| 311 request.suggestions.add(suggestion); | 312 request.suggestions.add(suggestion); |
| 312 } | 313 } |
| 313 } | 314 } |
| OLD | NEW |