Skip to content

Commit

Permalink
Merged branch idea243.release into idea243.x
Browse files Browse the repository at this point in the history
  • Loading branch information
builduser committed Jan 14, 2025
2 parents f5b9a83 + 4223a85 commit b274635
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ import scala.collection.mutable.ArrayBuffer
trait ScopeAnnotator extends ElementAnnotator[ScalaPsiElement] {

override def annotate(element: ScalaPsiElement, typeAware: Boolean)
(implicit holder: ScalaAnnotationHolder): Unit =
annotateScope(element)
(implicit holder: ScalaAnnotationHolder): Unit = {
if (typeAware) {
annotateScope(element)
}
}

//Do not process class parameters, template body and early definitions separately
//process them in a single pass for the whole template definition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<text resource-bundle="messages/ScalaBundle" key="additional.compiler.options"/>
</properties>
</component>
<component id="6935" class="com.intellij.ui.RawCommandLineEditor" binding="myAdditionalCompilerOptions">
<component id="6935" class="com.intellij.ui.RawCommandLineEditor" binding="myAdditionalCompilerOptions" custom-create="true">
<constraints>
<grid row="12" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="8" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="250" height="-1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.RawCommandLineEditor;
import com.intellij.ui.TitledSeparator;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.util.Function;
import org.intellij.lang.annotations.Language;
import org.jetbrains.plugins.scala.ScalaBundle;
import org.jetbrains.plugins.scala.compiler.data.CompileOrder;
import org.jetbrains.plugins.scala.compiler.data.DebuggingInfoLevel;
Expand All @@ -19,6 +20,8 @@
import javax.swing.*;
import java.awt.*;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import java.util.ResourceBundle;

@SuppressWarnings({"unchecked", "deprecation"})
Expand Down Expand Up @@ -53,6 +56,7 @@ public class ScalaCompilerSettingsPanel {
private final MyPathEditor myPluginsEditor = new MyPathEditor(new FileChooserDescriptor(true, false, true, true, false, true));

public ScalaCompilerSettingsPanel() {
$$$setupUI$$$();
myCompileOrder.setRenderer(SimpleMappingListCellRenderer.create(
Pair.create(CompileOrder.Mixed, ScalaBundle.message("compile.order.mixed")),
Pair.create(CompileOrder.JavaThenScala, ScalaBundle.message("compile.order.java.then.scala")),
Expand Down Expand Up @@ -96,7 +100,7 @@ public ScalaCompilerSettingsState getState() {
state.continuations = myContinuations.isSelected();
state.debuggingInfoLevel = (DebuggingInfoLevel) myDebuggingInfoLevel.getSelectedItem();
String options = myAdditionalCompilerOptions.getText().trim();
state.additionalCompilerOptions = options.isEmpty() ? new String[0] : options.split("\\s+");
state.additionalCompilerOptions = options.isEmpty() ? new String[0] : lineSplitter.apply(options).toArray(String[]::new);
state.plugins = urlsToPaths(myPluginsEditor.getPaths());

state.nameHashing = myNameHashing;
Expand Down Expand Up @@ -137,7 +141,7 @@ public void setState(ScalaCompilerSettingsState state) {
mySpecialization.setSelected(state.specialization);
myContinuations.setSelected(state.continuations);
myDebuggingInfoLevel.setSelectedItem(state.debuggingInfoLevel);
myAdditionalCompilerOptions.setText(StringUtil.join(state.additionalCompilerOptions, " "));
myAdditionalCompilerOptions.setText(lineJoiner.apply(Arrays.asList(state.additionalCompilerOptions)));
myPluginsEditor.setPaths(pathsToUrls(state.plugins));

myNameHashing = state.nameHashing;
Expand Down Expand Up @@ -168,13 +172,6 @@ public void setProfile(ScalaCompilerSettingsProfile profile) {
setState(profile.getSettings().toState());
}

{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}

/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
Expand All @@ -183,6 +180,7 @@ public void setProfile(ScalaCompilerSettingsProfile profile) {
* @noinspection ALL
*/
private void $$$setupUI$$$() {
createUIComponents();
myContentPanel = new JPanel();
myContentPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1));
myPluginsPanel = new JPanel();
Expand All @@ -194,7 +192,6 @@ public void setProfile(ScalaCompilerSettingsProfile profile) {
final JLabel label1 = new JLabel();
this.$$$loadLabelText$$$(label1, this.$$$getMessageFromBundle$$$("messages/ScalaBundle", "additional.compiler.options"));
panel1.add(label1, new GridConstraints(12, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
myAdditionalCompilerOptions = new RawCommandLineEditor();
myAdditionalCompilerOptions.setDialogCaption("");
panel1.add(myAdditionalCompilerOptions, new GridConstraints(12, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, new Dimension(250, -1), null, null, 0, false));
final JLabel label2 = new JLabel();
Expand Down Expand Up @@ -356,4 +353,24 @@ public void setProfile(ScalaCompilerSettingsProfile profile) {
return myContentPanel;
}

private void createUIComponents() {
myAdditionalCompilerOptions = new RawCommandLineEditor(lineSplitter, lineJoiner);
}

// A space (' ') followed by two backslashes ('\') followed by a space.
// This separator is used to join all options on a single line when the editor is collapsed to a single line.
// It's not shown when the whole list of options is expanded.
// The separator was chosen such that it probably won't show up in any settings and cause them to be split when
// they shouldn't.
private static final String joinSeparator = " \\\\ ";

// Same as the `joinSeparator` above, but in regex form, with extra escape characters.
@Language("RegExp")
private static final String splitRegex = " \\\\\\\\ ";

private static final Function<String, List<String>> lineSplitter =
string -> Arrays.asList(string.split(splitRegex));

private static final Function<List<String>, String> lineJoiner =
strings -> String.join(joinSeparator, strings);
}

0 comments on commit b274635

Please sign in to comment.