Skip to content

Commit

Permalink
add option to disable forcing the default compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
LabyStudio committed Dec 27, 2022
1 parent 20584b3 commit 9d3c54c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
Expand Up @@ -127,7 +127,8 @@ public void actionPerformed(@NotNull AnActionEvent event) {
progress.setTitle("Initialize hotswap task...");

// Create compiler and progress
boolean forceDefault = event.getInputEvent().isShiftDown();
boolean forceDefault = event.getInputEvent().isShiftDown()
&& this.configuration.isForceDefaultCompilerShift();
AbstractCompiler compiler = context.compiler(this.configuration, forceDefault);
ClassFile outputFile = context.getClassFile(psiFile);
VirtualFile sourceFile = psiFile.getVirtualFile();
Expand Down
Expand Up @@ -14,6 +14,7 @@ public class SingleHotswapConfiguration implements PersistentStateComponent<Sing

private boolean useBuiltInCompiler = true;
private boolean showCompileDuration = true;
private boolean forceDefaultCompilerShift = false;

@Override
public @Nullable SingleHotswapConfiguration getState() {
Expand All @@ -31,12 +32,13 @@ public boolean equals(Object o) {
if (o == null || this.getClass() != o.getClass()) return false;
SingleHotswapConfiguration that = (SingleHotswapConfiguration) o;
return this.useBuiltInCompiler == that.useBuiltInCompiler
&& this.showCompileDuration == that.showCompileDuration;
&& this.showCompileDuration == that.showCompileDuration
&& this.forceDefaultCompilerShift == that.forceDefaultCompilerShift;
}

@Override
public int hashCode() {
return Objects.hash(this.useBuiltInCompiler, this.showCompileDuration);
return Objects.hash(this.useBuiltInCompiler, this.showCompileDuration, this.forceDefaultCompilerShift);
}

public boolean isUseBuiltInCompiler() {
Expand All @@ -54,4 +56,12 @@ public boolean isShowCompileDuration() {
public void setShowCompileDuration(boolean showCompileDuration) {
this.showCompileDuration = showCompileDuration;
}

public boolean isForceDefaultCompilerShift() {
return this.forceDefaultCompilerShift;
}

public void setForceDefaultCompilerShift(boolean forceDefaultCompilerShift) {
this.forceDefaultCompilerShift = forceDefaultCompilerShift;
}
}
Expand Up @@ -24,6 +24,7 @@ public class SingleHotswapConfigurationGui implements SearchableConfigurable, Co

private JCheckBox checkBoxUseBuiltInCompiler;
private JCheckBox checkBoxShowCompileDuration;
private JCheckBox checkBoxForceDefaultCompilerShift;

public SingleHotswapConfigurationGui() {
this.state = ServiceManager.getService(SingleHotswapConfiguration.class);
Expand All @@ -50,8 +51,12 @@ public String getDisplayName() {
this.checkBoxShowCompileDuration = new JCheckBox("Show Compile Duration");
this.checkBoxShowCompileDuration.setToolTipText("Shows the duration of the compilation time in the status bar.");

this.checkBoxForceDefaultCompilerShift = new JCheckBox("Force Default Compiler When Holding Shift");
this.checkBoxForceDefaultCompilerShift.setToolTipText("Forces the default compiler when holding the shift key while pressing the hotswap button.");

panel.add(this.checkBoxUseBuiltInCompiler, new GridBagConstraints(0, RELATIVE, 1, 1, 1.0, 0.0, NORTHWEST, NONE, JBUI.emptyInsets(), 0, 0));
panel.add(this.checkBoxShowCompileDuration, new GridBagConstraints(0, RELATIVE, 1, 1, 1.0, 0.0, NORTHWEST, NONE, JBUI.insetsTop(4), 0, 0));
panel.add(this.checkBoxForceDefaultCompilerShift, new GridBagConstraints(0, RELATIVE, 1, 1, 1.0, 0.0, NORTHWEST, NONE, JBUI.insetsTop(4), 0, 0));
container.add(panel);

return container;
Expand All @@ -60,18 +65,21 @@ public String getDisplayName() {
@Override
public boolean isModified() {
return this.state.isUseBuiltInCompiler() != this.checkBoxUseBuiltInCompiler.isSelected()
|| this.state.isShowCompileDuration() != this.checkBoxShowCompileDuration.isSelected();
|| this.state.isShowCompileDuration() != this.checkBoxShowCompileDuration.isSelected()
|| this.state.isForceDefaultCompilerShift() != this.checkBoxForceDefaultCompilerShift.isSelected();
}

@Override
public void apply() {
this.state.setUseBuiltInCompiler(this.checkBoxUseBuiltInCompiler.isSelected());
this.state.setShowCompileDuration(this.checkBoxShowCompileDuration.isSelected());
this.state.setForceDefaultCompilerShift(this.checkBoxForceDefaultCompilerShift.isSelected());
}

@Override
public void reset() {
this.checkBoxUseBuiltInCompiler.setSelected(this.state.isUseBuiltInCompiler());
this.checkBoxShowCompileDuration.setSelected(this.state.isShowCompileDuration());
this.checkBoxForceDefaultCompilerShift.setSelected(this.state.isForceDefaultCompilerShift());
}
}
6 changes: 5 additions & 1 deletion src/main/resources/META-INF/plugin.xml
@@ -1,7 +1,7 @@
<idea-plugin>
<id>net.labymod.intellij.singlehotswap</id>
<name>Single Hotswap</name>
<version>2.2</version>
<version>2.3</version>
<vendor email="labystudio@gmail.com" url="https://www.labymod.net">LabyMedia</vendor>

<idea-version since-build="203.000"/>
Expand Down Expand Up @@ -53,6 +53,10 @@

<change-notes>
<![CDATA[
v2.3 (27.12.2022):
<ul>
<li>Added option to disable forcing the default compiler</li>
</ul>
v2.2 (15.12.2022):
<ul>
<li>Added hotswap button to new UI</li>
Expand Down

0 comments on commit 9d3c54c

Please sign in to comment.