diff options
author | Till Brychcy | 2018-10-03 10:21:39 +0000 |
---|---|---|
committer | Till Brychcy | 2018-10-05 21:25:12 +0000 |
commit | e29e536a8af05578c6efc9b982cb39d5e09b4e03 (patch) | |
tree | 71c4474d09c24db5f401b454c2321e4d3772e8f8 /org.eclipse.jdt.apt.pluggable.core | |
parent | a627e47891a7ae0c2b0fc8860ecc0529255b7673 (diff) | |
download | eclipse.jdt.core-e29e536a8af05578c6efc9b982cb39d5e09b4e03.tar.gz eclipse.jdt.core-e29e536a8af05578c6efc9b982cb39d5e09b4e03.tar.xz eclipse.jdt.core-e29e536a8af05578c6efc9b982cb39d5e09b4e03.zip |
Bug 539774 - Spurious compilation failures caused by java model usageI20181006-0600I20181005-1800
during annotation processing.
Change-Id: If2e649786f4e6d1117636cb52556d8a3f791ec87
Diffstat (limited to 'org.eclipse.jdt.apt.pluggable.core')
-rw-r--r-- | org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeFilerImpl.java | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeFilerImpl.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeFilerImpl.java index 80218d6b47..75c763378e 100644 --- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeFilerImpl.java +++ b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeFilerImpl.java @@ -38,12 +38,14 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.apt.core.internal.AptCompilationParticipant; import org.eclipse.jdt.apt.core.internal.generatedfile.GeneratedSourceFolderManager; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.apt.pluggable.core.Apt6Plugin; import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeAnnotationProcessorManager; import org.eclipse.jdt.internal.apt.pluggable.core.dispatch.IdeProcessingEnvImpl; +import org.eclipse.jdt.internal.compiler.lookup.ModuleBinding; +import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; +import org.eclipse.jdt.internal.compiler.lookup.TagBits; /** * Implementation of the Filer interface that is used in IDE mode. @@ -162,14 +164,16 @@ public class IdeFilerImpl implements Filer { if (AptCompilationParticipant.getInstance().getJava6GeneratedFiles().contains(file)) { throw new FilerException("Source file already created: " + file.getFullPath()); //$NON-NLS-1$ } - IJavaProject javaProject = _env.getJavaProject(); - IType type = null; - try { - name = name.toString().replace('/', '.'); - type = javaProject.findType(name.toString()); - } catch (JavaModelException e) { - } - if (type != null) { + // TODO: is the following correct? + // JDK 9's createSourceFile API mentions '/' as separator for a module prefix. + // Otherwise shouldn't <code>name</code> already be "."-separated? + name = name.toString().replace('/', '.'); + + ModuleBinding m = _env._current_module; + if (m == null) + m = _env.getCompiler().lookupEnvironment.UnNamedModule; + ReferenceBinding type = m.environment.getType(CharOperation.splitOn('.', name.toString().toCharArray()), m); + if (type != null && (type.tagBits & TagBits.HasMissingType) == 0) { throw new FilerException("Source file already exists : " + name); //$NON-NLS-1$ } Set<IFile> parentFiles = Collections.emptySet(); |