aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2020-01-31 04:42:05 +0100
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2020-01-31 04:42:05 +0100
commitd31182c4383a5ccc499862d2a8035d49e5202319 (patch)
treeddfb30ece5140587aed9ddd7dc0e248fb2ac30ec /src/core
parent6e2b5802beded1dc3c965d18ecda7f3d90b7e761 (diff)
downloadlombok-d31182c4383a5ccc499862d2a8035d49e5202319.tar.gz
lombok-d31182c4383a5ccc499862d2a8035d49e5202319.tar.bz2
lombok-d31182c4383a5ccc499862d2a8035d49e5202319.zip
[fixes #2235] aliasing the old wither to the new one was broken for explicit imports.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lombok/core/ImportList.java8
-rw-r--r--src/core/lombok/core/TypeResolver.java4
-rw-r--r--src/core/lombok/eclipse/EclipseImportList.java9
-rw-r--r--src/core/lombok/javac/JavacImportList.java9
4 files changed, 23 insertions, 7 deletions
diff --git a/src/core/lombok/core/ImportList.java b/src/core/lombok/core/ImportList.java
index 95e266c4..208645a0 100644
--- a/src/core/lombok/core/ImportList.java
+++ b/src/core/lombok/core/ImportList.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 The Project Lombok Authors.
+ * Copyright (C) 2013-2020 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -30,6 +30,12 @@ public interface ImportList {
String getFullyQualifiedNameForSimpleName(String unqualified);
/**
+ * If there is an explicit import of the stated unqualified type name, return that. Otherwise, return null.
+ * Do not translate the produced fully qualified name to the alias.
+ */
+ String getFullyQualifiedNameForSimpleNameNoAliasing(String unqualified);
+
+ /**
* Returns true if the package name is explicitly star-imported, OR the packageName refers to this source file's own package name, OR packageName is 'java.lang'.
*/
boolean hasStarImport(String packageName);
diff --git a/src/core/lombok/core/TypeResolver.java b/src/core/lombok/core/TypeResolver.java
index 2c36d1fc..4f2df72e 100644
--- a/src/core/lombok/core/TypeResolver.java
+++ b/src/core/lombok/core/TypeResolver.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2019 The Project Lombok Authors.
+ * Copyright (C) 2009-2020 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -57,7 +57,7 @@ public class TypeResolver {
int firstDot = typeRef.indexOf('.');
if (firstDot == -1) firstDot = typeRef.length();
String firstTypeRef = typeRef.substring(0, firstDot);
- String fromExplicitImport = imports.getFullyQualifiedNameForSimpleName(firstTypeRef);
+ String fromExplicitImport = imports.getFullyQualifiedNameForSimpleNameNoAliasing(firstTypeRef);
if (fromExplicitImport != null) {
String fqn = fromExplicitImport + typeRef.substring(firstDot);
if (qualifieds.contains(fqn)) return LombokInternalAliasing.processAliases(fqn);
diff --git a/src/core/lombok/eclipse/EclipseImportList.java b/src/core/lombok/eclipse/EclipseImportList.java
index 6d60f5aa..9a04403d 100644
--- a/src/core/lombok/eclipse/EclipseImportList.java
+++ b/src/core/lombok/eclipse/EclipseImportList.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 The Project Lombok Authors.
+ * Copyright (C) 2013-2020 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -45,6 +45,11 @@ public class EclipseImportList implements ImportList {
}
@Override public String getFullyQualifiedNameForSimpleName(String unqualified) {
+ String q = getFullyQualifiedNameForSimpleNameNoAliasing(unqualified);
+ return q == null ? null : LombokInternalAliasing.processAliases(q);
+ }
+
+ @Override public String getFullyQualifiedNameForSimpleNameNoAliasing(String unqualified) {
if (imports != null) {
outer:
for (ImportReference imp : imports) {
@@ -54,7 +59,7 @@ public class EclipseImportList implements ImportList {
int len = token.length;
if (len != unqualified.length()) continue;
for (int i = 0; i < len; i++) if (token[i] != unqualified.charAt(i)) continue outer;
- return LombokInternalAliasing.processAliases(toQualifiedName(tokens));
+ return toQualifiedName(tokens);
}
}
return null;
diff --git a/src/core/lombok/javac/JavacImportList.java b/src/core/lombok/javac/JavacImportList.java
index 8de61afc..d498c2ab 100644
--- a/src/core/lombok/javac/JavacImportList.java
+++ b/src/core/lombok/javac/JavacImportList.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2015 The Project Lombok Authors.
+ * Copyright (C) 2013-2020 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -43,13 +43,18 @@ public class JavacImportList implements ImportList {
}
@Override public String getFullyQualifiedNameForSimpleName(String unqualified) {
+ String q = getFullyQualifiedNameForSimpleNameNoAliasing(unqualified);
+ return q == null ? null : LombokInternalAliasing.processAliases(q);
+ }
+
+ @Override public String getFullyQualifiedNameForSimpleNameNoAliasing(String unqualified) {
for (JCTree def : defs) {
if (!(def instanceof JCImport)) continue;
JCTree qual = ((JCImport) def).qualid;
if (!(qual instanceof JCFieldAccess)) continue;
String simpleName = ((JCFieldAccess) qual).name.toString();
if (simpleName.equals(unqualified)) {
- return LombokInternalAliasing.processAliases(qual.toString());
+ return qual.toString();
}
}