Search in sources :

Example 11 with CompileContext

use of com.intellij.openapi.compiler.CompileContext in project azure-tools-for-java by Microsoft.

the class IDEHelperImpl method buildArtifact.

private static ListenableFuture<Boolean> buildArtifact(@NotNull Project project, @NotNull final Artifact artifact, boolean rebuild) {
    final SettableFuture<Boolean> future = SettableFuture.create();
    Set<Artifact> artifacts = new LinkedHashSet<Artifact>(1);
    artifacts.add(artifact);
    CompileScope scope = ArtifactCompileScope.createArtifactsScope(project, artifacts, rebuild);
    ArtifactsWorkspaceSettings.getInstance(project).setArtifactsToBuild(artifacts);
    CompilerManager.getInstance(project).make(scope, new CompileStatusNotification() {

        @Override
        public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
            future.set(!aborted && errors == 0);
        }
    });
    return future;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CompileStatusNotification(com.intellij.openapi.compiler.CompileStatusNotification) ArtifactCompileScope(com.intellij.packaging.impl.compiler.ArtifactCompileScope) CompileScope(com.intellij.openapi.compiler.CompileScope) CompileContext(com.intellij.openapi.compiler.CompileContext) Artifact(com.intellij.packaging.artifacts.Artifact)

Example 12 with CompileContext

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

the class JavaAutoRunManager method createWatcher.

@NotNull
@Override
protected AutoTestWatcher createWatcher(Project project) {
    return new AutoTestWatcher() {

        private boolean myHasErrors = false;

        private CompilationStatusListener myStatusListener;

        @Override
        public void activate() {
            if (myStatusListener == null) {
                myStatusListener = new CompilationStatusListener() {

                    private boolean myFoundFilesToMake = false;

                    @Override
                    public void compilationFinished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
                        if (!myFoundFilesToMake)
                            return;
                        if (errors == 0) {
                            restartAllAutoTests(0);
                        }
                        myHasErrors = errors == 0;
                        myFoundFilesToMake = false;
                    }

                    @Override
                    public void automakeCompilationFinished(int errors, int warnings, CompileContext compileContext) {
                        compilationFinished(false, errors, warnings, compileContext);
                    }

                    @Override
                    public void fileGenerated(String outputRoot, String relativePath) {
                        myFoundFilesToMake = true;
                    }
                };
                CompilerManager.getInstance(project).addCompilationStatusListener(myStatusListener, project);
            }
        }

        @Override
        public void deactivate() {
            if (myStatusListener != null) {
                CompilerManager.getInstance(project).removeCompilationStatusListener(myStatusListener);
            }
        }

        @Override
        public boolean isUpToDate(int modificationStamp) {
            return !myHasErrors;
        }
    };
}
Also used : AutoTestWatcher(com.intellij.execution.testframework.autotest.AutoTestWatcher) CompilationStatusListener(com.intellij.openapi.compiler.CompilationStatusListener) CompileContext(com.intellij.openapi.compiler.CompileContext) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with CompileContext

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

the class BaseClassesAnalysisAction method compileAndAnalyze.

private void compileAndAnalyze(@NotNull Project project, @NotNull AnalysisScope scope) {
    if (project.isDisposed()) {
        return;
    }
    final CompilerManager compilerManager = CompilerManager.getInstance(project);
    compilerManager.make(compilerManager.createProjectCompileScope(project), new CompileStatusNotification() {

        @Override
        public void finished(final boolean aborted, final int errors, final int warnings, final CompileContext compileContext) {
            if (aborted || errors != 0)
                return;
            ApplicationManager.getApplication().invokeLater(() -> doAnalyze(project, scope));
        }
    });
}
Also used : CompileStatusNotification(com.intellij.openapi.compiler.CompileStatusNotification) CompilerManager(com.intellij.openapi.compiler.CompilerManager) CompileContext(com.intellij.openapi.compiler.CompileContext)

Example 14 with CompileContext

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

the class ShowSerializedXmlAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final PsiClass psiClass = getPsiClass(e);
    if (psiClass == null)
        return;
    final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
    final Module module = ModuleUtilCore.findModuleForPsiElement(psiClass);
    if (module == null || virtualFile == null)
        return;
    final String className = ClassUtil.getJVMClassName(psiClass);
    final Project project = getEventProject(e);
    CompilerManager.getInstance(project).make(new FileSetCompileScope(Collections.singletonList(virtualFile), new Module[] { module }), new CompileStatusNotification() {

        @Override
        public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
            if (aborted || errors > 0)
                return;
            generateAndShowXml(module, className);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) CompileStatusNotification(com.intellij.openapi.compiler.CompileStatusNotification) PsiClass(com.intellij.psi.PsiClass) Module(com.intellij.openapi.module.Module) CompileContext(com.intellij.openapi.compiler.CompileContext) FileSetCompileScope(com.intellij.compiler.impl.FileSetCompileScope)

Example 15 with CompileContext

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

the class GradleStartupActivity method runActivity.

@Override
public void runActivity(@NotNull final Project project) {
    configureBuildClasspath(project);
    showNotificationForUnlinkedGradleProject(project);
    final GradleResourceCompilerConfigurationGenerator buildConfigurationGenerator = new GradleResourceCompilerConfigurationGenerator(project);
    CompilerManager.getInstance(project).addBeforeTask(new CompileTask() {

        @Override
        public boolean execute(CompileContext context) {
            AccessToken token = ReadAction.start();
            try {
                buildConfigurationGenerator.generateBuildConfiguration(context);
            } finally {
                token.finish();
            }
            return true;
        }
    });
}
Also used : GradleResourceCompilerConfigurationGenerator(org.jetbrains.plugins.gradle.config.GradleResourceCompilerConfigurationGenerator) CompileTask(com.intellij.openapi.compiler.CompileTask) AccessToken(com.intellij.openapi.application.AccessToken) CompileContext(com.intellij.openapi.compiler.CompileContext)

Aggregations

CompileContext (com.intellij.openapi.compiler.CompileContext)18 CompilerManager (com.intellij.openapi.compiler.CompilerManager)9 CompileStatusNotification (com.intellij.openapi.compiler.CompileStatusNotification)8 CompileTask (com.intellij.openapi.compiler.CompileTask)6 Module (com.intellij.openapi.module.Module)5 Project (com.intellij.openapi.project.Project)5 CompileScope (com.intellij.openapi.compiler.CompileScope)4 AccessToken (com.intellij.openapi.application.AccessToken)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 ArtifactCompileScope (com.intellij.packaging.impl.compiler.ArtifactCompileScope)3 FileSetCompileScope (com.intellij.compiler.impl.FileSetCompileScope)2 CompilationStatusListener (com.intellij.openapi.compiler.CompilationStatusListener)2 NotNull (org.jetbrains.annotations.NotNull)2 GradleResourceCompilerConfigurationGenerator (org.jetbrains.plugins.gradle.config.GradleResourceCompilerConfigurationGenerator)2 AndroidGradleBuildConfiguration (com.android.tools.idea.gradle.project.build.compiler.AndroidGradleBuildConfiguration)1 PsiClassWriter (com.intellij.compiler.PsiClassWriter)1 CompileContextImpl (com.intellij.compiler.impl.CompileContextImpl)1 ModuleCompileScope (com.intellij.compiler.impl.ModuleCompileScope)1 InstrumentationClassFinder (com.intellij.compiler.instrumentation.InstrumentationClassFinder)1 CompilerTask (com.intellij.compiler.progress.CompilerTask)1