aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2010-11-22 23:02:08 +0100
committerRoel Spilker <r.spilker@gmail.com>2010-11-22 23:02:08 +0100
commit8eb05b357d37b8e58cfb4ecb331371c88f1a856b (patch)
tree6576e7498333121091568bfaca600278977611df
parent3a89cbe7e7610c649c45e3647d766fdb027f068d (diff)
parent7dede9a6647ded762701d70d6e71066557196fb5 (diff)
downloadlombok-8eb05b357d37b8e58cfb4ecb331371c88f1a856b.tar.gz
lombok-8eb05b357d37b8e58cfb4ecb331371c88f1a856b.tar.bz2
lombok-8eb05b357d37b8e58cfb4ecb331371c88f1a856b.zip
Merge branch 'master' of git@github.com:rzwitserloot/lombok
-rw-r--r--src/core/lombok/javac/JavacAST.java10
-rw-r--r--src/core/lombok/javac/JavacNode.java10
-rw-r--r--src/core/lombok/javac/JavacResolution.java24
-rw-r--r--src/core/lombok/javac/handlers/HandleVal.java4
4 files changed, 45 insertions, 3 deletions
diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java
index fb837255..35916fa5 100644
--- a/src/core/lombok/javac/JavacAST.java
+++ b/src/core/lombok/javac/JavacAST.java
@@ -34,6 +34,7 @@ import lombok.core.AST;
import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.model.JavacElements;
+import com.sun.tools.javac.model.JavacTypes;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
@@ -61,6 +62,7 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
private final JavacElements elements;
private final TreeMaker treeMaker;
private final Symtab symtab;
+ private final JavacTypes javacTypes;
private final Log log;
private final Context context;
@@ -80,6 +82,7 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
this.elements = JavacElements.instance(context);
this.treeMaker = TreeMaker.instance(context);
this.symtab = Symtab.instance(context);
+ this.javacTypes = JavacTypes.instance(context);
clearChanged();
}
@@ -135,6 +138,13 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
return symtab;
}
+ /**
+ * @return The implementation of {@link javax.lang.model.util.Types} of javac. Contains a few extra methods beyond
+ * the ones listed in the official annotation API interface. */
+ public JavacTypes getTypesUtil() {
+ return javacTypes;
+ }
+
/** {@inheritDoc} */
@Override protected JavacNode buildTree(JCTree node, Kind kind) {
switch (kind) {
diff --git a/src/core/lombok/javac/JavacNode.java b/src/core/lombok/javac/JavacNode.java
index 8bbd007f..7dd49644 100644
--- a/src/core/lombok/javac/JavacNode.java
+++ b/src/core/lombok/javac/JavacNode.java
@@ -28,6 +28,7 @@ import javax.tools.Diagnostic;
import lombok.core.AST.Kind;
import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.model.JavacTypes;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
@@ -178,6 +179,15 @@ public class JavacNode extends lombok.core.LombokNode<JavacAST, JavacNode, JCTre
}
/**
+ * Convenient shortcut to the owning JavacAST object's getTypesUtil method.
+ *
+ * @see JavacAST#getTypesUtil()
+ */
+ public JavacTypes getTypesUtil() {
+ return ast.getTypesUtil();
+ }
+
+ /**
* Convenient shortcut to the owning JavacAST object's getContext method.
*
* @see JavacAST#getContext()
diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java
index 653e6d6d..730cca31 100644
--- a/src/core/lombok/javac/JavacResolution.java
+++ b/src/core/lombok/javac/JavacResolution.java
@@ -242,7 +242,7 @@ public class JavacResolution {
}
}
- public Map<JCTree, JCTree> resolve(JavacNode node) {
+ public Map<JCTree, JCTree> resolveMethodMember(JavacNode node) {
ArrayDeque<JCTree> stack = new ArrayDeque<JCTree>();
{
@@ -268,6 +268,28 @@ public class JavacResolution {
}
}
+ public void resolveClassMember(JavacNode node) {
+ ArrayDeque<JCTree> stack = new ArrayDeque<JCTree>();
+
+ {
+ JavacNode n = node;
+ while (n != null) {
+ stack.push(n.get());
+ n = n.up();
+ }
+ }
+
+ logDisabler.disableLoggers();
+ try {
+ EnvFinder finder = new EnvFinder(node.getContext());
+ while (!stack.isEmpty()) stack.pop().accept(finder);
+
+ attrib(node.get(), finder.get());
+ } finally {
+ logDisabler.enableLoggers();
+ }
+ }
+
private void attrib(JCTree tree, Env<AttrContext> env) {
if (tree instanceof JCBlock) attr.attribStat(tree, env);
else if (tree instanceof JCMethodDecl) attr.attribStat(((JCMethodDecl)tree).body, env);
diff --git a/src/core/lombok/javac/handlers/HandleVal.java b/src/core/lombok/javac/handlers/HandleVal.java
index bf938362..3aa695ea 100644
--- a/src/core/lombok/javac/handlers/HandleVal.java
+++ b/src/core/lombok/javac/handlers/HandleVal.java
@@ -71,14 +71,14 @@ public class HandleVal extends JavacASTAdapter {
if (rhsOfEnhancedForLoop == null) {
if (local.init.type == null) {
JavacResolution resolver = new JavacResolution(localNode.getContext());
- type = ((JCExpression) resolver.resolve(localNode).get(local.init)).type;
+ type = ((JCExpression) resolver.resolveMethodMember(localNode).get(local.init)).type;
} else {
type = local.init.type;
}
} else {
if (rhsOfEnhancedForLoop.type == null) {
JavacResolution resolver = new JavacResolution(localNode.getContext());
- type = ((JCExpression) resolver.resolve(localNode.directUp()).get(rhsOfEnhancedForLoop)).type;
+ type = ((JCExpression) resolver.resolveMethodMember(localNode.directUp()).get(rhsOfEnhancedForLoop)).type;
} else {
type = rhsOfEnhancedForLoop.type;
}