diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2011-11-20 19:20:34 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2011-11-20 19:20:34 +0100 |
commit | 246b4cc2bc03e5cccfd7ccca5aa48a3e8bb55b0c (patch) | |
tree | 14b9ec45c05f7e1a87c241a0957ddcbce6e5a0c4 /src | |
parent | 0139c62b6aac6f607639491b985c7a8cbb0a2b24 (diff) | |
download | lombok-246b4cc2bc03e5cccfd7ccca5aa48a3e8bb55b0c.tar.gz lombok-246b4cc2bc03e5cccfd7ccca5aa48a3e8bb55b0c.tar.bz2 lombok-246b4cc2bc03e5cccfd7ccca5aa48a3e8bb55b0c.zip |
Fixed issue 300: 'lombok.val' (vs. just val and an import statement) didn't fix auto-complete dialogs.
However, now the auto-highlight feature will crash with an IOOBE if you click in lombok.val.
Diffstat (limited to 'src')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/PatchVal.java | 2 | ||||
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java | 29 |
2 files changed, 7 insertions, 24 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java index d1d0409c..d59ff735 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java @@ -70,7 +70,7 @@ public class PatchVal { return true; } - private static boolean couldBeVal(TypeReference ref) { + public static boolean couldBeVal(TypeReference ref) { if (ref instanceof SingleTypeReference) { char[] token = ((SingleTypeReference)ref).token; return matches("val", token); diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java b/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java index 543780c8..863af59d 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java @@ -44,7 +44,6 @@ import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; import org.eclipse.jdt.internal.compiler.ast.Annotation; import org.eclipse.jdt.internal.compiler.ast.ForeachStatement; import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; -import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference; import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.parser.Parser; @@ -64,10 +63,7 @@ public class PatchValEclipse { ForeachStatement foreachDecl = (ForeachStatement) astStack[astPtr]; ASTNode init = foreachDecl.collection; if (init == null) return; - if (foreachDecl.elementVariable != null && foreachDecl.elementVariable.type instanceof SingleTypeReference) { - SingleTypeReference ref = (SingleTypeReference) foreachDecl.elementVariable.type; - if (ref.token == null || ref.token.length != 3 || ref.token[0] != 'v' || ref.token[1] != 'a' || ref.token[2] != 'l') return; - } else return; + if (foreachDecl.elementVariable == null || !PatchVal.couldBeVal(foreachDecl.elementVariable.type)) return; try { if (Reflection.iterableCopyField != null) Reflection.iterableCopyField.set(foreachDecl.elementVariable, init); @@ -90,10 +86,7 @@ public class PatchValEclipse { if (!(variableDecl instanceof LocalDeclaration)) return; ASTNode init = variableDecl.initialization; if (init == null) return; - if (variableDecl.type instanceof SingleTypeReference) { - SingleTypeReference ref = (SingleTypeReference) variableDecl.type; - if (ref.token == null || ref.token.length != 3 || ref.token[0] != 'v' || ref.token[1] != 'a' || ref.token[2] != 'l') return; - } else return; + if (!PatchVal.couldBeVal(variableDecl.type)) return; try { if (Reflection.initCopyField != null) Reflection.initCopyField.set(variableDecl, init); @@ -120,20 +113,10 @@ public class PatchValEclipse { Annotation valAnnotation = null; for (Annotation ann : in.annotations) { - if (ann.type instanceof SingleTypeReference) { - if (PatchVal.matches("val", ((SingleTypeReference)ann.type).token)) { - found = true; - valAnnotation = ann; - break; - } - } - if (ann.type instanceof QualifiedTypeReference) { - char[][] tokens = ((QualifiedTypeReference)ann.type).tokens; - if (tokens != null && tokens.length == 2 && PatchVal.matches("lombok", tokens[0]) && PatchVal.matches("val", tokens[1])) { - found = true; - valAnnotation = ann; - break; - } + if (PatchVal.couldBeVal(ann.type)) { + found = true; + valAnnotation = ann; + break; } } |