Skip to content

Commit b90ff9c

Browse files
Completely disable formatter settings that are not fully supported
1 parent d269a90 commit b90ff9c

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

src/main/java/io/protostuff/jetbrains/plugin/formatter/FormattingModelBuilder.java

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,35 @@
1010
import io.protostuff.jetbrains.plugin.ProtoLanguage;
1111
import org.jetbrains.annotations.NotNull;
1212
import org.jetbrains.annotations.Nullable;
13+
1314
import static io.protostuff.jetbrains.plugin.formatter.StatementBlock.*;
15+
1416
/**
1517
* @author Kostiantyn Shchepanovskyi
1618
*/
1719
public class FormattingModelBuilder implements com.intellij.formatting.FormattingModelBuilder {
1820

21+
public static SpacingBuilder createSpacingBuilder(CodeStyleSettings settings) {
22+
CommonCodeStyleSettings protoSettings = settings.getCommonSettings(ProtoLanguage.INSTANCE);
23+
SpacingBuilder builder = new SpacingBuilder(settings, ProtoLanguage.INSTANCE);
24+
builder.around(ASSIGN).spacing(1, 1, 0, false, 0);
25+
builder.before(SEMICOLON).spacing(0, 0, 0, false, 0);
26+
builder.after(LINE_COMMENT).spacing(0, 0, 1, true, 2);
27+
builder.after(LCURLY).spacing(0, 0, 1, true, 2);
28+
builder.before(RCURLY).spacing(0, 0, 1, true, 2);
29+
builder.after(LPAREN).spacing(0, 0, 0, false, 0);
30+
builder.before(RPAREN).spacing(0, 0, 0, false, 0);
31+
builder.after(LSQUARE).spacing(0, 0, 0, false, 0);
32+
builder.before(RSQUARE).spacing(0, 0, 0, false, 0);
33+
builder.before(LT).spacing(0, 0, 0, false, 0);
34+
builder.after(LT).spacing(0, 0, 0, false, 0);
35+
builder.before(GT).spacing(0, 0, 0, false, 0);
36+
builder.before(COMMA).spacing(0, 0, 0, false, 0);
37+
builder.before(SEMICOLON).spacing(0, 0, 0, false, 0);
38+
builder.after(COMMA).spacing(1, 1, 0, false, 0);
39+
return builder;
40+
}
41+
1942
@NotNull
2043
@Override
2144
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
@@ -32,25 +55,4 @@ public FormattingModel createModel(PsiElement element, CodeStyleSettings setting
3255
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
3356
return null;
3457
}
35-
36-
public static SpacingBuilder createSpacingBuilder(CodeStyleSettings settings) {
37-
CommonCodeStyleSettings protoSettings = settings.getCommonSettings(ProtoLanguage.INSTANCE);
38-
return new SpacingBuilder(settings, ProtoLanguage.INSTANCE)
39-
.around(ASSIGN).spaceIf(protoSettings.SPACE_AROUND_ASSIGNMENT_OPERATORS)
40-
.before(SEMICOLON).spaceIf(protoSettings.SPACE_BEFORE_SEMICOLON)
41-
.after(LINE_COMMENT).spacing(0, 0, 1, true, 2)
42-
.after(LCURLY).spacing(0, 0, 1, true, 2)
43-
.before(RCURLY).spacing(0, 0, 1, true, 2)
44-
.after(LPAREN).spacing(0, 0, 0, false, 0)
45-
.before(RPAREN).spacing(0, 0, 0, false, 0)
46-
.after(LSQUARE).spacing(0, 0, 0, false, 0)
47-
.before(RSQUARE).spacing(0, 0, 0, false, 0)
48-
.before(LT).spacing(0, 0, 0, false, 0)
49-
.after(LT).spacing(0, 0, 0, false, 0)
50-
.before(GT).spacing(0, 0, 0, false, 0)
51-
.before(COMMA).spacing(0, 0, 0, false, 0)
52-
.before(SEMICOLON).spacing(0, 0, 0, false, 0)
53-
.after(COMMA).spacing(1, 1, 0, false, 0);
54-
55-
}
5658
}

src/main/java/io/protostuff/jetbrains/plugin/formatter/ProtoLanguageCodeStyleSettingsProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @
3434
// consumer.renameStandardOption("SPACE_AROUND_ASSIGNMENT_OPERATORS", "Space around assignment operator");
3535
// break;
3636
// case WRAPPING_AND_BRACES_SETTINGS:
37+
// consumer.showStandardOptions("KEEP_LINE_BREAKS");
3738
// consumer.showStandardOptions("BRACE_STYLE");
3839
// break;
3940
// case BLANK_LINES_SETTINGS:
@@ -60,6 +61,8 @@ public CommonCodeStyleSettings getDefaultCommonSettings() {
6061
settings.SPACE_AROUND_ASSIGNMENT_OPERATORS = true;
6162
settings.SPACE_BEFORE_SEMICOLON = false;
6263
settings.BRACE_STYLE = END_OF_LINE;
64+
settings.KEEP_BLANK_LINES_IN_CODE = 2;
65+
settings.KEEP_LINE_BREAKS = false;
6366
return settings;
6467
}
6568

src/test/java/io/protostuff/jetbrains/plugin/formatter/FormatterTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ public void testCustomIndent() {
5353
});
5454
}
5555

56-
public void testDisableSpaceAroundAssignmentOperator() {
57-
run("disable_space_around_assignment_operator", settings -> {
58-
settings.SPACE_AROUND_ASSIGNMENT_OPERATORS = false;
59-
});
60-
}
56+
// public void testDisableSpaceAroundAssignmentOperator() {
57+
// run("disable_space_around_assignment_operator", settings -> {
58+
// settings.SPACE_AROUND_ASSIGNMENT_OPERATORS = false;
59+
// });
60+
// }
6161

6262
}

0 commit comments

Comments
 (0)