1) rollback of rollback fixRetrieveRightBraceOrSemiColonPosition

2) HandleEqualsAndHashCode now use SetGeneratedByVisitor to ensure "correct" sourcepositions
3) SetGeneratedByVisitor now sets QualifiedNameReference.sourcePositions
This commit is contained in:
Jappe van der Hel committed 2012-01-18 11:53:17 +01:00
1 parent 68fe3f41e9
commit 5185f97cd6
3 files changed
+14 -4

No files matched your search

@@ -222,14 +222,17 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
}
MethodDeclaration equalsMethod = createEquals(typeNode, nodesForEquality, callSuper, errorNode.get(), fieldAccess, needsCanEqual);
equalsMethod.traverse(new SetGeneratedByVisitor(errorNode.get()), ((TypeDeclaration)typeNode.get()).scope);
injectMethod(typeNode, equalsMethod);
if (needsCanEqual) {
MethodDeclaration canEqualMethod = createCanEqual(typeNode, errorNode.get());
canEqualMethod.traverse(new SetGeneratedByVisitor(errorNode.get()), ((TypeDeclaration)typeNode.get()).scope);
injectMethod(typeNode, canEqualMethod);
}
MethodDeclaration hashCodeMethod = createHashCode(typeNode, nodesForEquality, callSuper, errorNode.get(), fieldAccess);
hashCodeMethod.traverse(new SetGeneratedByVisitor(errorNode.get()), ((TypeDeclaration)typeNode.get()).scope);
injectMethod(typeNode, hashCodeMethod);
}
@@ -247,6 +247,13 @@ public final class SetGeneratedByVisitor extends ASTVisitor {
node.nameSourcePosition = recalcSourcePosition(node.nameSourcePosition);
}
private void applyOffsetQualifiedNameReference(QualifiedNameReference node) {
applyOffsetExpression(node);
for (int i = 0; i < node.sourcePositions.length; i++) {
node.sourcePositions[i] = recalcSourcePosition(node.sourcePositions[i]);
}
}
private void applyOffsetQualifiedTypeReference(QualifiedTypeReference node) {
applyOffsetExpression(node);
for (int i = 0; i < node.sourcePositions.length; i++) {
@@ -787,8 +794,8 @@ public final class SetGeneratedByVisitor extends ASTVisitor {
}
@Override public boolean visit(QualifiedNameReference node, BlockScope scope) {
setGeneratedBy(node, source);
applyOffsetExpression(node);
setGeneratedBy(node, source);
applyOffsetQualifiedNameReference(node);
return super.visit(node, scope);
}
@@ -237,8 +237,8 @@ public class PatchFixes {
}
public static int fixRetrieveRightBraceOrSemiColonPosition(int original, int end) {
return original;
// return original == -1 ? end : original; // Need to fix: see issue 325.
// return original;
return original == -1 ? end : original; // Need to fix: see issue 325.
}
public static final int ALREADY_PROCESSED_FLAG = 0x800000; //Bit 24