use of com.intellij.pom.java.LanguageLevel in project android by JetBrains.
the class JavaLanguageLevelModuleSetupStep method doSetUpModule.
@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull JavaModuleModel javaModuleModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
LanguageLevel languageLevel = javaModuleModel.getJavaLanguageLevel();
if (languageLevel == null) {
// Java language is still not correct. Most likely this module does not have dependents.
// Get minimum language level from all Android modules.
languageLevel = getMinimumLanguageLevelForAndroidModules(ideModelsProvider);
}
if (languageLevel == null) {
// The minimum safe Java language level.
languageLevel = JDK_1_6;
}
ModifiableRootModel rootModel = ideModelsProvider.getModifiableRootModel(module);
LanguageLevelModuleExtensionImpl moduleExtension = rootModel.getModuleExtension(LanguageLevelModuleExtensionImpl.class);
moduleExtension.setLanguageLevel(languageLevel);
}
use of com.intellij.pom.java.LanguageLevel in project android by JetBrains.
the class PostProjectBuildTasksExecutorTest method testGetMaxJavaLangLevel4.
public void testGetMaxJavaLangLevel4() {
expect(myAndroidModel1.getDataBindingEnabled()).andStubReturn(false);
expect(myAndroidModel2.getDataBindingEnabled()).andStubReturn(false);
expect(myAndroidModel1.getJavaLanguageLevel()).andStubReturn(LanguageLevel.JDK_1_6);
expect(myAndroidModel2.getJavaLanguageLevel()).andStubReturn(LanguageLevel.JDK_1_6);
replay(myAndroidModel1, myAndroidModel2);
addAndroidModelToFacet(myModule, myAndroidModel1);
addAndroidModelToFacet(myModule2, myAndroidModel2);
LanguageLevel maxJavaLangLevel = myExecutor.getMaxJavaLangLevel();
assertEquals(LanguageLevel.JDK_1_6, maxJavaLangLevel);
verify(myAndroidModel1, myAndroidModel2);
}
use of com.intellij.pom.java.LanguageLevel in project android by JetBrains.
the class PostProjectBuildTasksExecutorTest method testGetMaxJavaLangLevel3.
public void testGetMaxJavaLangLevel3() {
expect(myAndroidModel1.getDataBindingEnabled()).andStubReturn(false);
expect(myAndroidModel2.getDataBindingEnabled()).andStubReturn(false);
expect(myAndroidModel1.getJavaLanguageLevel()).andStubReturn(LanguageLevel.JDK_1_7);
expect(myAndroidModel2.getJavaLanguageLevel()).andStubReturn(LanguageLevel.JDK_1_7);
replay(myAndroidModel1, myAndroidModel2);
addAndroidModelToFacet(myModule, myAndroidModel1);
addAndroidModelToFacet(myModule2, myAndroidModel2);
LanguageLevel maxJavaLangLevel = myExecutor.getMaxJavaLangLevel();
assertEquals(LanguageLevel.JDK_1_7, maxJavaLangLevel);
verify(myAndroidModel1, myAndroidModel2);
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class ProcessCandidateParameterTypeInferencePolicy method inferConstraint.
protected static Pair<PsiType, ConstraintType> inferConstraint(PsiTypeParameter typeParameter, PsiExpression innerMethodCall, int parameterIdx, PsiType innerReturnType, JavaResolveResult result, final PsiSubstitutor substitutor) {
final PsiElement element = result.getElement();
if (element instanceof PsiMethod) {
final PsiMethod method = (PsiMethod) element;
final PsiParameter[] parameters = method.getParameterList().getParameters();
PsiParameter parameter = null;
if (parameters.length > parameterIdx) {
parameter = parameters[parameterIdx];
} else if (method.isVarArgs()) {
parameter = parameters[parameters.length - 1];
}
if (parameter != null) {
final PsiParameter finalParameter = parameter;
PsiType type = PsiResolveHelper.ourGuard.doPreventingRecursion(innerMethodCall, true, () -> substitutor.substitute(finalParameter.getType()));
final LanguageLevel languageLevel = PsiUtil.getLanguageLevel(finalParameter);
final Pair<PsiType, ConstraintType> constraint = new PsiOldInferenceHelper(element.getManager()).getSubstitutionForTypeParameterConstraint(typeParameter, innerReturnType, type, false, languageLevel);
if (constraint != null)
return constraint;
}
}
return null;
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class CompletionStyleTest method testAfterNew15.
public void testAfterNew15() throws Exception {
final LanguageLevelProjectExtension ll = LanguageLevelProjectExtension.getInstance(getProject());
final LanguageLevel old = ll.getLanguageLevel();
ll.setLanguageLevel(LanguageLevel.JDK_1_5);
try {
final String path = BASE_PATH;
configureByFile(path + "/AfterNew15.java");
performSmartCompletion();
select('\n', getSelected());
checkResultByFile(path + "/AfterNew15-out.java");
} finally {
ll.setLanguageLevel(old);
}
}
Aggregations