use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class GroovyHotSwapper method patchJavaParameters.
@Override
public void patchJavaParameters(Executor executor, RunProfile configuration, JavaParameters javaParameters) {
ApplicationManager.getApplication().assertReadAccessAllowed();
if (!executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) {
return;
}
if (!GroovyDebuggerSettings.getInstance().ENABLE_GROOVY_HOTSWAP) {
return;
}
if (hasSpringLoadedReloader(javaParameters)) {
return;
}
if (!(configuration instanceof RunConfiguration)) {
return;
}
final Project project = ((RunConfiguration) configuration).getProject();
if (project == null) {
return;
}
if (!LanguageLevelProjectExtension.getInstance(project).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) {
return;
}
if (configuration instanceof ModuleBasedConfiguration) {
final Module module = ((ModuleBasedConfiguration) configuration).getConfigurationModule().getModule();
if (module != null) {
final LanguageLevel level = LanguageLevelModuleExtensionImpl.getInstance(module).getLanguageLevel();
if (level != null && !level.isAtLeast(LanguageLevel.JDK_1_5)) {
return;
}
}
}
Sdk jdk = javaParameters.getJdk();
if (jdk != null) {
String vendor = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VENDOR);
if (vendor != null && vendor.contains("IBM")) {
LOG.info("Due to IBM JDK peculiarities (IDEA-59070) we don't add Groovy agent when running applications under it");
return;
}
}
if (!project.isDefault() && containsGroovyClasses(project)) {
final String agentPath = handleSpacesInPath(getAgentJarPath());
if (agentPath != null) {
javaParameters.getVMParametersList().add("-javaagent:" + agentPath);
}
}
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class MavenModuleImporter method configLanguageLevel.
private void configLanguageLevel() {
if ("false".equalsIgnoreCase(System.getProperty("idea.maven.configure.language.level")))
return;
LanguageLevel level = null;
Element cfg = myMavenProject.getPluginConfiguration("com.googlecode", "maven-idea-plugin");
if (cfg != null) {
level = MAVEN_IDEA_PLUGIN_LEVELS.get(cfg.getChildTextTrim("jdkLevel"));
}
if (level == null) {
level = LanguageLevel.parse(myMavenProject.getSourceLevel());
}
// default source and target settings of maven-compiler-plugin is 1.5, see details at http://maven.apache.org/plugins/maven-compiler-plugin
if (level == null) {
level = LanguageLevel.JDK_1_5;
}
myRootModelAdapter.setLanguageLevel(level);
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class Java15FormInspection method checkComponentProperties.
protected void checkComponentProperties(Module module, final IComponent component, final FormErrorCollector collector) {
final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
final PsiManager psiManager = PsiManager.getInstance(module.getProject());
final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
if (aClass == null) {
return;
}
for (final IProperty prop : component.getModifiedProperties()) {
final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, prop.getName(), false, true);
if (getter == null)
continue;
final LanguageLevel languageLevel = LanguageLevelUtil.getEffectiveLanguageLevel(module);
if (Java15APIUsageInspection.getLastIncompatibleLanguageLevel(getter, languageLevel) != null) {
registerError(component, collector, prop, "@since " + Java15APIUsageInspection.getShortName(languageLevel));
}
}
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class SceneBuilderImpl method collectCustomComponents.
private Collection<CustomComponent> collectCustomComponents() {
if (myProject.isDisposed()) {
return Collections.emptyList();
}
final PsiClass nodeClass = JavaPsiFacade.getInstance(myProject).findClass(JavaFxCommonNames.JAVAFX_SCENE_NODE, GlobalSearchScope.allScope(myProject));
if (nodeClass == null) {
return Collections.emptyList();
}
final Collection<PsiClass> psiClasses = CachedValuesManager.getCachedValue(nodeClass, () -> {
// Take custom components from libraries, but not from the project modules, because SceneBuilder instantiates the components' classes.
// Modules might be not compiled or may change since last compile, it's too expensive to keep track of that.
final GlobalSearchScope scope = ProjectScope.getLibrariesScope(nodeClass.getProject());
final String ideJdkVersion = Object.class.getPackage().getSpecificationVersion();
final LanguageLevel ideLanguageLevel = LanguageLevel.parse(ideJdkVersion);
final Query<PsiClass> query = ClassInheritorsSearch.search(nodeClass, scope, true, true, false);
final Set<PsiClass> result = new THashSet<>();
query.forEach(psiClass -> {
if (psiClass.hasModifierProperty(PsiModifier.PUBLIC) && !psiClass.hasModifierProperty(PsiModifier.ABSTRACT) && !isBuiltInComponent(psiClass) && isCompatibleLanguageLevel(psiClass, ideLanguageLevel)) {
result.add(psiClass);
}
});
return CachedValueProvider.Result.create(result, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
});
if (psiClasses.isEmpty()) {
return Collections.emptyList();
}
return prepareCustomComponents(psiClasses);
}
use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.
the class CompileDriver method validateCompilerConfiguration.
private boolean validateCompilerConfiguration(final CompileScope scope) {
try {
final Module[] scopeModules = scope.getAffectedModules();
final List<String> modulesWithoutOutputPathSpecified = new ArrayList<>();
final List<String> modulesWithoutJdkAssigned = new ArrayList<>();
final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
for (final Module module : scopeModules) {
if (!compilerManager.isValidationEnabled(module)) {
continue;
}
final boolean hasSources = hasSources(module, JavaSourceRootType.SOURCE);
final boolean hasTestSources = hasSources(module, JavaSourceRootType.TEST_SOURCE);
if (!hasSources && !hasTestSources) {
// todo still there may be problems with this approach if some generated files are attributed by this module
continue;
}
final Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
if (jdk == null) {
modulesWithoutJdkAssigned.add(module.getName());
}
final String outputPath = getModuleOutputPath(module, false);
final String testsOutputPath = getModuleOutputPath(module, true);
if (outputPath == null && testsOutputPath == null) {
modulesWithoutOutputPathSpecified.add(module.getName());
} else {
if (outputPath == null) {
if (hasSources) {
modulesWithoutOutputPathSpecified.add(module.getName());
}
}
if (testsOutputPath == null) {
if (hasTestSources) {
modulesWithoutOutputPathSpecified.add(module.getName());
}
}
}
}
if (!modulesWithoutJdkAssigned.isEmpty()) {
showNotSpecifiedError("error.jdk.not.specified", modulesWithoutJdkAssigned, ProjectBundle.message("modules.classpath.title"));
return false;
}
if (!modulesWithoutOutputPathSpecified.isEmpty()) {
showNotSpecifiedError("error.output.not.specified", modulesWithoutOutputPathSpecified, CommonContentEntriesEditor.NAME);
return false;
}
final List<Chunk<ModuleSourceSet>> chunks = ModuleCompilerUtil.getCyclicDependencies(myProject, Arrays.asList(scopeModules));
for (final Chunk<ModuleSourceSet> chunk : chunks) {
final Set<ModuleSourceSet> sourceSets = chunk.getNodes();
if (sourceSets.size() <= 1) {
// no need to check one-module chunks
continue;
}
Sdk jdk = null;
LanguageLevel languageLevel = null;
for (final ModuleSourceSet sourceSet : sourceSets) {
Module module = sourceSet.getModule();
final Sdk moduleJdk = ModuleRootManager.getInstance(module).getSdk();
if (jdk == null) {
jdk = moduleJdk;
} else {
if (!jdk.equals(moduleJdk)) {
showCyclicModulesHaveDifferentJdksError(ModuleSourceSet.getModules(sourceSets));
return false;
}
}
LanguageLevel moduleLanguageLevel = EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(module);
if (languageLevel == null) {
languageLevel = moduleLanguageLevel;
} else {
if (!languageLevel.equals(moduleLanguageLevel)) {
showCyclicModulesHaveDifferentLanguageLevel(ModuleSourceSet.getModules(sourceSets));
return false;
}
}
}
}
return true;
} catch (Throwable e) {
LOG.info(e);
return false;
}
}
Aggregations