From 6b91620d9efab992ee8e909b3e7b9cac0ac6f607 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 13 Dec 2011 06:26:40 +0100 Subject: Refactored the type resolver, and made the 'find locally named classes that shadow' feature way better; previously it would only find very few locally named classes (your own class and any parent outers, that was it, no siblings). --- src/core/lombok/eclipse/HandlerLibrary.java | 4 ++-- src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 13 ++----------- 2 files changed, 4 insertions(+), 13 deletions(-) (limited to 'src/core/lombok/eclipse') diff --git a/src/core/lombok/eclipse/HandlerLibrary.java b/src/core/lombok/eclipse/HandlerLibrary.java index 197d7a7e..5c75c071 100644 --- a/src/core/lombok/eclipse/HandlerLibrary.java +++ b/src/core/lombok/eclipse/HandlerLibrary.java @@ -173,11 +173,11 @@ public class HandlerLibrary { String pkgName = annotationNode.getPackageDeclaration(); Collection imports = annotationNode.getImportStatements(); - TypeResolver resolver = new TypeResolver(typeLibrary, pkgName, imports); + TypeResolver resolver = new TypeResolver(pkgName, imports); TypeReference rawType = annotation.type; if (rawType == null) return; - for (String fqn : resolver.findTypeMatches(annotationNode, toQualifiedName(annotation.type.getTypeName()))) { + for (String fqn : resolver.findTypeMatches(annotationNode, typeLibrary, toQualifiedName(annotation.type.getTypeName()))) { boolean isPrintAST = fqn.equals(PrintAST.class.getName()); if (isPrintAST == skipPrintAst) continue; AnnotationHandlerContainer container = annotationHandlers.get(fqn); diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 5130c7de..c6d7eb41 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -30,7 +30,6 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -46,7 +45,6 @@ import lombok.core.AnnotationValues.AnnotationValue; import lombok.eclipse.EclipseAST; import lombok.eclipse.EclipseNode; import lombok.core.TransformationsUtil; -import lombok.core.TypeLibrary; import lombok.core.TypeResolver; import org.eclipse.core.runtime.ILog; @@ -260,16 +258,9 @@ public class EclipseHandlerUtil { if (!lastPartA.equals(lastPartB)) return false; String typeName = toQualifiedName(typeRef.getTypeName()); - TypeLibrary library = new TypeLibrary(); - library.addType(type.getName()); - TypeResolver resolver = new TypeResolver(library, node.getPackageDeclaration(), node.getImportStatements()); - Collection typeMatches = resolver.findTypeMatches(node, typeName); + TypeResolver resolver = new TypeResolver(node.getPackageDeclaration(), node.getImportStatements()); + return resolver.typeMatches(node, type.getName(), typeName); - for (String match : typeMatches) { - if (match.equals(type.getName())) return true; - } - - return false; } public static Annotation copyAnnotation(Annotation annotation, ASTNode source) { -- cgit