mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
IDEA-140344 allow to override heap size locally without modifying VM options
Effective value is determined in the following order: 1. user-local heap size; 2. user-local VM options; 3. shared heap size; 4. shared VM options. 3 already had higher priority than 4, so newly added 1 has higher priority than 2 for consistency. GitOrigin-RevId: 9677822c66c02c047cec602d757cd3591dd881b3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
43fc9ab7cb
commit
066d57a271
@@ -28,6 +28,17 @@ public final class ComparingUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isModified(JTextField textField, int defaultValue, int value) {
|
||||
try {
|
||||
String text = textField.getText().trim();
|
||||
int fieldValue = text.isEmpty() ? defaultValue : Integer.parseInt(text);
|
||||
return fieldValue != value;
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isModified(RawCommandLineEditor editor, String value) {
|
||||
return !editor.getText().equals(value);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.compiler.options.CompilerUIConfigurable">
|
||||
<grid id="1663f" binding="myPanel" layout-manager="GridLayoutManager" row-count="13" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="1663f" binding="myPanel" layout-manager="GridLayoutManager" row-count="14" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="28" y="24" width="1417" height="706"/>
|
||||
@@ -72,32 +72,6 @@
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="settings.build.project.automatically"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="17126" class="javax.swing.JLabel" binding="mySharedHeapSizeLabel">
|
||||
<constraints>
|
||||
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="a28b8"/>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="settings.build.process.heap.size"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a28b8" class="javax.swing.JTextField" binding="mySharedHeapSizeField">
|
||||
<constraints>
|
||||
<grid row="8" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<columns value="5"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5b86a" class="javax.swing.JLabel" binding="myVMOptionsLabel">
|
||||
<constraints>
|
||||
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="b5547"/>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="settings.user.local.build.process.vm.options"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="ba694" class="javax.swing.JCheckBox" binding="myCbParallelCompilation">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
@@ -138,31 +112,6 @@
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="label.option.display.notification.popup"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b5547" class="javax.swing.JTextField" binding="myVMOptionsField">
|
||||
<constraints>
|
||||
<grid row="10" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="7261c" class="javax.swing.JTextField" binding="mySharedVMOptionsField">
|
||||
<constraints>
|
||||
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="8c035" class="javax.swing.JLabel" binding="mySharedVMOptionsLabel">
|
||||
<constraints>
|
||||
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="7261c"/>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="settings.shared.build.process.vm.options"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="6ee49" binding="myAssertNotNullPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
@@ -196,7 +145,7 @@
|
||||
</grid>
|
||||
<component id="5c3dc" class="javax.swing.JLabel" binding="myWarningLabel">
|
||||
<constraints>
|
||||
<grid row="12" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="13" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value=""/>
|
||||
@@ -204,9 +153,76 @@
|
||||
</component>
|
||||
<vspacer id="60b1c">
|
||||
<constraints>
|
||||
<grid row="11" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="12" column="2" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="17126" class="javax.swing.JLabel" binding="mySharedHeapSizeLabel">
|
||||
<constraints>
|
||||
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="a28b8"/>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="settings.build.process.heap.size"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="a28b8" class="javax.swing.JTextField" binding="mySharedHeapSizeField">
|
||||
<constraints>
|
||||
<grid row="8" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<columns value="5"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="8c035" class="javax.swing.JLabel" binding="mySharedVMOptionsLabel">
|
||||
<constraints>
|
||||
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="7261c"/>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="settings.shared.build.process.vm.options"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7261c" class="javax.swing.JTextField" binding="mySharedVMOptionsField">
|
||||
<constraints>
|
||||
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="cfc41" class="javax.swing.JLabel" binding="myHeapSizeLabel">
|
||||
<constraints>
|
||||
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="settings.user.local.build.process.heap.size"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="618d6" class="javax.swing.JTextField" binding="myHeapSizeField">
|
||||
<constraints>
|
||||
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<columns value="5"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5b86a" class="javax.swing.JLabel" binding="myVMOptionsLabel">
|
||||
<constraints>
|
||||
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="b5547"/>
|
||||
<text resource-bundle="messages/JavaCompilerBundle" key="settings.user.local.build.process.vm.options"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b5547" class="javax.swing.JTextField" binding="myVMOptionsField">
|
||||
<constraints>
|
||||
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -58,9 +58,11 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
private JCheckBox myCbParallelCompilation;
|
||||
private JTextField mySharedHeapSizeField;
|
||||
private JTextField mySharedVMOptionsField;
|
||||
private JTextField myHeapSizeField;
|
||||
private JTextField myVMOptionsField;
|
||||
private JLabel mySharedHeapSizeLabel;
|
||||
private JLabel mySharedVMOptionsLabel;
|
||||
private JLabel myHeapSizeLabel;
|
||||
private JLabel myVMOptionsLabel;
|
||||
private JCheckBox myCbRebuildOnDependencyChange;
|
||||
private JLabel myResourcePatternsLabel;
|
||||
@@ -81,14 +83,19 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
|
||||
myPatternLegendLabel.setForeground(new JBColor(Gray._50, Gray._130));
|
||||
tweakControls(project);
|
||||
myVMOptionsField.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
DocumentAdapter updateStateListener = new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(@NotNull DocumentEvent e) {
|
||||
mySharedVMOptionsField.setEnabled(e.getDocument().getLength() == 0);
|
||||
mySharedHeapSizeField.setEnabled(ContainerUtil.find(ParametersListUtil.parse(myVMOptionsField.getText()),
|
||||
s -> StringUtil.startsWithIgnoreCase(s, "-Xmx")) == null);
|
||||
mySharedVMOptionsField.setEnabled(myVMOptionsField.getDocument().getLength() == 0);
|
||||
mySharedHeapSizeField.setEnabled(
|
||||
myHeapSizeField.getDocument().getLength() == 0 &&
|
||||
ContainerUtil.find(ParametersListUtil.parse(myVMOptionsField.getText()),
|
||||
s -> StringUtil.startsWithIgnoreCase(s, "-Xmx")) == null
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
||||
myVMOptionsField.getDocument().addDocumentListener(updateStateListener);
|
||||
myHeapSizeField.getDocument().addDocumentListener(updateStateListener);
|
||||
myConfigureAnnotations.addActionListener(e -> {
|
||||
NullableNotNullDialog.showDialogWithInstrumentationOptions(myPanel);
|
||||
myCbAssertNotNull.setSelected(!NullableNotNullManager.getInstance(myProject).getInstrumentedNotNulls().isEmpty());
|
||||
@@ -130,7 +137,7 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
controls.put(Setting.AUTO_MAKE, ContainerUtil.newArrayList(myCbEnableAutomake, myEnableAutomakeLegendLabel));
|
||||
controls.put(Setting.PARALLEL_COMPILATION, ContainerUtil.newArrayList(myCbParallelCompilation, myParallelCompilationLegendLabel));
|
||||
controls.put(Setting.REBUILD_MODULE_ON_DEPENDENCY_CHANGE, ContainerUtil.newArrayList(myCbRebuildOnDependencyChange));
|
||||
controls.put(Setting.HEAP_SIZE, ContainerUtil.newArrayList(mySharedHeapSizeLabel, mySharedHeapSizeField));
|
||||
controls.put(Setting.HEAP_SIZE, ContainerUtil.newArrayList(myHeapSizeLabel, myHeapSizeField, mySharedHeapSizeLabel, mySharedHeapSizeField));
|
||||
controls.put(Setting.COMPILER_VM_OPTIONS, ContainerUtil.newArrayList(myVMOptionsLabel, myVMOptionsField, mySharedVMOptionsLabel, mySharedVMOptionsField));
|
||||
|
||||
for (Setting setting : myDisabledSettings) {
|
||||
@@ -155,6 +162,8 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
myCbEnableAutomake.setSelected(workspaceConfiguration.MAKE_PROJECT_ON_SAVE);
|
||||
myCbParallelCompilation.setSelected(workspaceConfiguration.PARALLEL_COMPILATION);
|
||||
myCbRebuildOnDependencyChange.setSelected(workspaceConfiguration.REBUILD_ON_DEPENDENCY_CHANGE);
|
||||
int heapSize = workspaceConfiguration.COMPILER_PROCESS_HEAP_SIZE;
|
||||
myHeapSizeField.setText(heapSize > 0 ? String.valueOf(heapSize) : "");
|
||||
final int javacPreferred = JavacConfiguration.getOptions(myProject, JavacConfiguration.class).MAXIMUM_HEAP_SIZE; // for compatibility with older projects
|
||||
mySharedHeapSizeField.setText(String.valueOf(configuration.getBuildProcessHeapSize(javacPreferred)));
|
||||
final String options = workspaceConfiguration.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS;
|
||||
@@ -212,6 +221,8 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
}
|
||||
if (!myDisabledSettings.contains(Setting.HEAP_SIZE)) {
|
||||
try {
|
||||
String heapSizeText = myHeapSizeField.getText().trim();
|
||||
workspaceConfiguration.COMPILER_PROCESS_HEAP_SIZE = heapSizeText.isEmpty() ? 0 : Integer.parseInt(heapSizeText);
|
||||
configuration.setBuildProcessHeapSize(Integer.parseInt(mySharedHeapSizeField.getText().trim()));
|
||||
}
|
||||
catch (NumberFormatException ignored) {
|
||||
@@ -281,6 +292,8 @@ public class CompilerUIConfigurable implements SearchableConfigurable, Configura
|
||||
&& ComparingUtils.isModified(myCbParallelCompilation, workspaceConfiguration.PARALLEL_COMPILATION);
|
||||
isModified |= !myDisabledSettings.contains(Setting.REBUILD_MODULE_ON_DEPENDENCY_CHANGE)
|
||||
&& ComparingUtils.isModified(myCbRebuildOnDependencyChange, workspaceConfiguration.REBUILD_ON_DEPENDENCY_CHANGE);
|
||||
isModified |= !myDisabledSettings.contains(Setting.HEAP_SIZE)
|
||||
&& ComparingUtils.isModified(myHeapSizeField, 0, workspaceConfiguration.COMPILER_PROCESS_HEAP_SIZE);
|
||||
isModified |= !myDisabledSettings.contains(Setting.COMPILER_VM_OPTIONS)
|
||||
&& ComparingUtils.isModified(myVMOptionsField, workspaceConfiguration.COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS);
|
||||
|
||||
|
||||
@@ -1100,7 +1100,11 @@ public final class BuildManager implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
if (userDefinedHeapSize != null) {
|
||||
final int localHeapSize = config.COMPILER_PROCESS_HEAP_SIZE;
|
||||
if (localHeapSize > 0) {
|
||||
cmdLine.addParameter("-Xmx" + localHeapSize + "m");
|
||||
}
|
||||
else if (userDefinedHeapSize != null) {
|
||||
cmdLine.addParameter(userDefinedHeapSize);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -125,7 +125,8 @@ settings.configure.annotations=&Configure annotations...
|
||||
settings.build.project.automatically=Build project automatically
|
||||
settings.compile.independent.modules.in.parallel=Compile independent modules in parallel
|
||||
settings.rebuild.module.on.dependency.change=Rebuild module on dependency change
|
||||
settings.build.process.heap.size=Build process heap size (Mbytes):
|
||||
settings.build.process.heap.size=Shared build process heap size (Mbytes):
|
||||
settings.user.local.build.process.heap.size=User-local build process heap size (Mbytes) (overrides Shared size):
|
||||
settings.shared.build.process.vm.options=Shared build process VM options:
|
||||
settings.user.local.build.process.vm.options=User-local build process VM options (overrides Shared options):
|
||||
settings.auto.build.only.works.while.not.running=(only works while not running / debugging)
|
||||
|
||||
@@ -28,6 +28,7 @@ public class CompilerWorkspaceConfiguration implements PersistentStateComponent<
|
||||
public boolean CLEAR_OUTPUT_DIRECTORY = true;
|
||||
public boolean MAKE_PROJECT_ON_SAVE = false; // until we fix problems with several open projects (IDEA-104064), daemon slowness (IDEA-104666)
|
||||
public boolean PARALLEL_COMPILATION = false;
|
||||
public int COMPILER_PROCESS_HEAP_SIZE = 0;
|
||||
public String COMPILER_PROCESS_ADDITIONAL_VM_OPTIONS = "";
|
||||
public boolean REBUILD_ON_DEPENDENCY_CHANGE = true;
|
||||
public boolean COMPILE_AFFECTED_UNLOADED_MODULES_BEFORE_COMMIT = true;
|
||||
|
||||
Reference in New Issue
Block a user