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

Unified Diff: pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Issue 2618653002: Issue 28261. Add support for implementing generic methods in Quick Fix. (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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/correction/util.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/correction/fix_internal.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index efec5eeb46118204359679ef9dace81dfcec3234..be1083c5f4ee83418601452d33c93735b028e190 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -1365,6 +1365,7 @@ class FixProcessor {
void _addFix_createMissingOverrides_single(SourceBuilder sb,
ClassDeclaration targetClass, ExecutableElement element) {
+ utils.targetExecutableElement = element;
// prepare environment
String prefix = utils.getIndent(1);
String prefix2 = utils.getIndent(2);
@@ -1400,6 +1401,17 @@ class FixProcessor {
}
// name
sb.append(element.displayName);
+ // type parameters
+ {
+ List<TypeParameterElement> typeParameters = element.typeParameters;
+ if (typeParameters.isNotEmpty) {
+ sb.append('<');
+ for (TypeParameterElement typeParameter in typeParameters) {
+ _appendTypeParameter(sb, typeParameter);
+ }
+ sb.append('>');
+ }
+ }
// parameters + body
if (isGetter) {
sb.append(' => null;');
@@ -1417,6 +1429,7 @@ class FixProcessor {
sb.append('}');
}
sb.append(eol);
+ utils.targetExecutableElement = null;
}
void _addFix_createNoSuchMethod() {
@@ -2534,7 +2547,7 @@ class FixProcessor {
}
void _appendType(SourceBuilder sb, DartType type,
- {String groupId, bool orVar: false}) {
+ {String groupId, bool orVar: false, bool trailingSpace: true}) {
if (type != null && !type.isDynamic) {
String typeSource = utils.getTypeSource(type, librariesToImport);
if (groupId != null) {
@@ -2544,12 +2557,23 @@ class FixProcessor {
} else {
sb.append(typeSource);
}
- sb.append(' ');
+ if (trailingSpace) {
+ sb.append(' ');
+ }
} else if (orVar) {
sb.append('var ');
}
}
+ void _appendTypeParameter(
+ SourceBuilder sb, TypeParameterElement typeParameter) {
+ sb.append(typeParameter.name);
+ if (typeParameter.bound != null) {
+ sb.append(' extends ');
+ _appendType(sb, typeParameter.bound, trailingSpace: false);
+ }
+ }
+
/**
* Computes the name of the library at the given [path].
* See https://www.dartlang.org/articles/style-guide/#names for conventions.
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/correction/util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698