aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/eclipse/handlers
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-09-01 21:09:27 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-09-01 21:09:27 +0200
commitcb4c8ca4a1392844cd01b573e53b7926c1374872 (patch)
tree93718044c8c1ab0c86e828458f3c0a436d5ac432 /src/lombok/eclipse/handlers
parentb069df74842976439112fd6a3d771ea8b30b31b4 (diff)
downloadlombok-cb4c8ca4a1392844cd01b573e53b7926c1374872.tar.gz
lombok-cb4c8ca4a1392844cd01b573e53b7926c1374872.tar.bz2
lombok-cb4c8ca4a1392844cd01b573e53b7926c1374872.zip
Fixed the problem where the eclipse editor AST just loses track of things when using @SneakyThrows (syntax colouring goes away, first character in the file is italic).
Diffstat (limited to 'src/lombok/eclipse/handlers')
-rw-r--r--src/lombok/eclipse/handlers/HandleSneakyThrows.java28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/lombok/eclipse/handlers/HandleSneakyThrows.java b/src/lombok/eclipse/handlers/HandleSneakyThrows.java
index 5c39cf86..e01cbcde 100644
--- a/src/lombok/eclipse/handlers/HandleSneakyThrows.java
+++ b/src/lombok/eclipse/handlers/HandleSneakyThrows.java
@@ -154,19 +154,24 @@ public class HandleSneakyThrows implements EclipseAnnotationHandler<SneakyThrows
return true;
}
-
+
private Statement buildTryCatchBlock(Statement[] contents, DeclaredException exception) {
+ long p = exception.getPos();
+ int pS = (int)(p >> 32), pE = (int)p;
+
TryStatement tryStatement = new TryStatement();
tryStatement.tryBlock = new Block(0);
+ tryStatement.tryBlock.sourceStart = pS;
+ tryStatement.tryBlock.sourceEnd = pE;
tryStatement.tryBlock.statements = contents;
TypeReference typeReference;
if ( exception.exceptionName.indexOf('.') == -1 ) {
- typeReference = new SingleTypeReference(exception.exceptionName.toCharArray(), exception.getPos());
+ typeReference = new SingleTypeReference(exception.exceptionName.toCharArray(), p);
} else {
String[] x = exception.exceptionName.split("\\.");
char[][] elems = new char[x.length][];
long[] poss = new long[x.length];
- int start = (int)(exception.getPos() >> 32);
+ int start = pS;
for ( int i = 0 ; i < x.length ; i++ ) {
elems[i] = x[i].trim().toCharArray();
int end = start + x[i].length();
@@ -176,19 +181,26 @@ public class HandleSneakyThrows implements EclipseAnnotationHandler<SneakyThrows
typeReference = new QualifiedTypeReference(elems, poss);
}
- Argument catchArg = new Argument("$ex".toCharArray(), exception.getPos(), typeReference, 0);
+ Argument catchArg = new Argument("$ex".toCharArray(), p, typeReference, 0);
+ catchArg.declarationSourceEnd = catchArg.declarationEnd = catchArg.sourceEnd = pE;
+ catchArg.declarationSourceStart = catchArg.modifiersSourceStart = catchArg.sourceStart = pS;
tryStatement.catchArguments = new Argument[] { catchArg };
MessageSend sneakyThrowStatement = new MessageSend();
- sneakyThrowStatement.receiver = new QualifiedNameReference(new char[][] { "lombok".toCharArray(), "Lombok".toCharArray() }, new long[] { 0, 0 }, 0, 0);
+ sneakyThrowStatement.receiver = new QualifiedNameReference(new char[][] { "lombok".toCharArray(), "Lombok".toCharArray() }, new long[] { p, p }, pS, pE);
sneakyThrowStatement.selector = "sneakyThrow".toCharArray();
- sneakyThrowStatement.arguments = new Expression[] { new SingleNameReference("$ex".toCharArray(), 0) };
- Statement rethrowStatement = new ThrowStatement(sneakyThrowStatement, 0, 0);
+ sneakyThrowStatement.arguments = new Expression[] { new SingleNameReference("$ex".toCharArray(), p) };
+ sneakyThrowStatement.sourceStart = pS;
+ sneakyThrowStatement.sourceEnd = sneakyThrowStatement.statementEnd = pE;
+ Statement rethrowStatement = new ThrowStatement(sneakyThrowStatement, pS, pE);
Block block = new Block(0);
+ block.sourceStart = pS;
+ block.sourceEnd = pE;
block.statements = new Statement[] { rethrowStatement };
- block.sourceStart = block.sourceEnd = -2;
tryStatement.catchBlocks = new Block[] { block };
+ tryStatement.sourceStart = pS;
+ tryStatement.sourceEnd = pE;
return tryStatement;
}
}