diff options
-rw-r--r-- | src/delombok/lombok/delombok/PrettyCommentsPrinter.java | 18 | ||||
-rw-r--r-- | src/utils/lombok/javac/JCNoTypeFactory.java | 11 | ||||
-rw-r--r-- | src/utils/lombok/javac/Javac.java | 37 |
3 files changed, 20 insertions, 46 deletions
diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java index 745aea79..9817f050 100644 --- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java +++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java @@ -602,7 +602,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { /** Is the given tree an enumerator definition? */ boolean isEnumerator(JCTree t) { - return getTag(t) == VARDEF && (((JCVariableDecl) t).mods.flags & ENUM) != 0; + return Javac.compareCTC(getTag(t), VARDEF) && (((JCVariableDecl) t).mods.flags & ENUM) != 0; } /** Print unit consisting of package clause and import statements in toplevel, @@ -626,7 +626,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { for (List<JCTree> l = tree.defs; l.nonEmpty() && (cdef == null || getTag(l.head) == IMPORT); l = l.tail) { - if (getTag(l.head) == IMPORT) { + if (Javac.compareCTC(getTag(l.head), IMPORT)) { JCImport imp = (JCImport)l.head; Name name = TreeInfo.name(imp.qualid); if (name == name.table.fromChars(new char[] {'*'}, 0, 1) || @@ -845,7 +845,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { printStat(tree.body); align(); print(" while "); - if (getTag(tree.cond) == PARENS) { + if (Javac.compareCTC(getTag(tree.cond), PARENS)) { printExpr(tree.cond); } else { print("("); @@ -861,7 +861,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { public void visitWhileLoop(JCWhileLoop tree) { try { print("while "); - if (getTag(tree.cond) == PARENS) { + if (Javac.compareCTC(getTag(tree.cond), PARENS)) { printExpr(tree.cond); } else { print("("); @@ -879,7 +879,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { try { print("for ("); if (tree.init.nonEmpty()) { - if (getTag(tree.init.head) == VARDEF) { + if (Javac.compareCTC(getTag(tree.init.head), VARDEF)) { printExpr(tree.init.head); for (List<JCStatement> l = tree.init.tail; l.nonEmpty(); l = l.tail) { JCVariableDecl vdef = (JCVariableDecl)l.head; @@ -926,7 +926,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { public void visitSwitch(JCSwitch tree) { try { print("switch "); - if (getTag(tree.selector) == PARENS) { + if (Javac.compareCTC(getTag(tree.selector), PARENS)) { printExpr(tree.selector); } else { print("("); @@ -965,7 +965,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { public void visitSynchronized(JCSynchronized tree) { try { print("synchronized "); - if (getTag(tree.lock) == PARENS) { + if (Javac.compareCTC(getTag(tree.lock), PARENS)) { printExpr(tree.lock); } else { print("("); @@ -1023,7 +1023,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { public void visitIf(JCIf tree) { try { print("if "); - if (getTag(tree.cond) == PARENS) { + if (Javac.compareCTC(getTag(tree.cond), PARENS)) { printExpr(tree.cond); } else { print("("); @@ -1119,7 +1119,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { public void visitApply(JCMethodInvocation tree) { try { if (!tree.typeargs.isEmpty()) { - if (getTag(tree.meth) == SELECT) { + if (Javac.compareCTC(getTag(tree.meth), SELECT)) { JCFieldAccess left = (JCFieldAccess)tree.meth; printExpr(left.selected); print(".<"); diff --git a/src/utils/lombok/javac/JCNoTypeFactory.java b/src/utils/lombok/javac/JCNoTypeFactory.java new file mode 100644 index 00000000..e7be7665 --- /dev/null +++ b/src/utils/lombok/javac/JCNoTypeFactory.java @@ -0,0 +1,11 @@ +package lombok.javac; + +import com.sun.tools.javac.code.Symbol.TypeSymbol; +import com.sun.tools.javac.code.Type; + + +public class JCNoTypeFactory { + public static final Type getJCNotType(Object typeTag, TypeSymbol tsym) { + + } +} diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java index b766630f..9f2936a8 100644 --- a/src/utils/lombok/javac/Javac.java +++ b/src/utils/lombok/javac/Javac.java @@ -26,7 +26,6 @@ import java.util.Objects; import java.util.regex.Pattern; import com.sun.tools.javac.main.JavaCompiler; -import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCBinary; import com.sun.tools.javac.tree.JCTree.JCExpression; import com.sun.tools.javac.tree.JCTree.JCFieldAccess; @@ -102,42 +101,6 @@ public class Javac { public static final Object CTC_PLUS = getTreeTag("PLUS"); public static final Object CTC_EQUAL = getTreeTag("EQ"); -// /** -// * Retrieves the current ordinal position of a type tag. -// * -// * For JDK 8 this is the ordinal position within the -// * <code>com.sun.tools.javac.code.TypeTag enum</code> for JDK 7 and lower, -// * this is the value of the constant within -// * <code>com.sun.tools.javac.code.TypeTags</code> -// * -// * Solves the problem of compile time constant inlining, resulting in lombok -// * having the wrong value (javac compiler changes private api constants from -// * time to time). -// * -// * @param identifier -// * @return the ordinal value of the typetag constant -// */ -// public static int getTypeTag(String identifier) { -// try { -// if (JavaCompiler.version().startsWith("1.8")) { -// Object enumInstance = Class.forName("com.sun.tools.javac.code.TypeTag").getField(identifier).get(null); -// return (int) Class.forName("com.sun.tools.javac.code.TypeTag").getField("order").get(enumInstance); -// -// } else { -// return (int) Class.forName("com.sun.tools.javac.code.TypeTags").getField(identifier).get(null); -// } -// } catch (NoSuchFieldException e) { -// throw new RuntimeException(e); -// } catch (IllegalAccessException e) { -// throw new RuntimeException(e); -// } catch (Exception e) { -// if (e instanceof RuntimeException) throw (RuntimeException) e; -// throw new RuntimeException(e); -// } -// } - - - public static boolean compareCTC(Object ctc1, Object ctc2) { return Objects.equals(ctc1, ctc2); } |