| 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 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 10 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 | 316 |
| 317 void _buildSuggestions(InterfaceType type, LibraryElement library) { | 317 void _buildSuggestions(InterfaceType type, LibraryElement library) { |
| 318 // Visit all of the types in the class hierarchy, collecting possible | 318 // Visit all of the types in the class hierarchy, collecting possible |
| 319 // completions. If multiple elements are found that complete to the same | 319 // completions. If multiple elements are found that complete to the same |
| 320 // identifier, addSuggestion will discard all but the first (with a few | 320 // identifier, addSuggestion will discard all but the first (with a few |
| 321 // exceptions to handle getter/setter pairs). | 321 // exceptions to handle getter/setter pairs). |
| 322 for (InterfaceType targetType in _getTypeOrdering(type)) { | 322 for (InterfaceType targetType in _getTypeOrdering(type)) { |
| 323 for (MethodElement method in targetType.methods) { | 323 for (MethodElement method in targetType.methods) { |
| 324 addSuggestion(method); | 324 // Exclude static methods when completion on an instance |
| 325 if (!method.isStatic) { |
| 326 addSuggestion(method); |
| 327 } |
| 325 } | 328 } |
| 326 for (PropertyAccessorElement propertyAccessor in targetType.accessors) { | 329 for (PropertyAccessorElement propertyAccessor in targetType.accessors) { |
| 327 if (propertyAccessor.isSynthetic) { | 330 if (!propertyAccessor.isStatic) { |
| 328 // Avoid visiting a field twice | 331 if (propertyAccessor.isSynthetic) { |
| 329 if (propertyAccessor.isGetter) { | 332 // Avoid visiting a field twice |
| 330 addSuggestion(propertyAccessor.variable); | 333 if (propertyAccessor.isGetter) { |
| 334 addSuggestion(propertyAccessor.variable); |
| 335 } |
| 336 } else { |
| 337 addSuggestion(propertyAccessor); |
| 331 } | 338 } |
| 332 } else { | |
| 333 addSuggestion(propertyAccessor); | |
| 334 } | 339 } |
| 335 } | 340 } |
| 336 } | 341 } |
| 337 } | 342 } |
| 338 | 343 |
| 339 /** | 344 /** |
| 340 * Get a list of [InterfaceType]s that should be searched to find the | 345 * Get a list of [InterfaceType]s that should be searched to find the |
| 341 * possible completions for an object having type [type]. | 346 * possible completions for an object having type [type]. |
| 342 */ | 347 */ |
| 343 List<InterfaceType> _getTypeOrdering(InterfaceType type) { | 348 List<InterfaceType> _getTypeOrdering(InterfaceType type) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 * or `false` if [computeFull] should be called. | 578 * or `false` if [computeFull] should be called. |
| 574 */ | 579 */ |
| 575 bool computeFast(AstNode node); | 580 bool computeFast(AstNode node); |
| 576 | 581 |
| 577 /** | 582 /** |
| 578 * Return a future that computes the suggestions given a fully resolved AST. | 583 * Return a future that computes the suggestions given a fully resolved AST. |
| 579 * The future returns `true` if suggestions were added, else `false`. | 584 * The future returns `true` if suggestions were added, else `false`. |
| 580 */ | 585 */ |
| 581 Future<bool> computeFull(AstNode node); | 586 Future<bool> computeFull(AstNode node); |
| 582 } | 587 } |
| OLD | NEW |