@NotNull @Override public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) { final Block impexBlock = new ImpexBlock( element.getNode(), null, Alignment.createAlignment(), createSpaceBuilder(settings) ); return FormattingModelProvider.createFormattingModelForPsiFile( element.getContainingFile(), impexBlock, settings ); }
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { ASTNode root = CsvFormatHelper.getRoot(element.getNode()); CsvFormattingInfo formattingInfo = new CsvFormattingInfo( settings, CsvFormatHelper.createSpaceBuilder(settings), CsvFormatHelper.createColumnInfoMap(root, settings) ); return FormattingModelProvider.createFormattingModelForPsiFile( element.getContainingFile(), new CsvBlock(root, formattingInfo), settings ); }
public static Map<Integer, CsvColumnInfo<ASTNode>> createColumnInfoMap(ASTNode root, CodeStyleSettings settings) { Map<Integer, CsvColumnInfo<ASTNode>> columnInfoMap = new HashMap<>(); ASTNode child = root.getFirstChildNode(); while (child != null) { if (child.getElementType() == CsvTypes.RECORD) { Integer column = 0; ASTNode subChild = child.getFirstChildNode(); while (subChild != null) { if (subChild.getElementType() == CsvTypes.FIELD) { int length = getTextLength(subChild, settings); if (!columnInfoMap.containsKey(column)) { columnInfoMap.put(column, new CsvColumnInfo(column, length)); } else if (columnInfoMap.get(column).getMaxLength() < length) { columnInfoMap.get(column).setMaxLength(length); } columnInfoMap.get(column).addElement(subChild); ++column; } subChild = subChild.getTreeNext(); } } child = child.getTreeNext(); } return columnInfoMap; }
private static Spacing getSpacing(ASTNode node, CodeStyleSettings settings) { LuaSpacingProcessor spacingProcessor = mySharedProcessorAllocator.get(); try { if (spacingProcessor == null) { spacingProcessor = new LuaSpacingProcessor(new MyLuaSpacingVisitor(node, settings)); mySharedProcessorAllocator.set(spacingProcessor); } else { spacingProcessor.setVisitor(new MyLuaSpacingVisitor(node, settings)); } spacingProcessor.doInit(); return spacingProcessor.getResult(); } catch (Exception e) { LOG.error(e); return null; } finally { spacingProcessor.clear(); } }
/** * Generates blocks for binary expressions * * @param node * @return */ private static List<Block> generateForBinaryExpr(final ASTNode node, Wrap myWrap, CodeStyleSettings mySettings) { final ArrayList<Block> subBlocks = new ArrayList<Block>(); Alignment alignment = mySettings.ALIGN_MULTILINE_BINARY_OPERATION ? Alignment.createAlignment() : null; LuaBinaryExpression myExpr = (LuaBinaryExpression) node.getPsi(); ASTNode[] children = node.getChildren(null); if (myExpr.getLeftExpression() instanceof LuaBinaryExpression) { addBinaryChildrenRecursively(myExpr.getLeftExpression(), subBlocks, Indent.getContinuationWithoutFirstIndent(), alignment, myWrap, mySettings); } for (ASTNode childNode : children) { if (canBeCorrectBlock(childNode) && !(childNode.getPsi() instanceof LuaBinaryExpression)) { subBlocks.add(new LuaFormattingBlock(childNode, alignment, Indent.getContinuationWithoutFirstIndent(), myWrap, mySettings)); } } if (myExpr.getRightExpression() instanceof LuaBinaryExpression) { addBinaryChildrenRecursively(myExpr.getRightExpression(), subBlocks, Indent.getContinuationWithoutFirstIndent(), alignment, myWrap, mySettings); } return subBlocks; }
/** * Adds all children of specified element to given list * * @param elem * @param list * @param indent * @param alignment */ private static void addBinaryChildrenRecursively(PsiElement elem, List<Block> list, Indent indent, Alignment alignment, Wrap myWrap, CodeStyleSettings mySettings) { if (elem == null) return; ASTNode[] children = elem.getNode().getChildren(null); // For binary expressions if ((elem instanceof LuaBinaryExpression)) { LuaBinaryExpression myExpr = ((LuaBinaryExpression) elem); if (myExpr.getLeftExpression() instanceof LuaBinaryExpression) { addBinaryChildrenRecursively(myExpr.getLeftExpression(), list, Indent.getContinuationWithoutFirstIndent(), alignment, myWrap, mySettings); } for (ASTNode childNode : children) { if (canBeCorrectBlock(childNode) && !(childNode.getPsi() instanceof LuaBinaryExpression)) { list.add(new LuaFormattingBlock(childNode, alignment, indent, myWrap, mySettings)); } } if (myExpr.getRightExpression() instanceof LuaBinaryExpression) { addBinaryChildrenRecursively(myExpr.getRightExpression(), list, Indent.getContinuationWithoutFirstIndent(), alignment, myWrap, mySettings); } } }
public void testCommentAfterDeclaration() throws Exception { CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject()); CommonCodeStyleSettings javaSettings = codeStyleSettings.getCommonSettings(JavaLanguage.INSTANCE); int oldMargin = codeStyleSettings.getDefaultRightMargin(); int oldWrap = javaSettings.ASSIGNMENT_WRAP; try { codeStyleSettings.setDefaultRightMargin(20); javaSettings.ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; doMethodTest( "int i=0; //comment comment", "int i =\n" + " 0; //comment comment" ); } finally { codeStyleSettings.setDefaultRightMargin(oldMargin); javaSettings.ASSIGNMENT_WRAP = oldWrap; } }
@NotNull private static TextRange doProcess(@NotNull PsiElement source, @NotNull TextRange range, @NotNull CodeStyleSettings settings) { ASTNode node = source.getNode(); if (node == null) { return range; } Language language = source.getLanguage(); if (language != JavaLanguage.INSTANCE) { // We had the only complaint for tabs not being converted to spaces for now. It was for the java code which has // a single block for the multi-line comment. This check should be removed if it is decided to generalize // this logic to other languages as well. return range; } if (!source.isValid()) return range; PsiFile file = source.getContainingFile(); CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptionsByFile(file, range); boolean useTabs = indentOptions.USE_TAB_CHARACTER; boolean smartTabs = indentOptions.SMART_TABS; int tabWidth = indentOptions.TAB_SIZE; return processViaPsi(node, range, new TreeHelperImpl(), useTabs, smartTabs, tabWidth); }
@Override public void apply(CodeStyleSettings settings) { settings.LINE_SEPARATOR = getSelectedLineSeparator(); settings.setDefaultRightMargin(getRightMargin()); settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = myCbWrapWhenTypingReachesRightMargin.isSelected(); settings.FORMATTER_TAGS_ENABLED = myEnableFormatterTags.isSelected(); settings.FORMATTER_TAGS_ACCEPT_REGEXP = myAcceptRegularExpressionsCheckBox.isSelected(); settings.FORMATTER_OFF_TAG = getTagText(myFormatterOffTagField, settings.FORMATTER_OFF_TAG); settings.setFormatterOffPattern(compilePattern(settings, myFormatterOffTagField, settings.FORMATTER_OFF_TAG)); settings.FORMATTER_ON_TAG = getTagText(myFormatterOnTagField, settings.FORMATTER_ON_TAG); settings.setFormatterOnPattern(compilePattern(settings, myFormatterOnTagField, settings.FORMATTER_ON_TAG)); settings.AUTODETECT_INDENTS = myAutodetectIndentsBox.isSelected(); if (myShowDetectedIndentNotification.isEnabled()) { FileIndentOptionsProvider.setShowNotification(myShowDetectedIndentNotification.isSelected()); } for (GeneralCodeStyleOptionsProvider option : myAdditionalOptions) { option.apply(settings); } }
public void testLastLineIndent() throws Exception{ final String initialText = "a\n"; final TestFormattingModel model = new TestFormattingModel(initialText); model.setRootBlock(new FormattingModelXmlReader(model).readTestBlock("lineIndent")); final CommonCodeStyleSettings.IndentOptions indentOptions = new CommonCodeStyleSettings.IndentOptions(); indentOptions.CONTINUATION_INDENT_SIZE = 8; indentOptions.INDENT_SIZE = 4; indentOptions.LABEL_INDENT_SIZE = 1; final CodeStyleSettings settings = new CodeStyleSettings(false); settings.setDefaultRightMargin(myRightMargin); try { FormatterEx.getInstanceEx().adjustLineIndent(model, settings, indentOptions, initialText.length() - 1, new TextRange(0, initialText.length())); } catch (IncorrectOperationException e) { fail(); } assertEquals("a\n ", FormatterImpl.getText(model)); }
public static List<Pair<String, Boolean>> sortItemsAccordingToSettings(List<Pair<String, Boolean>> names, final CodeStyleSettings settings) { int[] entryForName = ArrayUtil.newIntArray(names.size()); PackageEntry[] entries = settings.IMPORT_LAYOUT_TABLE.getEntries(); for(int i = 0; i < names.size(); i++){ Pair<String, Boolean> pair = names.get(i); String packageName = pair.getFirst(); Boolean isStatic = pair.getSecond(); entryForName[i] = findEntryIndex(packageName, isStatic, entries); } List<Pair<String, Boolean>> resultList = new ArrayList<Pair<String, Boolean>>(names.size()); for(int i = 0; i < entries.length; i++){ for(int j = 0; j < names.size(); j++){ if (entryForName[j] == i){ resultList.add(names.get(j)); names.set(j, null); } } } for (Pair<String, Boolean> name : names) { if (name != null) resultList.add(name); } return resultList; }
@NotNull public static String getCodeStyleIntent(InsertionContext insertionContext) { final CodeStyleSettings currentSettings = CodeStyleSettingsManager.getSettings(insertionContext.getProject()); final CommonCodeStyleSettings.IndentOptions indentOptions = currentSettings.getIndentOptions(insertionContext.getFile().getFileType()); return indentOptions.USE_TAB_CHARACTER ? "\t" : StringUtil.repeatSymbol(' ', indentOptions.INDENT_SIZE); }
AppleScriptBlock(ASTNode node, @Nullable Wrap wrap, @Nullable Alignment alignment, CodeStyleSettings settings) { super(node, wrap, alignment); mySettings = settings; myIndentProcessor = new AppleScriptIndentProcessor(settings.getCommonSettings(AppleScriptLanguage.INSTANCE)); myIndent = myIndentProcessor.getChildIndent(myNode); mySpacingProcessor = new AppleScriptSpacingProcessor(node, settings.getCommonSettings(AppleScriptLanguage.INSTANCE)); myWrappingProcessor = new AppleScriptWrappingProcessor(node, settings.getCommonSettings(AppleScriptLanguage.INSTANCE)); }
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { PsiFile containingFile = element.getContainingFile().getViewProvider().getPsi(AppleScriptLanguage.INSTANCE); assert containingFile != null : element.getContainingFile(); ASTNode astNode = containingFile.getNode(); assert astNode != null; CommonCodeStyleSettings appleScriptSettings = settings.getCommonSettings(AppleScriptLanguage.INSTANCE); final AppleScriptBlock rootBlock = new AppleScriptBlock(astNode, null, null, settings); return new AppleScriptFormattingModel(containingFile, rootBlock, FormattingDocumentModelImpl.createOn(containingFile)); }
@Override public TemplateLanguageBlock createTemplateLanguageBlock( @NotNull ASTNode node, @Nullable Wrap wrap, @Nullable Alignment alignment, @Nullable List<DataLanguageBlockWrapper> foreignChildren, @NotNull CodeStyleSettings codeStyleSettings) { final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(node.getPsi().getContainingFile()); if (node.getPsi() instanceof TagElement) { return new SoyTagBlock( this, codeStyleSettings, node, foreignChildren, new HtmlPolicy(codeStyleSettings, documentModel)); } else if(node.getPsi() instanceof TagBlockElement) { return new SoyTagBlockBlock( this, codeStyleSettings, node, foreignChildren, new HtmlPolicy(codeStyleSettings, documentModel)); } else if (node.getPsi() instanceof SoyStatementList) { return new SoyStatementListBlock( this, codeStyleSettings, node, foreignChildren, new HtmlPolicy(codeStyleSettings, documentModel)); } else { return new SoyBlock( this, codeStyleSettings, node, foreignChildren, new HtmlPolicy(codeStyleSettings, documentModel)); } }
@NotNull public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { final PsiFile file = element.getContainingFile(); if (element.getNode().getElementType() == SoyTypes.OTHER) { return new SimpleTemplateLanguageFormattingModelBuilder().createModel(element, settings); } else { return new DocumentBasedFormattingModel( getRootBlock(file, file.getViewProvider(), settings), element.getProject(), settings, file.getFileType(), file); } }
public SoyStatementListBlock( @NotNull TemplateLanguageBlockFactory blockFactory, @NotNull CodeStyleSettings settings, @NotNull ASTNode node, @Nullable List<DataLanguageBlockWrapper> foreignChildren, HtmlPolicy htmlPolicy) { super(blockFactory, settings, node, foreignChildren, htmlPolicy); }
public SoyBlock( @NotNull TemplateLanguageBlockFactory blockFactory, @NotNull CodeStyleSettings settings, @NotNull ASTNode node, @Nullable List<DataLanguageBlockWrapper> foreignChildren, HtmlPolicy htmlPolicy) { super(blockFactory, settings, node, foreignChildren); myHtmlPolicy = htmlPolicy; }
public SoyTagBlock( @NotNull TemplateLanguageBlockFactory blockFactory, @NotNull CodeStyleSettings settings, @NotNull ASTNode node, @Nullable List<DataLanguageBlockWrapper> foreignChildren, HtmlPolicy htmlPolicy) { super(blockFactory, settings, node, foreignChildren, htmlPolicy); }
public SoyTagBlockBlock( @NotNull TemplateLanguageBlockFactory blockFactory, @NotNull CodeStyleSettings settings, @NotNull ASTNode node, @Nullable List<DataLanguageBlockWrapper> foreignChildren, HtmlPolicy htmlPolicy) { super(blockFactory, settings, node, foreignChildren, htmlPolicy); }
@Override protected void initTabs(CodeStyleSettings settings) { addIndentOptionsTab(settings); addSpacesTab(settings); addWrappingAndBracesTab(settings); addBlankLinesTab(settings); }
@NotNull @Override public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) { return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), new CptBlock(element.getNode(), Wrap.createWrap(WrapType.NONE, false), Indent.getNoneIndent(), Indent.getNoneIndent(), Alignment.createAlignment(), createSpaceBuilder(settings)), settings); }
private static SpacingBuilder createSpaceBuilder(CodeStyleSettings settings) { return new SpacingBuilder(settings, CptLanguage.INSTANCE) .around(CptTypes.SEPARATOR) .spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS) //.around(CptTypes.MAP) //.spaceIf(settings.SPACE_AROUND_LAMBDA_ARROW) .before(CptTypes.MAPPING) .spaces(2); }
private void disableWrapOnType(final Language impexLanguage) { final CodeStyleScheme currentScheme = CodeStyleSchemes.getInstance().getCurrentScheme(); final CodeStyleSettings codeStyleSettings = currentScheme.getCodeStyleSettings(); if (impexLanguage != null) { CommonCodeStyleSettings langSettings = codeStyleSettings.getCommonSettings(impexLanguage); if (langSettings != null) { langSettings.WRAP_ON_TYPING = CommonCodeStyleSettings.WrapOnTyping.NO_WRAP.intValue; } } }
@NotNull @Override public FormattingModel createModel( final PsiElement element, final CodeStyleSettings settings ) { final Block block = new FlexibleSearchBlock( element.getNode(), null, Alignment.createAlignment(), createSpaceBuilder(settings) ); return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings); }
private static SpacingBuilder createSpaceBuilder(final CodeStyleSettings settings) { return new SpacingBuilder(settings, FlexibleSearchLanguage.getInstance()) .after(FlexibleSearchTypes.COMP_OP) .spaceIf(true) .before(FlexibleSearchTypes.COMP_OP) .spaceIf(true) .after(FlexibleSearchTypes.LEFT_DOUBLE_BRACE) .spaceIf(true) .before(FlexibleSearchTypes.RIGHT_DOUBLE_BRACE) .spaceIf(true) .before(FlexibleSearchTypes.LEFT_BRACE) .spaceIf(true) .after(FlexibleSearchTypes.RIGHT_BRACE) .spaceIf(true) .before(FlexibleSearchTypes.LEFT_PAREN) .spaceIf(true) .after(FlexibleSearchTypes.RIGHT_PAREN) .spaceIf(true) .around(TokenSet.create(FlexibleSearchTypes.WHERE, FlexibleSearchTypes.WHERE_CLAUSE)) .spaceIf(true) ; }
public static int getTextLength(ASTNode node, CodeStyleSettings codeStyleSettings) { CsvCodeStyleSettings csvCodeStyleSettings = codeStyleSettings.getCustomSettings(CsvCodeStyleSettings.class); String text = node.getText(); int length = node.getTextLength(); if (csvCodeStyleSettings.TABULARIZE && !csvCodeStyleSettings.WHITE_SPACES_OUTSIDE_QUOTES && text.startsWith("\"")) { text = text.substring(1, text.length() - 1); text = BEGIN_WHITE_SPACE_PATTERN.matcher(text).replaceFirst(""); text = END_WHITE_SPACE_PATTERN.matcher(text).replaceFirst(""); length = text.length() + 2; } return length; }
public static SpacingBuilder createSpaceBuilder(CodeStyleSettings settings) { CsvCodeStyleSettings csvCodeStyleSettings = settings.getCustomSettings(CsvCodeStyleSettings.class); SpacingBuilder builder = new SpacingBuilder(settings, CsvLanguage.INSTANCE); if (csvCodeStyleSettings.TRIM_LEADING_WHITE_SPACES || csvCodeStyleSettings.TABULARIZE) { builder .after(CsvTypes.COMMA).spaceIf(csvCodeStyleSettings.SPACE_AFTER_SEPARATOR) .after(CsvTypes.CRLF).spaces(0); if (csvCodeStyleSettings.TABULARIZE && !csvCodeStyleSettings.WHITE_SPACES_OUTSIDE_QUOTES) { builder.before(CsvTypes.QUOTE).spaces(0); } } else if (csvCodeStyleSettings.SPACE_AFTER_SEPARATOR) { builder.after(CsvTypes.COMMA).spaces(1); } if (csvCodeStyleSettings.TRIM_TRAILING_WHITE_SPACES || csvCodeStyleSettings.TABULARIZE) { builder .before(CsvTypes.COMMA).spaceIf(csvCodeStyleSettings.SPACE_BEFORE_SEPARATOR) .before(CsvTypes.CRLF).spaces(0); if (csvCodeStyleSettings.TABULARIZE && !csvCodeStyleSettings.WHITE_SPACES_OUTSIDE_QUOTES) { builder.after(CsvTypes.QUOTE).spaces(0); } } else if (csvCodeStyleSettings.SPACE_BEFORE_SEPARATOR) { builder.before(CsvTypes.COMMA).spaces(1); } return builder; }
public static String getCurrentSeparator(@Nullable Project project) { if (ApplicationManager.getApplication().isUnitTestMode()) { return DEFAULT_SEPARATOR; } if (project != null) { CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getInstance(project).getCurrentSettings(); if (codeStyleSettings != null) { CsvCodeStyleSettings csvCodeStyleSettings = codeStyleSettings.getCustomSettings(CsvCodeStyleSettings.class); if (csvCodeStyleSettings != null) { return csvCodeStyleSettings.getSeparator(); } } } return DEFAULT_SEPARATOR; }
@Override public CharSequence adjustWhiteSpaceIfNecessary(@NotNull CharSequence whiteSpaceText, @NotNull PsiElement startElement, int startOffset, int endOffset, CodeStyleSettings codeStyleSettings) { return whiteSpaceText; }
public void apply(@NotNull CodeStyleSettings settings) { CommonCodeStyleSettings langSettings = settings.getCommonSettings(myLanguage); if (langSettings != settings) { if (myDefaultGeneralCheckBox.isSelected()) { langSettings.RIGHT_MARGIN = -1; } else { langSettings.RIGHT_MARGIN = getFieldRightMargin(settings.getDefaultRightMargin()); } } langSettings.WRAP_ON_TYPING = getSelectedWrapOnTypingValue(); }
public void testSCR3493e() throws Exception { CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject()); boolean use_tab_character = settings.useTabCharacter(null); boolean smart_tabs = settings.isSmartTabs(null); try { settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = true; settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = true; doTest(); } finally { settings.getIndentOptions(StdFileTypes.JAVA).USE_TAB_CHARACTER = use_tab_character; settings.getIndentOptions(StdFileTypes.JAVA).SMART_TABS = smart_tabs; } }
private Context(@NotNull Rearranger<E> rearranger, @NotNull Collection<ArrangementEntryWrapper<E>> wrappers, @NotNull Document document, @NotNull List<ArrangementSectionRule> sectionRules, @NotNull List<? extends ArrangementMatchRule> rulesByPriority, @NotNull CodeStyleSettings settings, @NotNull Changer changer) { this.rearranger = rearranger; this.wrappers = wrappers; this.document = document; this.sectionRules = sectionRules; this.rulesByPriority = rulesByPriority; this.settings = settings; this.changer = changer; }
public static List<Block> generateSubBlocks(ASTNode node, Alignment myAlignment, Wrap myWrap, CodeStyleSettings mySettings, LuaFormattingBlock formattingBlock) { // //For binary expressions PsiElement blockPsi = formattingBlock.getNode().getPsi(); if (blockPsi instanceof LuaBinaryExpression && !(blockPsi.getParent() instanceof LuaBinaryExpression)) { return generateForBinaryExpr(node, myWrap, mySettings); } LOG.info(">> parent: " + blockPsi + ": " + node); // For other cases final ArrayList<Block> subBlocks = new ArrayList<Block>(); ASTNode[] children = getLuaChildren(node); ASTNode prevChildNode = null; for (ASTNode childNode : children) { LOG.info("Processing: " + childNode); if (canBeCorrectBlock(childNode)) { final Indent indent = LuaIndentProcessor.getChildIndent(formattingBlock, prevChildNode, childNode); LOG.info("" + level + " child: " + childNode + "indent " + indent); level++; subBlocks.add( new LuaFormattingBlock(childNode, blockPsi instanceof LuaFormattingBlock ? null : myAlignment, indent, myWrap, mySettings)); --level; prevChildNode = childNode; } } LOG.info("<< parent: " + blockPsi+ ": " + node); return subBlocks; }
public LuaFormattingBlock(@NotNull final ASTNode node, @Nullable final Alignment alignment, @NotNull final Indent indent, @Nullable final Wrap wrap, final CodeStyleSettings settings) { myNode = node; myAlignment = alignment; myIndent = indent; myWrap = wrap; mySettings = settings; }
public boolean isModified(CodeStyleSettings settings) { Iterable<String> oldProperties = getPropertyNames(settings); int i = 0; for (String property : oldProperties) { if (i >= myModel.size() || !property.equals(myModel.getElementAt(i))) { return true; } i++; } return false; }
@Override protected void initTabs(CodeStyleSettings settings) { addIndentOptionsTab(settings); addTab(new CodeStyleXmlPanel(settings)); addTab(new XmlArrangementPanel(settings)); for (CodeStyleSettingsProvider provider : Extensions.getExtensions(CodeStyleSettingsProvider.EXTENSION_POINT_NAME)) { if (provider.getLanguage() == XMLLanguage.INSTANCE && !provider.hasSettingsPage()) { createTab(provider); } } }
@Override protected void resetImpl(final CodeStyleSettings settings) { String lineSeparator = settings.LINE_SEPARATOR; if ("\n".equals(lineSeparator)) { myLineSeparatorCombo.setSelectedItem(UNIX_STRING); } else if ("\r\n".equals(lineSeparator)) { myLineSeparatorCombo.setSelectedItem(WINDOWS_STRING); } else if ("\r".equals(lineSeparator)) { myLineSeparatorCombo.setSelectedItem(MACINTOSH_STRING); } else { myLineSeparatorCombo.setSelectedItem(SYSTEM_DEPENDANT_STRING); } myRightMarginField.setText(String.valueOf(settings.getDefaultRightMargin())); myCbWrapWhenTypingReachesRightMargin.setSelected(settings.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN); myAcceptRegularExpressionsCheckBox.setSelected(settings.FORMATTER_TAGS_ACCEPT_REGEXP); myEnableFormatterTags.setSelected(settings.FORMATTER_TAGS_ENABLED); myFormatterOnTagField.setText(settings.FORMATTER_ON_TAG); myFormatterOffTagField.setText(settings.FORMATTER_OFF_TAG); setFormatterTagControlsEnabled(settings.FORMATTER_TAGS_ENABLED); myAutodetectIndentsBox.setSelected(settings.AUTODETECT_INDENTS); myShowDetectedIndentNotification.setEnabled(myAutodetectIndentsBox.isSelected()); myShowDetectedIndentNotification.setSelected(FileIndentOptionsProvider.isShowNotification()); for (GeneralCodeStyleOptionsProvider option : myAdditionalOptions) { option.reset(settings); } }
@Override public Object getValue(CodeStyleSettings settings) { try { return field.getInt(getSettings(settings)); } catch (IllegalAccessException e) { return null; } }
@NotNull @Override public FormattingModel createModel(PsiElement psiElement, CodeStyleSettings settings) { SpacingBuilder spacingBuilder = createSpaceBuilder(settings); final FusionBlock block = new FusionBlock(psiElement.getNode(), null, null, settings, spacingBuilder); return FormattingModelProvider.createFormattingModelForPsiFile(psiElement.getContainingFile(), block, settings); }