aboutsummaryrefslogtreecommitdiff
path: root/src/utils/lombok
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/lombok')
-rw-r--r--src/utils/lombok/core/LombokImmutableList.java6
-rw-r--r--src/utils/lombok/javac/Javac.java13
-rw-r--r--src/utils/lombok/javac/TreeMirrorMaker.java44
3 files changed, 57 insertions, 6 deletions
diff --git a/src/utils/lombok/core/LombokImmutableList.java b/src/utils/lombok/core/LombokImmutableList.java
index e0e1136c..4603f2ad 100644
--- a/src/utils/lombok/core/LombokImmutableList.java
+++ b/src/utils/lombok/core/LombokImmutableList.java
@@ -80,6 +80,12 @@ public final class LombokImmutableList<T> implements Iterable<T> {
return copyOf(list);
}
+ public static <T> LombokImmutableList<T> copyOf(T[] array) {
+ Object[] content = new Object[array.length];
+ System.arraycopy(array, 0, content, 0, array.length);
+ return new LombokImmutableList<T>(content);
+ }
+
private LombokImmutableList(Object[] content) {
this.content = content;
}
diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java
index e207c44a..003281ad 100644
--- a/src/utils/lombok/javac/Javac.java
+++ b/src/utils/lombok/javac/Javac.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2013 The Project Lombok Authors.
+ * Copyright (C) 2009-2015 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
@@ -162,9 +162,16 @@ public class Javac {
public static final TypeTag CTC_VOID = typeTag("VOID");
public static final TypeTag CTC_NONE = typeTag("NONE");
public static final TypeTag CTC_BOT = typeTag("BOT");
+ public static final TypeTag CTC_ERROR = typeTag("ERROR");
+ public static final TypeTag CTC_UNKNOWN = typeTag("UNKNOWN");
+ public static final TypeTag CTC_UNDETVAR = typeTag("UNDETVAR");
public static final TypeTag CTC_CLASS = typeTag("CLASS");
public static final TreeTag CTC_NOT_EQUAL = treeTag("NE");
+ public static final TreeTag CTC_LESS_THAN = treeTag("LT");
+ public static final TreeTag CTC_GREATER_THAN = treeTag("GT");
+ public static final TreeTag CTC_LESS_OR_EQUAL= treeTag("LE");
+ public static final TreeTag CTC_GREATER_OR_EQUAL = treeTag("GE");
public static final TreeTag CTC_POS = treeTag("POS");
public static final TreeTag CTC_NEG = treeTag("NEG");
public static final TreeTag CTC_NOT = treeTag("NOT");
@@ -172,10 +179,14 @@ public class Javac {
public static final TreeTag CTC_BITXOR = treeTag("BITXOR");
public static final TreeTag CTC_UNSIGNED_SHIFT_RIGHT = treeTag("USR");
public static final TreeTag CTC_MUL = treeTag("MUL");
+ public static final TreeTag CTC_DIV = treeTag("DIV");
public static final TreeTag CTC_PLUS = treeTag("PLUS");
+ public static final TreeTag CTC_MINUS = treeTag("MINUS");
public static final TreeTag CTC_EQUAL = treeTag("EQ");
public static final TreeTag CTC_PREINC = treeTag("PREINC");
public static final TreeTag CTC_PREDEC = treeTag("PREDEC");
+ public static final TreeTag CTC_POSTINC = treeTag("POSTINC");
+ public static final TreeTag CTC_POSTDEC = treeTag("POSTDEC");
private static final Method getExtendsClause, getEndPosition, storeEnd;
diff --git a/src/utils/lombok/javac/TreeMirrorMaker.java b/src/utils/lombok/javac/TreeMirrorMaker.java
index 23ec2406..093839d7 100644
--- a/src/utils/lombok/javac/TreeMirrorMaker.java
+++ b/src/utils/lombok/javac/TreeMirrorMaker.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 The Project Lombok Authors.
+ * Copyright (C) 2010-2015 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
@@ -26,11 +26,19 @@ import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Map;
+import static lombok.javac.Javac.*;
+import lombok.javac.JavacTreeMaker.TypeTag;
+
+import com.sun.source.tree.ClassTree;
import com.sun.source.tree.LabeledStatementTree;
+import com.sun.source.tree.NewClassTree;
import com.sun.source.tree.VariableTree;
import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCNewClass;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.tree.TreeCopier;
+import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
/**
@@ -46,7 +54,7 @@ import com.sun.tools.javac.util.List;
public class TreeMirrorMaker extends TreeCopier<Void> {
private final IdentityHashMap<JCTree, JCTree> originalToCopy = new IdentityHashMap<JCTree, JCTree>();
- public TreeMirrorMaker(JavacTreeMaker maker) {
+ public TreeMirrorMaker(JavacTreeMaker maker, Context context) {
super(maker.getUnderlyingTreeMaker());
}
@@ -86,11 +94,27 @@ public class TreeMirrorMaker extends TreeCopier<Void> {
return Collections.unmodifiableMap(originalToCopy);
}
- // Fix for NPE in HandleVal. See http://code.google.com/p/projectlombok/issues/detail?id=205
- // Maybe this should be done elsewhere...
+ // Monitor issue 205 and issue 694 when making changes here.
@Override public JCTree visitVariable(VariableTree node, Void p) {
+ JCVariableDecl original = node instanceof JCVariableDecl ? (JCVariableDecl) node : null;
JCVariableDecl copy = (JCVariableDecl) super.visitVariable(node, p);
- copy.sym = ((JCVariableDecl) node).sym;
+ if (original == null) return copy;
+
+ copy.sym = original.sym;
+ if (copy.sym != null) copy.type = original.type;
+ if (copy.type != null) {
+ boolean wipeSymAndType = copy.type.isErroneous();
+ if (!wipeSymAndType) {
+ TypeTag typeTag = TypeTag.typeTag(copy.type);
+ wipeSymAndType = (CTC_NONE.equals(typeTag) || CTC_ERROR.equals(typeTag) || CTC_UNKNOWN.equals(typeTag) || CTC_UNDETVAR.equals(typeTag));
+ }
+
+ if (wipeSymAndType) {
+ copy.sym = null;
+ copy.type = null;
+ }
+ }
+
return copy;
}
@@ -99,4 +123,14 @@ public class TreeMirrorMaker extends TreeCopier<Void> {
@Override public JCTree visitLabeledStatement(LabeledStatementTree node, Void p) {
return node.getStatement().accept(this, p);
}
+
+ @Override public JCTree visitNewClass(NewClassTree node, Void p) {
+ JCNewClass copy = (JCNewClass) super.visitNewClass(node, p);
+ return copy;
+ }
+
+ @Override public JCTree visitClass(ClassTree node, Void p) {
+ JCClassDecl copy = (JCClassDecl) super.visitClass(node, p);
+ return copy;
+ }
}