Search in sources :

Example 1 with CompilerManager

use of com.intellij.openapi.compiler.CompilerManager in project intellij-community by JetBrains.

the class MavenTasksManager method initComponent.

@Override
public void initComponent() {
    if (!isNormalProject())
        return;
    if (isInitialized.getAndSet(true))
        return;
    CompilerManager compilerManager = CompilerManager.getInstance(myProject);
    class MyCompileTask implements CompileTask {

        private final boolean myBefore;

        MyCompileTask(boolean before) {
            myBefore = before;
        }

        @Override
        public boolean execute(CompileContext context) {
            return doExecute(myBefore, context);
        }
    }
    compilerManager.addBeforeTask(new MyCompileTask(true));
    compilerManager.addAfterTask(new MyCompileTask(false));
}
Also used : CompileTask(com.intellij.openapi.compiler.CompileTask) CompilerManager(com.intellij.openapi.compiler.CompilerManager) CompileContext(com.intellij.openapi.compiler.CompileContext)

Example 2 with CompilerManager

use of com.intellij.openapi.compiler.CompilerManager in project intellij-community by JetBrains.

the class ValidationConfigurable method getValidators.

private List<Compiler> getValidators() {
    final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
    final List<Compiler> validators = new ArrayList<>();
    validators.addAll(Arrays.asList(compilerManager.getCompilers(Validator.class)));
    for (GenericCompiler compiler : compilerManager.getCompilers(GenericCompiler.class)) {
        if (compiler.getOrderPlace() == GenericCompiler.CompileOrderPlace.VALIDATING) {
            validators.add(compiler);
        }
    }
    return validators;
}
Also used : GenericCompiler(com.intellij.openapi.compiler.generic.GenericCompiler) Compiler(com.intellij.openapi.compiler.Compiler) CompilerManager(com.intellij.openapi.compiler.CompilerManager) GenericCompiler(com.intellij.openapi.compiler.generic.GenericCompiler)

Example 3 with CompilerManager

use of com.intellij.openapi.compiler.CompilerManager in project intellij-community by JetBrains.

the class CompilerConfigurationImpl method createCompilers.

private void createCompilers() {
    if (JAVAC_EXTERNAL_BACKEND != null) {
        return;
    }
    JAVAC_EXTERNAL_BACKEND = new JavacCompiler(myProject);
    myRegisteredCompilers.add(JAVAC_EXTERNAL_BACKEND);
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
        if (EclipseCompiler.isInitialized()) {
            final EclipseCompiler eclipse = new EclipseCompiler(myProject);
            myRegisteredCompilers.add(eclipse);
        }
    }
    final Set<FileType> types = new HashSet<>();
    for (BackendCompiler compiler : Extensions.getExtensions(BackendCompiler.EP_NAME, myProject)) {
        myRegisteredCompilers.add(compiler);
        types.addAll(compiler.getCompilableFileTypes());
    }
    final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
    for (FileType type : types) {
        compilerManager.addCompilableFileType(type);
    }
    myDefaultJavaCompiler = JAVAC_EXTERNAL_BACKEND;
    for (BackendCompiler compiler : myRegisteredCompilers) {
        if (compiler.getId().equals(myState.DEFAULT_COMPILER)) {
            myDefaultJavaCompiler = compiler;
            break;
        }
    }
    myState.DEFAULT_COMPILER = myDefaultJavaCompiler.getId();
}
Also used : EclipseCompiler(com.intellij.compiler.impl.javaCompiler.eclipse.EclipseCompiler) JavacCompiler(com.intellij.compiler.impl.javaCompiler.javac.JavacCompiler) FileType(com.intellij.openapi.fileTypes.FileType) CompilerManager(com.intellij.openapi.compiler.CompilerManager) BackendCompiler(com.intellij.compiler.impl.javaCompiler.BackendCompiler)

Example 4 with CompilerManager

use of com.intellij.openapi.compiler.CompilerManager in project intellij-community by JetBrains.

the class ExternalSystemTaskActivator method init.

