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

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

Issue 1009833002: Quick Assist for creating a constructor for selected final fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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/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 a887ed69f0db5253e3c0d24a592a15292fc359bd..134dabc0406070ad4c1ae5e06820c4a28cfcdf89 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -382,8 +382,8 @@ class FixProcessor {
ClassElement targetElement = targetType.element as ClassElement;
String targetFile = targetElement.source.fullName;
ClassDeclaration targetClass = targetElement.node;
- _ConstructorLocation targetLocation =
- _prepareNewConstructorLocation(targetClass);
+ ConstructorLocation targetLocation =
+ utils.findNewConstructorLocation(targetClass);
// build method source
SourceBuilder sb = new SourceBuilder(targetFile, targetLocation.offset);
{
@@ -436,8 +436,8 @@ class FixProcessor {
ClassElement targetElement = targetType.element as ClassElement;
String targetFile = targetElement.source.fullName;
ClassDeclaration targetClass = targetElement.node;
- _ConstructorLocation targetLocation =
- _prepareNewConstructorLocation(targetClass);
+ ConstructorLocation targetLocation =
+ utils.findNewConstructorLocation(targetClass);
// build method source
SourceBuilder sb = new SourceBuilder(targetFile, targetLocation.offset);
{
@@ -572,8 +572,8 @@ class FixProcessor {
argumentsBuffer.append(parameterName);
}
// add proposal
- _ConstructorLocation targetLocation =
- _prepareNewConstructorLocation(targetClassNode);
+ ConstructorLocation targetLocation =
+ utils.findNewConstructorLocation(targetClassNode);
SourceBuilder sb = new SourceBuilder(file, targetLocation.offset);
{
String indent = utils.getIndent(1);
@@ -2128,29 +2128,6 @@ class FixProcessor {
return node is SimpleIdentifier && node.name == 'await';
}
- _ConstructorLocation _prepareNewConstructorLocation(
- ClassDeclaration classDeclaration) {
- List<ClassMember> members = classDeclaration.members;
- // find the last field/constructor
- ClassMember lastFieldOrConstructor = null;
- for (ClassMember member in members) {
- if (member is FieldDeclaration || member is ConstructorDeclaration) {
- lastFieldOrConstructor = member;
- } else {
- break;
- }
- }
- // after the last field/constructor
- if (lastFieldOrConstructor != null) {
- return new _ConstructorLocation(
- eol + eol, lastFieldOrConstructor.end, '');
- }
- // at the beginning of the class
- String suffix = members.isEmpty ? '' : eol;
- return new _ConstructorLocation(
- eol, classDeclaration.leftBracket.end, suffix);
- }
-
_FieldLocation _prepareNewFieldLocation(ClassDeclaration classDeclaration) {
String indent = utils.getIndent(1);
// find the last field
@@ -2305,17 +2282,6 @@ class _ClosestElementFinder {
}
/**
- * Describes the location for a newly created [ConstructorDeclaration].
- */
-class _ConstructorLocation {
- final String prefix;
- final int offset;
- final String suffix;
-
- _ConstructorLocation(this.prefix, this.offset, this.suffix);
-}
-
-/**
* Describes the location for a newly created [FieldDeclaration].
*/
class _FieldLocation {

Powered by Google App Engine
This is Rietveld 408576698