com.intellij.openapi.compiler.CompileContext Java Examples
The following examples show how to use
com.intellij.openapi.compiler.CompileContext.
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: RoboVmCompileTask.java From robovm-idea with GNU General Public License v2.0 | 6 votes |
@Override public boolean execute(CompileContext context) { if(context.getMessageCount(CompilerMessageCategory.ERROR) > 0) { RoboVmPlugin.logError(context.getProject(), "Can't compile application due to previous compilation errors"); return false; } RunConfiguration c = context.getCompileScope().getUserData(CompileStepBeforeRun.RUN_CONFIGURATION); if(c == null || !(c instanceof RoboVmRunConfiguration)) { CreateIpaAction.IpaConfig ipaConfig = context.getCompileScope().getUserData(CreateIpaAction.IPA_CONFIG_KEY); if(ipaConfig != null) { return compileForIpa(context, ipaConfig); } else { return true; } } else { return compileForRunConfiguration(context, (RoboVmRunConfiguration)c); } }
Example #2
Source File: MakeUtil.java From consulo with Apache License 2.0 | 6 votes |
public static VirtualFile getSourceRoot(CompileContext context, Module module, VirtualFile file) { final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(module.getProject()).getFileIndex(); final VirtualFile root = fileIndex.getSourceRootForFile(file); if (root != null) { return root; } // try to find among roots of generated files. final VirtualFile[] sourceRoots = context.getSourceRoots(module); for (final VirtualFile sourceRoot : sourceRoots) { if (fileIndex.isInSourceContent(sourceRoot)) { continue; // skip content source roots, need only roots for generated files } if (VfsUtil.isAncestor(sourceRoot, file, false)) { return sourceRoot; } } return null; }
Example #3
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 #4
Source File: GaugeRefactorHandler.java From Intellij-Plugin with Apache License 2.0 | 6 votes |
private void refactor(String currentStepText, String newStepText, TransactionId contextTransaction, CompileContext context, RefactorStatusCallback refactorStatusCallback) { refactorStatusCallback.onStatusChange("Refactoring..."); Module module = GaugeUtil.moduleForPsiElement(file); TransactionGuard.getInstance().submitTransaction(() -> { }, contextTransaction, () -> { Api.PerformRefactoringResponse response = null; FileDocumentManager.getInstance().saveAllDocuments(); FileDocumentManager.getInstance().saveDocumentAsIs(editor.getDocument()); GaugeService gaugeService = Gauge.getGaugeService(module, true); try { response = gaugeService.getGaugeConnection().sendPerformRefactoringRequest(currentStepText, newStepText); } catch (Exception e) { refactorStatusCallback.onFinish(new RefactoringStatus(false, String.format("Could not execute refactor command: %s", e.toString()))); return; } new UndoHandler(response.getFilesChangedList(), module.getProject(), "Refactoring").handle(); if (!response.getSuccess()) { showMessage(response, context, refactorStatusCallback); return; } refactorStatusCallback.onFinish(new RefactoringStatus(true)); }); }
Example #5
Source File: HaxeCompilerUtil.java From intellij-haxe with Apache License 2.0 | 6 votes |
private static void addErrorToContext(String error, CompileContext context, String errorRoot) { // TODO: Add a button to the Haxe module settings to control whether we always open the window or not. if (context.getUserData(messageWindowAutoOpened) == null) { openCompilerMessagesWindow(context); context.putUserData(messageWindowAutoOpened, "yes"); } final HaxeCompilerError compilerError = HaxeCompilerError.create (errorRoot, error, !ApplicationManager.getApplication().isUnitTestMode()); if (null != compilerError) { String path = compilerError.getPath(); context.addMessage (compilerError.getCategory(), compilerError.getErrorMessage(), path == null ? null : VfsUtilCore.pathToUrl(compilerError.getPath()), compilerError.getLine(), compilerError.getColumn()); } }
Example #6
Source File: ArtifactCompilerUtil.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull public static Pair<InputStream, Long> getArchiveEntryInputStream(VirtualFile sourceFile, final CompileContext context) throws IOException { final String fullPath = sourceFile.getPath(); final int jarEnd = fullPath.indexOf(ArchiveFileSystem.ARCHIVE_SEPARATOR); LOG.assertTrue(jarEnd != -1, fullPath); String pathInJar = fullPath.substring(jarEnd + ArchiveFileSystem.ARCHIVE_SEPARATOR.length()); String jarPath = fullPath.substring(0, jarEnd); final ZipFile jarFile = new ZipFile(new File(FileUtil.toSystemDependentName(jarPath))); final ZipEntry entry = jarFile.getEntry(pathInJar); if (entry == null) { context.addMessage(CompilerMessageCategory.ERROR, "Cannot extract '" + pathInJar + "' from '" + jarFile.getName() + "': entry not found", null, -1, -1); return Pair.empty(); } BufferedInputStream bufferedInputStream = new BufferedInputStream(jarFile.getInputStream(entry)) { @Override public void close() throws IOException { super.close(); jarFile.close(); } }; return Pair.<InputStream, Long>create(bufferedInputStream, entry.getSize()); }
Example #7
Source File: CompilerUtil.java From consulo with Apache License 2.0 | 6 votes |
public static Map<Module, List<VirtualFile>> buildModuleToFilesMap(final CompileContext context, final List<VirtualFile> files) { //assertion: all files are different final Map<Module, List<VirtualFile>> map = new THashMap<Module, List<VirtualFile>>(); ApplicationManager.getApplication().runReadAction(new Runnable() { public void run() { for (VirtualFile file : files) { final Module module = context.getModuleByFile(file); if (module == null) { continue; // looks like file invalidated } List<VirtualFile> moduleFiles = map.get(module); if (moduleFiles == null) { moduleFiles = new ArrayList<VirtualFile>(); map.put(module, moduleFiles); } moduleFiles.add(file); } } }); return map; }
Example #8
Source File: CompilerUtil.java From consulo with Apache License 2.0 | 5 votes |
public static <T extends Throwable> void runInContext(CompileContext context, String title, ThrowableRunnable<T> action) throws T { if (title != null) { context.getProgressIndicator().pushState(); context.getProgressIndicator().setText(title); } try { action.run(); } finally { if (title != null) { context.getProgressIndicator().popState(); } } }
Example #9
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 #10
Source File: ArchivesBuilder.java From consulo with Apache License 2.0 | 5 votes |
public ArchivesBuilder(@Nonnull Set<ArchivePackageInfo> archivesToBuild, @Nonnull FileFilter fileFilter, @Nonnull CompileContext context) { DependentArchivesEvaluator evaluator = new DependentArchivesEvaluator(); for (ArchivePackageInfo archivePackageInfo : archivesToBuild) { evaluator.addArchiveWithDependencies(archivePackageInfo); } myArchivesToBuild = evaluator.getArchivePackageInfos(); myFileFilter = fileFilter; myContext = context; }
Example #11
Source File: ArtifactsCompiler.java From consulo with Apache License 2.0 | 5 votes |
public static void addWrittenPaths(final CompileContext context, Set<String> writtenPaths) { Set<String> paths = context.getUserData(WRITTEN_PATHS_KEY); if (paths == null) { paths = new THashSet<String>(); context.putUserData(WRITTEN_PATHS_KEY, paths); } paths.addAll(writtenPaths); }
Example #12
Source File: ArtifactsCompiler.java From consulo with Apache License 2.0 | 5 votes |
public static void addChangedArtifact(final CompileContext context, Artifact artifact) { Set<Artifact> artifacts = context.getUserData(CHANGED_ARTIFACTS); if (artifacts == null) { artifacts = new THashSet<Artifact>(); context.putUserData(CHANGED_ARTIFACTS, artifacts); } artifacts.add(artifact); }
Example #13
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 #14
Source File: ArtifactsProcessingItemsBuilderContext.java From consulo with Apache License 2.0 | 5 votes |
public ArtifactsProcessingItemsBuilderContext(CompileContext compileContext) { myCompileContext = compileContext; myItemsBySource = new HashMap<VirtualFile, ArtifactCompilerCompileItem>(); mySourceByOutput = new HashMap<String, VirtualFile>(); myJarByPath = new HashMap<String, ArchivePackageInfo>(); myPrintToLog = ArtifactsCompilerInstance.FULL_LOG.isDebugEnabled(); }
Example #15
Source File: TranslatingCompilerFilesMonitor.java From consulo with Apache License 2.0 | 5 votes |
public abstract void collectFiles(CompileContext context, TranslatingCompiler compiler, Iterator<VirtualFile> scopeSrcIterator, boolean forceCompile, boolean isRebuild, Collection<VirtualFile> toCompile, Collection<Trinity<File, String, Boolean>> toDelete);
Example #16
Source File: GenericCompilerRunner.java From consulo with Apache License 2.0 | 5 votes |
public GenericCompilerRunner(CompileContext context, boolean forceCompile, boolean onlyCheckStatus, final GenericCompiler[] compilers) { myContext = context; myForceCompile = forceCompile; myOnlyCheckStatus = onlyCheckStatus; myCompilers = compilers; myProject = myContext.getProject(); }
Example #17
Source File: HaxeCompilerUtil.java From intellij-haxe with Apache License 2.0 | 5 votes |
private static void openCompilerMessagesWindow(final CompileContext context) { // Force the compile window open. We should probably have a configuration button // on the compile gui page to force it open or not. if (!isHeadless()) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { // This was lifted from intellij-community/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java final ToolWindow tw = ToolWindowManager.getInstance(context.getProject()).getToolWindow(ToolWindowId.MESSAGES_WINDOW); if (tw != null) { tw.activate(null, false); } } }); } }
Example #18
Source File: HaxeCompilerUtil.java From intellij-haxe with Apache License 2.0 | 5 votes |
/** * Add errors to the compile context. * * @param context * @param errorRoot * @param errors */ public static void fillContext(CompileContext context, String errorRoot, String[] errors) { for (String error : errors) { addErrorToContext(error, context, errorRoot); } }
Example #19
Source File: HaxeCompilerTask.java From intellij-haxe with Apache License 2.0 | 5 votes |
@Override public boolean execute(CompileContext context) { if (haxeCompiler == null) { haxeCompiler = new HaxeCompiler(); } FileProcessingCompiler.ProcessingItem[] processingItems = haxeCompiler.getProcessingItems(context); haxeCompiler.process(context, processingItems); return true; }
Example #20
Source File: GaugeRefactorHandler.java From Intellij-Plugin with Apache License 2.0 | 5 votes |
private void showMessage(Api.PerformRefactoringResponse response, CompileContext context, RefactorStatusCallback refactorStatusCallback) { refactorStatusCallback.onFinish(new RefactoringStatus(false, "Please fix all errors before refactoring.")); for (String error : response.getErrorsList()) { GaugeError gaugeError = GaugeError.getInstance(error); if (gaugeError != null) { context.addMessage(CompilerMessageCategory.ERROR, gaugeError.getMessage(), Paths.get(gaugeError.getFileName()).toUri().toString(), gaugeError.getLineNumber(), -1); } else { context.addMessage(CompilerMessageCategory.ERROR, error, null, -1, -1); } } }
Example #21
Source File: SandCompiler.java From consulo with Apache License 2.0 | 5 votes |
@Override public void compile(CompileContext context, Chunk<Module> moduleChunk, VirtualFile[] files, OutputSink sink) { try { context.addMessage(CompilerMessageCategory.WARNING, "my warning", null, -1, -1); Thread.sleep(5000L); } catch (InterruptedException e) { e.printStackTrace(); } if (myAddError) { context.addMessage(CompilerMessageCategory.ERROR, "my error", null, -1, -1); } myAddError = !myAddError; }
Example #22
Source File: ArtifactsProcessingItemsBuilderContext.java From consulo with Apache License 2.0 | 4 votes |
public CompileContext getCompileContext() { return myCompileContext; }
Example #23
Source File: CompilerUtil.java From consulo with Apache License 2.0 | 4 votes |
public static Map<Module, List<VirtualFile>> buildModuleToFilesMap(CompileContext context, VirtualFile[] files) { return buildModuleToFilesMap(context, Arrays.asList(files)); }
Example #24
Source File: FileProcessingCompilerAdapter.java From consulo with Apache License 2.0 | 4 votes |
public CompileContext getCompileContext() { return myCompileContext; }
Example #25
Source File: PackagingCompilerAdapter.java From consulo with Apache License 2.0 | 4 votes |
public PackagingCompilerAdapter(CompileContext compileContext, PackagingCompiler compiler) { super(compileContext, compiler); myCompiler = compiler; }
Example #26
Source File: PackagingCompilerAdapter.java From consulo with Apache License 2.0 | 4 votes |
@Override public void processOutdatedItem(CompileContext context, File file, @Nullable ValidityState state) { myCompiler.processOutdatedItem(context, file, state); }
Example #27
Source File: FileProcessingCompilerAdapter.java From consulo with Apache License 2.0 | 4 votes |
protected FileProcessingCompilerAdapter(CompileContext compileContext, FileProcessingCompiler compiler) { myCompileContext = compileContext; myCompiler = compiler; }
Example #28
Source File: SandCompiler.java From consulo with Apache License 2.0 | 4 votes |
@Override public boolean isCompilableFile(VirtualFile file, CompileContext context) { return file.getFileType() == SandFileType.INSTANCE; }
Example #29
Source File: ArtifactsCompiler.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public static Set<String> getWrittenPaths(@Nonnull CompileContext context) { return context.getUserData(WRITTEN_PATHS_KEY); }
Example #30
Source File: ArtifactsCompiler.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public static Set<Artifact> getChangedArtifacts(final CompileContext compileContext) { return compileContext.getUserData(CHANGED_ARTIFACTS); }