aboutsummaryrefslogtreecommitdiff
path: root/src/utils/lombok
diff options
context:
space:
mode:
authorJan Lahoda <lahoda@gmail.com>2014-02-04 21:25:29 +0100
committerJan Lahoda <lahoda@gmail.com>2014-02-04 21:25:29 +0100
commitd1182bbf45ffd392134cb2379b33913f744b69d0 (patch)
tree3b3fce9da901e90246eff4b3784a56bb31d1abaa /src/utils/lombok
parent5782b909c5c0e8f766de36d600bc314eaa98e6b2 (diff)
downloadlombok-d1182bbf45ffd392134cb2379b33913f744b69d0.tar.gz
lombok-d1182bbf45ffd392134cb2379b33913f744b69d0.tar.bz2
lombok-d1182bbf45ffd392134cb2379b33913f744b69d0.zip
#471: @SneakyThrows should work in NetBeans
Diffstat (limited to 'src/utils/lombok')
-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 {