diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-06-12 09:54:24 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-06-12 09:54:24 +0200 |
commit | 637298300039a4b943e49c654cb4d2b26161ba60 (patch) | |
tree | dfe03dd68e2b961f67260b72e6fb130e8e05bb94 /src/lombok/transformations | |
parent | 40e35d6f79f456fb868c95d764f5d0c9869ea6e4 (diff) | |
download | lombok-637298300039a4b943e49c654cb4d2b26161ba60.tar.gz lombok-637298300039a4b943e49c654cb4d2b26161ba60.tar.bz2 lombok-637298300039a4b943e49c654cb4d2b26161ba60.zip |
Now everything works; handlers are called via SPI, and annotations are being parsed. w00t!
Diffstat (limited to 'src/lombok/transformations')
-rw-r--r-- | src/lombok/transformations/TypeLibrary.java | 3 | ||||
-rw-r--r-- | src/lombok/transformations/TypeResolver.java | 23 |
2 files changed, 16 insertions, 10 deletions
diff --git a/src/lombok/transformations/TypeLibrary.java b/src/lombok/transformations/TypeLibrary.java index 00ae64b0..9b5c8e57 100644 --- a/src/lombok/transformations/TypeLibrary.java +++ b/src/lombok/transformations/TypeLibrary.java @@ -33,6 +33,7 @@ public class TypeLibrary { } public Collection<String> findCompatible(String typeReference) { - return simpleToQualifiedMap.get(typeReference); + Set<String> result = simpleToQualifiedMap.get(typeReference); + return result == null ? Collections.<String>emptySet() : result; } } diff --git a/src/lombok/transformations/TypeResolver.java b/src/lombok/transformations/TypeResolver.java index 2a012f57..3c3617a6 100644 --- a/src/lombok/transformations/TypeResolver.java +++ b/src/lombok/transformations/TypeResolver.java @@ -6,23 +6,21 @@ import java.util.HashSet; import java.util.Set; import lombok.eclipse.EclipseAST; +import lombok.eclipse.EclipseAST.Node; -import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.eclipse.jdt.internal.compiler.ast.ImportReference; +import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.ast.TypeReference; -import org.eclipse.jdt.internal.compiler.parser.Parser; public class TypeResolver { private final TypeLibrary library; - private final EclipseAST ast; private Collection<String> imports; - public TypeResolver(TypeLibrary library, Parser parser, EclipseAST ast) { + public TypeResolver(TypeLibrary library, EclipseAST.Node top) { this.library = library; - this.ast = ast; - this.imports = makeImportList((CompilationUnitDeclaration) ast.top().getEclipseNode()); + this.imports = makeImportList((CompilationUnitDeclaration) top.getEclipseNode()); } private static Collection<String> makeImportList(CompilationUnitDeclaration declaration) { @@ -33,8 +31,8 @@ public class TypeResolver { } return imports; } - - public Collection<String> findTypeMatches(ASTNode context, TypeReference type) { + + public Collection<String> findTypeMatches(Node context, TypeReference type) { Collection<String> potentialMatches = library.findCompatible(toQualifiedName(type.getTypeName())); if ( potentialMatches.isEmpty() ) return Collections.emptyList(); @@ -50,7 +48,14 @@ public class TypeResolver { if ( potentialMatches.isEmpty() ) return Collections.emptyList(); //Find a lexically accessible type of the same simple name in the same Compilation Unit. If it exists: no matches. - + Node n = context; + while ( n != null ) { + if ( n.getEclipseNode() instanceof TypeDeclaration ) { + char[] name = ((TypeDeclaration)n.getEclipseNode()).name; + if ( name != null && new String(name).equals(simpleName) ) return Collections.emptyList(); + } + n = n.up(); + } // The potential matches we found by comparing the import statements is our matching set. Return it. return potentialMatches; |