use of com.intellij.openapi.compiler.CompilerManager in project android by JetBrains.
the class IdeFrameFixture method invokeProjectMakeUsingJps.
@NotNull
public CompileContext invokeProjectMakeUsingJps() {
Project project = getProject();
AndroidGradleBuildConfiguration buildConfiguration = AndroidGradleBuildConfiguration.getInstance(project);
buildConfiguration.USE_EXPERIMENTAL_FASTER_BUILD = false;
AtomicReference<CompileContext> contextRef = new AtomicReference<>();
CompilerManager compilerManager = CompilerManager.getInstance(project);
Disposable disposable = new NoOpDisposable();
compilerManager.addCompilationStatusListener(new CompilationStatusListener() {
@Override
public void compilationFinished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
contextRef.set(compileContext);
}
}, disposable);
try {
selectProjectMakeAction();
Wait.seconds(10).expecting("Build (" + COMPILE_JAVA + ") for project " + quote(project.getName()) + " to finish'").until(() -> contextRef.get() != null);
return contextRef.get();
} finally {
Disposer.dispose(disposable);
}
}
use of com.intellij.openapi.compiler.CompilerManager in project intellij-plugins by JetBrains.
the class FlexCompilerHandler method projectOpened.
public void projectOpened() {
CompilerManager compilerManager = CompilerManager.getInstance(myProject);
if (compilerManager != null) {
compilerManager.addBeforeTask(new ValidateFlashConfigurationsPrecompileTask());
compilerManager.addBeforeTask(new FlexUnitPrecompileTask(myProject));
compilerManager.addAfterTask(new FlexUnitAfterCompileTask());
compilerManager.setValidationEnabled(FlexModuleType.getInstance(), false);
}
myWidget = new ActiveBuildConfigurationWidget(myProject);
}
use of com.intellij.openapi.compiler.CompilerManager in project intellij-community by JetBrains.
the class ClassFilesIndexFeaturesHolder method projectOpened.
@Override
public final void projectOpened() {
for (final ClassFilesIndexFeature feature : ClassFilesIndexFeature.values()) {
final RegistryValue registryValue = feature.getRegistryValue();
registryValue.addListener(new RegistryValueListener.Adapter() {
@Override
public void afterValueChanged(final RegistryValue rawValue) {
if (!rawValue.asBoolean() && myEnabledFeatures.containsKey(feature)) {
disposeFeature(feature);
}
}
}, myProject);
}
final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
compilerManager.addBeforeTask(new CompileTask() {
@Override
public boolean execute(final CompileContext context) {
close();
return true;
}
});
}
use of com.intellij.openapi.compiler.CompilerManager in project intellij-community by JetBrains.
the class CompileAction method getCompilableFiles.
private static VirtualFile[] getCompilableFiles(Project project, VirtualFile[] files) {
if (files == null || files.length == 0) {
return VirtualFile.EMPTY_ARRAY;
}
final PsiManager psiManager = PsiManager.getInstance(project);
final CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(project);
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final CompilerManager compilerManager = CompilerManager.getInstance(project);
final List<VirtualFile> filesToCompile = new ArrayList<>();
for (final VirtualFile file : files) {
if (!fileIndex.isInSourceContent(file)) {
continue;
}
if (!file.isInLocalFileSystem()) {
continue;
}
if (file.isDirectory()) {
final PsiDirectory directory = psiManager.findDirectory(file);
if (directory == null || JavaDirectoryService.getInstance().getPackage(directory) == null) {
continue;
}
} else {
FileType fileType = file.getFileType();
if (!(compilerManager.isCompilableFileType(fileType) || compilerConfiguration.isCompilableResourceFile(project, file))) {
continue;
}
}
filesToCompile.add(file);
}
return VfsUtilCore.toVirtualFileArray(filesToCompile);
}
use of com.intellij.openapi.compiler.CompilerManager in project intellij-community by JetBrains.
the class CompilerEncodingServiceImpl method computeModuleCharsetMap.
@NotNull
private Map<Module, Set<Charset>> computeModuleCharsetMap() {
final Map<Module, Set<Charset>> map = new THashMap<>();
final Map<VirtualFile, Charset> mappings = ((EncodingProjectManagerImpl) EncodingProjectManager.getInstance(myProject)).getAllMappings();
ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
for (Map.Entry<VirtualFile, Charset> entry : mappings.entrySet()) {
final VirtualFile file = entry.getKey();
final Charset charset = entry.getValue();
if (file == null || charset == null || (!file.isDirectory() && !compilerManager.isCompilableFileType(file.getFileType())) || !index.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES))
continue;
final Module module = index.getModuleForFile(file);
if (module == null)
continue;
Set<Charset> set = map.get(module);
if (set == null) {
set = new LinkedHashSet<>();
map.put(module, set);
final VirtualFile sourceRoot = index.getSourceRootForFile(file);
VirtualFile current = file.getParent();
Charset parentCharset = null;
while (current != null) {
final Charset currentCharset = mappings.get(current);
if (currentCharset != null) {
parentCharset = currentCharset;
}
if (current.equals(sourceRoot)) {
break;
}
current = current.getParent();
}
if (parentCharset != null) {
set.add(parentCharset);
}
}
set.add(charset);
}
//todo[nik,jeka] perhaps we should take into account encodings of source roots only not individual files
for (Module module : ModuleManager.getInstance(myProject).getModules()) {
for (VirtualFile file : ModuleRootManager.getInstance(module).getSourceRoots(true)) {
Charset encoding = EncodingProjectManager.getInstance(myProject).getEncoding(file, true);
if (encoding != null) {
Set<Charset> charsets = map.get(module);
if (charsets == null) {
charsets = new LinkedHashSet<>();
map.put(module, charsets);
}
charsets.add(encoding);
}
}
}
return map;
}
Aggregations