mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
revert adding option for dot placement in java formatter
This commit is contained in:
@@ -201,11 +201,6 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett
|
||||
|
||||
String groupName = ApplicationBundle.message("wrapping.fields.annotation");
|
||||
consumer.showCustomOption(JavaCodeStyleSettings.class, "DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION", "Do not wrap after single annotation", groupName);
|
||||
|
||||
consumer.showCustomOption(JavaCodeStyleSettings.class,
|
||||
"PLACE_DOT_ON_NEXT_LINE",
|
||||
ApplicationBundle.message("checkbox.place.dot.on.next.line"),
|
||||
CodeStyleSettingsCustomizable.WRAPPING_CALL_CHAIN);
|
||||
}
|
||||
else if (settingsType == SettingsType.BLANK_LINES_SETTINGS) {
|
||||
consumer.showAllStandardOptions();
|
||||
|
||||
@@ -100,8 +100,6 @@ public class JavaCodeStyleSettings extends CustomCodeStyleSettings implements Im
|
||||
|
||||
public boolean SPACES_WITHIN_ANGLE_BRACKETS;
|
||||
|
||||
public boolean PLACE_DOT_ON_NEXT_LINE = true;
|
||||
|
||||
//Type arguments
|
||||
public boolean SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENT;
|
||||
|
||||
|
||||
@@ -58,31 +58,7 @@ public class CallChunkBlockBuilder {
|
||||
}
|
||||
return new SyntheticCodeBlock(subBlocks, alignment, mySettings, myJavaSettings, Indent.getContinuationIndent(myIndentSettings.USE_RELATIVE_INDENTS), wrap);
|
||||
}
|
||||
|
||||
// Support for groovy style dot placement
|
||||
if (!subNodes.isEmpty()) {
|
||||
final ASTNode lastNode = subNodes.get(subNodes.size() - 1);
|
||||
if (lastNode.getElementType() == JavaTokenType.DOT) {
|
||||
AlignmentStrategy strategy = AlignmentStrategy.getNullStrategy();
|
||||
subNodes.remove(subNodes.size() - 1);
|
||||
if (!subNodes.isEmpty()) {
|
||||
subBlocks.add(create(subNodes, wrap, null));
|
||||
}
|
||||
Block block =
|
||||
newJavaBlock(lastNode, mySettings, myJavaSettings, Indent.getNoneIndent(), Wrap.createWrap(WrapType.NONE, true), strategy,
|
||||
myFormattingMode);
|
||||
subBlocks.add(block);
|
||||
return new SyntheticCodeBlock(subBlocks, alignment, mySettings, myJavaSettings,
|
||||
Indent.getContinuationWithoutFirstIndent(myIndentSettings.USE_RELATIVE_INDENTS), wrap);
|
||||
}
|
||||
}
|
||||
List<Block> blocks = createJavaBlocks(subNodes);
|
||||
|
||||
// Last line not contains '.', but needs to be wrapped
|
||||
final Wrap finalWrap = myJavaSettings.PLACE_DOT_ON_NEXT_LINE ? null : wrap;
|
||||
return new SyntheticCodeBlock(blocks, alignment, mySettings, myJavaSettings,
|
||||
Indent.getContinuationWithoutFirstIndent(myIndentSettings.USE_RELATIVE_INDENTS),
|
||||
finalWrap);
|
||||
return new SyntheticCodeBlock(createJavaBlocks(subNodes), alignment, mySettings, myJavaSettings, Indent.getContinuationWithoutFirstIndent(myIndentSettings.USE_RELATIVE_INDENTS), null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+8
-14
@@ -82,11 +82,7 @@ class ChainMethodCallsBlockBuilder {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!myJavaSettings.PLACE_DOT_ON_NEXT_LINE) {
|
||||
wrap = Wrap.createWrap(mySettings.METHOD_CALL_CHAIN_WRAP, true);
|
||||
} else {
|
||||
wrap = null;
|
||||
}
|
||||
wrap = null;
|
||||
chainedCallsAlignment = null;
|
||||
}
|
||||
|
||||
@@ -127,26 +123,24 @@ class ChainMethodCallsBlockBuilder {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<ChainedCallChunk> splitMethodCallOnChunksByDots(@NotNull List<? extends ASTNode> nodes) {
|
||||
private static List<ChainedCallChunk> splitMethodCallOnChunksByDots(@NotNull List<? extends ASTNode> nodes) {
|
||||
List<ChainedCallChunk> result = new ArrayList<>();
|
||||
|
||||
List<ASTNode> current = new ArrayList<>();
|
||||
boolean placeDotOnNextLine = myJavaSettings.PLACE_DOT_ON_NEXT_LINE;
|
||||
for (ASTNode node : nodes) {
|
||||
if (!placeDotOnNextLine) {
|
||||
current.add(node);
|
||||
}
|
||||
if (node.getElementType() == JavaTokenType.DOT || node.getPsi() instanceof PsiComment) {
|
||||
result.add(new ChainedCallChunk(current));
|
||||
if (!current.isEmpty()) {
|
||||
result.add(new ChainedCallChunk(current));
|
||||
}
|
||||
current = new ArrayList<>();
|
||||
}
|
||||
if (placeDotOnNextLine) {
|
||||
current.add(node);
|
||||
}
|
||||
current.add(node);
|
||||
}
|
||||
|
||||
if (!current.isEmpty()) {
|
||||
result.add(new ChainedCallChunk(current));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +211,6 @@ public class JavaCodeStyleSettingsTest extends CodeStyleTestCase {
|
||||
"parentheses_expression_left_paren_wrap = false\n" +
|
||||
"parentheses_expression_right_paren_wrap = false\n" +
|
||||
"place_assignment_sign_on_next_line = false\n" +
|
||||
"place_dot_on_next_line = true\n" +
|
||||
"prefer_longer_names = true\n" +
|
||||
"prefer_parameters_wrap = false\n" +
|
||||
"repeat_synchronized = true\n" +
|
||||
|
||||
-50
@@ -935,54 +935,4 @@ public class JavaFormatterWrapTest extends AbstractJavaFormatterTest {
|
||||
"}"
|
||||
);
|
||||
}
|
||||
|
||||
public void testDotPlacement() {
|
||||
getSettings().METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS;
|
||||
getSettings().KEEP_LINE_BREAKS = false;
|
||||
getJavaSettings().PLACE_DOT_ON_NEXT_LINE = false;
|
||||
|
||||
|
||||
doTextTest(
|
||||
"public class Chains {\n" +
|
||||
" static Chains get() {return null;}\n" +
|
||||
" Chains foo() {\n" +
|
||||
" return null;\n" +
|
||||
" }\n" +
|
||||
" Chains bar() {\n" +
|
||||
" return null;\n" +
|
||||
" }\n" +
|
||||
" public static void main(String[] args) {\n" +
|
||||
" get()\n" +
|
||||
" .bar()\n" +
|
||||
" .foo()\n" +
|
||||
" .bar()\n" +
|
||||
" .bar()\n" +
|
||||
" .foo();\n" +
|
||||
" }\n" +
|
||||
"}\n",
|
||||
|
||||
"public class Chains {\n" +
|
||||
" static Chains get() {\n" +
|
||||
" return null;\n" +
|
||||
" }\n" +
|
||||
"\n " +
|
||||
" Chains foo() {\n" +
|
||||
" return null;\n" +
|
||||
" }\n" +
|
||||
"\n " +
|
||||
" Chains bar() {\n" +
|
||||
" return null;\n" +
|
||||
" }\n" +
|
||||
"\n " +
|
||||
" public static void main(String[] args) {\n" +
|
||||
" get().\n" +
|
||||
" bar().\n" +
|
||||
" foo().\n" +
|
||||
" bar().\n" +
|
||||
" bar().\n" +
|
||||
" foo();\n" +
|
||||
" }\n" +
|
||||
"}\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,7 +511,6 @@ group.javadoc.alignment=Alignment
|
||||
checkbox.enable.javadoc.formatting=Enable JavaDoc formatting
|
||||
checkbox.align.parameter.descriptions=Align parameter descriptions
|
||||
checkbox.align.thrown.exception.descriptions=Align thrown exception descriptions
|
||||
checkbox.place.dot.on.next.line=Place dot on next line
|
||||
checkbox.after.description=After description
|
||||
checkbox.after.parameter.descriptions=After parameter descriptions
|
||||
checkbox.after.return.tag=After return tag
|
||||
|
||||
Reference in New Issue
Block a user