use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class GantScriptType method additionalScopeFiles.
public static List<VirtualFile> additionalScopeFiles(@NotNull GroovyFile file) {
final Module module = ModuleUtilCore.findModuleForPsiElement(file);
if (module != null) {
final String sdkHome = GantUtils.getSdkHomeFromClasspath(module);
if (sdkHome != null) {
return Collections.emptyList();
}
}
final GantSettings gantSettings = GantSettings.getInstance(file.getProject());
final VirtualFile home = gantSettings.getSdkHome();
if (home == null) {
return Collections.emptyList();
}
return gantSettings.getClassRoots();
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class GrabDependencies method invoke.
@Override
public void invoke(@NotNull final Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
final Module module = ModuleUtilCore.findModuleForPsiElement(file);
assert module != null;
final VirtualFile vfile = file.getOriginalFile().getVirtualFile();
assert vfile != null;
if (JavaPsiFacade.getInstance(project).findClass("org.apache.ivy.core.report.ResolveReport", file.getResolveScope()) == null) {
Messages.showErrorDialog("Sorry, but IDEA cannot @Grab the dependencies without Ivy. Please add Ivy to your module dependencies and re-run the action.", "Ivy Missing");
return;
}
Map<String, String> queries = prepareQueries(file);
final Map<String, GeneralCommandLine> lines = new HashMap<>();
for (String grabText : queries.keySet()) {
final JavaParameters javaParameters = GroovyScriptRunConfiguration.createJavaParametersWithSdk(module);
try {
DefaultGroovyScriptRunner.configureGenericGroovyRunner(javaParameters, module, GRAPE_RUNNER, false, true);
javaParameters.getClassPath().add(PathUtil.getJarPathForClass(GrapeRunner.class));
javaParameters.getProgramParametersList().add(queries.get(grabText));
javaParameters.setUseDynamicClasspath(true);
lines.put(grabText, javaParameters.toCommandLine());
} catch (CantRunException e) {
String title = "Can't run @Grab: " + ExceptionUtil.getMessage(e);
NOTIFICATION_GROUP.createNotification(title, ExceptionUtil.getThrowableText(e), NotificationType.ERROR, null).notify(project);
return;
}
}
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Processing @Grab Annotations") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
int jarCount = 0;
String messages = "";
for (Map.Entry<String, GeneralCommandLine> entry : lines.entrySet()) {
String grabText = entry.getKey();
indicator.setText2(grabText);
try {
final GrapeProcessHandler handler = new GrapeProcessHandler(entry.getValue(), module);
handler.startNotify();
handler.waitFor();
jarCount += handler.jarCount;
messages += "<b>" + grabText + "</b>: " + handler.messages + "<p>";
} catch (ExecutionException e) {
LOG.error(e);
}
}
final String finalMessages = messages;
final String title = jarCount + " Grape dependency jar" + (jarCount == 1 ? "" : "s") + " added";
NOTIFICATION_GROUP.createNotification(title, finalMessages, NotificationType.INFORMATION, null).notify(project);
}
});
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class GriffonDefaultImportContributor method appendImplicitlyImportedPackages.
@NotNull
@Override
public List<String> appendImplicitlyImportedPackages(@NotNull GroovyFile file) {
Module module = ModuleUtilCore.findModuleForPsiElement(file);
MvcFramework framework = MvcFramework.getInstance(module);
if (framework instanceof GriffonFramework) {
ArrayList<String> result = new ArrayList<>();
result.add("griffon.core");
result.add("griffon.util");
VirtualFile griffonApp = framework.findAppDirectory(file);
if (griffonApp != null) {
VirtualFile models = griffonApp.findChild("models");
VirtualFile views = griffonApp.findChild("views");
VirtualFile vFile = file.getOriginalFile().getVirtualFile();
assert vFile != null;
assert module != null;
if (models != null && VfsUtilCore.isAncestor(models, vFile, true)) {
result.addAll(getDefaultImports(module).first);
} else if (views != null && VfsUtilCore.isAncestor(views, vFile, true)) {
result.addAll(getDefaultImports(module).second);
}
}
return result;
}
return Collections.emptyList();
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class SceneBuilderImpl method isCompatibleLanguageLevel.
private static boolean isCompatibleLanguageLevel(@NotNull PsiClass aClass, @Nullable LanguageLevel targetLevel) {
if (targetLevel == null)
return true;
final Project project = aClass.getProject();
final VirtualFile vFile = PsiUtilCore.getVirtualFile(aClass);
if (vFile == null)
return true;
Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(vFile);
if (module == null) {
final OrderEntry entry = LibraryUtil.findLibraryEntry(vFile, project);
if (entry != null) {
module = entry.getOwnerModule();
}
}
Sdk jdk = module != null ? ModuleRootManager.getInstance(module).getSdk() : null;
if (jdk == null) {
jdk = ProjectRootManager.getInstance(project).getProjectSdk();
}
if (jdk == null)
return true;
final String versionString = jdk.getVersionString();
if (versionString != null) {
final JavaSdkVersion jdkVersion = JdkVersionUtil.getVersion(versionString);
if (jdkVersion != null) {
return targetLevel.isAtLeast(jdkVersion.getMaxLanguageLevel());
}
}
return true;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class JavaFxArtifactProperties method onBuildFinished.
@Override
public void onBuildFinished(@NotNull final Artifact artifact, @NotNull final CompileContext compileContext) {
if (!(artifact.getArtifactType() instanceof JavaFxApplicationArtifactType)) {
return;
}
final Project project = compileContext.getProject();
final Set<Module> modules = ReadAction.compute(() -> ArtifactUtil.getModulesIncludedInArtifacts(Collections.singletonList(artifact), project));
if (modules.isEmpty()) {
return;
}
Sdk fxCompatibleSdk = null;
for (Module module : modules) {
final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk != null && sdk.getSdkType() instanceof JavaSdk) {
if (((JavaSdk) sdk.getSdkType()).isOfVersionOrHigher(sdk, JavaSdkVersion.JDK_1_7)) {
fxCompatibleSdk = sdk;
break;
}
}
}
if (fxCompatibleSdk == null) {
compileContext.addMessage(CompilerMessageCategory.ERROR, "Java version 7 or higher is required to build JavaFX package", null, -1, -1);
return;
}
final JavaFxArtifactProperties properties = (JavaFxArtifactProperties) artifact.getProperties(JavaFxArtifactPropertiesProvider.getInstance());
final JavaFxPackager javaFxPackager = new JavaFxPackager(artifact, properties, project) {
@Override
protected void registerJavaFxPackagerError(String message) {
compileContext.addMessage(CompilerMessageCategory.ERROR, message, null, -1, -1);
}
};
javaFxPackager.buildJavaFxArtifact(fxCompatibleSdk.getHomePath());
}
Aggregations