use of com.intellij.psi.codeStyle.JavaCodeStyleSettings in project intellij-community by JetBrains.
the class UnnecessaryFullyQualifiedNameFixTest method doTest.
private void doTest(@Language("JAVA") @NotNull @NonNls String before, @Language("JAVA") @NotNull @NonNls String after, @MagicConstant(intValues = { JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_ALWAYS, JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_IF_NOT_IMPORTED, JavaCodeStyleSettings.SHORTEN_NAMES_ALWAYS_AND_ADD_IMPORT }) int classNamesInJavadoc, String fileName) {
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
final JavaCodeStyleSettings javaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class);
final int oldClassNamesInJavadoc = javaSettings.CLASS_NAMES_IN_JAVADOC;
try {
javaSettings.CLASS_NAMES_IN_JAVADOC = classNamesInJavadoc;
doTest(InspectionGadgetsBundle.message("unnecessary.fully.qualified.name.replace.quickfix"), before, after, fileName);
} finally {
javaSettings.CLASS_NAMES_IN_JAVADOC = oldClassNamesInJavadoc;
}
}
use of com.intellij.psi.codeStyle.JavaCodeStyleSettings in project intellij-community by JetBrains.
the class JavaRearranger method getBlankLines.
@Override
public int getBlankLines(@NotNull CodeStyleSettings settings, @Nullable JavaElementArrangementEntry parent, @Nullable JavaElementArrangementEntry previous, @NotNull JavaElementArrangementEntry target) {
if (previous == null) {
return -1;
}
CommonCodeStyleSettings commonSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
JavaCodeStyleSettings javaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class);
if (FIELD.equals(target.getType())) {
if (parent != null && parent.getType() == INTERFACE) {
return commonSettings.BLANK_LINES_AROUND_FIELD_IN_INTERFACE;
} else if (INIT_BLOCK.equals(previous.getType())) {
return javaSettings.BLANK_LINES_AROUND_INITIALIZER;
} else {
return commonSettings.BLANK_LINES_AROUND_FIELD;
}
} else if (METHOD.equals(target.getType())) {
if (parent != null && parent.getType() == INTERFACE) {
return commonSettings.BLANK_LINES_AROUND_METHOD_IN_INTERFACE;
} else {
return commonSettings.BLANK_LINES_AROUND_METHOD;
}
} else if (CLASS.equals(target.getType())) {
return commonSettings.BLANK_LINES_AROUND_CLASS;
} else if (INIT_BLOCK.equals(target.getType())) {
return javaSettings.BLANK_LINES_AROUND_INITIALIZER;
} else {
return -1;
}
}
use of com.intellij.psi.codeStyle.JavaCodeStyleSettings in project intellij-community by JetBrains.
the class JavaFormattingModelBuilder method createModel.
@Override
@NotNull
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
final FileElement fileElement = TreeUtil.getFileElement((TreeElement) SourceTreeToPsiMap.psiElementToTree(element));
LOG.assertTrue(fileElement != null, "File element should not be null for " + element);
CommonCodeStyleSettings commonSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
JavaCodeStyleSettings customJavaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class);
Block block = AbstractJavaBlock.newJavaBlock(fileElement, commonSettings, customJavaSettings);
FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile());
return new PsiBasedFormatterModelWithShiftIndentInside(element.getContainingFile(), block, model);
}
use of com.intellij.psi.codeStyle.JavaCodeStyleSettings in project intellij-community by JetBrains.
the class MigrateTypeSignatureTest method testSpecJavadoc.
public void testSpecJavadoc() throws Exception {
JavaCodeStyleSettings settings = getCurrentCodeStyleSettings().getCustomSettings(JavaCodeStyleSettings.class);
settings.CLASS_NAMES_IN_JAVADOC = JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_ALWAYS;
doTestFirstParamType("meth", "Spec", myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null));
}
use of com.intellij.psi.codeStyle.JavaCodeStyleSettings in project intellij-community by JetBrains.
the class FullyQualifiedNamesInJavadocOptionProvider method apply.
public void apply(@NotNull CodeStyleSettings settings) {
JavaCodeStyleSettings javaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class);
javaSettings.CLASS_NAMES_IN_JAVADOC = getSelectedIntOptionValue();
}
Aggregations