mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
BAZEL-2160 JavacConfiguration should be as a light service - it is PSC, but project-level one
GitOrigin-RevId: 66552adea34221b53a78060831bbc5683bf2fba0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fcb3926ebb
commit
7e547b4d43
+6
-7
@@ -1,10 +1,7 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.compiler.impl.javaCompiler.javac;
|
||||
|
||||
import com.intellij.openapi.components.PathMacroManager;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -13,7 +10,7 @@ import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerOptions;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("LightServiceMigrationCode")
|
||||
@Service(Service.Level.PROJECT)
|
||||
@State(name = "JavacSettings", storages = @Storage("compiler.xml"))
|
||||
public final class JavacConfiguration implements PersistentStateComponent<JpsJavaCompilerOptions> {
|
||||
private final JpsJavaCompilerOptions mySettings = new JpsJavaCompilerOptions();
|
||||
@@ -27,7 +24,8 @@ public final class JavacConfiguration implements PersistentStateComponent<JpsJav
|
||||
public @NotNull JpsJavaCompilerOptions getState() {
|
||||
final JpsJavaCompilerOptions state = new JpsJavaCompilerOptions();
|
||||
XmlSerializerUtil.copyBean(mySettings, state);
|
||||
state.ADDITIONAL_OPTIONS_OVERRIDE = new HashMap<>(state.ADDITIONAL_OPTIONS_OVERRIDE); // copyBean copies by reference, we need a map clone here
|
||||
// `copyBean` copies by reference, we need a map clone here
|
||||
state.ADDITIONAL_OPTIONS_OVERRIDE = new HashMap<>(state.ADDITIONAL_OPTIONS_OVERRIDE);
|
||||
final PathMacroManager macros = PathMacroManager.getInstance(project);
|
||||
state.ADDITIONAL_OPTIONS_STRING = macros.collapsePathsRecursively(state.ADDITIONAL_OPTIONS_STRING);
|
||||
for (Map.Entry<String, String> entry : state.ADDITIONAL_OPTIONS_OVERRIDE.entrySet()) {
|
||||
@@ -41,7 +39,8 @@ public final class JavacConfiguration implements PersistentStateComponent<JpsJav
|
||||
XmlSerializerUtil.copyBean(state, mySettings);
|
||||
}
|
||||
|
||||
public static JpsJavaCompilerOptions getOptions(Project project, Class<? extends JavacConfiguration> aClass) {
|
||||
// we cannot change the signature of this method to preserve backward compatibility
|
||||
public static JpsJavaCompilerOptions getOptions(Project project, @SuppressWarnings("TypeParameterExtendsFinalClass") Class<? extends JavacConfiguration> aClass) {
|
||||
JavacConfiguration configuration = project.getService(aClass);
|
||||
return configuration.mySettings;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user