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

Unified Diff: pkg/analysis_server/lib/src/services/refactoring/extract_local.dart

Issue 574573002: Add SourceFileEdit.time field. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: tweak Created 6 years, 3 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/refactoring/extract_local.dart
diff --git a/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart b/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
index 0bbda87bc55d0e78b0413827e6659528d44136e0..6d1b462c945314d095ed0f7f34275e22c01e90b2 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/extract_local.dart
@@ -35,6 +35,7 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl implements
final CompilationUnit unit;
final int selectionOffset;
final int selectionLength;
+ CompilationUnitElement unitElement;
String file;
SourceRange selectionRange;
CorrectionUtils utils;
@@ -54,7 +55,7 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl implements
ExtractLocalRefactoringImpl(this.unit, this.selectionOffset,
this.selectionLength) {
- file = unit.element.source.fullName;
+ unitElement = unit.element;
selectionRange = new SourceRange(selectionOffset, selectionLength);
utils = new CorrectionUtils(unit);
}
@@ -122,7 +123,7 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl implements
String declarationSource = '$keyword $name = ';
SourceEdit edit =
new SourceEdit(singleExpression.offset, 0, declarationSource);
- change.addEdit(file, edit);
+ addElementSourceChange(change, unitElement, edit);
return new Future.value(change);
}
// add variable declaration
@@ -158,21 +159,23 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl implements
String prefix = utils.getNodePrefix(target);
SourceEdit edit =
new SourceEdit(target.offset, 0, declarationSource + eol + prefix);
- change.addEdit(file, edit);
+ addElementSourceChange(change, unitElement, edit);
} else if (target is ExpressionFunctionBody) {
String prefix = utils.getNodePrefix(target.parent);
String indent = utils.getIndent(1);
String declStatement = prefix + indent + declarationSource + eol;
String exprStatement = prefix + indent + 'return ';
Expression expr = target.expression;
- change.addEdit(
- file,
+ addElementSourceChange(
+ change,
+ unitElement,
new SourceEdit(
target.offset,
expr.offset - target.offset,
'{' + eol + declStatement + exprStatement));
- change.addEdit(
- file,
+ addElementSourceChange(
+ change,
+ unitElement,
new SourceEdit(expr.end, 0, ';' + eol + prefix + '}'));
}
}
@@ -184,7 +187,7 @@ class ExtractLocalRefactoringImpl extends RefactoringImpl implements
// replace occurrences with variable reference
for (SourceRange range in occurrences) {
SourceEdit edit = new SourceEdit.range(range, occurrenceReplacement);
- change.addEdit(file, edit);
+ addElementSourceChange(change, unitElement, edit);
}
// done
return new Future.value(change);

Powered by Google App Engine
This is Rietveld 408576698