Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjay2018-09-26 03:06:28 -0400
committerjay2018-09-26 03:06:28 -0400
commit3ccd57c481cc77b3726464874886fdf9669c7a5c (patch)
tree8dfdfbd7e0bd3568fc04f02ff7fb2627706d883f /org.eclipse.jdt.compiler.apt
parent2a269a8600046558a3c0af2e8dcd9a733817dfd9 (diff)
parent1aa58eac3b0985df8c3358b7c4aec62fb9a6b2e8 (diff)
downloadeclipse.jdt.core-3ccd57c481cc77b3726464874886fdf9669c7a5c.tar.gz
eclipse.jdt.core-3ccd57c481cc77b3726464874886fdf9669c7a5c.tar.xz
eclipse.jdt.core-3ccd57c481cc77b3726464874886fdf9669c7a5c.zip
Merge branch 'BETA_JAVA11'
# Conflicts: # org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java # org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java # org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java # org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java # org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseFileManager.java # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AmbiguousMethodTest.java # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286ReservedWordTest.java # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodParametersAttributeTest.java # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PolymorphicSignatureTest.java # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemConstructorTest.java # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StaticImportTest.java # org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/TestCase.java # org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/RunAllJava10Tests.java # org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java # org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests10.java # org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugs10Tests.java # org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/NameLookupTests2.java # org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java # org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java # org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java # org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java # org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/env/ISourceModule.java # org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocTagConstants.java # org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/ScannerHelper.java # org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java # org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IAttributeNamesConstants.java # org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IClassFileReader.java # org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPool.java # org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPoolConstant.java # org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPoolEntry.java # org.eclipse.jdt.core/model/org/eclipse/jdt/core/util/IConstantPoolEntry2.java # org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ClassFileReader.java # org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/ConstantPool.java # org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java Change-Id: If63162fb2d7e2e3a57e078289a4b6cf31c31ab66
Diffstat (limited to 'org.eclipse.jdt.compiler.apt')
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java18
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java59
2 files changed, 71 insertions, 6 deletions
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java
index e9d501eab7..ef7e53d93b 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/dispatch/BatchFilerImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2015 BEA Systems, Inc.
+ * Copyright (c) 2006, 2018 BEA Systems, Inc.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -24,6 +24,7 @@ import java.util.HashSet;
import javax.annotation.processing.Filer;
import javax.annotation.processing.FilerException;
import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
import javax.tools.FileObject;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
@@ -136,8 +137,19 @@ public class BatchFilerImpl implements Filer {
@Override
public JavaFileObject createSourceFile(CharSequence name,
Element... originatingElements) throws IOException {
- JavaFileObject jfo = _fileManager.getJavaFileForOutput(
- StandardLocation.SOURCE_OUTPUT, name.toString(), JavaFileObject.Kind.SOURCE, null);
+ String moduleAndPkgString = name.toString();
+ int slash = moduleAndPkgString.indexOf('/');
+ String mod = null;
+ if (slash != -1) {
+ name = moduleAndPkgString.substring(slash + 1, name.length());
+ mod = moduleAndPkgString.substring(0, slash);
+ }
+ TypeElement typeElement = _env._elementUtils.getTypeElement(name);
+ if (typeElement != null) {
+ throw new FilerException("Source file already exists : " + moduleAndPkgString); //$NON-NLS-1$
+ }
+ Location location = mod == null ? StandardLocation.SOURCE_OUTPUT : _fileManager.getLocationForModule(StandardLocation.SOURCE_OUTPUT, mod);
+ JavaFileObject jfo = _fileManager.getJavaFileForOutput(location, name.toString(), JavaFileObject.Kind.SOURCE, null);
URI uri = jfo.toUri();
if (_createdFiles.contains(uri)) {
throw new FilerException("Source file already created : " + name); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java
index 46b2ce3f83..b51cb094af 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/util/EclipseFileManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2017 IBM Corporation and others.
+ * Copyright (c) 2006, 2018 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -1393,7 +1393,17 @@ public class EclipseFileManager implements StandardJavaFileManager {
@Override
public Location getLocationForModule(Location location, String moduleName) throws IOException {
validateModuleLocation(location, moduleName);
- return this.locationHandler.getLocation(location, moduleName);
+ Location result = this.locationHandler.getLocation(location, moduleName);
+ if (result == null && location == StandardLocation.CLASS_OUTPUT) {
+ LocationWrapper wrapper = this.locationHandler.getLocation(StandardLocation.MODULE_SOURCE_PATH, moduleName);
+ deriveOutputLocationForModules(moduleName, wrapper.paths);
+ result = getLocationForModule(location, moduleName);
+ } else if (result == null && location == StandardLocation.SOURCE_OUTPUT) {
+ LocationWrapper wrapper = this.locationHandler.getLocation(StandardLocation.MODULE_SOURCE_PATH, moduleName);
+ deriveSourceOutputLocationForModules(moduleName, wrapper.paths);
+ result = getLocationForModule(location, moduleName);
+ }
+ return result;
}
@Override
@@ -1451,7 +1461,50 @@ public class EclipseFileManager implements StandardJavaFileManager {
}
return null;
}
-
+ private void deriveOutputLocationForModules(String moduleName, Collection<? extends Path> paths) {
+ LocationWrapper wrapper = this.locationHandler.getLocation(StandardLocation.CLASS_OUTPUT, moduleName);
+ if (wrapper == null) {
+ // First get from our internally known location for legacy/unnamed location
+ wrapper = this.locationHandler.getLocation(StandardLocation.CLASS_OUTPUT, ""); //$NON-NLS-1$
+ if (wrapper == null) {
+ wrapper = this.locationHandler.getLocation(StandardLocation.CLASS_OUTPUT);
+ }
+ if (wrapper != null) {
+ Iterator<? extends Path> iterator = wrapper.paths.iterator();
+ if (iterator.hasNext()) {
+ try {
+ // Per module output location is always a singleton list
+ Path path = iterator.next().resolve(moduleName);
+ this.locationHandler.setLocation(StandardLocation.CLASS_OUTPUT, moduleName, Collections.singletonList(path));
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+ private void deriveSourceOutputLocationForModules(String moduleName, Collection<? extends Path> paths) {
+ LocationWrapper wrapper = this.locationHandler.getLocation(StandardLocation.SOURCE_OUTPUT, moduleName);
+ if (wrapper == null) {
+ // First get from our internally known location for legacy/unnamed location
+ wrapper = this.locationHandler.getLocation(StandardLocation.SOURCE_OUTPUT, ""); //$NON-NLS-1$
+ if (wrapper == null) {
+ wrapper = this.locationHandler.getLocation(StandardLocation.SOURCE_OUTPUT);
+ }
+ if (wrapper != null) {
+ Iterator<? extends Path> iterator = wrapper.paths.iterator();
+ if (iterator.hasNext()) {
+ try {
+ // Per module output location is always a singleton list
+ Path path = iterator.next().resolve(moduleName);
+ this.locationHandler.setLocation(StandardLocation.SOURCE_OUTPUT, moduleName, Collections.singletonList(path));
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
@Override
public void setLocationForModule(Location location, String moduleName, Collection<? extends Path> paths) throws IOException {
validateModuleLocation(location, moduleName);

Back to the top