use of com.intellij.openapi.compiler.CompilerMessageCategory in project intellij-elixir by KronicDeth.
the class ElixirCompilerError method create.
@Nullable
public static ElixirCompilerError create(String rootPath, String elixircMessage) {
Matcher matcher = COMPILER_MESSAGE_PATTERN.matcher(StringUtil.trimTrailing(elixircMessage));
if (!matcher.matches())
return null;
String relativeFilePath = FileUtil.toSystemIndependentName(matcher.group(1));
String line = matcher.group(2);
String warning = matcher.group(3);
String details = matcher.group(4);
String path = StringUtil.isEmpty(rootPath) ? relativeFilePath : new File(FileUtil.toSystemIndependentName(rootPath), relativeFilePath).getPath();
int lineNumber = StringUtil.parseInt(line, UNKNOWN_LINE_NUMBER);
CompilerMessageCategory category = warning != null ? CompilerMessageCategory.WARNING : CompilerMessageCategory.ERROR;
assert path != null;
return new ElixirCompilerError(details, VfsUtilCore.pathToUrl(path), lineNumber, category);
}
use of com.intellij.openapi.compiler.CompilerMessageCategory in project intellij-community by JetBrains.
the class CompilerTask method doAddMessage.
private void doAddMessage(final CompilerMessage message) {
synchronized (myMessageViewLock) {
if (myErrorTreeView != null) {
final Navigatable navigatable = message.getNavigatable();
final VirtualFile file = message.getVirtualFile();
final CompilerMessageCategory category = message.getCategory();
final int type = translateCategory(category);
final String[] text = convertMessage(message);
if (navigatable != null) {
final String groupName = file != null ? file.getPresentableUrl() : category.getPresentableText();
myErrorTreeView.addMessage(type, text, groupName, navigatable, message.getExportTextPrefix(), message.getRenderTextPrefix(), message.getVirtualFile());
} else {
myErrorTreeView.addMessage(type, text, file, -1, -1, message.getVirtualFile());
}
final boolean shouldAutoActivate = !myMessagesAutoActivated && (CompilerMessageCategory.ERROR.equals(category) || (CompilerMessageCategory.WARNING.equals(category) && !ErrorTreeViewConfiguration.getInstance(myProject).isHideWarnings()));
if (shouldAutoActivate) {
myMessagesAutoActivated = true;
activateMessageView();
}
}
}
}
use of com.intellij.openapi.compiler.CompilerMessageCategory in project intellij-community by JetBrains.
the class CompilerTask method addMessage.
public void addMessage(final CompilerMessage message) {
prepareMessageView();
final CompilerMessageCategory messageCategory = message.getCategory();
if (CompilerMessageCategory.WARNING.equals(messageCategory)) {
myWarningCount += 1;
} else if (CompilerMessageCategory.ERROR.equals(messageCategory)) {
myErrorCount += 1;
informWolf(message);
}
if (ApplicationManager.getApplication().isDispatchThread()) {
openMessageView();
doAddMessage(message);
} else {
final Window window = getWindow();
final ModalityState modalityState = window != null ? ModalityState.stateForComponent(window) : ModalityState.NON_MODAL;
ApplicationManager.getApplication().invokeLater(() -> {
if (myProject != null && !myProject.isDisposed()) {
openMessageView();
doAddMessage(message);
}
}, modalityState);
}
}
use of com.intellij.openapi.compiler.CompilerMessageCategory in project intellij-community by JetBrains.
the class OutputParser method processJavacMessages.
private static void processJavacMessages(final List<String> javacMessages, final AntBuildMessageView messageView, final Project project) {
if (javacMessages == null) {
return;
}
final com.intellij.compiler.OutputParser outputParser = new JavacOutputParser(project);
com.intellij.compiler.OutputParser.Callback callback = new com.intellij.compiler.OutputParser.Callback() {
private int myIndex = -1;
@Nullable
public String getCurrentLine() {
if (myIndex >= javacMessages.size()) {
return null;
}
return javacMessages.get(myIndex);
}
public String getNextLine() {
final int size = javacMessages.size();
final int next = Math.min(myIndex + 1, javacMessages.size());
myIndex = next;
if (next >= size) {
return null;
}
return javacMessages.get(next);
}
@Override
public void pushBack(String line) {
myIndex--;
}
public void message(final CompilerMessageCategory category, final String message, final String url, final int lineNum, final int columnNum) {
StringTokenizer tokenizer = new StringTokenizer(message, "\n", false);
final String[] strings = new String[tokenizer.countTokens()];
//noinspection ForLoopThatDoesntUseLoopVariable
for (int idx = 0; tokenizer.hasMoreTokens(); idx++) {
strings[idx] = tokenizer.nextToken();
}
ApplicationManager.getApplication().runReadAction(() -> {
VirtualFile file = url == null ? null : VirtualFileManager.getInstance().findFileByUrl(url);
messageView.outputJavacMessage(convertCategory(category), strings, file, url, lineNum, columnNum);
if (file != null && category == CompilerMessageCategory.ERROR) {
final WolfTheProblemSolver wolf = WolfTheProblemSolver.getInstance(project);
final Problem problem = wolf.convertToProblem(file, lineNum, columnNum, strings);
wolf.weHaveGotNonIgnorableProblems(file, Collections.singletonList(problem));
}
});
}
public void setProgressText(String text) {
}
public void fileProcessed(String path) {
}
public void fileGenerated(String path) {
}
};
try {
while (true) {
if (!outputParser.processMessageLine(callback)) {
break;
}
}
} catch (Exception e) {
//ignore
}
}
use of com.intellij.openapi.compiler.CompilerMessageCategory in project android by JetBrains.
the class AndroidMavenExecutor method generateResources.
public static Map<CompilerMessageCategory, List<String>> generateResources(final Module module) {
MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(module.getProject());
final MavenRunnerParameters parameters = new MavenRunnerParameters(true, projectsManager.findProject(module).getDirectory(), Collections.singletonList("process-resources"), projectsManager.getExplicitProfiles());
final Map<CompilerMessageCategory, List<String>> result = new HashMap<CompilerMessageCategory, List<String>>();
result.put(CompilerMessageCategory.ERROR, new ArrayList<String>());
try {
JavaParameters javaParams = ApplicationManager.getApplication().runReadAction(new Computable<JavaParameters>() {
@Nullable
@Override
public JavaParameters compute() {
try {
return MavenExternalParameters.createJavaParameters(module.getProject(), parameters);
} catch (ExecutionException e) {
LOG.info(e);
result.get(CompilerMessageCategory.ERROR).add(e.getMessage());
return null;
}
}
});
if (javaParams == null) {
return result;
}
GeneralCommandLine commandLine = javaParams.toCommandLine();
final StringBuildingOutputProcessor processor = new StringBuildingOutputProcessor();
boolean success = AndroidUtils.executeCommand(commandLine, processor, WaitingStrategies.WaitForever.getInstance()) == ExecutionStatus.SUCCESS;
String message = processor.getMessage();
if (!success) {
LOG.info(message);
String lcmessage = message.toLowerCase();
int buildErrorIndex = lcmessage.indexOf(BUILD_ERROR_INDICATOR);
if (buildErrorIndex >= 0) {
result.get(CompilerMessageCategory.ERROR).add(message.substring(buildErrorIndex));
}
}
} catch (ExecutionException e) {
LOG.info(e);
result.get(CompilerMessageCategory.ERROR).add(e.getMessage());
}
return result;
}
Aggregations