use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class CodeStyleSchemesModel method differsFromDefault.
@Override
public boolean differsFromDefault(@NotNull CodeStyleScheme scheme) {
CodeStyleSettings defaults = CodeStyleSettings.getDefaults();
CodeStyleSettings clonedSettings = getCloneSettings(scheme);
return !defaults.equals(clonedSettings);
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class IndentOptionsDetectorImpl method calcLineIndentInfo.
@Nullable
private List<LineIndentInfo> calcLineIndentInfo(@Nullable ProgressIndicator indicator) {
if (myDocument == null || myDocument.getLineCount() < 3 || isFileBigToDetect()) {
return null;
}
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(myProject);
FormattingModelBuilder modelBuilder = LanguageFormatting.INSTANCE.forContext(myFile);
if (modelBuilder == null)
return null;
FormattingModel model = modelBuilder.createModel(myFile, settings);
Block rootBlock = model.getRootBlock();
return new FormatterBasedLineIndentInfoBuilder(myDocument, rootBlock, indicator).build();
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class PsiViewerDialog method buildBlocks.
@Nullable
private static Block buildBlocks(@NotNull PsiElement rootElement) {
FormattingModelBuilder formattingModelBuilder = LanguageFormatting.INSTANCE.forContext(rootElement);
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(rootElement.getProject());
if (formattingModelBuilder != null) {
FormattingModel formattingModel = formattingModelBuilder.createModel(rootElement, settings);
return formattingModel.getRootBlock();
} else {
return null;
}
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class SimpleIndentingBackspaceHandlerTest method testDeletingTabWhenIndentSizeIsSmaller.
public void testDeletingTabWhenIndentSizeIsSmaller() {
CodeStyleSettings settings = new CodeStyleSettings();
CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions();
assertNotNull(indentOptions);
indentOptions.INDENT_SIZE = 2;
indentOptions.TAB_SIZE = 4;
CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(settings);
try {
doTest("\t<caret>text", " <caret>text");
} finally {
CodeStyleSettingsManager.getInstance().dropTemporarySettings();
}
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class JDParamListOwnerComment method generateList.
/**
* Generates parameters or exceptions
*
*/
protected void generateList(@NotNull String prefix, @NotNull StringBuilder sb, @NotNull List<NameDesc> list, @NotNull String tag, boolean align_comments, boolean generate_empty_tags, boolean wrapDescription) {
CodeStyleSettings settings = myFormatter.getSettings();
CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(JavaFileType.INSTANCE);
String continuationIndent = new IndentInfo(0, indentOptions.CONTINUATION_INDENT_SIZE, 0).generateNewWhiteSpace(indentOptions);
int max = 0;
if (align_comments && !wrapDescription) {
for (NameDesc nd : list) {
int currentLength = nd.name.length();
if (isNull(nd.desc) && !generate_empty_tags)
continue;
//finding longest parameter length
if (currentLength > max) {
max = currentLength;
}
}
}
StringBuilder fill = new StringBuilder(prefix.length() + tag.length() + max + 1);
fill.append(prefix);
StringUtil.repeatSymbol(fill, ' ', max + 1 + tag.length());
String wrapParametersPrefix = prefix + continuationIndent;
for (NameDesc nd : list) {
if (isNull(nd.desc) && !generate_empty_tags)
continue;
if (wrapDescription && !isNull(nd.desc)) {
sb.append(prefix).append(tag).append(nd.name).append("\n");
sb.append(wrapParametersPrefix);
sb.append(myFormatter.getParser().formatJDTagDescription(nd.desc, wrapParametersPrefix));
} else if (align_comments) {
sb.append(prefix);
sb.append(tag);
sb.append(nd.name);
int spacesNumber = max + 1 - nd.name.length();
StringUtil.repeatSymbol(sb, ' ', Math.max(0, spacesNumber));
sb.append(myFormatter.getParser().formatJDTagDescription(nd.desc, fill));
} else {
sb.append(prefix);
String description = (nd.desc == null) ? "" : nd.desc;
sb.append(myFormatter.getParser().formatJDTagDescription(tag + nd.name + " " + description, prefix));
}
}
}
Aggregations