com.intellij.openapi.compiler.CompilerMessageCategory Java Examples
The following examples show how to use
com.intellij.openapi.compiler.CompilerMessageCategory.
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: ArchivesBuilder.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private ArchivePackageInfo[] sortArchives() { final DFSTBuilder<ArchivePackageInfo> builder = new DFSTBuilder<>(GraphGenerator.create(CachingSemiGraph.create(new ArchivesGraph()))); if (!builder.isAcyclic()) { final Pair<ArchivePackageInfo, ArchivePackageInfo> dependency = builder.getCircularDependency(); String message = CompilerBundle .message("packaging.compiler.error.cannot.build.circular.dependency.found.between.0.and.1", dependency.getFirst().getPresentableDestination(), dependency.getSecond().getPresentableDestination()); myContext.addMessage(CompilerMessageCategory.ERROR, message, null, -1, -1); return null; } ArchivePackageInfo[] archives = myArchivesToBuild.toArray(new ArchivePackageInfo[myArchivesToBuild.size()]); Arrays.sort(archives, builder.comparator()); archives = ArrayUtil.reverseArray(archives); return archives; }
Example #3
Source File: CompilerTask.java From consulo with Apache License 2.0 | 6 votes |
public void addMessage(final CompilerMessage message) { final CompilerMessageCategory messageCategory = message.getCategory(); if (CompilerMessageCategory.WARNING.equals(messageCategory)) { myWarningCount += 1; } else if (CompilerMessageCategory.ERROR.equals(messageCategory)) { myErrorCount += 1; informWolf(message); } Application application = Application.get(); if (application.isDispatchThread()) { // implicit ui thread //noinspection RequiredXAction doAddMessage(message); } else { application.invokeLater(() -> { if (!myProject.isDisposed()) { doAddMessage(message); } }, ModalityState.NON_MODAL); } }
Example #4
Source File: ArtifactsCompilerInstance.java From consulo with Apache License 2.0 | 6 votes |
private void extractFile(VirtualFile sourceFile, File toFile, Set<String> writtenPaths, FileFilter fileFilter) throws IOException { if (!writtenPaths.add(toFile.getPath())) { return; } if (!FileUtil.createParentDirs(toFile)) { myContext.addMessage(CompilerMessageCategory.ERROR, "Cannot create directory for '" + toFile.getAbsolutePath() + "' file", null, -1, -1); return; } InputStream input = ArtifactCompilerUtil.getArchiveEntryInputStream(sourceFile, myContext).getFirst(); if (input == null) return; final BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(toFile)); try { FileUtil.copy(input, output); } finally { input.close(); output.close(); } }
Example #5
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 #6
Source File: PantsIntegrationTestCase.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
protected void assertCompilationFailed(final Module... modules) throws Exception { final List<CompilerMessage> messages = compileAndGetMessages(modules); for (CompilerMessage message : messages) { if (message.getCategory() == CompilerMessageCategory.ERROR) { return; } } fail("Compilation didn't fail!\n" + messages); }
Example #7
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 #8
Source File: GenericCompilerRunner.java From consulo with Apache License 2.0 | 5 votes |
private void checkForErrorsOrCanceled() throws ExitException { if (myContext.getMessageCount(CompilerMessageCategory.ERROR) > 0) { throw new ExitException(ExitStatus.ERRORS); } if (myContext.getProgressIndicator().isCanceled()) { throw new ExitException(ExitStatus.CANCELLED); } }
Example #9
Source File: CompileContextExProxy.java From consulo with Apache License 2.0 | 5 votes |
@Override public void addMessage(final CompilerMessageCategory category, final String message, @javax.annotation.Nullable final String url, final int lineNum, final int columnNum, final Navigatable navigatable) { myDelegate.addMessage(category, message, url, lineNum, columnNum, navigatable); }
Example #10
Source File: CacheUtils.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static Set<VirtualFile> getFilesCompiledWithErrors(final CompileContextEx context) { CompilerMessage[] messages = context.getMessages(CompilerMessageCategory.ERROR); Set<VirtualFile> compiledWithErrors = Collections.emptySet(); if (messages.length > 0) { compiledWithErrors = new HashSet<VirtualFile>(messages.length); for (CompilerMessage message : messages) { final VirtualFile file = message.getVirtualFile(); if (file != null) { compiledWithErrors.add(file); } } } return compiledWithErrors; }
Example #11
Source File: CompilerTask.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess private void doAddMessage(final CompilerMessage message) { UIAccess.assertIsUIThread(); final CompilerMessageCategory category = message.getCategory(); final boolean shouldAutoActivate = !myMessagesAutoActivated && (CompilerMessageCategory.ERROR.equals(category) || (CompilerMessageCategory.WARNING.equals(category) && !ProblemsView.getInstance(myProject).isHideWarnings())); if (shouldAutoActivate) { myMessagesAutoActivated = true; activateMessageView(); } }
Example #12
Source File: CompilerMessageImpl.java From consulo with Apache License 2.0 | 5 votes |
public CompilerMessageImpl(Project project, CompilerMessageCategory category, String message, @Nullable final VirtualFile file, int row, int column, @Nullable final Navigatable navigatable) { myProject = project; myCategory = category; myNavigatable = navigatable; myMessage = message == null ? "" : message; myRow = row; myColumn = column; myFile = file; }
Example #13
Source File: ArtifactsCompilerInstance.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public List<ArtifactCompilerCompileItem> getItems(@Nonnull ArtifactBuildTarget target) { myBuilderContext = new ArtifactsProcessingItemsBuilderContext(myContext); final Artifact artifact = target.getArtifact(); ThrowableComputable<Map<String,String>,RuntimeException> action = () -> ArtifactSortingUtil.getInstance(getProject()).getArtifactToSelfIncludingNameMap(); final Map<String, String> selfIncludingArtifacts = AccessRule.read(action); final String selfIncludingName = selfIncludingArtifacts.get(artifact.getName()); if (selfIncludingName != null) { String name = selfIncludingName.equals(artifact.getName()) ? "it" : "'" + selfIncludingName + "' artifact"; myContext.addMessage(CompilerMessageCategory.ERROR, "Cannot build '" + artifact.getName() + "' artifact: " + name + " includes itself in the output layout", null, -1, -1); return Collections.emptyList(); } final String outputPath = artifact.getOutputPath(); if (outputPath == null || outputPath.length() == 0) { myContext.addMessage(CompilerMessageCategory.ERROR, "Cannot build '" + artifact.getName() + "' artifact: output path is not specified", null, -1, -1); return Collections.emptyList(); } DumbService.getInstance(getProject()).waitForSmartMode(); AccessRule.read(() -> { collectItems(artifact, outputPath); }); return new ArrayList<ArtifactCompilerCompileItem>(myBuilderContext.getProcessingItems()); }
Example #14
Source File: HaxeCompilerError.java From intellij-haxe with Apache License 2.0 | 5 votes |
public HaxeCompilerError(CompilerMessageCategory category, String errorMessage, String path, int line, int column) { this.category = category; this.errorMessage = errorMessage; this.path = path; this.line = line; this.column = column; }
Example #15
Source File: HaxeCompilerErrorParsingTest.java From intellij-haxe with Apache License 2.0 | 5 votes |
public void testWarnings() { final String error = "hello/HelloWorld.hx:18: lines 18-24 : Warning : Danger, Will Robinson!"; final String rootPath = "/trees/test"; final HaxeCompilerError compilerError = HaxeCompilerError.create(rootPath, error, false); assertNotNull(compilerError); assertEquals(CompilerMessageCategory.WARNING, compilerError.getCategory()); assertEquals("/trees/test/hello/HelloWorld.hx", compilerError.getPath()); assertEquals("Danger, Will Robinson!", compilerError.getErrorMessage()); assertEquals(18, compilerError.getLine()); assertEquals(-1, compilerError.getColumn()); }
Example #16
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 #17
Source File: HaxeCompilerErrorParsingTest.java From intellij-haxe with Apache License 2.0 | 5 votes |
public void disabledtestUserProperiesErrorWin() { final String error = "C:/Users/fedor.korotkov/workspace/haxe-bubble-breaker/src/Main.hx:5: characters 0-21 : Class not found : StringTools212"; final String rootPath = "C:/Users/fedor.korotkov/workspace/haxe-bubble-breaker"; final HaxeCompilerError compilerError = HaxeCompilerError.create(rootPath, error, false); assertNotNull(compilerError); assertEquals(CompilerMessageCategory.ERROR, compilerError.getCategory()); assertEquals("C:/Users/fedor.korotkov/workspace/haxe-bubble-breaker/src/Main.hx", compilerError.getPath()); assertEquals("Class not found : StringTools212", compilerError.getErrorMessage()); assertEquals(5, compilerError.getLine()); assertEquals(0, compilerError.getColumn()); }
Example #18
Source File: HaxeCompilerErrorParsingTest.java From intellij-haxe with Apache License 2.0 | 5 votes |
public void testNMEErrorWin() { final String error = "src/Main.hx:5: characters 0-21 : Class not found : StringTools212"; final String rootPath = "C:/Users/fedor.korotkov/workspace/haxe-bubble-breaker"; final HaxeCompilerError compilerError = HaxeCompilerError.create(rootPath, error, false); assertNotNull(compilerError); assertEquals(CompilerMessageCategory.ERROR, compilerError.getCategory()); assertEquals("C:/Users/fedor.korotkov/workspace/haxe-bubble-breaker/src/Main.hx", compilerError.getPath()); assertEquals("Class not found : StringTools212", compilerError.getErrorMessage()); assertEquals(5, compilerError.getLine()); assertEquals(0, compilerError.getColumn()); }
Example #19
Source File: HaxeCompilerErrorParsingTest.java From intellij-haxe with Apache License 2.0 | 5 votes |
public void testNMEErrorRelativeUnix() { final String error = "./HelloWorld.hx:12: characters 1-16 : Unknown identifier : addEvetListener"; final String rootPath = "/trees/test"; final HaxeCompilerError compilerError = HaxeCompilerError.create(rootPath, error, false); assertNotNull(compilerError); assertEquals(CompilerMessageCategory.ERROR, compilerError.getCategory()); assertEquals("/trees/test/./HelloWorld.hx", compilerError.getPath()); assertEquals("Unknown identifier : addEvetListener", compilerError.getErrorMessage()); assertEquals(12, compilerError.getLine()); assertEquals(1, compilerError.getColumn()); }
Example #20
Source File: HaxeCompilerErrorParsingTest.java From intellij-haxe with Apache License 2.0 | 5 votes |
public void testNMEErrorAbsoluteUnix() { final String error = "/an/absolute/path/HelloWorld.hx:12: characters 1-16 : Unknown identifier : addEvetListener"; final String rootPath = "/trees/test"; final HaxeCompilerError compilerError = HaxeCompilerError.create(rootPath, error, false); assertNotNull(compilerError); assertEquals(CompilerMessageCategory.ERROR, compilerError.getCategory()); if (Platform.current() == Platform.UNIX) { assertEquals("/an/absolute/path/HelloWorld.hx", compilerError.getPath()); } assertEquals("Unknown identifier : addEvetListener", compilerError.getErrorMessage()); assertEquals(12, compilerError.getLine()); assertEquals(1, compilerError.getColumn()); }
Example #21
Source File: HaxeCompilerErrorParsingTest.java From intellij-haxe with Apache License 2.0 | 5 votes |
public void testNMEErrorNoColumnUnix() { final String error = "hello/HelloWorld.hx:18: lines 18-24 : Interfaces cannot implement another interface (use extends instead)"; final String rootPath = "/trees/test"; final HaxeCompilerError compilerError = HaxeCompilerError.create(rootPath, error, false); assertNotNull(compilerError); assertEquals(CompilerMessageCategory.ERROR, compilerError.getCategory()); assertEquals("/trees/test/hello/HelloWorld.hx", compilerError.getPath()); assertEquals("Interfaces cannot implement another interface (use extends instead)", compilerError.getErrorMessage()); assertEquals(18, compilerError.getLine()); assertEquals(-1, compilerError.getColumn()); }
Example #22
Source File: HaxeCompilerErrorTest.java From intellij-haxe with Apache License 2.0 | 5 votes |
private void doTest(String output, CompilerMessageCategory cat, String msg, String path, int line, int col) throws Throwable { HaxeCompilerError e = HaxeCompilerError.create("", output); assertEquals(cat, e.getCategory()); assertEquals(msg, e.getErrorMessage()); assertEquals(path, e.getPath()); assertEquals(line, e.getLine()); assertEquals(col, e.getColumn()); }
Example #23
Source File: HaxeCompilerError.java From intellij-haxe with Apache License 2.0 | 4 votes |
public CompilerMessageCategory getCategory() { return category; }
Example #24
Source File: HaxeCompilerErrorTest.java From intellij-haxe with Apache License 2.0 | 4 votes |
public void testLinesError() throws Throwable { String compilerOutput = "Test.hx:4: lines 4-10 : Invalid -main : Test does not have static function main"; doTest(compilerOutput, CompilerMessageCategory.ERROR, "Invalid -main : Test does not have static function main", "Missing file: /Test.hx", 4, -1); }
Example #25
Source File: MSBaseDotNetCompilerOptionsBuilder.java From consulo-csharp with Apache License 2.0 | 4 votes |
@Override public DotNetCompilerMessage convertToMessage(Module module, String line) { if(line.startsWith("error")) { return new DotNetCompilerMessage(CompilerMessageCategory.ERROR, line, null, -1, 1); } else { Matcher matcher = LINE_ERROR_PATTERN.matcher(line); if(matcher.matches()) { CompilerMessageCategory category = CompilerMessageCategory.INFORMATION; if(matcher.group(4).equals("error")) { category = CompilerMessageCategory.ERROR; } else if(matcher.group(4).equals("warning")) { category = CompilerMessageCategory.WARNING; } String fileUrl = FileUtil.toSystemIndependentName(matcher.group(1)); if(!FileUtil.isAbsolute(fileUrl)) { fileUrl = module.getModuleDirUrl() + "/" + fileUrl; } else { fileUrl = VirtualFileManager.constructUrl(StandardFileSystems.FILE_PROTOCOL, fileUrl); } int codeLine = Integer.parseInt(matcher.group(2)); int codeColumn = Integer.parseInt(matcher.group(3)); String message = matcher.group(6); if(ApplicationProperties.isInSandbox()) { message += "(" + matcher.group(5) + ")"; } return new DotNetCompilerMessage(category, message, fileUrl, codeLine, codeColumn - 1); } } return null; }
Example #26
Source File: CompileContextExProxy.java From consulo with Apache License 2.0 | 4 votes |
@Override public int getMessageCount(final CompilerMessageCategory category) { return myDelegate.getMessageCount(category); }
Example #27
Source File: CompileContextExProxy.java From consulo with Apache License 2.0 | 4 votes |
@Override public CompilerMessage[] getMessages(final CompilerMessageCategory category) { return myDelegate.getMessages(category); }
Example #28
Source File: HaxeCompilerErrorTest.java From intellij-haxe with Apache License 2.0 | 4 votes |
public void testUnexpectedCharacter() throws Throwable { String compilerOutput = "Test.hx:4: characters 6-7 : Unexpected %"; String expected = "Unexpected %"; doTest(compilerOutput, CompilerMessageCategory.ERROR, expected, "Missing file: /Test.hx", 4, 6); }
Example #29
Source File: CompileContextExProxy.java From consulo with Apache License 2.0 | 4 votes |
@Override public void addMessage(final CompilerMessageCategory category, final String message, @Nullable final String url, final int lineNum, final int columnNum) { myDelegate.addMessage(category, message, url, lineNum, columnNum); }
Example #30
Source File: ArchivesBuilder.java From consulo with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private <T> void buildArchive(final ArchivePackageInfo archive) throws IOException { if (archive.getPackedFiles().isEmpty() && archive.getPackedArchives().isEmpty()) { myContext.addMessage(CompilerMessageCategory.WARNING, "Archive '" + archive.getPresentableDestination() + "' has no files so it won't be created", null, -1, -1); return; } myContext.getProgressIndicator().setText(CompilerBundle.message("packaging.compiler.message.building.0", archive.getPresentableDestination())); File tempFile = File.createTempFile("artifactCompiler", "tmp"); myBuiltArchives.put(archive, tempFile); FileUtil.createParentDirs(tempFile); ArchivePackageWriter<T> packageWriter = (ArchivePackageWriter<T>)archive.getPackageWriter(); T archiveFile; if (packageWriter instanceof ArchivePackageWriterEx) { archiveFile = ((ArchivePackageWriterEx<T>)packageWriter).createArchiveObject(tempFile, archive); } else { archiveFile = packageWriter.createArchiveObject(tempFile); } try { final THashSet<String> writtenPaths = new THashSet<>(); for (Pair<String, VirtualFile> pair : archive.getPackedFiles()) { final VirtualFile sourceFile = pair.getSecond(); if (sourceFile.isInLocalFileSystem()) { File file = VfsUtil.virtualToIoFile(sourceFile); addFileToArchive(archiveFile, packageWriter, file, pair.getFirst(), writtenPaths); } else { extractFileAndAddToArchive(archiveFile, packageWriter, sourceFile, pair.getFirst(), writtenPaths); } } for (Pair<String, ArchivePackageInfo> nestedArchive : archive.getPackedArchives()) { File nestedArchiveFile = myBuiltArchives.get(nestedArchive.getSecond()); if (nestedArchiveFile != null) { addFileToArchive(archiveFile, packageWriter, nestedArchiveFile, nestedArchive.getFirst(), writtenPaths); } else { LOGGER.debug("nested archive file " + nestedArchive.getFirst() + " for " + archive.getPresentableDestination() + " not found"); } } } catch (Exception e) { e.printStackTrace(); } finally { packageWriter.close(archiveFile); } }