diff --git a/src/org/jetbrains/plugins/scala/lang/formatting/settings/OtherCodeStylePanel.form b/src/org/jetbrains/plugins/scala/lang/formatting/settings/OtherCodeStylePanel.form index 8f76ab79196..f58c4466f6a 100644 --- a/src/org/jetbrains/plugins/scala/lang/formatting/settings/OtherCodeStylePanel.form +++ b/src/org/jetbrains/plugins/scala/lang/formatting/settings/OtherCodeStylePanel.form @@ -8,7 +8,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -62,6 +62,15 @@ + + + + + + + + + diff --git a/src/org/jetbrains/plugins/scala/lang/formatting/settings/OtherCodeStylePanel.java b/src/org/jetbrains/plugins/scala/lang/formatting/settings/OtherCodeStylePanel.java index 461a78ae494..8098c99bd97 100644 --- a/src/org/jetbrains/plugins/scala/lang/formatting/settings/OtherCodeStylePanel.java +++ b/src/org/jetbrains/plugins/scala/lang/formatting/settings/OtherCodeStylePanel.java @@ -6,12 +6,14 @@ import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.options.ConfigurationException; import com.intellij.psi.codeStyle.CodeStyleSettings; +import com.intellij.psi.codeStyle.CommonCodeStyleSettings; import com.intellij.uiDesigner.core.GridConstraints; import com.intellij.uiDesigner.core.GridLayoutManager; import com.intellij.uiDesigner.core.Spacer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.scala.ScalaFileType; +import org.jetbrains.plugins.scala.ScalaLanguage; import org.jetbrains.plugins.scala.highlighter.ScalaEditorHighlighter; import javax.swing.*; @@ -28,6 +30,7 @@ public class OtherCodeStylePanel extends CodeStyleAbstractPanel { private JCheckBox replaceWithUnicodeSymbolCheckBox1; private JCheckBox replaceInForGeneratorCheckBox; private JCheckBox replaceLambdaWithGreekLetter; + private JCheckBox lineCommentAtFirstColumnCheckBox; protected OtherCodeStylePanel(@NotNull CodeStyleSettings settings) { super(settings); @@ -67,16 +70,19 @@ public void apply(CodeStyleSettings settings) throws ConfigurationException { if (!isModified(settings)) return; ScalaCodeStyleSettings scalaCodeStyleSettings = settings.getCustomSettings(ScalaCodeStyleSettings.class); + CommonCodeStyleSettings commonCodeStyleSettings = settings.getCommonSettings(ScalaLanguage.Instance); scalaCodeStyleSettings.ENFORCE_FUNCTIONAL_SYNTAX_FOR_UNIT = enforceFunctionalSyntaxForCheckBox.isSelected(); scalaCodeStyleSettings.REPLACE_CASE_ARROW_WITH_UNICODE_CHAR = replaceWithUnicodeSymbolCheckBox.isSelected(); scalaCodeStyleSettings.REPLACE_MAP_ARROW_WITH_UNICODE_CHAR = replaceWithUnicodeSymbolCheckBox1.isSelected(); scalaCodeStyleSettings.REPLACE_FOR_GENERATOR_ARROW_WITH_UNICODE_CHAR = replaceInForGeneratorCheckBox.isSelected(); scalaCodeStyleSettings.REPLACE_LAMBDA_WITH_GREEK_LETTER = replaceLambdaWithGreekLetter.isSelected(); + commonCodeStyleSettings.LINE_COMMENT_AT_FIRST_COLUMN = lineCommentAtFirstColumnCheckBox.isSelected(); } @Override public boolean isModified(CodeStyleSettings settings) { ScalaCodeStyleSettings scalaCodeStyleSettings = settings.getCustomSettings(ScalaCodeStyleSettings.class); + CommonCodeStyleSettings commonCodeStyleSettings = settings.getCommonSettings(ScalaLanguage.Instance); if (scalaCodeStyleSettings.ENFORCE_FUNCTIONAL_SYNTAX_FOR_UNIT != enforceFunctionalSyntaxForCheckBox.isSelected()) return true; @@ -88,6 +94,8 @@ public boolean isModified(CodeStyleSettings settings) { return true; if (scalaCodeStyleSettings.REPLACE_LAMBDA_WITH_GREEK_LETTER != replaceLambdaWithGreekLetter.isSelected()) return true; + if (commonCodeStyleSettings.LINE_COMMENT_AT_FIRST_COLUMN != lineCommentAtFirstColumnCheckBox.isSelected()) + return true; return false; @@ -102,11 +110,13 @@ public JComponent getPanel() { @Override protected void resetImpl(CodeStyleSettings settings) { ScalaCodeStyleSettings scalaCodeStyleSettings = settings.getCustomSettings(ScalaCodeStyleSettings.class); + CommonCodeStyleSettings commonCodeStyleSettings = settings.getCommonSettings(ScalaLanguage.Instance); enforceFunctionalSyntaxForCheckBox.setSelected(scalaCodeStyleSettings.ENFORCE_FUNCTIONAL_SYNTAX_FOR_UNIT); replaceWithUnicodeSymbolCheckBox.setSelected(scalaCodeStyleSettings.REPLACE_CASE_ARROW_WITH_UNICODE_CHAR); replaceWithUnicodeSymbolCheckBox1.setSelected(scalaCodeStyleSettings.REPLACE_MAP_ARROW_WITH_UNICODE_CHAR); replaceInForGeneratorCheckBox.setSelected(scalaCodeStyleSettings.REPLACE_FOR_GENERATOR_ARROW_WITH_UNICODE_CHAR); replaceLambdaWithGreekLetter.setSelected(scalaCodeStyleSettings.REPLACE_LAMBDA_WITH_GREEK_LETTER); + lineCommentAtFirstColumnCheckBox.setSelected(commonCodeStyleSettings.LINE_COMMENT_AT_FIRST_COLUMN); } { @@ -127,13 +137,13 @@ protected void resetImpl(CodeStyleSettings settings) { final JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); contentPanel = new JPanel(); - contentPanel.setLayout(new GridLayoutManager(6, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPanel.setLayout(new GridLayoutManager(7, 1, new Insets(0, 0, 0, 0), -1, -1)); panel1.add(contentPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); enforceFunctionalSyntaxForCheckBox = new JCheckBox(); enforceFunctionalSyntaxForCheckBox.setText("Enforce procedure syntax for methods with Unit return type"); contentPanel.add(enforceFunctionalSyntaxForCheckBox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); - contentPanel.add(spacer1, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + contentPanel.add(spacer1, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); replaceWithUnicodeSymbolCheckBox = new JCheckBox(); replaceWithUnicodeSymbolCheckBox.setText("Replace '=>' with unicode symbol"); contentPanel.add(replaceWithUnicodeSymbolCheckBox, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); @@ -147,5 +157,9 @@ protected void resetImpl(CodeStyleSettings settings) { replaceLambdaWithGreekLetter.setSelected(false); replaceLambdaWithGreekLetter.setText("Kind Projector: Replace 'Lambda' with unicode symbol"); contentPanel.add(replaceLambdaWithGreekLetter, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + lineCommentAtFirstColumnCheckBox = new JCheckBox(); + lineCommentAtFirstColumnCheckBox.setSelected(false); + lineCommentAtFirstColumnCheckBox.setText("Line comment on first column"); + contentPanel.add(lineCommentAtFirstColumnCheckBox, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); } } diff --git a/src/org/jetbrains/plugins/scala/lang/formatting/settings/ScalaLanguageCodeStyleSettingsProvider.scala b/src/org/jetbrains/plugins/scala/lang/formatting/settings/ScalaLanguageCodeStyleSettingsProvider.scala index af6cf64ce57..5bd45b20d61 100644 --- a/src/org/jetbrains/plugins/scala/lang/formatting/settings/ScalaLanguageCodeStyleSettingsProvider.scala +++ b/src/org/jetbrains/plugins/scala/lang/formatting/settings/ScalaLanguageCodeStyleSettingsProvider.scala @@ -182,6 +182,7 @@ class ScalaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsPr indentOptions.INDENT_SIZE = 2 indentOptions.TAB_SIZE = 2 indentOptions.CONTINUATION_INDENT_SIZE = 2 + commonCodeStyleSettings.LINE_COMMENT_AT_FIRST_COLUMN = true commonCodeStyleSettings }