本文整理汇总了Java中com.intellij.psi.codeStyle.CommonCodeStyleSettings类的典型用法代码示例。如果您正苦于以下问题:Java CommonCodeStyleSettings类的具体用法?Java CommonCodeStyleSettings怎么用?Java CommonCodeStyleSettings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommonCodeStyleSettings类属于com.intellij.psi.codeStyle包,在下文中一共展示了CommonCodeStyleSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDependentSpacingForClosure
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
@NotNull
static Spacing createDependentSpacingForClosure(@NotNull CommonCodeStyleSettings settings,
@NotNull GroovyCodeStyleSettings groovySettings,
@NotNull GrClosableBlock closure,
final boolean forArrow) {
boolean spaceWithinBraces = closure.getParent() instanceof GrStringInjection
? groovySettings.SPACE_WITHIN_GSTRING_INJECTION_BRACES
: settings.SPACE_WITHIN_BRACES;
GrStatement[] statements = closure.getStatements();
if (statements.length > 0) {
final PsiElement startElem = forArrow ? statements[0] : closure;
int start = startElem.getTextRange().getStartOffset();
int end = statements[statements.length - 1].getTextRange().getEndOffset();
TextRange range = new TextRange(start, end);
int minSpaces = spaceWithinBraces || forArrow ? 1 : 0;
int maxSpaces = spaceWithinBraces || forArrow ? 1 : 0;
return Spacing.createDependentLFSpacing(minSpaces, maxSpaces, range, settings.KEEP_LINE_BREAKS, settings.KEEP_BLANK_LINES_IN_CODE);
}
return spaceWithinBraces || forArrow ? COMMON_SPACING : NO_SPACING_WITH_NEWLINE;
}
示例2: reinitDocumentIndentOptions
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
private void reinitDocumentIndentOptions() {
if (myEditor == null) return;
final Project project = myEditor.getProject();
final DocumentEx document = myEditor.getDocument();
if (project == null || project.isDisposed()) return;
final PsiDocumentManager psiManager = PsiDocumentManager.getInstance(project);
final PsiFile file = psiManager.getPsiFile(document);
if (file == null) return;
CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(project).getCurrentSettings();
CommonCodeStyleSettings.IndentOptions options = settings.getIndentOptionsByFile(file);
if (CodeStyleSettings.isRecalculateForCommittedDocument(options)) {
PsiDocumentManager.getInstance(project).performForCommittedDocument(document, new Runnable() {
@Override
public void run() {
CodeStyleSettingsManager.updateDocumentIndentOptions(project, document);
}
});
}
else {
CodeStyleSettingsManager.updateDocumentIndentOptions(project, document);
}
}
示例3: apply
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
@Override
public void apply(CodeStyleSettings settings) {
settings.HTML_KEEP_BLANK_LINES = getIntValue(myKeepBlankLines);
settings.HTML_ATTRIBUTE_WRAP = ourWrappings[myWrapAttributes.getSelectedIndex()];
settings.HTML_TEXT_WRAP = myWrapText.isSelected() ? CommonCodeStyleSettings.WRAP_AS_NEEDED : CommonCodeStyleSettings.DO_NOT_WRAP;
settings.HTML_SPACE_INSIDE_EMPTY_TAG = mySpaceInEmptyTag.isSelected();
settings.HTML_ALIGN_ATTRIBUTES = myAlignAttributes.isSelected();
settings.HTML_ALIGN_TEXT = myAlignText.isSelected();
settings.HTML_KEEP_WHITESPACES = myKeepWhiteSpaces.isSelected();
settings.HTML_SPACE_AROUND_EQUALITY_IN_ATTRINUTE = mySpacesAroundEquality.isSelected();
settings.HTML_SPACE_AFTER_TAG_NAME = mySpacesAroundTagName.isSelected();
settings.HTML_ELEMENTS_TO_INSERT_NEW_LINE_BEFORE = myInsertNewLineTagNames.getText();
settings.HTML_ELEMENTS_TO_REMOVE_NEW_LINE_BEFORE = myRemoveNewLineTagNames.getText();
settings.HTML_DO_NOT_INDENT_CHILDREN_OF = myDoNotAlignChildrenTagNames.getText();
settings.HTML_DO_NOT_ALIGN_CHILDREN_OF_MIN_LINES = getIntValue(myDoNotAlignChildrenMinSize);
settings.HTML_INLINE_ELEMENTS = myInlineElementsTagNames.getText();
settings.HTML_DONT_ADD_BREAKS_IF_INLINE_CONTENT = myDontBreakIfInlineContent.getText();
settings.HTML_KEEP_WHITESPACES_INSIDE = myKeepWhiteSpacesTagNames.getText();
settings.HTML_KEEP_LINE_BREAKS = myShouldKeepBlankLines.isSelected();
settings.HTML_KEEP_LINE_BREAKS_IN_TEXT = myShouldKeepLineBreaksInText.isSelected();
myRightMarginForm.apply(settings);
}
示例4: testWrapRightMargin
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
public void testWrapRightMargin() {
final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings();
final CommonCodeStyleSettings pythonSettings = settings.getCommonSettings(PythonLanguage.getInstance());
int oldValue = pythonSettings.RIGHT_MARGIN;
boolean oldMarginValue = settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN;
pythonSettings.RIGHT_MARGIN = 100;
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
try {
final String testName = "wrap/" + getTestName(true);
myFixture.configureByFile(testName + ".py");
for (int i = 0; i != 45; ++i) {
myFixture.type(' ');
}
myFixture.checkResultByFile(testName + ".after.py");
}
finally {
pythonSettings.RIGHT_MARGIN = oldValue;
settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = oldMarginValue;
}
}
示例5: testEnumConstantsWrapping
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
@SuppressWarnings("SpellCheckingInspection")
public void testEnumConstantsWrapping() {
// Inspired by IDEA-54667
getSettings().ENUM_CONSTANTS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().RIGHT_MARGIN = 80;
// Don't expect the constants to be placed on new line.
doTextTest(
"enum Test {FIRST, SECOND}",
"enum Test {FIRST, SECOND}"
);
// Expect not only enum constants to be wrapped but line break inside enum-level curly braces as well.
doTextTest(
"enum Test {FIRST, SECOND, THIIIIIIIIIIIIIIIIIRRDDDDDDDDDDDDDD, FOURTHHHHHHHHHHHHHHHH}",
"enum Test {\n" +
" FIRST, SECOND, THIIIIIIIIIIIIIIIIIRRDDDDDDDDDDDDDD, FOURTHHHHHHHHHHHHHHHH\n" +
"}"
);
}
示例6: testResourceListWrap
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
public void testResourceListWrap() {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().RIGHT_MARGIN = 40;
getSettings().RESOURCE_LIST_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
doMethodTest("try (MyResource r1 = null; MyResource r2 = null) { }",
"try (MyResource r1 = null;\n" +
" MyResource r2 = null) { }");
getSettings().RESOURCE_LIST_LPAREN_ON_NEXT_LINE = true;
getSettings().RESOURCE_LIST_RPAREN_ON_NEXT_LINE = true;
doMethodTest("try (MyResource r1 = null; MyResource r2 = null) { }",
"try (\n" +
" MyResource r1 = null;\n" +
" MyResource r2 = null\n" +
") { }");
}
示例7: testSCR1615
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
public void testSCR1615() throws Exception {
getSettings().CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
getSettings().METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE_SHIFTED;
doTextTest(
"public class ZZZZ \n" +
" { \n" +
" public ZZZZ() \n" +
" { \n" +
" if (a){\n" +
"foo();}\n" +
" } \n" +
" }",
"public class ZZZZ\n" +
" {\n" +
" public ZZZZ()\n" +
" {\n" +
" if (a)\n" +
" {\n" +
" foo();\n" +
" }\n" +
" }\n" +
" }");
}
示例8: doEnterTestForWeb11600
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
private void doEnterTestForWeb11600() {
final JsonCodeStyleSettings settings = getCustomCodeStyleSettings();
final CommonCodeStyleSettings.IndentOptions indentOptions = getIndentOptions();
final int oldPropertyAlignment = settings.PROPERTY_ALIGNMENT;
final int oldIndentSize = indentOptions.INDENT_SIZE;
settings.PROPERTY_ALIGNMENT = JsonCodeStyleSettings.ALIGN_PROPERTY_ON_VALUE;
indentOptions.INDENT_SIZE = 4;
try {
doTest("\n");
}
finally {
indentOptions.INDENT_SIZE = oldIndentSize;
settings.PROPERTY_ALIGNMENT = oldPropertyAlignment;
}
}
示例9: testSCR1703
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
public void testSCR1703() throws Exception {
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
doTextTest("class Foo{\n" +
" void foo() {\n" +
" for (Object o : localizations) {\n" +
" //do something \n" +
" }\n" +
" }\n" +
"}", "class Foo {\n" +
" void foo() {\n" +
" for (Object o : localizations)\n" +
" {\n" +
" //do something \n" +
" }\n" +
" }\n" +
"}");
}
示例10: SyntheticCodeBlock
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
public SyntheticCodeBlock(List<Block> subBlocks,
Alignment alignment,
CommonCodeStyleSettings settings,
JavaCodeStyleSettings javaSettings,
Indent indent,
Wrap wrap)
{
myJavaSettings = javaSettings;
myIndentContent = indent;
if (subBlocks.isEmpty()) {
LOG.assertTrue(false);
}
mySubBlocks = new ArrayList<Block>(subBlocks);
myAlignment = alignment;
mySettings = settings;
myWrap = wrap;
myTextRange = new TextRange(mySubBlocks.get(0).getTextRange().getStartOffset(),
mySubBlocks.get(mySubBlocks.size() - 1).getTextRange().getEndOffset());
}
示例11: Context
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
public Context(@NotNull Document document,
@NotNull AlignmentImpl alignment,
@NotNull LeafBlockWrapper targetBlock,
@NotNull Map<AbstractBlockWrapper, Set<AbstractBlockWrapper>> alignmentMappings,
@NotNull Map<LeafBlockWrapper, Set<LeafBlockWrapper>> backwardShiftedAlignedBlocks,
@NotNull CommonCodeStyleSettings.IndentOptions indentOptions,
int maxAlignmentSpaces)
{
this.document = document;
this.alignment = alignment;
this.targetBlock = targetBlock;
this.alignmentMappings = alignmentMappings;
this.backwardShiftedAlignedBlocks = backwardShiftedAlignedBlocks;
this.indentOptions = indentOptions;
this.maxAlignmentSpaces = maxAlignmentSpaces;
}
示例12: testDoNotWrapLBrace
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
public void testDoNotWrapLBrace() throws IncorrectOperationException {
getSettings().BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
getSettings().RIGHT_MARGIN = 66;
doTextTest("public class Test {\n" +
" void foo(){\n" +
" if (veryLongIdentifier1 == 1 && veryLongIdentifier2 == 2) {\n" +
" doSmth();\n" +
" }\n" +
" }\n" +
"}", "public class Test {\n" +
" void foo() {\n" +
" if (veryLongIdentifier1 == 1 && veryLongIdentifier2 == 2) {\n" +
" doSmth();\n" +
" }\n" +
" }\n" +
"}");
}
示例13: testIfStatementElseBranchIsOnNewLine
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
public void testIfStatementElseBranchIsOnNewLine() throws Exception {
getSettings().KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = true;
getSettings().BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
String before = "if (2 > 3) {\n" +
" System.out.println(\"AA!\");\n" +
"} else {\n" +
" int a = 3;\n" +
"}";
String after = "if (2 > 3)\n" +
"{\n" +
" System.out.println(\"AA!\");\n" +
"} else\n" +
"{\n" +
" int a = 3;\n" +
"}";
doMethodTest(before, after);
}
示例14: test_RParen_OnNextLine_IfWrapped
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
public void test_RParen_OnNextLine_IfWrapped() {
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS;
getSettings().CALL_PARAMETERS_RPAREN_ON_NEXT_LINE = true;
doMethodTest("fuun(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\", \"cccccccccccccc\");",
"fuun(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n" +
" \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\n" +
" \"cccccccccccccc\"" +
"\n);");
getSettings().CALL_PARAMETERS_RPAREN_ON_NEXT_LINE = false;
doMethodTest("fuun(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\", \"cccccccccccccc\");",
"fuun(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n" +
" \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\n" +
" \"cccccccccccccc\");");
}
示例15: testDoNotWrapMethodsWithMethodCallAsParameters
import com.intellij.psi.codeStyle.CommonCodeStyleSettings; //导入依赖的package包/类
@SuppressWarnings("SpellCheckingInspection")
public void testDoNotWrapMethodsWithMethodCallAsParameters() {
getSettings().WRAP_LONG_LINES = true;
getSettings().RIGHT_MARGIN = 140;
getSettings().PREFER_PARAMETERS_WRAP = true;
getSettings().CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_ON_EVERY_ITEM;
getSettings().CALL_PARAMETERS_RPAREN_ON_NEXT_LINE = true;
getSettings().CALL_PARAMETERS_LPAREN_ON_NEXT_LINE = true;
String before = " processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, getMessage());";
String after = "processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, getMessage());";
doMethodTest(before, after);
before = " processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, getMessage(loooooooooooooooooongParamName));";
after = "processingEnv.getMessenger().printMessage(Diagnostic.Kind.ERROR, getMessage(loooooooooooooooooongParamName));";
doMethodTest(before, after);
}