use of com.intellij.openapi.compiler.CompilerManager in project intellij-community by JetBrains.
the class PackageFileAction method getFilesToPackage.
@NotNull
private static List<VirtualFile> getFilesToPackage(@NotNull AnActionEvent e, @NotNull Project project) {
final VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (files == null)
return Collections.emptyList();
List<VirtualFile> result = new ArrayList<>();
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final CompilerManager compilerManager = CompilerManager.getInstance(project);
for (VirtualFile file : files) {
if (file == null || file.isDirectory() || fileIndex.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) && compilerManager.isCompilableFileType(file.getFileType())) {
return Collections.emptyList();
}
final Collection<? extends Artifact> artifacts = ArtifactBySourceFileFinder.getInstance(project).findArtifacts(file);
for (Artifact artifact : artifacts) {
if (!StringUtil.isEmpty(artifact.getOutputPath())) {
result.add(file);
break;
}
}
}
return result;
}
use of com.intellij.openapi.compiler.CompilerManager in project intellij-community by JetBrains.
the class InternalProjectTaskRunner method runModulesBuildTasks.
private static void runModulesBuildTasks(@NotNull Project project, @NotNull ProjectTaskContext context, @Nullable CompileStatusNotification compileNotification, @NotNull Map<Class<? extends ProjectTask>, List<ProjectTask>> tasksMap) {
Collection<? extends ProjectTask> buildTasks = tasksMap.get(ModuleBuildTask.class);
if (ContainerUtil.isEmpty(buildTasks))
return;
ModulesBuildSettings modulesBuildSettings = assembleModulesBuildSettings(buildTasks);
CompilerManager compilerManager = CompilerManager.getInstance(project);
CompileScope scope = createScope(compilerManager, context, modulesBuildSettings.modules, modulesBuildSettings.includeDependentModules, modulesBuildSettings.includeRuntimeDependencies);
if (modulesBuildSettings.isIncrementalBuild) {
compilerManager.make(scope, compileNotification);
} else {
compilerManager.compile(scope, compileNotification);
}
}
use of com.intellij.openapi.compiler.CompilerManager in project android by JetBrains.
the class GradleModuleTasksProvider method getAffectedModules.
@NotNull
private static Module[] getAffectedModules(@NotNull Project project, @NotNull Module[] modules) {
final CompilerManager compilerManager = CompilerManager.getInstance(project);
CompileScope scope = compilerManager.createModulesCompileScope(modules, true, true);
return scope.getAffectedModules();
}
use of com.intellij.openapi.compiler.CompilerManager in project intellij-plugins by JetBrains.
the class FlexIconProvider method getIcon.
@Override
public Icon getIcon(@NotNull PsiElement element, int flags) {
int transformedFlags = ElementBase.transformFlags(element, flags);
Icon icon = null;
if (element instanceof XmlFile) {
if (JavaScriptSupportLoader.isFlexMxmFile((PsiFile) element)) {
final JSClass jsClass = XmlBackedJSClassFactory.getXmlBackedClass((XmlFile) element);
if (jsClass != null) {
icon = jsClass.getIcon(flags);
}
}
} else if (element instanceof JSFileImpl) {
final JSNamedElement mainDeclaredElement = ActionScriptResolveUtil.findMainDeclaredElement((JSFileImpl) element);
if (mainDeclaredElement != null) {
icon = mainDeclaredElement.getIcon(transformedFlags);
}
}
if (icon != null) {
final PsiFile psiFile = element.getContainingFile();
final VirtualFile vFile = psiFile == null ? null : psiFile.getVirtualFile();
CompilerManager compilerManager = CompilerManager.getInstance(element.getProject());
if (vFile != null && compilerManager != null && compilerManager.isExcludedFromCompilation(vFile)) {
icon = new LayeredIcon(icon, PlatformIcons.EXCLUDED_FROM_COMPILE_ICON);
}
}
return icon;
}
use of com.intellij.openapi.compiler.CompilerManager in project android by JetBrains.
the class AndroidJunitPatcher method handleJavaResources.
/**
* Puts folders with merged java resources for the selected variant of every module on the classpath.
*
* <p>The problem we're solving here is that CompilerModuleExtension supports only one directory for "compiler output". When IJ compiles
* Java projects, it copies resources to the output classes dir. This is something our Gradle plugin doesn't do, so we need to add the
* resource directories to the classpath here.
*
* <p>We need to do this for every project dependency as well, since we're using classes and resources directories of these directly.
*
* @see <a href="http://b.android.com/172409">Bug 172409</a>
*/
private static void handleJavaResources(@NotNull Module module, @NotNull AndroidModuleModel androidModel, @NotNull PathsList classPath) {
CompilerManager compilerManager = CompilerManager.getInstance(module.getProject());
CompileScope scope = compilerManager.createModulesCompileScope(new Module[] { module }, true, true);
// The only test resources we want to use, are the ones from the module where the test is. They should go first, before main resources.
JavaArtifact testArtifact = androidModel.getUnitTestArtifactInSelectedVariant();
if (testArtifact != null) {
try {
classPath.add(testArtifact.getJavaResourcesFolder());
} catch (UnsupportedMethodException ignored) {
// Java resources were not present in older versions of the gradle plugin.
}
}
FileRootSearchScope excludeScope = null;
TestArtifactSearchScopes testScopes = TestArtifactSearchScopes.get(module);
if (testScopes != null) {
excludeScope = testScopes.getUnitTestExcludeScope();
}
for (Module affectedModule : scope.getAffectedModules()) {
AndroidFacet facet = AndroidFacet.getInstance(affectedModule);
if (facet != null) {
AndroidModuleModel affectedAndroidModel = AndroidModuleModel.get(facet);
if (affectedAndroidModel != null) {
try {
File resourceFolder = affectedAndroidModel.getMainArtifact().getJavaResourcesFolder();
if (excludeScope != null && excludeScope.accept(resourceFolder)) {
continue;
}
classPath.add(resourceFolder);
} catch (UnsupportedMethodException ignored) {
// Java resources were not present in older versions of the gradle plugin.
}
}
}
}
}
Aggregations