public void init() {
    CompilerManager compilerManager = CompilerManager.getInstance(myProject);
    class MyCompileTask implements CompileTask {

        private final boolean myBefore;

        MyCompileTask(boolean before) {
            myBefore = before;
        }

        @Override
        public boolean execute(CompileContext context) {
            return doExecuteCompileTasks(myBefore, context);
        }
    }
    compilerManager.addBeforeTask(new MyCompileTask(true));
    compilerManager.addAfterTask(new MyCompileTask(false));
    fireTasksChanged();
}
Also used : CompileTask(com.intellij.openapi.compiler.CompileTask) CompilerManager(com.intellij.openapi.compiler.CompilerManager) CompileContext(com.intellij.openapi.compiler.CompileContext)

Example 5 with CompilerManager

use of com.intellij.openapi.compiler.CompilerManager in project intellij-community by JetBrains.

the class JavaCoverageEngine method recompileProjectAndRerunAction.

@Override
public boolean recompileProjectAndRerunAction(@NotNull final Module module, @NotNull final CoverageSuitesBundle suite, @NotNull final Runnable chooseSuiteAction) {
    final VirtualFile outputpath = CompilerModuleExtension.getInstance(module).getCompilerOutputPath();
    final VirtualFile testOutputpath = CompilerModuleExtension.getInstance(module).getCompilerOutputPathForTests();
    if ((outputpath == null && isModuleOutputNeeded(module, JavaSourceRootType.SOURCE)) || (suite.isTrackTestFolders() && testOutputpath == null && isModuleOutputNeeded(module, JavaSourceRootType.TEST_SOURCE))) {
        final Project project = module.getProject();
        if (suite.isModuleChecked(module))
            return false;
        suite.checkModule(module);
        final Runnable runnable = () -> {
            if (Messages.showOkCancelDialog("Project class files are out of date. Would you like to recompile? The refusal to do it will result in incomplete coverage information", "Project is out of date", Messages.getWarningIcon()) == Messages.OK) {
                final CompilerManager compilerManager = CompilerManager.getInstance(project);
                compilerManager.make(compilerManager.createProjectCompileScope(project), new CompileStatusNotification() {

                    public void finished(final boolean aborted, final int errors, final int warnings, final CompileContext compileContext) {
                        if (aborted || errors != 0)
                            return;
                        ApplicationManager.getApplication().invokeLater(() -> {
                            if (project.isDisposed())
                                return;
                            CoverageDataManager.getInstance(project).chooseSuitesBundle(suite);
                        });
                    }
                });
            } else if (!project.isDisposed()) {
                CoverageDataManager.getInstance(project).chooseSuitesBundle(null);
            }
        };
        ApplicationManager.getApplication().invokeLater(runnable);
        return true;
    }
    return false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) CompileStatusNotification(com.intellij.openapi.compiler.CompileStatusNotification) CompilerManager(com.intellij.openapi.compiler.CompilerManager) CompileContext(com.intellij.openapi.compiler.CompileContext)

Aggregations

CompilerManager (com.intellij.openapi.compiler.CompilerManager)22 CompileContext (com.intellij.openapi.compiler.CompileContext)9 Module (com.intellij.openapi.module.Module)6 CompileScope (com.intellij.openapi.compiler.CompileScope)5 CompileStatusNotification (com.intellij.openapi.compiler.CompileStatusNotification)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 NotNull (org.jetbrains.annotations.NotNull)5 CompileTask (com.intellij.openapi.compiler.CompileTask)3 Project (com.intellij.openapi.project.Project)3 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 FileType (com.intellij.openapi.fileTypes.FileType)2 ArtifactCompileScope (com.intellij.packaging.impl.compiler.ArtifactCompileScope)2 PsiFile (com.intellij.psi.PsiFile)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 JavaArtifact (com.android.builder.model.JavaArtifact)1 AndroidGradleBuildConfiguration (com.android.tools.idea.gradle.project.build.compiler.AndroidGradleBuildConfiguration)1 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)1 CompilerConfiguration (com.intellij.compiler.CompilerConfiguration)1