@Override public CommonCodeStyleSettings getDefaultCommonSettings() { CommonCodeStyleSettings defaultSettings = new CommonCodeStyleSettings(getLanguage()); CommonCodeStyleSettings.IndentOptions indentOptions = defaultSettings.initIndentOptions(); indentOptions.INDENT_SIZE = 8; indentOptions.CONTINUATION_INDENT_SIZE = 8; indentOptions.TAB_SIZE = 8; indentOptions.USE_TAB_CHARACTER = true; defaultSettings.BLOCK_COMMENT_AT_FIRST_COLUMN = false; defaultSettings.LINE_COMMENT_AT_FIRST_COLUMN = false; return defaultSettings; } }
private int normalIndentSize(@NotNull ASTNode node) { CommonCodeStyleSettings.IndentOptions indentOptions = commonCodeStyleSettings(node).getIndentOptions(); int normalIndentSize = 2; if (indentOptions != null) { normalIndentSize = indentOptions.INDENT_SIZE; } return normalIndentSize; }
@Override public CommonCodeStyleSettings getDefaultCommonSettings() { CommonCodeStyleSettings commonSettings = new CommonCodeStyleSettings(getLanguage()); commonSettings.initIndentOptions(); commonSettings.getIndentOptions().TAB_SIZE = 1; commonSettings.getIndentOptions().INDENT_SIZE = 1; commonSettings.getIndentOptions().USE_TAB_CHARACTER = true; commonSettings.getIndentOptions().SMART_TABS = false; commonSettings.getIndentOptions().KEEP_INDENTS_ON_EMPTY_LINES = true; commonSettings.WRAP_ON_TYPING = CommonCodeStyleSettings.WrapOnTyping.NO_WRAP.intValue; commonSettings.WRAP_LONG_LINES = false; commonSettings.RIGHT_MARGIN = Integer.MAX_VALUE; return commonSettings; } }
public void testTab() { run("use_tab", settings -> { CommonCodeStyleSettings.IndentOptions indentOptions = settings.initIndentOptions(); indentOptions.USE_TAB_CHARACTER = true; }); }
@NotNull @Override protected List<Block> buildSubBlocks() { return PerlInjectedLanguageBlocksBuilder.compute(myContext.getSettings().getRootSettings(), getNode(), getTextRange()); }
public void testCustomIndent() { run("custom_indent", settings -> { CommonCodeStyleSettings.IndentOptions indentOptions = settings.initIndentOptions(); indentOptions.INDENT_SIZE = 2; }); }
static SpacingBuilder getSpacingBuilder(CommonCodeStyleSettings settings, MathematicaCodeStyleSettings mathematicaSettings) { return new SpacingBuilder(settings.getRootSettings(), MathematicaLanguage.INSTANCE) .around(ourAssignments).spaceIf(mathematicaSettings.SPACE_AROUND_ASSIGNMENT_OPERATIONS) .around(ourArithmeticOperations).spaceIf(mathematicaSettings.SPACE_AROUND_ARITHMETIC_OPERATIONS) .aroundInside(MINUS, MINUS_EXPRESSION).spaceIf(mathematicaSettings.SPACE_AROUND_ARITHMETIC_OPERATIONS) .around(ourRelationalOperations).spaceIf(mathematicaSettings.SPACE_AROUND_RELATION_OPERATIONS) .around(ourRuleOperations).spaceIf(mathematicaSettings.SPACE_AROUND_RULE_OPERATIONS) .around(ourFunctionalOperations).spaceIf(mathematicaSettings.SPACE_AROUND_FUNCTIONAL_OPERATIONS) .around(ourOtherOperations).spaceIf(mathematicaSettings.SPACE_AROUND_OTHER_OPERATIONS) .after(COMMA).spaceIf(settings.SPACE_AFTER_COMMA) .before(LEFT_BRACKET).none() .after(RIGHT_BRACKET).none() ; } }
@Override public CommonCodeStyleSettings getDefaultCommonSettings() { CommonCodeStyleSettings defaultSettings = new CommonCodeStyleSettings(getLanguage()); CommonCodeStyleSettings.IndentOptions indentOptions = defaultSettings.initIndentOptions(); indentOptions.INDENT_SIZE = 4; indentOptions.CONTINUATION_INDENT_SIZE = 4; indentOptions.TAB_SIZE = 4; indentOptions.USE_TAB_CHARACTER = false; defaultSettings.BLOCK_COMMENT_AT_FIRST_COLUMN = false; defaultSettings.LINE_COMMENT_AT_FIRST_COLUMN = false; return defaultSettings; } }
@Override public void importTo(@NotNull final CodeStyleSettings settings) { CommonCodeStyleSettings javaSettings = getJavaSettings(settings); CommonCodeStyleSettings.IndentOptions indentOptions = javaSettings.getIndentOptions(); if (indentOptions != null) { indentOptions.INDENT_SIZE = basicIndent; indentOptions.CONTINUATION_INDENT_SIZE = continuationIndent; } javaSettings.INDENT_CASE_FROM_SWITCH = indentCase; } }
mySpacingBuilder = new SpacingBuilder(commonSettings.getRootSettings(), TemplateToolkitLanguage.INSTANCE) .around(TT2_PERIOD).spaces(0) .after(TT2_MINUS_UNARY).spaces(0)
@Override public CommonCodeStyleSettings getDefaultCommonSettings() { CommonCodeStyleSettings defaultCommonSettings = new CommonCodeStyleSettings(getLanguage()); CommonCodeStyleSettings.IndentOptions indentOptions = defaultCommonSettings.initIndentOptions(); indentOptions.INDENT_SIZE = 2; indentOptions.CONTINUATION_INDENT_SIZE = 2; indentOptions.TAB_SIZE = 2; return defaultCommonSettings; }
public void testImportFileTabCharacterNoExplicitExtensions() { CommonCodeStyleSettings xmlSettings = codeStyleSettings.getCommonSettings(XMLLanguage.INSTANCE); CommonCodeStyleSettings.IndentOptions javaIndentOptions = javaSettings.getIndentOptions(); assertNotNull(javaIndentOptions); CommonCodeStyleSettings.IndentOptions xmlIndentOptions = xmlSettings.getIndentOptions(); assertNotNull(xmlIndentOptions); javaIndentOptions.USE_TAB_CHARACTER = true; xmlIndentOptions.USE_TAB_CHARACTER = true; importConfiguration( inTreeWalker( "<module name=\"FileTabCharacter\"/>\n" ) ); assertFalse(javaIndentOptions.USE_TAB_CHARACTER); assertFalse(xmlIndentOptions.USE_TAB_CHARACTER); }
@Nullable @Override public CommonCodeStyleSettings getDefaultCommonSettings() { CommonCodeStyleSettings settings = new CommonCodeStyleSettings(ProtoLanguage.INSTANCE); settings.initIndentOptions(); // TODO: we should define our own settings settings.SPACE_AROUND_ASSIGNMENT_OPERATORS = true; settings.SPACE_BEFORE_SEMICOLON = false; settings.BRACE_STYLE = END_OF_LINE; settings.KEEP_BLANK_LINES_IN_CODE = 2; settings.KEEP_LINE_BREAKS = false; return settings; }
public void testIndentationImporter() { javaSettings.INDENT_BREAK_FROM_CASE = false; CommonCodeStyleSettings.IndentOptions indentOptions = javaSettings.getIndentOptions(); assertNotNull(indentOptions); indentOptions.INDENT_SIZE = 8; indentOptions.CONTINUATION_INDENT_SIZE = 8; importConfiguration( inTreeWalker( " <module name=\"Indentation\">\n" + " <property name=\"basicOffset\" value=\"2\"/>\n" + " <property name=\"braceAdjustment\" value=\"0\"/>\n" + " <property name=\"caseIndent\" value=\"2\"/>\n" + " <property name=\"throwsIndent\" value=\"4\"/>\n" + " <property name=\"lineWrappingIndentation\" value=\"4\"/>\n" + " <property name=\"arrayInitIndent\" value=\"2\"/>\n" + "</module>" ) ); javaSettings.INDENT_BREAK_FROM_CASE = true; indentOptions.INDENT_SIZE = 2; indentOptions.CONTINUATION_INDENT_SIZE = 4; }
@Override public CommonCodeStyleSettings getDefaultCommonSettings() { CommonCodeStyleSettings defaultSettings = new CommonCodeStyleSettings(getLanguage()); IndentOptions indentOptions = defaultSettings.initIndentOptions(); indentOptions.INDENT_SIZE = 2; indentOptions.CONTINUATION_INDENT_SIZE = 4; indentOptions.TAB_SIZE = 2; indentOptions.USE_TAB_CHARACTER = false; return defaultSettings; }
public void testImportFileTabCharacter() { CommonCodeStyleSettings xmlSettings = codeStyleSettings.getCommonSettings(XMLLanguage.INSTANCE); CommonCodeStyleSettings.IndentOptions javaIndentOptions = javaSettings.getIndentOptions(); assertNotNull(javaIndentOptions); CommonCodeStyleSettings.IndentOptions xmlIndentOptions = xmlSettings.getIndentOptions(); assertNotNull(xmlIndentOptions); javaIndentOptions.USE_TAB_CHARACTER = true; xmlIndentOptions.USE_TAB_CHARACTER = true; importConfiguration( inTreeWalker( "<module name=\"FileTabCharacter\">\n" + " <property name=\"eachLine\" value=\"true\" />\n" + " <property name=\"fileExtensions\" value=\"java,xml\" />\n" + "</module>" ) ); assertFalse(javaIndentOptions.USE_TAB_CHARACTER); assertFalse(xmlIndentOptions.USE_TAB_CHARACTER); }
@Override public CommonCodeStyleSettings getDefaultCommonSettings() { final CommonCodeStyleSettings defaultSettings = new CommonCodeStyleSettings(getLanguage()); final CommonCodeStyleSettings.IndentOptions indentOptions = defaultSettings.initIndentOptions(); indentOptions.INDENT_SIZE = 4; indentOptions.CONTINUATION_INDENT_SIZE = 4; indentOptions.TAB_SIZE = 4; indentOptions.USE_TAB_CHARACTER = false; defaultSettings.BLOCK_COMMENT_AT_FIRST_COLUMN = false; defaultSettings.LINE_COMMENT_AT_FIRST_COLUMN = false; return defaultSettings; } }
@NotNull private static String getIndenter(@NotNull Project project, int indentSize) { CommonCodeStyleSettings.IndentOptions indentOptions = CodeStyle.getSettings(project).getCommonSettings(PerlLanguage.INSTANCE).getIndentOptions(); return StringUtil.repeat(indentOptions != null && indentOptions.USE_TAB_CHARACTER ? "\t" : " ", indentSize); }
@Nullable @Override public CommonCodeStyleSettings getDefaultCommonSettings() { CommonCodeStyleSettings settings = new CommonCodeStyleSettings(getLanguage()); CommonCodeStyleSettings.IndentOptions indentOptions = settings.initIndentOptions(); indentOptions.INDENT_SIZE = 2; indentOptions.CONTINUATION_INDENT_SIZE = 2; indentOptions.TAB_SIZE = 2; indentOptions.USE_TAB_CHARACTER = false; return settings; }
public PerlDocumentBasedFormattingModel(@NotNull Block rootBlock, @NotNull PsiElement element, @NotNull CodeStyleSettings settings ) { super(rootBlock, element.getProject(), settings, element.getContainingFile().getFileType(), element.getContainingFile()); myIndentOptions = settings.getCommonSettings(PerlLanguage.INSTANCE).getIndentOptions(); }