aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE2
-rw-r--r--build.xml1
-rw-r--r--doc/changelog.markdown1
-rw-r--r--src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java4
-rw-r--r--src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java4
-rw-r--r--src/core/lombok/eclipse/handlers/SetGeneratedByVisitor.java346
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java8
-rw-r--r--src/delombok/lombok/delombok/DelombokResult.java12
-rw-r--r--src/delombok/lombok/delombok/PrettyCommentsPrinter.java16
-rw-r--r--src/utils/lombok/javac/CommentCatcher.java17
-rw-r--r--src/utils/lombok/javac/CommentInfo.java (renamed from src/utils/lombok/javac/Comment.java)24
-rw-r--r--src/utils/lombok/javac/java6/CommentCollectingParser.java8
-rw-r--r--src/utils/lombok/javac/java6/CommentCollectingParserFactory.java8
-rw-r--r--src/utils/lombok/javac/java6/CommentCollectingScanner.java19
-rw-r--r--src/utils/lombok/javac/java7/CommentCollectingParser.java8
-rw-r--r--src/utils/lombok/javac/java7/CommentCollectingParserFactory.java8
-rw-r--r--src/utils/lombok/javac/java7/CommentCollectingScanner.java19
-rw-r--r--website/features/SneakyThrows.html6
18 files changed, 273 insertions, 238 deletions
diff --git a/LICENSE b/LICENSE
index d52e9ca5..1ff49b20 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (C) 2009-2010 The Project Lombok Authors.
+Copyright (C) 2009-2011 The Project Lombok Authors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/build.xml b/build.xml
index 510ba2df..3af7fd9a 100644
--- a/build.xml
+++ b/build.xml
@@ -188,6 +188,7 @@ the common tasks and can be called on to run the main aspects of all the sub-scr
</fileset>
<fileset dir="build" includes="changelog.txt" />
<fileset dir="." includes="LICENSE" />
+ <fileset dir="." includes="AUTHORS" />
<rule pattern="com.zwitserloot.cmdreader.**" result="lombok.libs.com.zwitserloot.cmdreader.@1" />
<rule pattern="org.objectweb.asm.**" result="lombok.libs.org.objectweb.asm.@1" />
<manifest>
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 04917001..74930b33 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -2,6 +2,7 @@ Lombok Changelog
----------------
### v0.10.5 (EDGE)
+* BUGFIX: Performance issues (memory leaks) when using lombok in netbeans, introduced in 0.10, have been fixed. [Issue #242](http://code.google.com/p/projectlombok/issues/detail?id=242)
* BUGFIX: Eclipse quickfix "Add unimplemented methods" would sometimes insert the new method stubs in strange places, especially if `@Data` was present. [Issue #51](http://code.google.com/p/projectlombok/issues/detail?id=51)
* BUGFIX: Using save action 'Use this qualifier for field accesses, only if necessary' did not work together with `@Data` in certain cases. [Issue #301](http://code.google.com/p/projectlombok/issues/detail?id=301)
diff --git a/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java b/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java
index 28d8d687..6815f5d9 100644
--- a/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java
+++ b/src/core/lombok/core/runtimeDependencies/CreateLombokRuntimeApp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Project Lombok Authors.
+ * Copyright (C) 2009-2011 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -160,6 +160,8 @@ public class CreateLombokRuntimeApp implements LombokApp {
boolean success = false;
try {
JarOutputStream jar = new JarOutputStream(out);
+ deps.put("LICENSE", CreateLombokRuntimeApp.class);
+ deps.put("AUTHORS", CreateLombokRuntimeApp.class);
for (Entry<String, Class<?>> dep : deps.entrySet()) {
InputStream in = dep.getValue().getResourceAsStream("/" + dep.getKey());
try {
diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
index 3c41f834..d4c63da3 100644
--- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
@@ -478,7 +478,8 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
setGeneratedBy(oRef, source);
TypeReference typeReference = createTypeReference(type, p);
-
+ setGeneratedBy(typeReference, source);
+
InstanceOfExpression instanceOf = new InstanceOfExpression(oRef, typeReference);
instanceOf.sourceStart = pS; instanceOf.sourceEnd = pE;
setGeneratedBy(instanceOf, source);
@@ -705,7 +706,6 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
setGeneratedBy(otherRef, source);
TypeReference typeReference = createTypeReference(type, p);
-
setGeneratedBy(typeReference, source);
InstanceOfExpression instanceOf = new InstanceOfExpression(otherRef, typeReference);
diff --git a/src/core/lombok/eclipse/handlers/SetGeneratedByVisitor.java b/src/core/lombok/eclipse/handlers/SetGeneratedByVisitor.java
index 588efc1b..8d5648fa 100644
--- a/src/core/lombok/eclipse/handlers/SetGeneratedByVisitor.java
+++ b/src/core/lombok/eclipse/handlers/SetGeneratedByVisitor.java
@@ -104,6 +104,8 @@ import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
public final class SetGeneratedByVisitor extends ASTVisitor {
+ private static final long INT_TO_LONG_MASK = 0x00000000FFFFFFFFL;
+
private final ASTNode source;
private final int newSourceStart;
private final int newSourceEnd;
@@ -114,61 +116,61 @@ public final class SetGeneratedByVisitor extends ASTVisitor {
this.newSourceEnd = this.source.sourceEnd;
}
- private static void applyOffset(JavadocAllocationExpression node, int newSourceStart, int newSourceEnd) {
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ private void applyOffset(JavadocAllocationExpression node) {
+ applyOffsetExpression(node);
node.memberStart = newSourceStart;
node.tagSourceEnd = newSourceEnd;
node.tagSourceStart = newSourceStart;
}
- private static void applyOffset(JavadocMessageSend node, int newSourceStart, int newSourceEnd) {
- applyOffsetMessageSend(node, newSourceStart, newSourceEnd);
+ private void applyOffset(JavadocMessageSend node) {
+ applyOffsetMessageSend(node);
node.tagSourceEnd = newSourceEnd;
node.tagSourceStart = newSourceStart;
}
- private static void applyOffset(JavadocSingleNameReference node, int newSourceStart, int newSourceEnd) {
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ private void applyOffset(JavadocSingleNameReference node) {
+ applyOffsetExpression(node);
node.tagSourceEnd = newSourceEnd;
node.tagSourceStart = newSourceStart;
}
- private static void applyOffset(JavadocSingleTypeReference node, int newSourceStart, int newSourceEnd) {
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ private void applyOffset(JavadocSingleTypeReference node) {
+ applyOffsetExpression(node);
node.tagSourceEnd = newSourceEnd;
node.tagSourceStart = newSourceStart;
}
- private static void applyOffset(JavadocFieldReference node, int newSourceStart, int newSourceEnd) {
- applyOffsetFieldReference(node, newSourceStart, newSourceEnd);
+ private void applyOffset(JavadocFieldReference node) {
+ applyOffsetFieldReference(node);
node.tagSourceEnd = newSourceEnd;
node.tagSourceStart = newSourceStart;
}
- private static void applyOffset(JavadocArrayQualifiedTypeReference node, int newSourceStart, int newSourceEnd) {
- applyOffsetQualifiedTypeReference(node, newSourceStart, newSourceEnd);
+ private void applyOffset(JavadocArrayQualifiedTypeReference node) {
+ applyOffsetQualifiedTypeReference(node);
node.tagSourceEnd = newSourceEnd;
node.tagSourceStart = newSourceStart;
}
- private static void applyOffset(JavadocQualifiedTypeReference node, int newSourceStart, int newSourceEnd) {
- applyOffsetQualifiedTypeReference(node, newSourceStart, newSourceEnd);
+ private void applyOffset(JavadocQualifiedTypeReference node) {
+ applyOffsetQualifiedTypeReference(node);
node.tagSourceEnd = newSourceEnd;
node.tagSourceStart = newSourceStart;
}
- private static void applyOffset(Annotation node, int newSourceStart, int newSourceEnd) {
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ private void applyOffset(Annotation node) {
+ applyOffsetExpression(node);
node.declarationSourceEnd = newSourceEnd;
}
- private static void applyOffset(ArrayTypeReference node, int newSourceStart, int newSourceEnd) {
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ private void applyOffset(ArrayTypeReference node) {
+ applyOffsetExpression(node);
node.originalSourceEnd = newSourceEnd;
}
- private static void applyOffset(AbstractMethodDeclaration node, int newSourceStart, int newSourceEnd) {
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ private void applyOffset(AbstractMethodDeclaration node) {
+ applyOffsetASTNode(node);
node.bodyEnd = newSourceEnd;
node.bodyStart = newSourceStart;
node.declarationSourceEnd = newSourceEnd;
@@ -176,22 +178,22 @@ public final class SetGeneratedByVisitor extends ASTVisitor {
node.modifiersSourceStart = newSourceStart;
}
- private static void applyOffset(Javadoc node, int newSourceStart, int newSourceEnd) {
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ private void applyOffset(Javadoc node) {
+ applyOffsetASTNode(node);
node.valuePositions = newSourceStart;
for (int i = 0; i < node.inheritedPositions.length; i++) {
- node.inheritedPositions[i] = recalcSourcePosition(node.inheritedPositions[i], newSourceStart, newSourceEnd);
+ node.inheritedPositions[i] = recalcSourcePosition(node.inheritedPositions[i]);
}
}
- private static void applyOffset(Initializer node, int newSourceStart, int newSourceEnd) {
- applyOffsetFieldDeclaration(node, newSourceStart, newSourceEnd);
+ private void applyOffset(Initializer node) {
+ applyOffsetFieldDeclaration(node);
node.bodyStart = newSourceStart;
node.bodyEnd = newSourceEnd;
}
- private static void applyOffset(TypeDeclaration node, int newSourceStart, int newSourceEnd) {
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ private void applyOffset(TypeDeclaration node) {
+ applyOffsetASTNode(node);
node.bodyEnd = newSourceEnd;
node.bodyStart = newSourceStart;
node.declarationSourceEnd = newSourceEnd;
@@ -199,703 +201,703 @@ public final class SetGeneratedByVisitor extends ASTVisitor {
node.modifiersSourceStart = newSourceStart;
}
- private static void applyOffset(ImportReference node, int newSourceStart, int newSourceEnd) {
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ private void applyOffset(ImportReference node) {
+ applyOffsetASTNode(node);
node.declarationEnd = newSourceEnd;
node.declarationSourceEnd = newSourceEnd;
node.declarationSourceStart = newSourceStart;
for (int i = 0; i < node.sourcePositions.length; i++) {
- node.sourcePositions[i] = recalcSourcePosition(node.sourcePositions[i], newSourceStart, newSourceEnd);
+ node.sourcePositions[i] = recalcSourcePosition(node.sourcePositions[i]);
}
}
- private static void applyOffsetASTNode(ASTNode node, int newSourceStart, int newSourceEnd) {
+ private void applyOffsetASTNode(ASTNode node) {
node.sourceEnd = newSourceEnd;
node.sourceStart = newSourceStart;
}
- private static void applyOffsetExpression(Expression node, int newSourceStart, int newSourceEnd) {
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ private void applyOffsetExpression(Expression node) {
+ applyOffsetASTNode(node);
// if (node.statementEnd != -1) {
node.statementEnd = newSourceEnd;
// }
}
- private static void applyOffsetVariable(AbstractVariableDeclaration node, int newSourceStart, int newSourceEnd) {
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ private void applyOffsetVariable(AbstractVariableDeclaration node) {
+ applyOffsetASTNode(node);
node.declarationEnd = newSourceEnd;
node.declarationSourceEnd = newSourceEnd;
node.declarationSourceStart = newSourceStart;
node.modifiersSourceStart = newSourceStart;
}
- private static void applyOffsetFieldDeclaration(FieldDeclaration node, int newSourceStart, int newSourceEnd) {
- applyOffsetVariable(node, newSourceStart, newSourceEnd);
+ private void applyOffsetFieldDeclaration(FieldDeclaration node) {
+ applyOffsetVariable(node);
node.endPart1Position = newSourceEnd;
node.endPart2Position = newSourceEnd;
}
- private static void applyOffsetFieldReference(FieldReference node, int newSourceStart, int newSourceEnd) {
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
- node.nameSourcePosition = recalcSourcePosition(node.nameSourcePosition, newSourceStart, newSourceEnd);
+ private void applyOffsetFieldReference(FieldReference node) {
+ applyOffsetExpression(node);
+ node.nameSourcePosition = recalcSourcePosition(node.nameSourcePosition);
}
- private static void applyOffsetMessageSend(MessageSend node, int newSourceStart, int newSourceEnd) {
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
- node.nameSourcePosition = recalcSourcePosition(node.nameSourcePosition, newSourceStart, newSourceEnd);
+ private void applyOffsetMessageSend(MessageSend node) {
+ applyOffsetExpression(node);
+ node.nameSourcePosition = recalcSourcePosition(node.nameSourcePosition);
}
- private static void applyOffsetQualifiedTypeReference(QualifiedTypeReference node, int newSourceStart, int newSourceEnd) {
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ private void applyOffsetQualifiedTypeReference(QualifiedTypeReference node) {
+ applyOffsetExpression(node);
for (int i = 0; i < node.sourcePositions.length; i++) {
- node.sourcePositions[i] = recalcSourcePosition(node.sourcePositions[i], newSourceStart, newSourceEnd);
+ node.sourcePositions[i] = recalcSourcePosition(node.sourcePositions[i]);
}
}
- /** See {@link FieldReference#nameSourcePosition} for explanation
- * @param newSourceEnd TODO*/
- private static long recalcSourcePosition(long sourcePosition, int newSourceStart, int newSourceEnd) {
- long start = (sourcePosition >>> 32);
- long end = (sourcePosition & 0x00000000FFFFFFFFL);
- start = newSourceStart;
- end = newSourceStart;
- return ((start<<32)+end);
+ /** See {@link FieldReference#nameSourcePosition} for explanation */
+ private long recalcSourcePosition(long sourcePosition) {
+// long start = (sourcePosition >>> 32);
+// long end = (sourcePosition & 0x00000000FFFFFFFFL);
+// start = newSourceStart;
+// end = newSourceStart;
+// return ((start<<32)+end);
+ return ((long)newSourceStart << 32) | (newSourceStart & INT_TO_LONG_MASK);
}
@Override public boolean visit(AllocationExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, this.newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(AND_AND_Expression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, this.newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(AnnotationMethodDeclaration node, ClassScope classScope) {
setGeneratedBy(node, source);
- applyOffset(node, this.newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, classScope);
}
@Override public boolean visit(Argument node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetVariable(node, this.newSourceStart, newSourceEnd);
+ applyOffsetVariable(node);
return super.visit(node, scope);
}
@Override public boolean visit(Argument node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetVariable(node, this.newSourceStart, newSourceEnd);
+ applyOffsetVariable(node);
return super.visit(node, scope);
}
@Override public boolean visit(ArrayAllocationExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, this.newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(ArrayInitializer node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, this.newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(ArrayQualifiedTypeReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetQualifiedTypeReference(node, this.newSourceStart, newSourceEnd);
+ applyOffsetQualifiedTypeReference(node);
return super.visit(node, scope);
}
@Override public boolean visit(ArrayQualifiedTypeReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetQualifiedTypeReference(node, this.newSourceStart, newSourceEnd);
+ applyOffsetQualifiedTypeReference(node);
return super.visit(node, scope);
}
@Override public boolean visit(ArrayReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, this.newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(ArrayTypeReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, this.newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(ArrayTypeReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, this.newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(AssertStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, this.newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(Assignment node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(BinaryExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(Block node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(BreakStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(CaseStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(CastExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(CharLiteral node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(ClassLiteralAccess node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(Clinit node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(CompilationUnitDeclaration node, CompilationUnitScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(CompoundAssignment node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(ConditionalExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(ConstructorDeclaration node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(ContinueStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(DoStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(DoubleLiteral node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(EmptyStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(EqualExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(ExplicitConstructorCall node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(ExtendedStringLiteral node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(FalseLiteral node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(FieldDeclaration node, MethodScope scope) {
setGeneratedBy(node, source);
- applyOffsetFieldDeclaration(node, newSourceStart, newSourceEnd);
+ applyOffsetFieldDeclaration(node);
return super.visit(node, scope);
}
@Override public boolean visit(FieldReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetFieldReference(node, newSourceStart, newSourceEnd);
+ applyOffsetFieldReference(node);
return super.visit(node, scope);
}
@Override public boolean visit(FieldReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetFieldReference(node, newSourceStart, newSourceEnd);
+ applyOffsetFieldReference(node);
return super.visit(node, scope);
}
@Override public boolean visit(FloatLiteral node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(ForeachStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(ForStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(IfStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(ImportReference node, CompilationUnitScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(Initializer node, MethodScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(InstanceOfExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(IntLiteral node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(Javadoc node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(Javadoc node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocAllocationExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocAllocationExpression node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocArgumentExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocArgumentExpression node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocArrayQualifiedTypeReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocArrayQualifiedTypeReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocArraySingleTypeReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocArraySingleTypeReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocFieldReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocFieldReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocImplicitTypeReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocImplicitTypeReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocMessageSend node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocMessageSend node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocQualifiedTypeReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocQualifiedTypeReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocReturnStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocReturnStatement node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocSingleNameReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocSingleNameReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocSingleTypeReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(JavadocSingleTypeReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(LabeledStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(LocalDeclaration node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetVariable(node, newSourceStart, newSourceEnd);
+ applyOffsetVariable(node);
return super.visit(node, scope);
}
@Override public boolean visit(LongLiteral node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(MarkerAnnotation node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(MemberValuePair node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(MessageSend node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetMessageSend(node, newSourceStart, newSourceEnd);
+ applyOffsetMessageSend(node);
return super.visit(node, scope);
}
@Override public boolean visit(MethodDeclaration node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(StringLiteralConcatenation node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(NormalAnnotation node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(NullLiteral node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(OR_OR_Expression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(ParameterizedQualifiedTypeReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetQualifiedTypeReference(node, newSourceStart, newSourceEnd);
+ applyOffsetQualifiedTypeReference(node);
return super.visit(node, scope);
}
@Override public boolean visit(ParameterizedQualifiedTypeReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetQualifiedTypeReference(node, newSourceStart, newSourceEnd);
+ applyOffsetQualifiedTypeReference(node);
return super.visit(node, scope);
}
@Override public boolean visit(ParameterizedSingleTypeReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(ParameterizedSingleTypeReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(PostfixExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(PrefixExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(QualifiedAllocationExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(QualifiedNameReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(QualifiedNameReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(QualifiedSuperReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(QualifiedSuperReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(QualifiedThisReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(QualifiedThisReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(QualifiedTypeReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetQualifiedTypeReference(node, newSourceStart, newSourceEnd);
+ applyOffsetQualifiedTypeReference(node);
return super.visit(node, scope);
}
@Override public boolean visit(QualifiedTypeReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetQualifiedTypeReference(node, newSourceStart, newSourceEnd);
+ applyOffsetQualifiedTypeReference(node);
return super.visit(node, scope);
}
@Override public boolean visit(ReturnStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(SingleMemberAnnotation node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(SingleNameReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(SingleNameReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(SingleTypeReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(SingleTypeReference node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(StringLiteral node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(SuperReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(SwitchStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
node.blockStart = newSourceStart;
return super.visit(node, scope);
}
@Override public boolean visit(SynchronizedStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(ThisReference node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@@ -906,73 +908,73 @@ public final class SetGeneratedByVisitor extends ASTVisitor {
@Override public boolean visit(ThrowStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(TrueLiteral node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(TryStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(TypeDeclaration node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(TypeDeclaration node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(TypeDeclaration node, CompilationUnitScope scope) {
setGeneratedBy(node, source);
- applyOffset(node, newSourceStart, newSourceEnd);
+ applyOffset(node);
return super.visit(node, scope);
}
@Override public boolean visit(TypeParameter node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetVariable(node, newSourceStart, newSourceEnd);
+ applyOffsetVariable(node);
return super.visit(node, scope);
}
@Override public boolean visit(TypeParameter node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetVariable(node, newSourceStart, newSourceEnd);
+ applyOffsetVariable(node);
return super.visit(node, scope);
}
@Override public boolean visit(UnaryExpression node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(WhileStatement node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetASTNode(node, newSourceStart, newSourceEnd);
+ applyOffsetASTNode(node);
return super.visit(node, scope);
}
@Override public boolean visit(Wildcard node, BlockScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
@Override public boolean visit(Wildcard node, ClassScope scope) {
setGeneratedBy(node, source);
- applyOffsetExpression(node, newSourceStart, newSourceEnd);
+ applyOffsetExpression(node);
return super.visit(node, scope);
}
} \ No newline at end of file
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index fc9435d8..2bf6c4ec 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -24,6 +24,7 @@ package lombok.javac.handlers;
import static lombok.javac.Javac.*;
import java.lang.annotation.Annotation;
+import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
@@ -89,11 +90,12 @@ public class JavacHandlerUtil {
}
}
- private static Map<JCTree, JCTree> generatedNodes = new WeakHashMap<JCTree, JCTree>();
+ private static Map<JCTree, WeakReference<JCTree>> generatedNodes = new WeakHashMap<JCTree, WeakReference<JCTree>>();
public static JCTree getGeneratedBy(JCTree node) {
synchronized (generatedNodes) {
- return generatedNodes.get(node);
+ WeakReference<JCTree> ref = generatedNodes.get(node);
+ return ref == null ? null : ref.get();
}
}
@@ -111,7 +113,7 @@ public class JavacHandlerUtil {
public static <T extends JCTree> T setGeneratedBy(T node, JCTree source) {
synchronized (generatedNodes) {
if (source == null) generatedNodes.remove(node);
- else generatedNodes.put(node, source);
+ else generatedNodes.put(node, new WeakReference<JCTree>(source));
}
return node;
}
diff --git a/src/delombok/lombok/delombok/DelombokResult.java b/src/delombok/lombok/delombok/DelombokResult.java
index 0ed39607..6fd62bf6 100644
--- a/src/delombok/lombok/delombok/DelombokResult.java
+++ b/src/delombok/lombok/delombok/DelombokResult.java
@@ -27,16 +27,16 @@ import java.util.List;
import javax.tools.JavaFileObject;
-import lombok.javac.Comment;
+import lombok.javac.CommentInfo;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
public class DelombokResult {
- private final List<Comment> comments;
+ private final List<CommentInfo> comments;
private final JCCompilationUnit compilationUnit;
private final boolean changed;
- public DelombokResult(List<Comment> comments, JCCompilationUnit compilationUnit, boolean changed) {
+ public DelombokResult(List<CommentInfo> comments, JCCompilationUnit compilationUnit, boolean changed) {
this.comments = comments;
this.compilationUnit = compilationUnit;
this.changed = changed;
@@ -55,9 +55,9 @@ public class DelombokResult {
out.write(String.valueOf(new Date()));
out.write(System.getProperty("line.separator"));
- com.sun.tools.javac.util.List<Comment> comments_;
- if (comments instanceof com.sun.tools.javac.util.List) comments_ = (com.sun.tools.javac.util.List<Comment>) comments;
- else comments_ = com.sun.tools.javac.util.List.from(comments.toArray(new Comment[0]));
+ com.sun.tools.javac.util.List<CommentInfo> comments_;
+ if (comments instanceof com.sun.tools.javac.util.List) comments_ = (com.sun.tools.javac.util.List<CommentInfo>) comments;
+ else comments_ = com.sun.tools.javac.util.List.from(comments.toArray(new CommentInfo[0]));
compilationUnit.accept(new PrettyCommentsPrinter(out, compilationUnit, comments_));
}
diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
index 387938c6..9b3b7eb8 100644
--- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
@@ -39,10 +39,10 @@ import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
-import lombok.javac.Comment;
+import lombok.javac.CommentInfo;
import lombok.javac.Javac;
-import lombok.javac.Comment.EndConnection;
-import lombok.javac.Comment.StartConnection;
+import lombok.javac.CommentInfo.EndConnection;
+import lombok.javac.CommentInfo.StartConnection;
import com.sun.source.tree.Tree;
import com.sun.tools.javac.code.BoundKind;
@@ -199,7 +199,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
}
}
- private List<Comment> comments;
+ private List<CommentInfo> comments;
private final JCCompilationUnit cu;
private boolean onNewLine = true;
private boolean aligned = false;
@@ -209,7 +209,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
private boolean needsNewLine = false;
private boolean needsAlign = false;
- public PrettyCommentsPrinter(Writer out, JCCompilationUnit cu, List<Comment> comments) {
+ public PrettyCommentsPrinter(Writer out, JCCompilationUnit cu, List<CommentInfo> comments) {
this.out = out;
this.comments = comments;
this.cu = cu;
@@ -222,7 +222,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
private void consumeComments(int till) throws IOException {
boolean prevNewLine = onNewLine;
boolean found = false;
- Comment head = comments.head;
+ CommentInfo head = comments.head;
while (comments.nonEmpty() && head.pos < till) {
printComment(head);
comments = comments.tail;
@@ -235,7 +235,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
private void consumeTrailingComments(int from) throws IOException {
boolean prevNewLine = onNewLine;
- Comment head = comments.head;
+ CommentInfo head = comments.head;
boolean stop = false;
while (comments.nonEmpty() && head.prevEndPos == from && !stop && !(head.start == StartConnection.ON_NEXT_LINE || head.start == StartConnection.START_OF_LINE)) {
from = head.endPos;
@@ -249,7 +249,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
}
}
- private void printComment(Comment comment) throws IOException {
+ private void printComment(CommentInfo comment) throws IOException {
prepareComment(comment.start);
print(comment.content);
switch (comment.end) {
diff --git a/src/utils/lombok/javac/CommentCatcher.java b/src/utils/lombok/javac/CommentCatcher.java
index 3bd64ec7..474dc43d 100644
--- a/src/utils/lombok/javac/CommentCatcher.java
+++ b/src/utils/lombok/javac/CommentCatcher.java
@@ -21,24 +21,23 @@
*/
package lombok.javac;
-import java.util.Collections;
-import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.List;
public class CommentCatcher {
private final JavaCompiler compiler;
- private final Map<JCCompilationUnit, List<Comment>> commentsMap;
+ private final Map<JCCompilationUnit, List<CommentInfo>> commentsMap;
public static CommentCatcher create(Context context) {
registerCommentsCollectingScannerFactory(context);
JavaCompiler compiler = new JavaCompiler(context);
- Map<JCCompilationUnit, List<Comment>> commentsMap = new WeakHashMap<JCCompilationUnit, List<Comment>>();
+ Map<JCCompilationUnit, List<CommentInfo>> commentsMap = new WeakHashMap<JCCompilationUnit, List<CommentInfo>>();
setInCompiler(compiler, context, commentsMap);
compiler.keepComments = true;
@@ -47,7 +46,7 @@ public class CommentCatcher {
return new CommentCatcher(compiler, commentsMap);
}
- private CommentCatcher(JavaCompiler compiler, Map<JCCompilationUnit, List<Comment>> commentsMap) {
+ private CommentCatcher(JavaCompiler compiler, Map<JCCompilationUnit, List<CommentInfo>> commentsMap) {
this.compiler = compiler;
this.commentsMap = commentsMap;
}
@@ -56,9 +55,9 @@ public class CommentCatcher {
return compiler;
}
- public List<Comment> getComments(JCCompilationUnit ast) {
- List<Comment> list = commentsMap.get(ast);
- return list == null ? Collections.<Comment>emptyList() : list;
+ public List<CommentInfo> getComments(JCCompilationUnit ast) {
+ List<CommentInfo> list = commentsMap.get(ast);
+ return list == null ? List.<CommentInfo>nil() : list;
}
private static void registerCommentsCollectingScannerFactory(Context context) {
@@ -74,7 +73,7 @@ public class CommentCatcher {
}
}
- private static void setInCompiler(JavaCompiler compiler, Context context, Map<JCCompilationUnit, List<Comment>> commentsMap) {
+ private static void setInCompiler(JavaCompiler compiler, Context context, Map<JCCompilationUnit, List<CommentInfo>> commentsMap) {
try {
if (JavaCompiler.version().startsWith("1.6")) {
diff --git a/src/utils/lombok/javac/Comment.java b/src/utils/lombok/javac/CommentInfo.java
index 491f17c7..7375d51a 100644
--- a/src/utils/lombok/javac/Comment.java
+++ b/src/utils/lombok/javac/CommentInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Project Lombok Authors.
+ * Copyright (C) 2009-2011 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -21,17 +21,31 @@
*/
package lombok.javac;
-public final class Comment {
+public final class CommentInfo {
public enum StartConnection {
+ /* Comment's start immediately follows a newline. */
START_OF_LINE,
+
+ /* Comment's start does not immediately follow a newline, but there is a newline between this
+ * and the previous comment (or pos 0 if first comment). */
ON_NEXT_LINE,
+
+ /* Comment's start immediately follows previous comment's end (or pos 0 if first comment). */
DIRECT_AFTER_PREVIOUS,
+
+ /* Comment's start does not immediately follow previous comment's end, but there is no newline in
+ * between this and previous comment (or pos 0 if first comment). */
AFTER_PREVIOUS
}
public enum EndConnection {
+ /* Comment is followed immediately by another node (not whitespace, not newline). */
DIRECT_AFTER_COMMENT,
+
+ /* Comment is followed by some non-newline whitespace then by another node. */
AFTER_COMMENT,
+
+ /* Comment is followed by optionally some whitespace then a newline. */
ON_NEXT_LINE
}
@@ -42,7 +56,7 @@ public final class Comment {
public final StartConnection start;
public final EndConnection end;
- public Comment(int prevEndPos, int pos, int endPos, String content, StartConnection start, EndConnection end) {
+ public CommentInfo(int prevEndPos, int pos, int endPos, String content, StartConnection start, EndConnection end) {
this.pos = pos;
this.prevEndPos = prevEndPos;
this.endPos = endPos;
@@ -51,6 +65,10 @@ public final class Comment {
this.end = end;
}
+ public boolean isJavadoc() {
+ return content.startsWith("/**");
+ }
+
@Override
public String toString() {
return String.format("%d: %s (%s,%s)", pos, content, start, end);
diff --git a/src/utils/lombok/javac/java6/CommentCollectingParser.java b/src/utils/lombok/javac/java6/CommentCollectingParser.java
index 0915bbb8..94a85e55 100644
--- a/src/utils/lombok/javac/java6/CommentCollectingParser.java
+++ b/src/utils/lombok/javac/java6/CommentCollectingParser.java
@@ -2,7 +2,7 @@ package lombok.javac.java6;
import java.util.Map;
-import lombok.javac.Comment;
+import lombok.javac.CommentInfo;
import com.sun.tools.javac.parser.EndPosParser;
import com.sun.tools.javac.parser.Lexer;
@@ -12,10 +12,10 @@ import com.sun.tools.javac.util.List;
class CommentCollectingParser extends EndPosParser {
- private final Map<JCCompilationUnit, List<Comment>> commentsMap;
+ private final Map<JCCompilationUnit, List<CommentInfo>> commentsMap;
private final Lexer lexer;
- protected CommentCollectingParser(Parser.Factory fac, Lexer S, boolean keepDocComments, Map<JCCompilationUnit, List<Comment>> commentsMap) {
+ protected CommentCollectingParser(Parser.Factory fac, Lexer S, boolean keepDocComments, Map<JCCompilationUnit, List<CommentInfo>> commentsMap) {
super(fac, S, keepDocComments);
lexer = S;
this.commentsMap = commentsMap;
@@ -24,7 +24,7 @@ class CommentCollectingParser extends EndPosParser {
@Override public JCCompilationUnit compilationUnit() {
JCCompilationUnit result = super.compilationUnit();
if (lexer instanceof CommentCollectingScanner) {
- List<Comment> comments = ((CommentCollectingScanner)lexer).getComments();
+ List<CommentInfo> comments = ((CommentCollectingScanner)lexer).getComments();
commentsMap.put(result, comments);
}
return result;
diff --git a/src/utils/lombok/javac/java6/CommentCollectingParserFactory.java b/src/utils/lombok/javac/java6/CommentCollectingParserFactory.java
index 074f956e..b2a248c8 100644
--- a/src/utils/lombok/javac/java6/CommentCollectingParserFactory.java
+++ b/src/utils/lombok/javac/java6/CommentCollectingParserFactory.java
@@ -3,7 +3,7 @@ package lombok.javac.java6;
import java.lang.reflect.Field;
import java.util.Map;
-import lombok.javac.Comment;
+import lombok.javac.CommentInfo;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.parser.Lexer;
@@ -13,13 +13,13 @@ import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
public class CommentCollectingParserFactory extends Parser.Factory {
- private final Map<JCCompilationUnit, List<Comment>> commentsMap;
+ private final Map<JCCompilationUnit, List<CommentInfo>> commentsMap;
static Context.Key<Parser.Factory> key() {
return parserFactoryKey;
}
- protected CommentCollectingParserFactory(Context context, Map<JCCompilationUnit, List<Comment>> commentsMap) {
+ protected CommentCollectingParserFactory(Context context, Map<JCCompilationUnit, List<CommentInfo>> commentsMap) {
super(context);
this.commentsMap = commentsMap;
}
@@ -32,7 +32,7 @@ public class CommentCollectingParserFactory extends Parser.Factory {
//Either way this will work out.
}
- public static void setInCompiler(JavaCompiler compiler, Context context, Map<JCCompilationUnit, List<Comment>> commentsMap) {
+ public static void setInCompiler(JavaCompiler compiler, Context context, Map<JCCompilationUnit, List<CommentInfo>> commentsMap) {
context.put(CommentCollectingParserFactory.key(), (Parser.Factory)null);
Field field;
try {
diff --git a/src/utils/lombok/javac/java6/CommentCollectingScanner.java b/src/utils/lombok/javac/java6/CommentCollectingScanner.java
index a33b4055..66e1514d 100644
--- a/src/utils/lombok/javac/java6/CommentCollectingScanner.java
+++ b/src/utils/lombok/javac/java6/CommentCollectingScanner.java
@@ -23,9 +23,9 @@ package lombok.javac.java6;
import java.nio.CharBuffer;
-import lombok.javac.Comment;
-import lombok.javac.Comment.EndConnection;
-import lombok.javac.Comment.StartConnection;
+import lombok.javac.CommentInfo;
+import lombok.javac.CommentInfo.EndConnection;
+import lombok.javac.CommentInfo.StartConnection;
import com.sun.tools.javac.parser.Scanner;
import com.sun.tools.javac.util.List;
@@ -33,7 +33,7 @@ import com.sun.tools.javac.util.ListBuffer;
public class CommentCollectingScanner extends Scanner {
- private final ListBuffer<Comment> comments = ListBuffer.lb();
+ private final ListBuffer<CommentInfo> comments = ListBuffer.lb();
private int endComment = 0;
public CommentCollectingScanner(CommentCollectingScannerFactory factory, CharBuffer charBuffer) {
@@ -54,14 +54,19 @@ public class CommentCollectingScanner extends Scanner {
StartConnection start = determineStartConnection(prevEndPos, pos);
EndConnection end = determineEndConnection(endPos);
- Comment comment = new Comment(prevEndPos, pos, endPos, content, start, end);
+ CommentInfo comment = new CommentInfo(prevEndPos, pos, endPos, content, start, end);
comments.append(comment);
}
private EndConnection determineEndConnection(int pos) {
boolean first = true;
for (int i = pos;; i++) {
- char c = getRawCharacters(i, i + 1)[0];
+ char c;
+ try {
+ c = getRawCharacters(i, i + 1)[0];
+ } catch (IndexOutOfBoundsException e) {
+ c = '\n';
+ }
if (isNewLine(c)) {
return EndConnection.ON_NEXT_LINE;
}
@@ -93,7 +98,7 @@ public class CommentCollectingScanner extends Scanner {
return c == '\n' || c == '\r';
}
- public List<Comment> getComments() {
+ public List<CommentInfo> getComments() {
return comments.toList();
}
}
diff --git a/src/utils/lombok/javac/java7/CommentCollectingParser.java b/src/utils/lombok/javac/java7/CommentCollectingParser.java
index 54cdb6a9..82f19c42 100644
--- a/src/utils/lombok/javac/java7/CommentCollectingParser.java
+++ b/src/utils/lombok/javac/java7/CommentCollectingParser.java
@@ -3,7 +3,7 @@ package lombok.javac.java7;
import java.util.List;
import java.util.Map;
-import lombok.javac.Comment;
+import lombok.javac.CommentInfo;
import com.sun.tools.javac.parser.EndPosParser;
import com.sun.tools.javac.parser.Lexer;
@@ -11,11 +11,11 @@ import com.sun.tools.javac.parser.ParserFactory;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
class CommentCollectingParser extends EndPosParser {
- private final Map<JCCompilationUnit, List<Comment>> commentsMap;
+ private final Map<JCCompilationUnit, List<CommentInfo>> commentsMap;
private final Lexer lexer;
protected CommentCollectingParser(ParserFactory fac, Lexer S,
- boolean keepDocComments, boolean keepLineMap, Map<JCCompilationUnit, List<Comment>> commentsMap) {
+ boolean keepDocComments, boolean keepLineMap, Map<JCCompilationUnit, List<CommentInfo>> commentsMap) {
super(fac, S, keepDocComments, keepLineMap);
lexer = S;
this.commentsMap = commentsMap;
@@ -24,7 +24,7 @@ class CommentCollectingParser extends EndPosParser {
public JCCompilationUnit parseCompilationUnit() {
JCCompilationUnit result = super.parseCompilationUnit();
if (lexer instanceof CommentCollectingScanner) {
- List<Comment> comments = ((CommentCollectingScanner)lexer).getComments();
+ List<CommentInfo> comments = ((CommentCollectingScanner)lexer).getComments();
commentsMap.put(result, comments);
}
return result;
diff --git a/src/utils/lombok/javac/java7/CommentCollectingParserFactory.java b/src/utils/lombok/javac/java7/CommentCollectingParserFactory.java
index 7d8c9537..e361a5bd 100644
--- a/src/utils/lombok/javac/java7/CommentCollectingParserFactory.java
+++ b/src/utils/lombok/javac/java7/CommentCollectingParserFactory.java
@@ -4,7 +4,7 @@ import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
-import lombok.javac.Comment;
+import lombok.javac.CommentInfo;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.parser.Lexer;
@@ -15,14 +15,14 @@ import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.util.Context;
public class CommentCollectingParserFactory extends ParserFactory {
- private final Map<JCCompilationUnit, List<Comment>> commentsMap;
+ private final Map<JCCompilationUnit, List<CommentInfo>> commentsMap;
private final Context context;
static Context.Key<ParserFactory> key() {
return parserFactoryKey;
}
- protected CommentCollectingParserFactory(Context context, Map<JCCompilationUnit, List<Comment>> commentsMap) {
+ protected CommentCollectingParserFactory(Context context, Map<JCCompilationUnit, List<CommentInfo>> commentsMap) {
super(context);
this.context = context;
this.commentsMap = commentsMap;
@@ -38,7 +38,7 @@ public class CommentCollectingParserFactory extends ParserFactory {
//Either way this will work out.
}
- public static void setInCompiler(JavaCompiler compiler, Context context, Map<JCCompilationUnit, List<Comment>> commentsMap) {
+ public static void setInCompiler(JavaCompiler compiler, Context context, Map<JCCompilationUnit, List<CommentInfo>> commentsMap) {
context.put(CommentCollectingParserFactory.key(), (ParserFactory)null);
Field field;
try {
diff --git a/src/utils/lombok/javac/java7/CommentCollectingScanner.java b/src/utils/lombok/javac/java7/CommentCollectingScanner.java
index b13973b1..e2d040f2 100644
--- a/src/utils/lombok/javac/java7/CommentCollectingScanner.java
+++ b/src/utils/lombok/javac/java7/CommentCollectingScanner.java
@@ -23,16 +23,16 @@ package lombok.javac.java7;
import java.nio.CharBuffer;
-import lombok.javac.Comment;
-import lombok.javac.Comment.EndConnection;
-import lombok.javac.Comment.StartConnection;
+import lombok.javac.CommentInfo;
+import lombok.javac.CommentInfo.EndConnection;
+import lombok.javac.CommentInfo.StartConnection;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.parser.Scanner;
public class CommentCollectingScanner extends Scanner {
- private final ListBuffer<Comment> comments = ListBuffer.lb();
+ private final ListBuffer<CommentInfo> comments = ListBuffer.lb();
private int endComment = 0;
public CommentCollectingScanner(CommentCollectingScannerFactory factory, CharBuffer charBuffer) {
@@ -53,14 +53,19 @@ public class CommentCollectingScanner extends Scanner {
StartConnection start = determineStartConnection(prevEndPos, pos);
EndConnection end = determineEndConnection(endPos);
- Comment comment = new Comment(prevEndPos, pos, endPos, content, start, end);
+ CommentInfo comment = new CommentInfo(prevEndPos, pos, endPos, content, start, end);
comments.append(comment);
}
private EndConnection determineEndConnection(int pos) {
boolean first = true;
for (int i = pos;; i++) {
- char c = getRawCharacters(i, i + 1)[0];
+ char c;
+ try {
+ c = getRawCharacters(i, i + 1)[0];
+ } catch (IndexOutOfBoundsException e) {
+ c = '\n';
+ }
if (isNewLine(c)) {
return EndConnection.ON_NEXT_LINE;
}
@@ -92,7 +97,7 @@ public class CommentCollectingScanner extends Scanner {
return c == '\n' || c == '\r';
}
- public List<Comment> getComments() {
+ public List<CommentInfo> getComments() {
return comments.toList();
}
}
diff --git a/website/features/SneakyThrows.html b/website/features/SneakyThrows.html
index 583dc40d..b88c726d 100644
--- a/website/features/SneakyThrows.html
+++ b/website/features/SneakyThrows.html
@@ -20,9 +20,6 @@
or otherwise modify the thrown checked exception; it simply fakes out the compiler. On the JVM (class file) level, all exceptions, checked or not,
can be thrown regardless of the <code>throws</code> clause of your methods, which is why this works.
</p><p>
- <em><strong>CAREFUL: </strong></em>Unlike other lombok transformations, you need to put <strong>lombok.jar</strong> on your classpath when
- you run your program.
- </p><p>
Common use cases for when you want to opt out of the checked exception mechanism center around 2 situations:<br /><ul>
<li>A needlessly strict interface, such as <code>Runnable</code> - whatever exception propagates out of your <code>run()</code> method,
checked or not, it will be passed to the <code>Thread</code>'s unhandled exception handler. Catching a checked exception and wrapping it
@@ -38,6 +35,9 @@
</p><p>
You can pass any number of exceptions to the <code>@SneakyThrows</code> annotation. If you pass no exceptions, you may throw any
exception sneakily.
+ </p><p>
+ <em>NOTE: </em> with lombok versions older than 0.10, unlike other lombok transformations, you need to put <strong>lombok.jar</strong> on your
+ classpath when you run your program.
</div>
<div class="snippets">
<div class="pre">