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

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

Issue 2962223002: Remove timeStamp from the ChangeBuilder API (Closed)
Patch Set: Created 3 years, 6 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 7b576c11ecec0f0505c4f1f54ff987554e5b63a1..1c0d97953c6b259c4c29847df19edbca9219e88b 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -106,7 +106,6 @@ class FixProcessor {
AnalysisDriver driver;
String file;
- int fileStamp;
CompilationUnitElement unitElement;
Source unitSource;
LibraryElement unitLibraryElement;
@@ -137,7 +136,6 @@ class FixProcessor {
unitSource = unitElement.source;
// file
file = unitSource.fullName;
- fileStamp = _modificationStamp(file);
// library
unitLibraryElement = unitElement.library;
String unitLibraryPath = unitLibraryElement.source.fullName;
@@ -173,12 +171,6 @@ class FixProcessor {
}
Future<List<Fix>> compute() async {
- // If the source was changed between the constructor and running
- // this asynchronous method, it is not safe to use the unit.
- if (_modificationStamp(unitSource.fullName) != fileStamp) {
- return const <Fix>[];
- }
-
try {
utils = new CorrectionUtils(unit);
} catch (e) {
@@ -455,8 +447,7 @@ class FixProcessor {
if (body != null && body.keyword == null) {
TypeProvider typeProvider = await this.typeProvider;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.convertFunctionFromSyncToAsync(body, typeProvider);
});
_addFixFromBuilder(changeBuilder, DartFixKind.ADD_ASYNC);
@@ -470,8 +461,7 @@ class FixProcessor {
String prefix = utils.getIndent(1);
String prefix2 = utils.getIndent(2);
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addInsertion(insertOffset, (DartEditBuilder builder) {
builder.selectHere();
builder.write(prefix);
@@ -544,9 +534,8 @@ class FixProcessor {
Source targetSource = targetElement.source;
String targetFile = targetSource.fullName;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder
- .addFileEdit(targetFile, targetSource.modificationStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(targetFile,
+ (DartFileEditBuilder builder) {
builder.addInsertion(targetOffset, (DartEditBuilder builder) {
if (numRequired != 0) {
builder.write(', ');
@@ -562,9 +551,8 @@ class FixProcessor {
changeBuilder, DartFixKind.ADD_MISSING_PARAMETER_REQUIRED);
if (optionalParameters.isEmpty) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder
- .addFileEdit(targetFile, targetSource.modificationStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(targetFile,
+ (DartFileEditBuilder builder) {
builder.addInsertion(targetOffset, (DartEditBuilder builder) {
if (numRequired != 0) {
builder.write(', ');
@@ -614,8 +602,7 @@ class FixProcessor {
int offset =
args.isEmpty ? argumentList.leftParenthesis.end : args.last.end;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addInsertion(offset, (DartEditBuilder builder) {
if (args.isNotEmpty) {
builder.write(', ');
@@ -656,8 +643,7 @@ class FixProcessor {
Position exitPosition = new Position(file, token.offset - 1);
String indent = utils.getIndent(1);
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleReplacement(
range.startLength(token, 0), '@override$eol$indent');
});
@@ -667,8 +653,7 @@ class FixProcessor {
Future<Null> _addFix_boolInsteadOfBoolean() async {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleReplacement(range.error(error), 'bool');
});
_addFixFromBuilder(changeBuilder, DartFixKind.REPLACE_BOOLEAN_WITH_BOOL);
@@ -678,8 +663,7 @@ class FixProcessor {
AstNode node = coveredNode;
if (node is Expression) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
AstNode parent = node.parent;
while (parent != null) {
if (parent is MethodInvocation && parent.target == node) {
@@ -710,7 +694,7 @@ class FixProcessor {
DartType newType = initializer.bestType;
if (newType is InterfaceType || newType is FunctionType) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
+ await changeBuilder.addFileEdit(file,
(DartFileEditBuilder builder) {
builder.addReplacement(range.node(typeNode),
(DartEditBuilder builder) {
@@ -736,8 +720,7 @@ class FixProcessor {
InstanceCreationExpression childArg = getChildWidget(namedExp, false);
if (childArg != null) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
convertFlutterChildToChildren2(
builder,
childArg,
@@ -755,8 +738,7 @@ class FixProcessor {
ListLiteral listArg = getChildList(namedExp);
if (listArg != null) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleInsertion(namedExp.offset + 'child'.length, 'ren');
if (listArg.typeArguments == null) {
builder.addSimpleInsertion(listArg.offset, '<Widget>');
@@ -801,7 +783,6 @@ class FixProcessor {
String suffix = '';
int offset = -1;
String filePath;
- int modificationTime = 0;
if (prefixElement == null) {
targetUnit = unitElement;
CompilationUnitMember enclosingMember =
@@ -811,7 +792,6 @@ class FixProcessor {
}
offset = enclosingMember.end;
filePath = file;
- modificationTime = fileStamp;
prefix = '$eol$eol';
} else {
for (ImportElement import in unitLibraryElement.imports) {
@@ -822,7 +802,6 @@ class FixProcessor {
Source targetSource = targetUnit.source;
offset = targetSource.contents.data.length;
filePath = targetSource.fullName;
- modificationTime = targetSource.modificationStamp;
prefix = '$eol';
suffix = '$eol';
break;
@@ -834,8 +813,7 @@ class FixProcessor {
return;
}
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(filePath, modificationTime,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(filePath, (DartFileEditBuilder builder) {
builder.addInsertion(offset, (DartEditBuilder builder) {
builder.write(prefix);
builder.writeClassDeclaration(name, nameGroupName: 'NAME');
@@ -877,8 +855,7 @@ class FixProcessor {
ClassMemberLocation targetLocation =
utils.prepareNewConstructorLocation(classDeclaration);
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addInsertion(targetLocation.offset, (DartEditBuilder builder) {
builder.write(targetLocation.prefix);
builder.writeConstructorDeclaration(classDeclaration.name.name,
@@ -921,8 +898,7 @@ class FixProcessor {
Source targetSource = targetElement.source;
String targetFile = targetSource.fullName;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(targetFile, targetSource.modificationStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(targetFile, (DartFileEditBuilder builder) {
builder.addInsertion(targetLocation.offset, (DartEditBuilder builder) {
builder.write(targetLocation.prefix);
builder.writeConstructorDeclaration(targetElement.name,
@@ -975,8 +951,7 @@ class FixProcessor {
utils.prepareNewConstructorLocation(targetTypeNode);
String targetFile = targetElement.source.fullName;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addInsertion(targetLocation.offset, (DartEditBuilder builder) {
builder.write(targetLocation.prefix);
builder.writeConstructorDeclaration(targetElement.name,
@@ -1026,8 +1001,7 @@ class FixProcessor {
}
String proposalName = _getConstructorProposalName(superConstructor);
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addInsertion(insertOffset, (DartEditBuilder builder) {
builder.write(prefix);
// add super constructor name
@@ -1085,8 +1059,7 @@ class FixProcessor {
utils.prepareNewConstructorLocation(targetClassNode);
String proposalName = _getConstructorProposalName(superConstructor);
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addInsertion(targetLocation.offset, (DartEditBuilder builder) {
void writeParameters(bool includeType) {
bool firstParameter = true;
@@ -1190,8 +1163,7 @@ class FixProcessor {
Source targetSource = targetClassElement.source;
String targetFile = targetSource.fullName;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(targetFile, targetSource.modificationStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(targetFile, (DartFileEditBuilder builder) {
Expression fieldTypeNode = climbPropertyAccess(nameNode);
DartType fieldType = _inferUndefinedExpressionType(fieldTypeNode);
builder.addInsertion(targetLocation.offset, (DartEditBuilder builder) {
@@ -1229,8 +1201,7 @@ class FixProcessor {
// Add proposal.
//
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
DartType fieldType = parameter.type?.type;
builder.addInsertion(targetLocation.offset, (DartEditBuilder builder) {
builder.write(targetLocation.prefix);
@@ -1349,8 +1320,7 @@ class FixProcessor {
Source targetSource = targetClassElement.source;
String targetFile = targetSource.fullName;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(targetFile, targetSource.modificationStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(targetFile, (DartFileEditBuilder builder) {
builder.addInsertion(targetLocation.offset, (DartEditBuilder builder) {
Expression fieldTypeNode = climbPropertyAccess(nameNode);
DartType fieldType = _inferUndefinedExpressionType(fieldTypeNode);
@@ -1377,7 +1347,7 @@ class FixProcessor {
if (isAbsolute(file) && AnalysisEngine.isDartFileName(file)) {
String libName = _computeLibraryName(file);
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(source.fullName, -1,
+ await changeBuilder.addFileEdit(source.fullName,
(DartFileEditBuilder builder) {
builder.addSimpleInsertion(0, 'library $libName;$eol$eol');
});
@@ -1401,8 +1371,7 @@ class FixProcessor {
assignment.operator.type == TokenType.EQ &&
assignment.parent is ExpressionStatement) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleInsertion(node.offset, 'var ');
});
_addFixFromBuilder(changeBuilder, DartFixKind.CREATE_LOCAL_VARIABLE,
@@ -1427,8 +1396,7 @@ class FixProcessor {
}
// build variable declaration source
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addInsertion(target.offset, (DartEditBuilder builder) {
builder.writeLocalVariableDeclaration(name,
nameGroupName: 'NAME', type: type, typeGroupName: 'TYPE');
@@ -1469,8 +1437,7 @@ class FixProcessor {
int insertOffset = targetClass.end - 1;
String prefix = utils.getIndent(1);
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addInsertion(insertOffset, (DartEditBuilder builder) {
// TODO(brianwilkerson) Compare with builder.writeOverrideOfInheritedMember
// The builder method doesn't merge getter/setter pairs into fields.
@@ -1589,8 +1556,7 @@ class FixProcessor {
String prefix = utils.getIndent(1);
int insertOffset = targetClass.end - 1;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addInsertion(insertOffset, (DartEditBuilder builder) {
builder.selectHere();
// insert empty line before existing member
@@ -1615,7 +1581,7 @@ class FixProcessor {
if (source != null) {
String libName = unitLibraryElement.name;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(source.fullName, -1,
+ await changeBuilder.addFileEdit(source.fullName,
(DartFileEditBuilder builder) {
// TODO(brianwilkerson) Consider using the URI rather than name
builder.addSimpleInsertion(0, 'part of $libName;$eol$eol');
@@ -1631,8 +1597,7 @@ class FixProcessor {
TypeAnnotation typeName = node.getAncestor((n) => n is TypeAnnotation);
TypeProvider typeProvider = this.typeProvider;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.replaceTypeWithFuture(typeName, typeProvider);
});
_addFixFromBuilder(changeBuilder, DartFixKind.REPLACE_RETURN_TYPE_FUTURE);
@@ -1641,8 +1606,7 @@ class FixProcessor {
Future<Null> _addFix_importLibrary(FixKind kind, Source library) async {
String libraryUri = getLibrarySourceUri(unitLibraryElement, library);
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.importLibraries([library]);
});
_addFixFromBuilder(changeBuilder, kind, args: [libraryUri]);
@@ -1674,8 +1638,7 @@ class FixProcessor {
PrefixElement prefix = imp.prefix;
if (prefix != null) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleReplacement(
range.startLength(node, 0), '${prefix.displayName}.');
});
@@ -1704,10 +1667,8 @@ class FixProcessor {
int offset = showCombinator.offset;
int length = showCombinator.end - offset;
String libraryFile = unitLibraryElement.source.fullName;
- int libraryStamp = unitLibraryElement.context
- .getModificationStamp(unitLibraryElement.source);
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(libraryFile, libraryStamp,
+ await changeBuilder.addFileEdit(libraryFile,
(DartFileEditBuilder builder) {
builder.addSimpleReplacement(
new SourceRange(offset, length), newShowCode);
@@ -1791,8 +1752,7 @@ class FixProcessor {
}
int insertOffset = error.offset + error.length;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleInsertion(insertOffset, ';');
});
_addFixFromBuilder(changeBuilder, DartFixKind.INSERT_SEMICOLON);
@@ -1803,8 +1763,7 @@ class FixProcessor {
if (coveredNode is IsExpression) {
IsExpression isExpression = coveredNode as IsExpression;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder
.addReplacement(range.endEnd(isExpression.expression, isExpression),
(DartEditBuilder builder) {
@@ -1819,8 +1778,7 @@ class FixProcessor {
if (coveredNode is IsExpression) {
IsExpression isExpression = coveredNode as IsExpression;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder
.addReplacement(range.endEnd(isExpression.expression, isExpression),
(DartEditBuilder builder) {
@@ -1839,8 +1797,7 @@ class FixProcessor {
}
String className = enclosingClass.name.name;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleInsertion(
enclosingClass.classKeyword.offset, 'abstract ');
});
@@ -1869,7 +1826,7 @@ class FixProcessor {
if (declarationList.variables.length == 1 &&
keywordToken.keyword == Keyword.FINAL) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
+ await changeBuilder.addFileEdit(file,
(DartFileEditBuilder builder) {
if (declarationList.type != null) {
builder.addReplacement(
@@ -1893,8 +1850,7 @@ class FixProcessor {
Future<Null> _addFix_nonBoolCondition_addNotNull() async {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleInsertion(error.offset + error.length, ' != null');
});
_addFixFromBuilder(changeBuilder, DartFixKind.ADD_NE_NULL);
@@ -1905,8 +1861,7 @@ class FixProcessor {
if (awaitExpression is AwaitExpression) {
final awaitToken = awaitExpression.awaitKeyword;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(range.startStart(awaitToken, awaitToken.next));
});
_addFixFromBuilder(changeBuilder, DartFixKind.REMOVE_AWAIT);
@@ -1920,8 +1875,7 @@ class FixProcessor {
if (parent is BinaryExpression) {
if (parent.rightOperand == coveredNode) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(range.endEnd(parent.leftOperand, coveredNode));
});
_addFixFromBuilder(changeBuilder, DartFixKind.REMOVE_DEAD_CODE);
@@ -1939,8 +1893,7 @@ class FixProcessor {
SourceRange rangeToRemove =
utils.getLinesRangeStatements(statementsToRemove);
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(rangeToRemove);
});
_addFixFromBuilder(changeBuilder, DartFixKind.REMOVE_DEAD_CODE);
@@ -1949,8 +1902,7 @@ class FixProcessor {
SourceRange rangeToRemove =
utils.getLinesRangeStatements(<Statement>[coveringNode]);
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(rangeToRemove);
});
_addFixFromBuilder(changeBuilder, DartFixKind.REMOVE_DEAD_CODE);
@@ -1961,15 +1913,13 @@ class FixProcessor {
EmptyStatement emptyStatement = node;
if (emptyStatement.parent is Block) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(utils.getLinesRange(range.node(emptyStatement)));
});
_addFixFromBuilder(changeBuilder, DartFixKind.REMOVE_EMPTY_STATEMENT);
} else {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleReplacement(
range.endEnd(emptyStatement.beginToken.previous, emptyStatement),
' {}');
@@ -1986,8 +1936,7 @@ class FixProcessor {
return;
}
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(range.endEnd(ancestor.name, ancestor.initializer));
});
_addFixFromBuilder(changeBuilder, DartFixKind.REMOVE_INITIALIZER);
@@ -1999,8 +1948,7 @@ class FixProcessor {
Token right = node.rightBracket;
if (node.expression != null && right != null) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleReplacement(
range.startStart(node, node.expression), r'$');
builder.addDeletion(range.token(right));
@@ -2016,8 +1964,7 @@ class FixProcessor {
node.getAncestor((node) => node is MethodDeclaration);
if (declaration != null) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(utils.getLinesRange(range.node(declaration)));
});
_addFixFromBuilder(changeBuilder, DartFixKind.REMOVE_METHOD_DECLARATION);
@@ -2031,8 +1978,7 @@ class FixProcessor {
FunctionBody body = method.body;
if (name != null && body != null) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleReplacement(range.endStart(name, body), ' ');
});
_addFixFromBuilder(
@@ -2046,8 +1992,7 @@ class FixProcessor {
MethodInvocation invocation = node.parent as MethodInvocation;
if (invocation.methodName == node && invocation.target != null) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(range.endEnd(node, invocation));
});
_addFixFromBuilder(
@@ -2063,15 +2008,13 @@ class FixProcessor {
final parent = thisExpression.parent;
if (parent is PropertyAccess) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(range.startEnd(parent, parent.operator));
});
_addFixFromBuilder(changeBuilder, DartFixKind.REMOVE_THIS_EXPRESSION);
} else if (parent is MethodInvocation) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(range.startEnd(parent, parent.operator));
});
_addFixFromBuilder(changeBuilder, DartFixKind.REMOVE_THIS_EXPRESSION);
@@ -2082,8 +2025,7 @@ class FixProcessor {
final TypeName type = node.getAncestor((node) => node is TypeName);
if (type != null) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(range.startStart(type, type.endToken.next));
});
_addFixFromBuilder(changeBuilder, DartFixKind.REMOVE_TYPE_NAME);
@@ -2099,8 +2041,7 @@ class FixProcessor {
int expressionPrecedence = getExpressionPrecedence(expression);
// remove 'as T' from 'e as T'
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(range.endEnd(expression, asExpression));
_removeEnclosingParentheses(builder, asExpression, expressionPrecedence);
});
@@ -2113,8 +2054,7 @@ class FixProcessor {
if (catchClause is CatchClause &&
catchClause.exceptionParameter == node) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(
range.startStart(catchClause.catchKeyword, catchClause.body));
});
@@ -2131,8 +2071,7 @@ class FixProcessor {
catchClause.stackTraceParameter == node &&
catchClause.exceptionParameter != null) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder
.addDeletion(range.endEnd(catchClause.exceptionParameter, node));
});
@@ -2151,8 +2090,7 @@ class FixProcessor {
}
// remove the whole line with import
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addDeletion(utils.getLinesRange(range.node(importDirective)));
});
_addFixFromBuilder(changeBuilder, DartFixKind.REMOVE_UNUSED_IMPORT);
@@ -2160,8 +2098,7 @@ class FixProcessor {
Future<Null> _addFix_replaceVarWithDynamic() async {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleReplacement(range.error(error), 'dynamic');
});
_addFixFromBuilder(changeBuilder, DartFixKind.REPLACE_VAR_WITH_DYNAMIC);
@@ -2184,8 +2121,7 @@ class FixProcessor {
final expression = thenStatement.expression.unParenthesized;
if (expression is AssignmentExpression) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addReplacement(range.node(ifStatement),
(DartEditBuilder builder) {
builder.write(utils.getNodeText(expression.leftHandSide));
@@ -2204,8 +2140,7 @@ class FixProcessor {
if (coveredNode is InstanceCreationExpression) {
var instanceCreation = coveredNode as InstanceCreationExpression;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleReplacement(
range.token(instanceCreation.keyword), 'const');
});
@@ -2218,8 +2153,7 @@ class FixProcessor {
node.getAncestor((node) => node is FunctionTypedFormalParameter);
if (functionTyped != null) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleReplacement(range.node(functionTyped),
utils.getNodeText(functionTyped.identifier));
});
@@ -2235,8 +2169,7 @@ class FixProcessor {
final InterfaceType type = instanceCreation.staticType;
final generics = instanceCreation.constructorName.type.typeArguments;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addReplacement(range.node(instanceCreation),
(DartEditBuilder builder) {
if (generics != null) {
@@ -2260,8 +2193,7 @@ class FixProcessor {
}
Future<Null> addFixOfExpression(InvocationExpression expression) async {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addReplacement(range.node(ancestor), (DartEditBuilder builder) {
if (expression is MethodInvocation && expression.target != null) {
builder.write(utils.getNodeText(expression.target));
@@ -2328,8 +2260,7 @@ class FixProcessor {
String closestName = finder._element.name;
if (closestName != null) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleReplacement(range.node(node), closestName);
});
_addFixFromBuilder(changeBuilder, DartFixKind.CHANGE_TO,
@@ -2392,8 +2323,7 @@ class FixProcessor {
if (finder._element != null) {
String closestName = finder._element.name;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleReplacement(range.node(node), closestName);
});
_addFixFromBuilder(changeBuilder, DartFixKind.CHANGE_TO,
@@ -2424,8 +2354,7 @@ class FixProcessor {
utils.targetClassElement = null;
// build method source
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addInsertion(insertOffset, (DartEditBuilder builder) {
builder.write(sourcePrefix);
// append return type
@@ -2486,8 +2415,7 @@ class FixProcessor {
if (finder._element != null) {
String closestName = finder._element.name;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
builder.addSimpleReplacement(range.node(node), closestName);
});
_addFixFromBuilder(changeBuilder, DartFixKind.CHANGE_TO,
@@ -2545,11 +2473,9 @@ class FixProcessor {
ClassMemberLocation targetLocation =
utils.prepareNewMethodLocation(targetClassNode);
String targetFile = targetElement.source.fullName;
- int targetStamp =
- targetElement.context.getModificationStamp(targetElement.source);
// build method source
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(targetFile, targetStamp,
+ await changeBuilder.addFileEdit(targetFile,
(DartFileEditBuilder builder) {
builder.addInsertion(targetLocation.offset, (DartEditBuilder builder) {
builder.write(targetLocation.prefix);
@@ -2615,8 +2541,7 @@ class FixProcessor {
}
}
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
// append new field formal initializers
if (lastRequiredParameter != null) {
builder.addSimpleInsertion(
@@ -2639,8 +2564,7 @@ class FixProcessor {
n.length == errorLength) {
Expression target = (n as MethodInvocation).target.unParenthesized;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
// replace "/" with "~/"
BinaryExpression binary = target as BinaryExpression;
builder.addSimpleReplacement(range.token(binary.operator), '~/');
@@ -2665,8 +2589,7 @@ class FixProcessor {
if (declaringElement is ClassElement) {
DartType declaringType = declaringElement.type;
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(file, fileStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {
// replace "target" with class name
builder.addReplacement(range.node(target), (DartEditBuilder builder) {
builder.writeType(declaringType);
@@ -2725,10 +2648,8 @@ class FixProcessor {
Element target) async {
// build method source
String targetFile = targetSource.fullName;
- int timeStamp = target.context.getModificationStamp(targetSource);
DartChangeBuilder changeBuilder = new DartChangeBuilder(driver);
- await changeBuilder.addFileEdit(targetFile, timeStamp,
- (DartFileEditBuilder builder) {
+ await changeBuilder.addFileEdit(targetFile, (DartFileEditBuilder builder) {
builder.addInsertion(insertOffset, (DartEditBuilder builder) {
builder.write(sourcePrefix);
builder.write(prefix);
@@ -3111,12 +3032,6 @@ class FixProcessor {
.isWithin(packageRoot.path, source.fullName);
}
- int _modificationStamp(String filePath) {
- // TODO(brianwilkerson) We have lost the ability for clients to know whether
- // it is safe to apply an edit.
- return driver.fsState.getFileForPath(filePath).exists ? 0 : -1;
- }
-
/**
* Removes any [ParenthesizedExpression] enclosing [expr].
*

Powered by Google App Engine
This is Rietveld 408576698