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

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

Issue 2613383003: Add support for generic function type syntax, part 1 (Closed)
Patch Set: Created 3 years, 11 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
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 41e50c53e5631d0c8b1f84348e202dd243b26bf4..ae669006a4b522b0cfbac074dfaa806fa8e04ae5 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
@@ -166,7 +166,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
if (optype.includeReturnValueSuggestions &&
(!optype.inStaticMethodBody || fieldDecl.isStatic)) {
bool deprecated = isDeprecated(fieldDecl) || isDeprecated(varDecl);
- TypeName typeName = fieldDecl.fields.type;
+ TypeAnnotation typeName = fieldDecl.fields.type;
_addLocalSuggestion_includeReturnValueSuggestions(
fieldDecl.documentationComment,
varDecl.name,
@@ -182,7 +182,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
void declaredFunction(FunctionDeclaration declaration) {
if (optype.includeReturnValueSuggestions ||
optype.includeVoidReturnSuggestions) {
- TypeName typeName = declaration.returnType;
+ TypeAnnotation typeName = declaration.returnType;
protocol.ElementKind elemKind;
int relevance = DART_RELEVANCE_DEFAULT;
if (declaration.isGetter) {
@@ -233,7 +233,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
}
@override
- void declaredLocalVar(SimpleIdentifier id, TypeName typeName) {
+ void declaredLocalVar(SimpleIdentifier id, TypeAnnotation typeName) {
if (optype.includeReturnValueSuggestions) {
_addLocalSuggestion_includeReturnValueSuggestions(
null, id, typeName, protocol.ElementKind.LOCAL_VARIABLE,
@@ -248,7 +248,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
(!optype.inStaticMethodBody || declaration.isStatic)) {
protocol.ElementKind elemKind;
FormalParameterList param;
- TypeName typeName = declaration.returnType;
+ TypeAnnotation typeName = declaration.returnType;
int relevance = DART_RELEVANCE_DEFAULT;
if (declaration.isGetter) {
elemKind = protocol.ElementKind.GETTER;
@@ -283,7 +283,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
}
@override
- void declaredParam(SimpleIdentifier id, TypeName typeName) {
+ void declaredParam(SimpleIdentifier id, TypeAnnotation typeName) {
if (optype.includeReturnValueSuggestions) {
_addLocalSuggestion_includeReturnValueSuggestions(
null, id, typeName, protocol.ElementKind.PARAMETER,
@@ -306,7 +306,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
}
void _addLocalSuggestion(Comment documentationComment, SimpleIdentifier id,
- TypeName typeName, protocol.ElementKind elemKind,
+ TypeAnnotation typeName, protocol.ElementKind elemKind,
{bool isAbstract: false,
bool isDeprecated: false,
ClassDeclaration classDecl,
@@ -377,7 +377,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
void _addLocalSuggestion_includeReturnValueSuggestions(
Comment documentationComment,
SimpleIdentifier id,
- TypeName typeName,
+ TypeAnnotation typeName,
protocol.ElementKind elemKind,
{bool isAbstract: false,
bool isDeprecated: false,
@@ -417,7 +417,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
void _addLocalSuggestion_includeTypeNameSuggestions(
Comment documentationComment,
SimpleIdentifier id,
- TypeName typeName,
+ TypeAnnotation typeName,
protocol.ElementKind elemKind,
{bool isAbstract: false,
bool isDeprecated: false,
@@ -443,7 +443,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
.map((FormalParameter param) => param.identifier.name)
.toList();
suggestion.parameterTypes = paramList.map((FormalParameter param) {
- TypeName type = null;
+ TypeAnnotation type = null;
if (param is DefaultFormalParameter) {
NormalFormalParameter child = param.parameter;
if (child is SimpleFormalParameter) {
@@ -460,11 +460,15 @@ class _LocalVisitor extends LocalDeclarationVisitor {
if (type == null) {
return 'dynamic';
}
- Identifier typeId = type.name;
- if (typeId == null) {
- return 'dynamic';
+ if (type is TypeName) {
+ Identifier typeId = type.name;
+ if (typeId == null) {
+ return 'dynamic';
+ }
+ return typeId.name;
}
- return typeId.name;
+ // TODO(brianwilkerson) Support function types.
+ return 'dynamic';
}).toList();
suggestion.requiredParameterCount = paramList
.where((FormalParameter param) => param is! DefaultFormalParameter)
@@ -473,8 +477,8 @@ class _LocalVisitor extends LocalDeclarationVisitor {
.any((FormalParameter param) => param.kind == ParameterKind.NAMED);
}
- bool _isVoid(TypeName returnType) {
- if (returnType != null) {
+ bool _isVoid(TypeAnnotation returnType) {
+ if (returnType is TypeName) {
Identifier id = returnType.name;
if (id != null && id.name == 'void') {
return true;

Powered by Google App Engine
This is Rietveld 408576698