Search in sources :

Example 6 with JavaCodeStyleSettings

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;
    }
}
Also used : JavaCodeStyleSettings(com.intellij.psi.codeStyle.JavaCodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) JavaCodeStyleSettings(com.intellij.psi.codeStyle.JavaCodeStyleSettings)

Example 7 with JavaCodeStyleSettings

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;
    }
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) JavaCodeStyleSettings(com.intellij.psi.codeStyle.JavaCodeStyleSettings)

Example 8 with JavaCodeStyleSettings

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);
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) FileElement(com.intellij.psi.impl.source.tree.FileElement) Block(com.intellij.formatting.Block) AbstractJavaBlock(com.intellij.psi.formatter.java.AbstractJavaBlock) JavaCodeStyleSettings(com.intellij.psi.codeStyle.JavaCodeStyleSettings) FormattingDocumentModelImpl(com.intellij.psi.formatter.FormattingDocumentModelImpl) PsiBasedFormatterModelWithShiftIndentInside(com.intellij.psi.impl.source.codeStyle.PsiBasedFormatterModelWithShiftIndentInside) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with JavaCodeStyleSettings

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));
}
Also used : JavaCodeStyleSettings(com.intellij.psi.codeStyle.JavaCodeStyleSettings)

Example 10 with JavaCodeStyleSettings

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();
}
Also used : JavaCodeStyleSettings(com.intellij.psi.codeStyle.JavaCodeStyleSettings)

Aggregations

JavaCodeStyleSettings (com.intellij.psi.codeStyle.JavaCodeStyleSettings)13 CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)7 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)4 Block (com.intellij.formatting.Block)1 FormattingDocumentModelImpl (com.intellij.psi.formatter.FormattingDocumentModelImpl)1 AbstractJavaBlock (com.intellij.psi.formatter.java.AbstractJavaBlock)1 PsiBasedFormatterModelWithShiftIndentInside (com.intellij.psi.impl.source.codeStyle.PsiBasedFormatterModelWithShiftIndentInside)1 FileElement (com.intellij.psi.impl.source.tree.FileElement)1 NotNull (org.jetbrains.annotations.NotNull)1