本文整理汇总了Java中com.intellij.psi.codeStyle.CommonCodeStyleSettings.END_OF_LINE属性的典型用法代码示例。如果您正苦于以下问题:Java CommonCodeStyleSettings.END_OF_LINE属性的具体用法?Java CommonCodeStyleSettings.END_OF_LINE怎么用?Java CommonCodeStyleSettings.END_OF_LINE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.psi.codeStyle.CommonCodeStyleSettings
的用法示例。
在下文中一共展示了CommonCodeStyleSettings.END_OF_LINE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSpaceBeforeMethodLBrace
@NotNull
private Spacing getSpaceBeforeMethodLBrace(@NotNull PsiMethod method) {
final int space = mySettings.SPACE_BEFORE_METHOD_LBRACE ? 1 : 0;
final int methodBraceStyle = mySettings.METHOD_BRACE_STYLE;
if (methodBraceStyle == CommonCodeStyleSettings.END_OF_LINE) {
return createNonLFSpace(space, null, false);
}
else if (methodBraceStyle == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) {
TextRange headerRange = new TextRange(getMethodHeaderStartOffset(method), getMethodHeaderEndOffset(method));
return createNonLFSpace(space, headerRange, false);
}
else if (shouldHandleAsSimpleMethod(method)) {
TextRange rangeWithoutAnnotations = new TextRange(getMethodHeaderStartOffset(method), method.getTextRange().getEndOffset());
return createNonLFSpace(space, rangeWithoutAnnotations, false);
}
return Spacing.createSpacing(space, space, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
示例2: getSpaceBeforeClassLBrace
@NotNull
private Spacing getSpaceBeforeClassLBrace(@NotNull PsiClass aClass) {
final int space = mySettings.SPACE_BEFORE_CLASS_LBRACE ? 1 : 0;
final int classBraceStyle = mySettings.CLASS_BRACE_STYLE;
if (classBraceStyle == CommonCodeStyleSettings.END_OF_LINE || shouldHandleAsSimpleClass(aClass)) {
return createNonLFSpace(space, null, false);
}
else if (classBraceStyle == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) {
final PsiIdentifier nameIdentifier = aClass.getNameIdentifier();
final int startOffset = nameIdentifier == null ? myParent.getTextRange().getStartOffset() : nameIdentifier.getTextRange().getStartOffset();
TextRange range = new TextRange(startOffset, myChild1.getTextRange().getEndOffset());
return createNonLFSpace(space, range, false);
}
return Spacing.createSpacing(space, space, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
示例3: testIfElse
public void testIfElse() throws Exception {
final CommonCodeStyleSettings settings = getSettings();
settings.IF_BRACE_FORCE = CommonCodeStyleSettings.DO_NOT_FORCE;
settings.FOR_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_IF_MULTILINE;
settings.WHILE_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_IF_MULTILINE;
settings.DOWHILE_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_IF_MULTILINE;
settings.ELSE_ON_NEW_LINE = true;
settings.SPECIAL_ELSE_IF_TREATMENT = false;
settings.WHILE_ON_NEW_LINE = true;
settings.CATCH_ON_NEW_LINE = true;
settings.FINALLY_ON_NEW_LINE = true;
settings.ALIGN_MULTILINE_BINARY_OPERATION = true;
settings.ALIGN_MULTILINE_TERNARY_OPERATION = true;
settings.ALIGN_MULTILINE_ASSIGNMENT = true;
settings.ALIGN_MULTILINE_EXTENDS_LIST = true;
settings.ALIGN_MULTILINE_THROWS_LIST = true;
settings.ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION = true;
settings.ALIGN_MULTILINE_FOR = true;
settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
settings.ALIGN_MULTILINE_PARAMETERS = true;
settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
settings.WHILE_ON_NEW_LINE = true;
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doTest();
}
示例4: testKeepSimpleBlocksInOneLine_OnIfStatementsElseBlock
public void testKeepSimpleBlocksInOneLine_OnIfStatementsElseBlock() throws Exception {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
String before = "if (2 > 3) {\n" +
" System.out.println(\"AA!\");\n" +
"} else { int a = 3; }";
String afterNextLineOption = "if (2 > 3)\n" +
"{\n" +
" System.out.println(\"AA!\");\n" +
"} else { int a = 3; }";
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doMethodTest(before, afterNextLineOption);
getSettings().BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doMethodTest(before, before);
}
示例5: getCodeBlockExternalIndent
protected Indent getCodeBlockExternalIndent() {
final int braceStyle = getBraceStyle();
if (braceStyle == CommonCodeStyleSettings.END_OF_LINE || braceStyle == CommonCodeStyleSettings.NEXT_LINE ||
braceStyle == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) {
return Indent.getNoneIndent();
}
return Indent.getNormalIndent();
}
示例6: valueToInt
private static int valueToInt(@NotNull String value) {
if (VALUE_END_OF_LINE.equals(value)) return CommonCodeStyleSettings.END_OF_LINE;
if (VALUE_NEXT_LINE.equals(value)) return CommonCodeStyleSettings.NEXT_LINE;
if (VALUE_NEXT_LINE_SHIFTED.equals(value)) return CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
if (VALUE_NEXT_LINE_IF_WRAPPED.equals(value)) return CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
return Integer.parseInt(value);
}
示例7: getSpaceBeforeLBrace
private Spacing getSpaceBeforeLBrace(@NotNull ASTNode lBraceBlock, boolean spaceBeforeLbrace, @Nullable TextRange nextLineIfWrappedOptionRange) {
int space = spaceBeforeLbrace ? 1 : 0;
if (mySettings.BRACE_STYLE == CommonCodeStyleSettings.END_OF_LINE) {
return createNonLFSpace(space, null, false);
}
else if (mySettings.BRACE_STYLE == CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED) {
return createNonLFSpace(space, nextLineIfWrappedOptionRange, false);
}
else if (shouldHandleAsSimpleBlock(lBraceBlock)) {
return createNonLFSpace(space, lBraceBlock.getTextRange(), false);
}
return Spacing.createSpacing(space, space, 1, false, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
示例8: doTestBracesNextLineStyle
private void doTestBracesNextLineStyle() throws Exception {
CommonCodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
try {
doTest();
}
finally {
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
}
}
示例9: testIfBraces
public void testIfBraces() throws Exception {
final CommonCodeStyleSettings settings = getSettings();
settings.IF_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
settings.KEEP_LINE_BREAKS = false;
doTest();
}
示例10: testRemoveLineBreak
public void testRemoveLineBreak() throws Exception {
getSettings().KEEP_LINE_BREAKS = true;
getSettings().CLASS_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
getSettings().BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doTextTest("class A\n" + "{\n" + "}", "class A {\n" + "}");
doTextTest("class A {\n" + " void foo()\n" + " {\n" + " }\n" + "}", "class A {\n" + " void foo() {\n" + " }\n" + "}");
doTextTest("class A {\n" + " void foo()\n" + " {\n" + " if (a)\n" + " {\n" + " }\n" + " }\n" + "}",
"class A {\n" + " void foo() {\n" + " if (a) {\n" + " }\n" + " }\n" + "}");
}
示例11: testStaticBlockBraces
public void testStaticBlockBraces() throws Exception {
getSettings().BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doTextTest("class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}",
"class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED;
doTextTest("class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}",
"class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doTextTest("class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}",
"class Foo {\n" + " static\n" + " {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
doTextTest("class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}",
"class Foo {\n" + " static\n" + " {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED2;
doTextTest("class Foo {\n" + " static {\n" + " //comment\n" + " i = foo();\n" + " }\n" + "}", "class Foo {\n" +
" static\n" +
" {\n" +
" //comment\n" +
" i = foo();\n" +
" }\n" +
"}");
}
示例12: testKeepSimpleBlocksInOneLine_OnIfStatementsThenBlock
public void testKeepSimpleBlocksInOneLine_OnIfStatementsThenBlock() throws Exception {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
String singleLine = "if (2 > 3) { System.out.println(\"AA!\"); }";
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doMethodTest(singleLine, singleLine);
getSettings().BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doMethodTest(singleLine, singleLine);
}
示例13: testSCR260
public void testSCR260() throws Exception {
final CommonCodeStyleSettings settings = getSettings();
settings.IF_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
settings.KEEP_LINE_BREAKS = false;
doTest();
}
示例14: testSCR524
public void testSCR524() throws Exception {
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false;
doTextTest("class Foo {\n" + " void foo() { return;}" + "}", "class Foo {\n" + " void foo() { return;}\n" + "}");
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED2;
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = false;
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
doTextTest("class Foo{\n" +
"void foo() {\n" +
"if(a) {return;}\n" +
"for(a = 0; a < 10; a++) {return;}\n" +
"switch(a) {case 1: return;}\n" +
"do{return;} while (a);\n" +
"while(a){return;}\n" +
"try{return;} catch(Ex e){return;} finally{return;}\n" +
"}\n" +
"}", "class Foo {\n" +
" void foo() {\n" +
" if (a) {return;}\n" +
" for (a = 0; a < 10; a++) {return;}\n" +
" switch (a)\n" +
" {\n" +
" case 1:\n" +
" return;\n" +
" }\n" +
" do {return;} while (a);\n" +
" while (a) {return;}\n" +
" try {return;} catch (Ex e) {return;} finally {return;}\n" +
" }\n" +
"}");
}
示例15: testCompleteIfNextLineBraceStyle
public void testCompleteIfNextLineBraceStyle() throws Exception {
CommonCodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doTest();
settings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
}