| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 7 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
| 8 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.
dart'; | 8 import 'package:analysis_server/src/services/completion/dart/suggestion_builder.
dart'; |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 for (ImportElement importElem in imports) { | 48 for (ImportElement importElem in imports) { |
| 49 if (importElem.prefix?.name == elem.name) { | 49 if (importElem.prefix?.name == elem.name) { |
| 50 LibraryElement library = importElem.importedLibrary; | 50 LibraryElement library = importElem.importedLibrary; |
| 51 if (library != null) { | 51 if (library != null) { |
| 52 // Suggest elements from the imported library | 52 // Suggest elements from the imported library |
| 53 AstNode parent = request.target.containingNode.parent; | 53 AstNode parent = request.target.containingNode.parent; |
| 54 bool isConstructor = parent.parent is ConstructorName; | 54 bool isConstructor = parent.parent is ConstructorName; |
| 55 bool typesOnly = parent is TypeName; | 55 bool typesOnly = parent is TypeName; |
| 56 bool instCreation = typesOnly && isConstructor; | 56 bool instCreation = typesOnly && isConstructor; |
| 57 LibraryElementSuggestionBuilder builder = | 57 LibraryElementSuggestionBuilder builder = |
| 58 new LibraryElementSuggestionBuilder( | 58 new LibraryElementSuggestionBuilder(containingLibrary, |
| 59 containingLibrary, | 59 CompletionSuggestionKind.INVOCATION, typesOnly, instCreation); |
| 60 CompletionSuggestionKind.INVOCATION, | |
| 61 typesOnly, | |
| 62 instCreation, | |
| 63 request.ideOptions); | |
| 64 library.visitChildren(builder); | 60 library.visitChildren(builder); |
| 65 suggestions.addAll(builder.suggestions); | 61 suggestions.addAll(builder.suggestions); |
| 66 | 62 |
| 67 // If the import is 'deferred' then suggest 'loadLibrary' | 63 // If the import is 'deferred' then suggest 'loadLibrary' |
| 68 if (importElem.isDeferred) { | 64 if (importElem.isDeferred) { |
| 69 FunctionElement loadLibFunct = library.loadLibraryFunction; | 65 FunctionElement loadLibFunct = library.loadLibraryFunction; |
| 70 suggestions.add(createSuggestion(loadLibFunct, request.ideOptions)); | 66 suggestions.add(createSuggestion(loadLibFunct)); |
| 71 } | 67 } |
| 72 } | 68 } |
| 73 } | 69 } |
| 74 } | 70 } |
| 75 return suggestions; | 71 return suggestions; |
| 76 } | 72 } |
| 77 } | 73 } |
| OLD | NEW |