aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2014-02-06 20:40:19 +0100
committerRoel Spilker <r.spilker@gmail.com>2014-02-06 20:40:19 +0100
commitc128331d4dd5c38f5f0218940632dfffb0b25f5c (patch)
tree34bf3d690afdeac8c37ef4e94b571d28cbb7c6b0 /src/utils
parente1344ec4c99878e2e6b7a09ae604b37b92dbb7eb (diff)
parentd1182bbf45ffd392134cb2379b33913f744b69d0 (diff)
downloadlombok-c128331d4dd5c38f5f0218940632dfffb0b25f5c.tar.gz
lombok-c128331d4dd5c38f5f0218940632dfffb0b25f5c.tar.bz2
lombok-c128331d4dd5c38f5f0218940632dfffb0b25f5c.zip
Merge pull request #43 from jlahoda/471
#471: @SneakyThrows should work in NetBeans
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/lombok/javac/Javac.java35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java
index bdf5e7a0..e207c44a 100644
--- a/src/utils/lombok/javac/Javac.java
+++ b/src/utils/lombok/javac/Javac.java
@@ -177,7 +177,7 @@ public class Javac {
public static final TreeTag CTC_PREINC = treeTag("PREINC");
public static final TreeTag CTC_PREDEC = treeTag("PREDEC");
- private static final Method getExtendsClause, getEndPosition;
+ private static final Method getExtendsClause, getEndPosition, storeEnd;
static {
getExtendsClause = getMethod(JCClassDecl.class, "getExtendsClause", new Class<?>[0]);
@@ -185,10 +185,32 @@ public class Javac {
if (getJavaCompilerVersion() < 8) {
getEndPosition = getMethod(DiagnosticPosition.class, "getEndPosition", java.util.Map.class);
+ storeEnd = getMethod(java.util.Map.class, "put", Object.class, Object.class);
} else {
getEndPosition = getMethod(DiagnosticPosition.class, "getEndPosition", "com.sun.tools.javac.tree.EndPosTable");
+ Method storeEndMethodTemp;
+ Class<?> endPosTable;
+ try {
+ endPosTable = Class.forName("com.sun.tools.javac.tree.EndPosTable");
+ } catch (ClassNotFoundException ex) {
+ throw sneakyThrow(ex);
+ }
+ try {
+ storeEndMethodTemp = endPosTable.getMethod("storeEnd", JCTree.class, int.class);
+ } catch (NoSuchMethodException e) {
+ try {
+ endPosTable = Class.forName("com.sun.tools.javac.parser.JavacParser$AbstractEndPosTable");
+ storeEndMethodTemp = endPosTable.getDeclaredMethod("storeEnd", JCTree.class, int.class);
+ } catch (NoSuchMethodException ex) {
+ throw sneakyThrow(ex);
+ } catch (ClassNotFoundException ex) {
+ throw sneakyThrow(ex);
+ }
+ }
+ storeEnd = storeEndMethodTemp;
}
getEndPosition.setAccessible(true);
+ storeEnd.setAccessible(true);
}
private static Method getMethod(Class<?> clazz, String name, Class<?>... paramTypes) {
@@ -250,6 +272,17 @@ public class Javac {
}
}
+ public static void storeEnd(JCTree tree, int pos, JCCompilationUnit top) {
+ try {
+ Object endPositions = JCCOMPILATIONUNIT_ENDPOSITIONS.get(top);
+ storeEnd.invoke(endPositions, tree, pos);
+ } catch (IllegalAccessException e) {
+ throw sneakyThrow(e);
+ } catch (InvocationTargetException e) {
+ throw sneakyThrow(e.getCause());
+ }
+ }
+
private static final Class<?> JC_VOID_TYPE, JC_NO_TYPE;
static {