com.intellij.openapi.compiler.CompileStatusNotification Java Examples
The following examples show how to use
com.intellij.openapi.compiler.CompileStatusNotification.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractRefactoringPanel.java From IntelliJDeodorant with MIT License | 6 votes |
/** * Compiles the project and runs the task only if there are no compilation errors. */ private static void runAfterCompilationCheck(ProjectInfo projectInfo, Task task) { ApplicationManager.getApplication().invokeLater(() -> { List<PsiClass> classes = projectInfo.getClasses(); if (!classes.isEmpty()) { VirtualFile[] virtualFiles = classes.stream() .map(classObject -> classObject.getContainingFile().getVirtualFile()).toArray(VirtualFile[]::new); Project project = projectInfo.getProject(); CompilerManager compilerManager = CompilerManager.getInstance(project); CompileStatusNotification callback = (aborted, errors, warnings, compileContext) -> { if (errors == 0 && !aborted) { ProgressManager.getInstance().run(task); } else { task.onCancel(); AbstractRefactoringPanel.showCompilationErrorNotification(project); } }; CompileScope compileScope = compilerManager.createFilesCompileScope(virtualFiles); compilerManager.make(compileScope, callback); } else { ProgressManager.getInstance().run(task); } }); }
Example #2
Source File: CreateIpaAction.java From robovm-idea with GNU General Public License v2.0 | 6 votes |
public void actionPerformed(final AnActionEvent e) { final CreateIpaDialog dialog = new CreateIpaDialog(e.getProject()); dialog.show(); if(dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { // create IPA IpaConfig ipaConfig = dialog.getIpaConfig(); CompileScope scope = CompilerManager.getInstance(e.getProject()).createModuleCompileScope(ipaConfig.module, true); scope.putUserData(IPA_CONFIG_KEY, ipaConfig); CompilerManager.getInstance(e.getProject()).compile(scope, new CompileStatusNotification() { @Override public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) { RoboVmPlugin.logInfo(e.getProject(), "IPA creation complete, %d errors, %d warnings", errors, warnings); } }); } }
Example #3
Source File: ServerConnectionManager.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
@Override public void run() { compilerManager.make( moduleScope, new CompileStatusNotification() { public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) { getResponse().set(!aborted && errors == 0); } } ); }
Example #4
Source File: CompileProjectAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override protected void doAction(DataContext dataContext, final Project project) { CompilerManager.getInstance(project).rebuild(new CompileStatusNotification() { @Override public void finished(boolean aborted, int errors, int warnings, final CompileContext compileContext) { if (aborted) return; String text = getTemplatePresentation().getText(); LocalHistory.getInstance().putSystemLabel(project, errors == 0 ? CompilerBundle.message("rebuild.lvcs.label.no.errors", text) : CompilerBundle.message("rebuild.lvcs.label.with.errors", text)); } }); }
Example #5
Source File: ContentResourceChangeListener.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 4 votes |
private void executeMakeInUIThread(final VirtualFileEvent event) { if(project.isInitialized() && !project.isDisposed() && project.isOpen()) { final CompilerManager compilerManager = CompilerManager.getInstance(project); if(!compilerManager.isCompilationActive() && !compilerManager.isExcludedFromCompilation(event.getFile()) // && ) { // Check first if there are no errors in the code CodeSmellDetector codeSmellDetector = CodeSmellDetector.getInstance(project); boolean isOk = true; if(codeSmellDetector != null) { List<CodeSmellInfo> codeSmellInfoList = codeSmellDetector.findCodeSmells(Arrays.asList(event.getFile())); for(CodeSmellInfo codeSmellInfo: codeSmellInfoList) { if(codeSmellInfo.getSeverity() == HighlightSeverity.ERROR) { isOk = false; break; } } } if(isOk) { // Changed file found in module. Make it. final ToolWindow tw = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW); final boolean isShown = tw != null && tw.isVisible(); compilerManager.compile( new VirtualFile[]{event.getFile()}, new CompileStatusNotification() { @Override public void finished(boolean b, int i, int i1, CompileContext compileContext) { if (tw != null && tw.isVisible()) { // Close / Hide the Build Message Window after we did the build if it wasn't shown if(!isShown) { tw.hide(null); } } } } ); } else { MessageManager messageManager = ComponentProvider.getComponent(project, MessageManager.class); if(messageManager != null) { messageManager.sendErrorNotification( "server.update.file.change.with.error", event.getFile() ); } } } } }
Example #6
Source File: CompileStepBeforeRun.java From consulo with Apache License 2.0 | 4 votes |
static AsyncResult<Void> doMake(UIAccess uiAccess, final Project myProject, final RunConfiguration configuration, final boolean ignoreErrors) { if (!(configuration instanceof RunProfileWithCompileBeforeLaunchOption)) { return AsyncResult.rejected(); } if (configuration instanceof RunConfigurationBase && ((RunConfigurationBase)configuration).excludeCompileBeforeLaunchOption()) { return AsyncResult.resolved(); } final RunProfileWithCompileBeforeLaunchOption runConfiguration = (RunProfileWithCompileBeforeLaunchOption)configuration; AsyncResult<Void> result = AsyncResult.undefined(); try { final CompileStatusNotification callback = (aborted, errors, warnings, compileContext) -> { if ((errors == 0 || ignoreErrors) && !aborted) { result.setDone(); } else { result.setRejected(); } }; TransactionGuard.submitTransaction(myProject, () -> { CompileScope scope; final CompilerManager compilerManager = CompilerManager.getInstance(myProject); if (Comparing.equal(Boolean.TRUE.toString(), System.getProperty(MAKE_PROJECT_ON_RUN_KEY))) { // user explicitly requested whole-project make scope = compilerManager.createProjectCompileScope(); } else { final Module[] modules = runConfiguration.getModules(); if (modules.length > 0) { for (Module module : modules) { if (module == null) { LOG.error("RunConfiguration should not return null modules. Configuration=" + runConfiguration.getName() + "; class=" + runConfiguration.getClass().getName()); } } scope = compilerManager.createModulesCompileScope(modules, true); } else { scope = compilerManager.createProjectCompileScope(); } } if (!myProject.isDisposed()) { compilerManager.make(scope, callback); } else { result.setRejected(); } }); } catch (Exception e) { result.rejectWithThrowable(e); } return result; }