backport: 15.2.0
This commit is contained in:
parent
882570b48c
commit
ffc47dc1b2
5 changed files with 40 additions and 5 deletions
|
@ -17,6 +17,13 @@ Changelog structure reference:
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [15.2.0]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Project
|
||||||
|
- Modifying the standard library path now also applies to ZLS
|
||||||
|
|
||||||
## [15.1.1]
|
## [15.1.1]
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -32,11 +32,15 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||||
import com.intellij.openapi.util.Disposer;
|
import com.intellij.openapi.util.Disposer;
|
||||||
import com.intellij.openapi.util.Pair;
|
import com.intellij.openapi.util.Pair;
|
||||||
import com.intellij.ui.JBColor;
|
import com.intellij.ui.JBColor;
|
||||||
|
import com.intellij.ui.components.JBCheckBox;
|
||||||
|
import com.intellij.ui.components.JBLabel;
|
||||||
import com.intellij.ui.dsl.builder.AlignX;
|
import com.intellij.ui.dsl.builder.AlignX;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -55,10 +59,23 @@ public class ZigProjectSettingsPanel implements MyDisposable {
|
||||||
|
|
||||||
private final JLabel toolchainVersion = new JLabel();
|
private final JLabel toolchainVersion = new JLabel();
|
||||||
|
|
||||||
|
private final JBCheckBox stdFieldOverride = new JBCheckBox("Override");
|
||||||
|
|
||||||
private final TextFieldWithBrowseButton pathToStdField = TextFieldUtil.pathToDirectoryTextField(this,
|
private final TextFieldWithBrowseButton pathToStdField = TextFieldUtil.pathToDirectoryTextField(this,
|
||||||
"Path to Standard Library",
|
"Path to Standard Library",
|
||||||
() -> {});
|
() -> {});
|
||||||
|
|
||||||
|
{
|
||||||
|
stdFieldOverride.addChangeListener(e -> {
|
||||||
|
if (stdFieldOverride.isSelected()) {
|
||||||
|
pathToStdField.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
pathToStdField.setEnabled(false);
|
||||||
|
updateUI();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void autodetect(ActionEvent e) {
|
private void autodetect(ActionEvent e) {
|
||||||
autodetect();
|
autodetect();
|
||||||
}
|
}
|
||||||
|
@ -83,8 +100,12 @@ public class ZigProjectSettingsPanel implements MyDisposable {
|
||||||
pathToToolchain.setText(Optional.ofNullable(value.getToolchainHomeDirectory())
|
pathToToolchain.setText(Optional.ofNullable(value.getToolchainHomeDirectory())
|
||||||
.orElse(""));
|
.orElse(""));
|
||||||
|
|
||||||
|
stdFieldOverride.setSelected(value.overrideStdPath);
|
||||||
|
|
||||||
pathToStdField.setText(Optional.ofNullable(value.getExplicitPathToStd()).orElse(""));
|
pathToStdField.setText(Optional.ofNullable(value.getExplicitPathToStd()).orElse(""));
|
||||||
|
|
||||||
|
pathToStdField.setEnabled(value.overrideStdPath);
|
||||||
|
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +119,11 @@ public class ZigProjectSettingsPanel implements MyDisposable {
|
||||||
r.button("Autodetect", $f(this::autodetect));
|
r.button("Autodetect", $f(this::autodetect));
|
||||||
});
|
});
|
||||||
p2.cell("Toolchain version", toolchainVersion);
|
p2.cell("Toolchain version", toolchainVersion);
|
||||||
p2.cell("Standard library location", pathToStdField, AlignX.FILL);
|
p2.cell("Override standard library path", stdFieldOverride);
|
||||||
|
p2.row("Standard library location", row -> {
|
||||||
|
row.cell(pathToStdField).resizableColumn().align(AlignX.FILL);
|
||||||
|
row.cell(stdFieldOverride);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +151,7 @@ public class ZigProjectSettingsPanel implements MyDisposable {
|
||||||
toolchainVersion.setText(StringUtil.orEmpty(zigVersion));
|
toolchainVersion.setText(StringUtil.orEmpty(zigVersion));
|
||||||
toolchainVersion.setForeground(JBColor.foreground());
|
toolchainVersion.setForeground(JBColor.foreground());
|
||||||
|
|
||||||
|
if (!stdFieldOverride.isSelected())
|
||||||
pathToStdField.setText(StringUtil.orEmpty(stdPath));
|
pathToStdField.setText(StringUtil.orEmpty(stdPath));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,12 @@ import java.nio.file.Path;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class ZigProjectSettings {
|
public class ZigProjectSettings {
|
||||||
|
public boolean overrideStdPath;
|
||||||
public String explicitPathToStd;
|
public String explicitPathToStd;
|
||||||
public String toolchainHomeDirectory;
|
public String toolchainHomeDirectory;
|
||||||
|
|
||||||
public ZigProjectSettings(String explicitPathToStd, AbstractZigToolchain toolchain) {
|
public ZigProjectSettings(String explicitPathToStd, AbstractZigToolchain toolchain) {
|
||||||
this(explicitPathToStd, (String)null);
|
this(true, explicitPathToStd, (String)null);
|
||||||
setToolchain(toolchain);
|
setToolchain(toolchain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ public final class ZigProjectSettingsService extends AbstractZigProjectSettingsS
|
||||||
public boolean isModified(ZigProjectSettings otherData) {
|
public boolean isModified(ZigProjectSettings otherData) {
|
||||||
val myData = getState();
|
val myData = getState();
|
||||||
return !Objects.equals(myData.toolchainHomeDirectory, otherData.toolchainHomeDirectory) ||
|
return !Objects.equals(myData.toolchainHomeDirectory, otherData.toolchainHomeDirectory) ||
|
||||||
!Objects.equals(myData.explicitPathToStd, otherData.explicitPathToStd);
|
!Objects.equals(myData.explicitPathToStd, otherData.explicitPathToStd) ||
|
||||||
|
!Objects.equals(myData.overrideStdPath, otherData.overrideStdPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,6 @@ public class ToolchainZLSConfigProvider implements ZLSConfigProvider {
|
||||||
return;
|
return;
|
||||||
val projectDir = ProjectUtil.guessProjectDir(project);
|
val projectDir = ProjectUtil.guessProjectDir(project);
|
||||||
val env = toolchain.zig().getEnv(projectDir == null ? Path.of(".") : projectDir.toNioPath());
|
val env = toolchain.zig().getEnv(projectDir == null ? Path.of(".") : projectDir.toNioPath());
|
||||||
env.ifPresent(e -> builder.zig_exe_path(e.zigExecutable()).zig_lib_path(e.libDirectory()));
|
env.ifPresent(e -> builder.zig_exe_path(e.zigExecutable()).zig_lib_path(state.overrideStdPath ? Path.of(state.explicitPathToStd).getParent().toString() : e.libDirectory()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue