make JpsElementContainerImpl thread-safe, deprecate JpsJavaExtensionService.getOrCreateCompilerConfiguration (IDEA-229603, IDEA-194275)

GitOrigin-RevId: bad2613431b74d98bbea88c884655db4b4c4873b
This commit is contained in:
Eugene Zhuravlev
2019-12-25 12:31:56 +00:00
committed by intellij-monorepo-bot
parent b11b5e516e
commit beed6d7bb2
31 changed files with 196 additions and 76 deletions
@@ -39,7 +39,7 @@ public final class FilteredResourceRootDescriptor extends ResourceRootDescriptor
@Override
public FileFilter createFileFilter() {
final JpsProject project = getTarget().getModule().getProject();
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
final JpsCompilerExcludes excludes = configuration.getCompilerExcludes();
return file -> !excludes.isExcluded(file) && configuration.isResourceFile(file, getRootFile());
}
@@ -92,7 +92,7 @@ public class JavaSourceRootDescriptor extends BuildRootDescriptor {
@NotNull
@Override
public FileFilter createFileFilter() {
final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(target.getModule().getProject()).getCompilerExcludes();
final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getCompilerConfiguration(target.getModule().getProject()).getCompilerExcludes();
final FileFilter baseFilter = BuilderRegistry.getInstance().getModuleBuilderFileFilter();
return file -> baseFilter.accept(file) && !excludes.isExcluded(file);
}
@@ -69,7 +69,7 @@ public class ResourceRootDescriptor extends BuildRootDescriptor {
@Override
public FileFilter createFileFilter() {
final JpsProject project = getTarget().getModule().getProject();
final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project).getCompilerExcludes();
final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project).getCompilerExcludes();
return file -> !excludes.isExcluded(file);
}
@@ -543,7 +543,7 @@ public class IncProjectBuilder {
final ProjectDescriptor projectDescriptor = context.getProjectDescriptor();
ProjectBuildException ex = null;
try {
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(projectDescriptor.getProject());
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(projectDescriptor.getProject());
final boolean shouldClear = configuration.isClearOutputDirectoryOnRebuild();
if (shouldClear) {
clearOutputs(context);
@@ -87,7 +87,7 @@ public final class ModuleBuildTarget extends JVMModuleBuildTarget<JavaSourceRoot
result.add(outputDir);
}
final JpsModule module = getModule();
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(module.getProject());
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(module.getProject());
final ProcessorConfigProfile profile = configuration.getAnnotationProcessingProfile(module);
if (profile.isEnabled()) {
final File annotationOut = ProjectPaths.getAnnotationProcessorGeneratedSourcesOutputDir(module, isTests(), profile);
@@ -152,7 +152,7 @@ public final class ModuleBuildTarget extends JVMModuleBuildTarget<JavaSourceRoot
List<JavaSourceRootDescriptor> roots = new ArrayList<>();
JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
Iterable<ExcludedJavaSourceRootProvider> excludedRootProviders = JpsServiceManager.getInstance().getExtensions(ExcludedJavaSourceRootProvider.class);
final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myModule.getProject());
final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getCompilerConfiguration(myModule.getProject());
roots_loop:
for (JpsTypedModuleSourceRoot<JavaSourceRootProperties> sourceRoot : myModule.getSourceRoots(type)) {
@@ -214,7 +214,7 @@ public final class ModuleBuildTarget extends JVMModuleBuildTarget<JavaSourceRoot
fingerprint += level.name().hashCode();
}
final JpsJavaCompilerConfiguration config = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(module.getProject());
final JpsJavaCompilerConfiguration config = JpsJavaExtensionService.getInstance().getCompilerConfiguration(module.getProject());
final String bytecodeTarget = config.getByteCodeTargetLevel(module.getName());
if (bytecodeTarget != null) {
if (logBuilder != null) {
@@ -48,7 +48,7 @@ public class NotNullInstrumentingBuilder extends BaseInstrumentingBuilder{
@Override
protected boolean isEnabled(CompileContext context, ModuleChunk chunk) {
final ProjectDescriptor pd = context.getProjectDescriptor();
return JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(pd.getProject()).isAddNotNullAssertions();
return JpsJavaExtensionService.getInstance().getCompilerConfiguration(pd.getProject()).isAddNotNullAssertions();
}
@Override
@@ -66,7 +66,7 @@ public class NotNullInstrumentingBuilder extends BaseInstrumentingBuilder{
InstrumentationClassFinder finder) {
try {
final ProjectDescriptor pd = context.getProjectDescriptor();
final List<String> notNulls = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(pd.getProject()).getNotNullAnnotations();
final List<String> notNulls = JpsJavaExtensionService.getInstance().getCompilerConfiguration(pd.getProject()).getNotNullAnnotations();
if (NotNullVerifyingInstrumenter.processClassFile((FailSafeClassReader)reader, writer, ArrayUtilRt.toStringArray(notNulls))) {
return new BinaryContent(writer.toByteArray());
}
@@ -34,7 +34,7 @@ import java.io.File;
public class AnnotationsExcludedJavaSourceRootProvider extends ExcludedJavaSourceRootProvider{
@Override
public boolean isExcludedFromCompilation(@NotNull JpsModule module, @NotNull JpsModuleSourceRoot root) {
final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(module.getProject());
final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getCompilerConfiguration(module.getProject());
final ProcessorConfigProfile profile = compilerConfig.getAnnotationProcessingProfile(module);
if (!profile.isEnabled()) {
return false;
@@ -55,8 +55,7 @@ import org.jetbrains.jps.model.serialization.PathMacroUtil;
import org.jetbrains.jps.service.JpsServiceManager;
import org.jetbrains.jps.service.SharedThreadPool;
import javax.tools.Diagnostic;
import javax.tools.JavaFileObject;
import javax.tools.*;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
@@ -766,7 +765,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
final List<String> compilationOptions = new ArrayList<>();
final List<String> vmOptions = new ArrayList<>();
final JpsProject project = context.getProjectDescriptor().getProject();
final JpsJavaCompilerOptions compilerOptions = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project).getCurrentCompilerOptions();
final JpsJavaCompilerOptions compilerOptions = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project).getCurrentCompilerOptions();
if (compilerOptions.DEBUGGING_INFO) {
compilationOptions.add("-g");
}
@@ -939,7 +938,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
}
private static void addCrossCompilationOptions(int compilerSdkVersion, List<? super String> options, CompileContext context, ModuleChunk chunk) {
final JpsJavaCompilerConfiguration compilerConfiguration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(
final JpsJavaCompilerConfiguration compilerConfiguration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(
context.getProjectDescriptor().getProject()
);
@@ -172,7 +172,7 @@ public class Java9Test extends IncrementalTestCase {
public void testExplodedAutoModuleWithManifest() {
setupInitialProject();
final Map<String, JpsModule> modules = setupModules();
JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myProject).addResourcePattern("*.MF");
JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject).addResourcePattern("*.MF");
assertEquals(2, modules.size());
assertTrue(modules.containsKey("A"));
@@ -39,7 +39,7 @@ public class ResourceCopyingTest extends JpsBuildTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myProject).addResourcePattern("*.xml");
JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject).addResourcePattern("*.xml");
}
public void testSimple() {
@@ -107,7 +107,7 @@ public class ResourceCopyingTest extends JpsBuildTestCase {
String excludedFile = createFile("res/excluded.java", "XXX");
JpsModule m = addModule("m");
m.addSourceRoot(JpsPathUtil.pathToUrl(PathUtil.getParentPath(file)), JavaResourceRootType.RESOURCE);
JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myProject).getCompilerExcludes().addExcludedFile(
JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject).getCompilerExcludes().addExcludedFile(
"file://" + FileUtil.toSystemIndependentName(excludedFile)
);
rebuildAllModules();
@@ -223,7 +223,7 @@ class ArtifactBuilderTest : ArtifactBuilderTestCase() {
fun testCopyResourcesFromModuleOutput() {
val file = createFile("src/a.xml", "")
JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myProject).addResourcePattern("*.xml")
JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject).addResourcePattern("*.xml")
val module = addModule("a", PathUtil.getParentPath(file))
val artifact = addArtifact(root().module(module))
buildArtifacts(artifact)
@@ -40,7 +40,7 @@ public class CleanArtifactOutputOnRebuildTest extends ArtifactBuilderTestCase {
}
public void testDoNotCleanOnRebuildIfOptionIsSwitchedOff() {
JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myProject).setClearOutputDirectoryOnRebuild(false);
JpsJavaExtensionService.getInstance().getCompilerConfiguration(myProject).setClearOutputDirectoryOnRebuild(false);
JpsArtifact a = addArtifact(root().fileCopy(createFile("a.txt")));
buildArtifacts(a);
createFileInArtifactOutput(a, "b.txt");
@@ -17,6 +17,8 @@ package org.jetbrains.jps.model;
import org.jetbrains.annotations.NotNull;
import java.util.function.Supplier;
/**
* @author nik
*/
@@ -36,6 +38,9 @@ public interface JpsElementContainer {
<T extends JpsElement, P, K extends JpsElementChildRole<T> &JpsElementParameterizedCreator<T, P>>
T setChild(@NotNull K role, @NotNull P param);
<T extends JpsElement, P, K extends JpsElementChildRole<T> &JpsElementParameterizedCreator<T, P>>
T getOrSetChild(@NotNull K role, @NotNull Supplier<P> param);
<T extends JpsElement>
T setChild(JpsElementChildRole<T> role, T child);
@@ -25,6 +25,8 @@ import java.util.Map;
* @author nik
*/
public abstract class JpsElementContainerEx implements JpsElementContainer {
protected abstract Object getDataLock();
protected abstract Map<JpsElementChildRole<?>, JpsElement> getElementsMap();
protected abstract void applyChanges(JpsElementContainerEx modified);
@@ -0,0 +1,49 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jps.model.ex;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.JpsElement;
import org.jetbrains.jps.model.JpsElementChildRole;
import org.jetbrains.jps.model.JpsElementCreator;
/**
* @author nik
*/
public class JpsFactoryElementChildRoleBase<E extends JpsElement> extends JpsElementChildRole<E> implements JpsElementCreator<E> {
private final String myDebugName;
private final JpsElementCreator<E> myFactoryImpl;
protected JpsFactoryElementChildRoleBase(String debugName, JpsElementCreator<E> factoryImpl) {
myDebugName = debugName;
myFactoryImpl = factoryImpl;
}
@Override
public String toString() {
return myDebugName;
}
@NotNull
@Override
public E create() {
return myFactoryImpl.create();
}
public static <E extends JpsElement> JpsFactoryElementChildRoleBase<E> create(String debugName, JpsElementCreator<E> factory) {
return new JpsFactoryElementChildRoleBase<>(debugName, factory);
}
}
@@ -91,9 +91,13 @@ public abstract class JpsJavaExtensionService {
public abstract JpsTypedLibrary<JpsSdk<JpsDummyElement>> addJavaSdk(@NotNull JpsGlobal global, @NotNull String name, @NotNull String homePath);
@Nullable
@NotNull
public abstract JpsJavaCompilerConfiguration getCompilerConfiguration(@NotNull JpsProject project);
/**
* @deprecated use {@link JpsJavaExtensionService#getCompilerConfiguration(JpsProject)} instead
*/
@Deprecated
@NotNull
public abstract JpsJavaCompilerConfiguration getOrCreateCompilerConfiguration(@NotNull JpsProject project);
@@ -20,12 +20,16 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.function.Supplier;
/**
* @author nik
*/
public class JpsElementContainerImpl extends JpsElementContainerEx implements JpsElementContainer {
private final Object myDataLock = new Object();
private final Map<JpsElementChildRole<?>, JpsElement> myElements = new THashMap<>(1);
private final @NotNull JpsCompositeElementBase<?> myParent;
@@ -35,24 +39,27 @@ public class JpsElementContainerImpl extends JpsElementContainerEx implements Jp
public JpsElementContainerImpl(@NotNull JpsElementContainerEx original, @NotNull JpsCompositeElementBase<?> parent) {
myParent = parent;
for (Map.Entry<JpsElementChildRole<?>, JpsElement> entry : original.getElementsMap().entrySet()) {
final JpsElementChildRole role = entry.getKey();
final JpsElement copy = entry.getValue().getBulkModificationSupport().createCopy();
JpsElementBase.setParent(copy, myParent);
myElements.put(role, copy);
synchronized (original.getDataLock()) {
for (Map.Entry<JpsElementChildRole<?>, JpsElement> entry : original.getElementsMap().entrySet()) {
final JpsElementChildRole role = entry.getKey();
final JpsElement copy = entry.getValue().getBulkModificationSupport().createCopy();
JpsElementBase.setParent(copy, myParent);
myElements.put(role, copy);
}
}
}
@Override
public <T extends JpsElement> T getChild(@NotNull JpsElementChildRole<T> role) {
//noinspection unchecked
return (T)myElements.get(role);
synchronized (myDataLock) {
//noinspection unchecked
return (T)myElements.get(role);
}
}
@NotNull
@Override
public <T extends JpsElement, P, K extends JpsElementChildRole<T> & JpsElementParameterizedCreator<T, P>> T setChild(@NotNull K role,
@NotNull P param) {
public <T extends JpsElement, P, K extends JpsElementChildRole<T> & JpsElementParameterizedCreator<T, P>> T setChild(@NotNull K role, @NotNull P param) {
final T child = role.create(param);
return setChild(role, child);
}
@@ -67,28 +74,75 @@ public class JpsElementContainerImpl extends JpsElementContainerEx implements Jp
@NotNull
@Override
public <T extends JpsElement, K extends JpsElementChildRole<T> & JpsElementCreator<T>> T getOrSetChild(@NotNull K role) {
final T child = getChild(role);
if (child == null) {
return setChild(role);
T added = null;
try {
synchronized (myDataLock) {
final T cached = (T)myElements.get(role);
if (cached != null) {
return cached;
}
return added = putChild(role, role.create());
}
}
finally {
if (added != null) {
fireChildSet(role, added);
}
}
}
@Override
public <T extends JpsElement, P, K extends JpsElementChildRole<T> & JpsElementParameterizedCreator<T, P>> T getOrSetChild(@NotNull K role, @NotNull Supplier<P> param) {
T added = null;
try {
synchronized (myDataLock) {
final T cached = (T)myElements.get(role);
if (cached != null) {
return cached;
}
return added = putChild(role, role.create(param.get()));
}
}
finally {
if (added != null) {
fireChildSet(role, added);
}
}
return child;
}
@Override
public <T extends JpsElement> T setChild(JpsElementChildRole<T> role, T child) {
myElements.put(role, child);
try {
synchronized (myDataLock) {
return putChild(role, child);
}
}
finally {
fireChildSet(role, child);
}
}
@NotNull
private <T extends JpsElement> T putChild(JpsElementChildRole<T> role, T child) {
JpsElementBase.setParent(child, myParent);
myElements.put(role, child);
return child;
}
private <T extends JpsElement> void fireChildSet(JpsElementChildRole<T> role, T child) {
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
if (eventDispatcher != null) {
eventDispatcher.fireElementAdded(child, role);
}
return child;
}
@Override
public <T extends JpsElement> void removeChild(@NotNull JpsElementChildRole<T> role) {
//noinspection unchecked
final T removed = (T)myElements.remove(role);
final T removed;
synchronized (myDataLock) {
removed = (T)myElements.remove(role);
}
if (removed == null) return;
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
if (eventDispatcher != null) {
@@ -98,19 +152,36 @@ public class JpsElementContainerImpl extends JpsElementContainerEx implements Jp
}
@Override
protected Map<JpsElementChildRole<?>, JpsElement> getElementsMap() {
protected final Object getDataLock() {
return myDataLock;
}
@Override
protected final Map<JpsElementChildRole<?>, JpsElement> getElementsMap() {
return myElements;
}
@Override
public void applyChanges(@NotNull JpsElementContainerEx modified) {
for (JpsElementChildRole<?> role : myElements.keySet()) {
final Collection<JpsElementChildRole<?>> roles = new ArrayList<>();
synchronized (myDataLock) {
roles.addAll(myElements.keySet());
}
for (JpsElementChildRole<?> role : roles) {
applyChanges(role, modified);
}
for (JpsElementChildRole<?> role : modified.getElementsMap().keySet()) {
if (!myElements.containsKey(role)) {
applyChanges(role, modified);
}
roles.clear();
synchronized (modified.getDataLock()) {
roles.addAll(modified.getElementsMap().keySet());
}
synchronized (myDataLock) {
roles.removeAll(myElements.keySet());
}
for (JpsElementChildRole<?> role : roles) {
applyChanges(role, modified);
}
}
@@ -13,7 +13,7 @@ import org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes;
public class JavaModuleIndexRole extends JpsElementChildRoleBase<JavaModuleIndex> implements JpsElementParameterizedCreator<JavaModuleIndex, JpsCompilerExcludes>{
public static final JavaModuleIndexRole INSTANCE = new JavaModuleIndexRole();
public JavaModuleIndexRole() {
private JavaModuleIndexRole() {
super("java module index");
}
@@ -7,7 +7,6 @@ import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsDummyElement;
import org.jetbrains.jps.model.JpsElementContainer;
import org.jetbrains.jps.model.JpsGlobal;
import org.jetbrains.jps.model.JpsProject;
import org.jetbrains.jps.model.java.*;
@@ -142,20 +141,17 @@ public class JpsJavaExtensionServiceImpl extends JpsJavaExtensionService {
return sdk;
}
@Nullable
@NotNull
@Override
public JpsJavaCompilerConfiguration getCompilerConfiguration(@NotNull JpsProject project) {
return project.getContainer().getChild(JpsJavaCompilerConfigurationImpl.ROLE);
return project.getContainer().getOrSetChild(JpsJavaCompilerConfigurationImpl.ROLE);
}
@Deprecated
@NotNull
@Override
public JpsJavaCompilerConfiguration getOrCreateCompilerConfiguration(@NotNull JpsProject project) {
JpsJavaCompilerConfiguration configuration = getCompilerConfiguration(project);
if (configuration == null) {
configuration = project.getContainer().setChild(JpsJavaCompilerConfigurationImpl.ROLE, new JpsJavaCompilerConfigurationImpl());
}
return configuration;
return getCompilerConfiguration(project);
}
@Nullable
@@ -236,11 +232,6 @@ public class JpsJavaExtensionServiceImpl extends JpsJavaExtensionService {
@NotNull
@Override
public JavaModuleIndex getJavaModuleIndex(@NotNull JpsProject project) {
JpsElementContainer container = project.getContainer();
JavaModuleIndex index = container.getChild(JavaModuleIndexRole.INSTANCE);
if (index == null) {
index = container.setChild(JavaModuleIndexRole.INSTANCE, getOrCreateCompilerConfiguration(project).getCompilerExcludes());
}
return index;
return project.getContainer().getOrSetChild(JavaModuleIndexRole.INSTANCE, () -> getCompilerConfiguration(project).getCompilerExcludes());
}
}
@@ -17,9 +17,8 @@ package org.jetbrains.jps.model.java.impl.compiler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.JpsElementChildRole;
import org.jetbrains.jps.model.ex.JpsCompositeElementBase;
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
import org.jetbrains.jps.model.ex.JpsFactoryElementChildRoleBase;
import org.jetbrains.jps.model.java.compiler.*;
import org.jetbrains.jps.model.module.JpsModule;
@@ -30,7 +29,7 @@ import java.util.*;
* @author nik
*/
public class JpsJavaCompilerConfigurationImpl extends JpsCompositeElementBase<JpsJavaCompilerConfigurationImpl> implements JpsJavaCompilerConfiguration {
public static final JpsElementChildRole<JpsJavaCompilerConfiguration> ROLE = JpsElementChildRoleBase.create("compiler configuration");
public static final JpsFactoryElementChildRoleBase<JpsJavaCompilerConfiguration> ROLE = JpsFactoryElementChildRoleBase.create("compiler configuration", () -> new JpsJavaCompilerConfigurationImpl());
private boolean myAddNotNullAssertions = true;
private List<String> myNotNullAnnotations = Collections.singletonList(NotNull.class.getName());
private boolean myClearOutputDirectoryOnRebuild = true;
@@ -35,7 +35,7 @@ public class JpsCompilerValidationExcludeSerializer extends JpsProjectExtensionS
@Override
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
JpsJavaCompilerConfigurationSerializer.readExcludes(componentTag, configuration.getValidationExcludes());
}
@@ -37,14 +37,14 @@ public class JpsEclipseCompilerOptionsSerializer extends JpsProjectExtensionSeri
@Override
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
EclipseCompilerOptions options = XmlSerializer.deserialize(componentTag, EclipseCompilerOptions.class);
configuration.setCompilerOptions(myCompilerId, options);
}
@Override
public void loadExtensionWithDefaultSettings(@NotNull JpsProject project) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
configuration.setCompilerOptions(myCompilerId, new EclipseCompilerOptions());
}
@@ -40,7 +40,7 @@ public class JpsJavaCompilerConfigurationSerializer extends JpsProjectExtensionS
@Override
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
Element addNotNullTag = componentTag.getChild(ADD_NOTNULL_ASSERTIONS);
if (addNotNullTag != null) {
configuration.setAddNotNullAssertions(Boolean.parseBoolean(addNotNullTag.getAttributeValue(ENABLED, "true")));
@@ -101,7 +101,7 @@ public class JpsJavaCompilerConfigurationSerializer extends JpsProjectExtensionS
@Override
public void loadExtensionWithDefaultSettings(@NotNull JpsProject project) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
for (String pattern : DEFAULT_WILDCARD_PATTERNS) {
configuration.addResourcePattern(pattern);
}
@@ -24,7 +24,7 @@ public class JpsJavaCompilerNotNullableSerializer extends JpsProjectExtensionSer
@Override
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
List<String> annoNames = new ArrayList<>();
for (Element option : componentTag.getChildren("instrumentedNotNulls")) {
for (Element item : option.getChildren("option")) {
@@ -39,7 +39,7 @@ public class JpsJavaCompilerNotNullableSerializer extends JpsProjectExtensionSer
@Override
public void loadExtensionWithDefaultSettings(@NotNull JpsProject project) {
JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project).setNotNullAnnotations(
JpsJavaExtensionService.getInstance().getCompilerConfiguration(project).setNotNullAnnotations(
Collections.singletonList(NotNull.class.getName()));
}
@@ -37,14 +37,14 @@ public class JpsJavaCompilerOptionsSerializer extends JpsProjectExtensionSeriali
@Override
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
JpsJavaCompilerOptions options = XmlSerializer.deserialize(componentTag, JpsJavaCompilerOptions.class);
configuration.setCompilerOptions(myCompilerId, options);
}
@Override
public void loadExtensionWithDefaultSettings(@NotNull JpsProject project) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
configuration.setCompilerOptions(myCompilerId, new JpsJavaCompilerOptions());
}
@@ -33,7 +33,7 @@ public class JpsJavaCompilerWorkspaceConfigurationSerializer extends JpsProjectE
@Override
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
String assertNotNull = JDOMExternalizerUtil.readField(componentTag, "ASSERT_NOT_NULL");
if (assertNotNull != null) {
configuration.setAddNotNullAssertions(Boolean.parseBoolean(assertNotNull));
@@ -24,7 +24,7 @@ public class JpsValidationSerializer extends JpsProjectExtensionSerializer {
@Override
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
ValidationConfigurationState state = XmlSerializer.deserialize(componentTag, ValidationConfigurationState.class);
Set<String> disabledValidators = state.VALIDATORS.entrySet().stream()
.filter(e -> e.getValue() == Boolean.FALSE)
@@ -37,14 +37,14 @@ public class RmicCompilerOptionsSerializer extends JpsProjectExtensionSerializer
@Override
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
RmicCompilerOptions options = XmlSerializer.deserialize(componentTag, RmicCompilerOptions.class);
configuration.setCompilerOptions(myCompilerId, options);
}
@Override
public void loadExtensionWithDefaultSettings(@NotNull JpsProject project) {
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
configuration.setCompilerOptions(myCompilerId, new RmicCompilerOptions());
}
@@ -203,7 +203,7 @@ public class GreclipseBuilder extends ModuleLevelBuilder {
static boolean useGreclipse(CompileContext context) {
JpsProject project = context.getProjectDescriptor().getProject();
return ID.equals(JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project).getJavaCompilerId());
return ID.equals(JpsJavaExtensionService.getInstance().getCompilerConfiguration(project).getJavaCompilerId());
}
private boolean performCompilation(List<String> args, StringWriter out, StringWriter err, Map<String, List<String>> outputs, CompileContext context, ModuleChunk chunk) {
@@ -428,7 +428,7 @@ public abstract class JpsGroovycRunner<R extends BuildRootDescriptor, T extends
private Map<String, String> buildClassToSourceMap(ModuleChunk chunk, CompileContext context, Set<String> toCompilePaths, Map<T, String> finalOutputs) throws IOException {
final Map<String, String> class2Src = new HashMap<>();
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(
context.getProjectDescriptor().getProject());
for (T target : getTargets(chunk)) {
String moduleOutputPath = finalOutputs.get(target);
@@ -115,7 +115,7 @@ public class FormsBindingManager extends FormsBuilder {
});
if (config.isInstrumentClasses()) {
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getCompilerConfiguration(project);
final JpsCompilerExcludes excludes = configuration.getCompilerExcludes();
// force compilation of bound source file if the form is dirty