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

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

Issue 1881153002: Code completion refactoring in local contributor, have calls to _addLocalSuggestion() split into th… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months 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 | no next file » | 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_reference_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
index 8d613cee379354e07aca7c56770a872d7e40a0e2..b6dab4c79bd6a160fd89bb21aa1d880c2c3df2d3 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_reference_contributor.dart
@@ -236,7 +236,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
@override
void declaredClass(ClassDeclaration declaration) {
if (optype.includeTypeNameSuggestions) {
- _addLocalSuggestion(
+ _addLocalSuggestion_includeTypeNameSuggestions(
declaration.name, NO_RETURN_TYPE, protocol.ElementKind.CLASS,
isAbstract: declaration.isAbstract,
isDeprecated: _isDeprecated(declaration));
@@ -246,8 +246,8 @@ class _LocalVisitor extends LocalDeclarationVisitor {
@override
void declaredClassTypeAlias(ClassTypeAlias declaration) {
if (optype.includeTypeNameSuggestions) {
- _addLocalSuggestion(declaration.name, NO_RETURN_TYPE,
- protocol.ElementKind.CLASS_TYPE_ALIAS,
+ _addLocalSuggestion_includeTypeNameSuggestions(declaration.name,
+ NO_RETURN_TYPE, protocol.ElementKind.CLASS_TYPE_ALIAS,
isAbstract: true, isDeprecated: _isDeprecated(declaration));
}
}
@@ -255,7 +255,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
@override
void declaredEnum(EnumDeclaration declaration) {
if (optype.includeTypeNameSuggestions) {
- _addLocalSuggestion(
+ _addLocalSuggestion_includeTypeNameSuggestions(
declaration.name, NO_RETURN_TYPE, protocol.ElementKind.ENUM,
isDeprecated: _isDeprecated(declaration));
}
@@ -267,7 +267,8 @@ class _LocalVisitor extends LocalDeclarationVisitor {
(!optype.inStaticMethodBody || fieldDecl.isStatic)) {
bool deprecated = _isDeprecated(fieldDecl) || _isDeprecated(varDecl);
TypeName typeName = fieldDecl.fields.type;
- _addLocalSuggestion(varDecl.name, typeName, protocol.ElementKind.FIELD,
+ _addLocalSuggestion_includeReturnValueSuggestions(
+ varDecl.name, typeName, protocol.ElementKind.FIELD,
isDeprecated: deprecated,
relevance: DART_RELEVANCE_LOCAL_FIELD,
classDecl: fieldDecl.parent);
@@ -298,7 +299,8 @@ class _LocalVisitor extends LocalDeclarationVisitor {
elemKind = protocol.ElementKind.FUNCTION;
relevance = DART_RELEVANCE_LOCAL_FUNCTION;
}
- _addLocalSuggestion(declaration.name, typeName, elemKind,
+ _addLocalSuggestion_includeReturnValueSuggestions(
+ declaration.name, typeName, elemKind,
isDeprecated: _isDeprecated(declaration),
param: declaration.functionExpression.parameters,
relevance: relevance);
@@ -309,8 +311,8 @@ class _LocalVisitor extends LocalDeclarationVisitor {
void declaredFunctionTypeAlias(FunctionTypeAlias declaration) {
if (optype.includeTypeNameSuggestions) {
// TODO (danrubel) determine parameters and return type
- _addLocalSuggestion(declaration.name, declaration.returnType,
- protocol.ElementKind.FUNCTION_TYPE_ALIAS,
+ _addLocalSuggestion_includeTypeNameSuggestions(declaration.name,
+ declaration.returnType, protocol.ElementKind.FUNCTION_TYPE_ALIAS,
isAbstract: true, isDeprecated: _isDeprecated(declaration));
}
}
@@ -323,7 +325,8 @@ class _LocalVisitor extends LocalDeclarationVisitor {
@override
void declaredLocalVar(SimpleIdentifier id, TypeName typeName) {
if (optype.includeReturnValueSuggestions) {
- _addLocalSuggestion(id, typeName, protocol.ElementKind.LOCAL_VARIABLE,
+ _addLocalSuggestion_includeReturnValueSuggestions(
+ id, typeName, protocol.ElementKind.LOCAL_VARIABLE,
relevance: DART_RELEVANCE_LOCAL_VARIABLE);
}
}
@@ -356,7 +359,8 @@ class _LocalVisitor extends LocalDeclarationVisitor {
param = declaration.parameters;
relevance = DART_RELEVANCE_LOCAL_METHOD;
}
- _addLocalSuggestion(declaration.name, typeName, elemKind,
+ _addLocalSuggestion_includeReturnValueSuggestions(
+ declaration.name, typeName, elemKind,
isAbstract: declaration.isAbstract,
isDeprecated: _isDeprecated(declaration),
classDecl: declaration.parent,
@@ -368,7 +372,8 @@ class _LocalVisitor extends LocalDeclarationVisitor {
@override
void declaredParam(SimpleIdentifier id, TypeName typeName) {
if (optype.includeReturnValueSuggestions) {
- _addLocalSuggestion(id, typeName, protocol.ElementKind.PARAMETER,
+ _addLocalSuggestion_includeReturnValueSuggestions(
+ id, typeName, protocol.ElementKind.PARAMETER,
relevance: DART_RELEVANCE_PARAMETER);
}
}
@@ -377,13 +382,45 @@ class _LocalVisitor extends LocalDeclarationVisitor {
void declaredTopLevelVar(
VariableDeclarationList varList, VariableDeclaration varDecl) {
if (optype.includeReturnValueSuggestions) {
- _addLocalSuggestion(
+ _addLocalSuggestion_includeReturnValueSuggestions(
varDecl.name, varList.type, protocol.ElementKind.TOP_LEVEL_VARIABLE,
isDeprecated: _isDeprecated(varList) || _isDeprecated(varDecl),
relevance: DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE);
}
}
+ void _addLocalSuggestion_includeTypeNameSuggestions(
+ SimpleIdentifier id, TypeName typeName, protocol.ElementKind elemKind,
+ {bool isAbstract: false,
+ bool isDeprecated: false,
+ ClassDeclaration classDecl,
+ FormalParameterList param,
+ int relevance: DART_RELEVANCE_DEFAULT}) {
+ if (optype.typeNameSuggestionsFilter(_staticTypeOfIdentifier(id))) {
+ _addLocalSuggestion(id, typeName, elemKind,
+ isAbstract: isAbstract,
+ isDeprecated: isDeprecated,
+ classDecl: classDecl,
+ param: param,
+ relevance: relevance);
+ }
+ }
+
+ void _addLocalSuggestion_includeReturnValueSuggestions(
+ SimpleIdentifier id, TypeName typeName, protocol.ElementKind elemKind,
+ {bool isAbstract: false,
+ bool isDeprecated: false,
+ ClassDeclaration classDecl,
+ FormalParameterList param,
+ int relevance: DART_RELEVANCE_DEFAULT}) {
+ _addLocalSuggestion(id, typeName, elemKind,
+ isAbstract: isAbstract,
+ isDeprecated: isDeprecated,
+ classDecl: classDecl,
+ param: param,
+ relevance: relevance);
+ }
+
void _addLocalSuggestion(
SimpleIdentifier id, TypeName typeName, protocol.ElementKind elemKind,
{bool isAbstract: false,
@@ -402,14 +439,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
suggestion.completion.startsWith('_')) {
suggestion.relevance = privateMemberRelevance;
}
- // if includeTypeNameSuggestions, then use the filter
- if (optype.includeTypeNameSuggestions) {
- if (optype.typeNameSuggestionsFilter(_staticTypeOfIdentifier(id))) {
- suggestionMap.putIfAbsent(suggestion.completion, () => suggestion);
- }
- } else {
- suggestionMap.putIfAbsent(suggestion.completion, () => suggestion);
- }
+ suggestionMap.putIfAbsent(suggestion.completion, () => suggestion);
suggestion.element = _createLocalElement(request.source, elemKind, id,
isAbstract: isAbstract,
isDeprecated: isDeprecated,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698