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 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; } }
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); }
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; }
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() { 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; } }
@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); }
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(); }
@Override protected void setUp() throws Exception { super.setUp(); CommonCodeStyleSettings.IndentOptions options = getSettings().getIndentOptions(); assertNotNull(options); options.INDENT_SIZE = 4; options.CONTINUATION_INDENT_SIZE = 8; }