use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class LanguageLevelCombo method sdkUpdated.
void sdkUpdated(Sdk sdk, boolean isDefaultProject) {
LanguageLevel newLevel = null;
if (sdk != null) {
JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
if (version != null) {
newLevel = version.getMaxLanguageLevel();
}
}
updateDefaultLevel(newLevel, isDefaultProject);
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class PsiScopesUtil method processQualifierType.
private static boolean processQualifierType(@NotNull final PsiType type, final MethodsProcessor processor, PsiManager manager, PsiMethodCallExpression call) throws MethodProcessorSetupFailedException {
LOG.assertTrue(type.isValid());
if (type instanceof PsiClassType) {
JavaResolveResult qualifierResult = ((PsiClassType) type).resolveGenerics();
return processQualifierResult(qualifierResult, processor, call);
}
if (type instanceof PsiArrayType) {
LanguageLevel languageLevel = PsiUtil.getLanguageLevel(call);
PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
JavaResolveResult qualifierResult = factory.getArrayClassType(((PsiArrayType) type).getComponentType(), languageLevel).resolveGenerics();
return processQualifierResult(qualifierResult, processor, call);
}
if (type instanceof PsiIntersectionType) {
for (PsiType conjunct : ((PsiIntersectionType) type).getConjuncts()) {
if (!processQualifierType(conjunct, processor, manager, call))
return false;
}
}
return true;
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class AnnotationFormatterTest method testEnumFormatting.
public void testEnumFormatting() throws Exception {
defaultSettings();
FormatterTestCase.getSettings(JavaLanguage.INSTANCE).ENUM_CONSTANTS_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS;
final LanguageLevel effectiveLanguageLevel = LanguageLevelProjectExtension.getInstance(LightPlatformTestCase.ourProject).getLanguageLevel();
try {
LanguageLevelProjectExtension.getInstance(LightPlatformTestCase.ourProject).setLanguageLevel(LanguageLevel.JDK_1_5);
doTextTest(" enum Breed {\n" + " Dalmatian ( \"spotted\" ),Labrador ( \"black\" ),Dachshund( \"brown\" );\n" + "\n" + " // constructor\n" + " Breed ( String colour )\n" + " {\n" + " this.colour = colour;\n" + " }\n" + "\n" + " private String colour;\n" + "\n" + " // additional method of every Breed object\n" + " public String getColour()\n" + " {\n" + " return colour;\n" + " }\n" + " }", "enum Breed {\n" + " Dalmatian(\"spotted\"),\n" + " Labrador(\"black\"),\n" + " Dachshund(\"brown\");\n" + "\n" + " // constructor\n" + " Breed(String colour) {\n" + " this.colour = colour;\n" + " }\n" + "\n" + " private String colour;\n" + "\n" + " // additional method of every Breed object\n" + " public String getColour() {\n" + " return colour;\n" + " }\n" + "}");
doTextTest(" enum Breed {\n" + " Dalmatian ( \"spotted\" ),Labrador ( \"black\" ),Dachshund( \"brown\" )\n" + " }", "enum Breed {\n" + " Dalmatian(\"spotted\"),\n" + " Labrador(\"black\"),\n" + " Dachshund(\"brown\")\n" + "}");
doTextTest("enum Command { \n" + " USED \n" + " , \n" + " UNUSED\n" + "; \n" + " }", "enum Command {\n" + " USED,\n" + " UNUSED;\n" + "}");
} finally {
LanguageLevelProjectExtension.getInstance(LightPlatformTestCase.ourProject).setLanguageLevel(effectiveLanguageLevel);
}
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class JavaFormatterTest method testAssertStatementWrapping2.
public void testAssertStatementWrapping2() throws Exception {
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
getSettings().ASSERT_STATEMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().RIGHT_MARGIN = 37;
final CommonCodeStyleSettings.IndentOptions options = getSettings().getRootSettings().getIndentOptions(StdFileTypes.JAVA);
options.INDENT_SIZE = 2;
options.CONTINUATION_INDENT_SIZE = 2;
getSettings().ASSERT_STATEMENT_COLON_ON_NEXT_LINE = true;
final JavaPsiFacade facade = getJavaFacade();
final LanguageLevel effectiveLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel();
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
try {
doTextTest("class Foo {\n" + " void foo() {\n" + " assert i + j + k + l + n + m <= 2 : \"assert description\";" + " }\n" + "}", "class Foo {\n" + " void foo() {\n" + " assert i + j + k + l + n + m <= 2\n" + " : \"assert description\";\n" + " }\n" + "}");
getSettings().ASSERT_STATEMENT_COLON_ON_NEXT_LINE = false;
doTextTest("class Foo {\n" + " void foo() {\n" + " assert i + j + k + l + n + m <= 2 : \"assert description\";" + " }\n" + "}", "class Foo {\n" + " void foo() {\n" + " assert\n" + " i + j + k + l + n + m <= 2 :\n" + " \"assert description\";\n" + " }\n" + "}");
} finally {
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(effectiveLanguageLevel);
}
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class JavaFormatterTest method testAssertStatementWrapping.
public void testAssertStatementWrapping() throws Exception {
getSettings().ASSERT_STATEMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
getSettings().BINARY_OPERATION_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
getSettings().RIGHT_MARGIN = 40;
final JavaPsiFacade facade = getJavaFacade();
final LanguageLevel effectiveLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel();
try {
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
getSettings().ASSERT_STATEMENT_COLON_ON_NEXT_LINE = false;
doTextTest("class Foo {\n" + " void foo() {\n" + " assert methodWithVeryVeryLongName() : foo;\n" + " assert i + j + k + l + n + m <= 2 : \"assert description\";\n" + " }\n" + "}\n", "class Foo {\n" + " void foo() {\n" + " assert methodWithVeryVeryLongName() :\n" + " foo;\n" + " assert i + j + k + l + n + m <= 2 :\n" + " \"assert description\";\n" + " }\n" + "}\n");
getSettings().ASSERT_STATEMENT_COLON_ON_NEXT_LINE = true;
doTextTest("class Foo {\n" + " void foo() {\n" + " assert methodWithVeryVeryLongName() : foo;\n" + " assert i + j + k + l + n + m <= 2 : \"assert description\";\n" + " }\n" + "}\n", "class Foo {\n" + " void foo() {\n" + " assert methodWithVeryVeryLongName()\n" + " : foo;\n" + " assert i + j + k + l + n + m <= 2\n" + " : \"assert description\";\n" + " }\n" + "}\n");
} finally {
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(effectiveLanguageLevel);
}
}
Aggregations