Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart

Issue 1527613008: cleanup LocalLibraryContributor (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/dart_completion_cache.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart
index 24cf9c7c4ff6509e7f85cc3e68d8e7a492a7a069..98dd66b39a3764e6afed37693b00c5da37c6fc25 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart
@@ -66,7 +66,16 @@ class _Visitor extends GeneralizingElementVisitor {
@override
void visitClassElement(ClassElement element) {
- _addSuggestion(element, DART_RELEVANCE_DEFAULT);
+ if (optype.includeTypeNameSuggestions) {
+ CompletionSuggestion suggestion =
+ createSuggestion(element, relevance: DART_RELEVANCE_DEFAULT);
+ if (suggestion != null) {
+ suggestions.add(suggestion);
+ }
+ }
+ if (optype.includeConstructorSuggestions) {
+ _addConstructorSuggestions(element, DART_RELEVANCE_DEFAULT);
+ }
}
@override
@@ -81,61 +90,22 @@ class _Visitor extends GeneralizingElementVisitor {
@override
void visitFunctionElement(FunctionElement element) {
- _addSuggestion(element, DART_RELEVANCE_LOCAL_FUNCTION);
- }
-
- @override
- void visitFunctionTypeAliasElement(FunctionTypeAliasElement element) {
- _addSuggestion(element, DART_RELEVANCE_LOCAL_FUNCTION);
- }
-
- @override
- void visitTopLevelVariableElement(TopLevelVariableElement element) {
- _addSuggestion(element, DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE);
- }
-
- /**
- * Add a suggestion for the given element.
- */
- void _addSuggestion(Element element, int relevance) {
- if (element is ExecutableElement) {
- // Do not suggest operators or local functions
- if (element.isOperator) {
- return;
- }
- if (element is FunctionElement) {
- if (element.enclosingElement is! CompilationUnitElement) {
- return;
- }
- }
+ // Do not suggest operators or local functions
+ if (element.isOperator) {
+ return;
}
-
+ if (element.enclosingElement is! CompilationUnitElement) {
+ return;
+ }
+ int relevance = DART_RELEVANCE_LOCAL_FUNCTION;
CompletionSuggestion suggestion =
createSuggestion(element, relevance: relevance);
-
if (suggestion != null) {
- if (element is ExecutableElement) {
- DartType returnType = element.returnType;
- if (returnType != null && returnType.isVoid) {
- if (optype.includeVoidReturnSuggestions) {
- suggestions.add(suggestion);
- }
- } else {
- if (optype.includeReturnValueSuggestions) {
- suggestions.add(suggestion);
- }
- }
- } else if (element is FunctionTypeAliasElement) {
- if (optype.includeTypeNameSuggestions) {
- suggestions.add(suggestion);
- }
- } else if (element is ClassElement) {
- if (optype.includeTypeNameSuggestions) {
+ DartType returnType = element.returnType;
+ if (returnType != null && returnType.isVoid) {
+ if (optype.includeVoidReturnSuggestions) {
suggestions.add(suggestion);
}
- if (optype.includeConstructorSuggestions) {
- _addConstructorSuggestions(element, relevance);
- }
} else {
if (optype.includeReturnValueSuggestions) {
suggestions.add(suggestion);
@@ -144,6 +114,28 @@ class _Visitor extends GeneralizingElementVisitor {
}
}
+ @override
+ void visitFunctionTypeAliasElement(FunctionTypeAliasElement element) {
+ if (optype.includeTypeNameSuggestions) {
+ CompletionSuggestion suggestion =
+ createSuggestion(element, relevance: DART_RELEVANCE_LOCAL_FUNCTION);
+ if (suggestion != null) {
+ suggestions.add(suggestion);
+ }
+ }
+ }
+
+ @override
+ void visitTopLevelVariableElement(TopLevelVariableElement element) {
+ if (optype.includeReturnValueSuggestions) {
+ CompletionSuggestion suggestion = createSuggestion(element,
+ relevance: DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE);
+ if (suggestion != null) {
+ suggestions.add(suggestion);
+ }
+ }
+ }
+
/**
* Add constructor suggestions for the given class.
*/
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/dart_completion_cache.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698