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

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

Issue 2622303006: Reapply "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/utilities.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart b/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart
index 0cba8717113dfa9d55a21dee6be3b09e6fd08e63..a3ec936bb7299bb792ede1bfdfbab7e16b93425f 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/utilities.dart
@@ -34,7 +34,7 @@ final TypeName NO_RETURN_TYPE = astFactory.typeName(
protocol.Element createLocalElement(
Source source, protocol.ElementKind kind, SimpleIdentifier id,
{String parameters,
- TypeName returnType,
+ TypeAnnotation returnType,
bool isAbstract: false,
bool isDeprecated: false}) {
String name;
@@ -64,7 +64,7 @@ protocol.Element createLocalElement(
CompletionSuggestion createLocalFieldSuggestion(
Source source, FieldDeclaration fieldDecl, VariableDeclaration varDecl) {
bool deprecated = isDeprecated(fieldDecl) || isDeprecated(varDecl);
- TypeName type = fieldDecl.fields.type;
+ TypeAnnotation type = fieldDecl.fields.type;
return createLocalSuggestion(
varDecl.name, deprecated, DART_RELEVANCE_LOCAL_FIELD, type,
classDecl: fieldDecl.parent,
@@ -78,7 +78,7 @@ CompletionSuggestion createLocalFieldSuggestion(
* suggestion or `null` if it could not be created.
*/
CompletionSuggestion createLocalSuggestion(SimpleIdentifier id,
- bool isDeprecated, int defaultRelevance, TypeName returnType,
+ bool isDeprecated, int defaultRelevance, TypeAnnotation returnType,
{ClassDeclaration classDecl,
CompletionSuggestionKind kind = CompletionSuggestionKind.INVOCATION,
protocol.Element element}) {
@@ -129,24 +129,29 @@ bool isDeprecated(AnnotatedNode node) {
/**
* Return the name for the given [type].
*/
-String nameForType(TypeName type) {
+String nameForType(TypeAnnotation type) {
if (type == NO_RETURN_TYPE) {
return null;
}
if (type == null) {
return DYNAMIC;
}
- Identifier id = type.name;
- if (id == null) {
- return DYNAMIC;
- }
- String name = id.name;
- if (name == null || name.length <= 0) {
- return DYNAMIC;
- }
- TypeArgumentList typeArgs = type.typeArguments;
- if (typeArgs != null) {
- //TODO (danrubel) include type arguments
+ if (type is TypeName) {
+ Identifier id = type.name;
+ if (id == null) {
+ return DYNAMIC;
+ }
+ String name = id.name;
+ if (name == null || name.length <= 0) {
+ return DYNAMIC;
+ }
+ TypeArgumentList typeArgs = type.typeArguments;
+ if (typeArgs != null) {
+ //TODO (danrubel) include type arguments
+ }
+ return name;
+ } else if (type is GenericFunctionType) {
+ // TODO(brianwilkerson) Implement this.
}
- return name;
+ return DYNAMIC;
}

Powered by Google App Engine
This is Rietveld 408576698