aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers/JavacHandlerUtil.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2012-07-16 22:51:56 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2012-07-16 22:51:56 +0200
commitfe4985e2127e5fc54a0a1ae3c2c4fef17789f8bd (patch)
tree5274a2a3644715bb9ca644861d4b3c1f555c6b7c /src/core/lombok/javac/handlers/JavacHandlerUtil.java
parentb1877a77be41695259108d2c755c87051b3f0d07 (diff)
downloadlombok-fe4985e2127e5fc54a0a1ae3c2c4fef17789f8bd.tar.gz
lombok-fe4985e2127e5fc54a0a1ae3c2c4fef17789f8bd.tar.bz2
lombok-fe4985e2127e5fc54a0a1ae3c2c4fef17789f8bd.zip
Added setting position of generated nodes in javac's @Synchronized as a 'pilot' to see if we cause any problems with this approach. It does generate nicer error messages!
Example: Using @Synchronized with named lock on a static method, naming a non-existent or instance lock. That used to error on line -1.
Diffstat (limited to 'src/core/lombok/javac/handlers/JavacHandlerUtil.java')
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 437ba6cb..d2905101 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -746,6 +746,8 @@ public class JavacHandlerUtil {
* In javac, dotted access of any kind, from {@code java.lang.String} to {@code var.methodName}
* is represented by a fold-left of {@code Select} nodes with the leftmost string represented by
* a {@code Ident} node. This method generates such an expression.
+ * <p>
+ * The position of the generated node(s) will be unpositioned (-1).
*
* For example, maker.Select(maker.Select(maker.Ident(NAME[java]), NAME[lang]), NAME[String]).
*
@@ -753,12 +755,30 @@ public class JavacHandlerUtil {
* @see com.sun.tools.javac.tree.JCTree.JCFieldAccess
*/
public static JCExpression chainDots(JavacNode node, String... elems) {
+ return chainDots(node, -1, elems);
+ }
+
+ /**
+ * In javac, dotted access of any kind, from {@code java.lang.String} to {@code var.methodName}
+ * is represented by a fold-left of {@code Select} nodes with the leftmost string represented by
+ * a {@code Ident} node. This method generates such an expression.
+ * <p>
+ * The position of the generated node(s) will be equal to the {@code pos} parameter.
+ *
+ * For example, maker.Select(maker.Select(maker.Ident(NAME[java]), NAME[lang]), NAME[String]).
+ *
+ * @see com.sun.tools.javac.tree.JCTree.JCIdent
+ * @see com.sun.tools.javac.tree.JCTree.JCFieldAccess
+ */
+ public static JCExpression chainDots(JavacNode node, int pos, String... elems) {
assert elems != null;
assert elems.length > 0;
- JCExpression e = node.getTreeMaker().Ident(node.toName(elems[0]));
+ TreeMaker maker = node.getTreeMaker();
+ if (pos != -1) maker = maker.at(pos);
+ JCExpression e = maker.Ident(node.toName(elems[0]));
for (int i = 1 ; i < elems.length ; i++) {
- e = node.getTreeMaker().Select(e, node.toName(elems[i]));
+ e = maker.Select(e, node.toName(elems[i]));
}
return e;
@@ -776,7 +796,7 @@ public class JavacHandlerUtil {
* @see com.sun.tools.javac.tree.JCTree.JCFieldAccess
*/
public static JCExpression chainDotsString(JavacNode node, String elems) {
- return chainDots(node, elems.split("\\."));
+ return chainDots(node, elems.split("\\."));
}
/**