Search in sources :

Example 1 with Problem

use of com.intellij.problems.Problem in project intellij-community by JetBrains.

the class AutoMakeMessageHandler method informWolf.

private void informWolf(Project project, CmdlineRemoteProto.Message.BuilderMessage.CompileMessage message) {
    final String srcPath = message.getSourceFilePath();
    if (srcPath != null && !project.isDisposed()) {
        final VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(srcPath);
        if (vFile != null) {
            final int line = (int) message.getLine();
            final int column = (int) message.getColumn();
            if (line > 0 && column > 0) {
                final Problem problem = myWolf.convertToProblem(vFile, line, column, new String[] { message.getText() });
                myWolf.weHaveGotProblems(vFile, Collections.singletonList(problem));
            } else {
                myWolf.queue(vFile);
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Problem(com.intellij.problems.Problem)

Example 2 with Problem

use of com.intellij.problems.Problem in project intellij-community by JetBrains.

the class WolfTheProblemSolverImpl method reportProblems.

@Override
public void reportProblems(@NotNull final VirtualFile file, @NotNull Collection<Problem> problems) {
    if (problems.isEmpty()) {
        clearProblems(file);
        return;
    }
    if (!isToBeHighlighted(file))
        return;
    boolean hasProblemsBefore;
    boolean fireChanged;
    synchronized (myProblems) {
        final ProblemFileInfo oldInfo = myProblems.remove(file);
        hasProblemsBefore = oldInfo != null;
        ProblemFileInfo newInfo = new ProblemFileInfo();
        myProblems.put(file, newInfo);
        for (Problem problem : problems) {
            newInfo.problems.add(problem);
            newInfo.hasSyntaxErrors |= ((ProblemImpl) problem).isSyntaxOnly();
        }
        fireChanged = hasProblemsBefore && !oldInfo.equals(newInfo);
    }
    doQueue(file);
    if (!hasProblemsBefore) {
        fireProblemListeners.problemsAppeared(file);
    } else if (fireChanged) {
        fireProblemListeners.problemsChanged(file);
    }
}
Also used : Problem(com.intellij.problems.Problem)

Example 3 with Problem

use of com.intellij.problems.Problem in project intellij-community by JetBrains.

the class GeneralHighlightingPass method reportErrorsToWolf.

private void reportErrorsToWolf() {
    // e.g. errors in evaluate expression
    if (!getFile().getViewProvider().isPhysical())
        return;
    Project project = getFile().getProject();
    // do not report problems in libraries
    if (!PsiManager.getInstance(project).isInProject(getFile()))
        return;
    VirtualFile file = getFile().getVirtualFile();
    if (file == null)
        return;
    List<Problem> problems = convertToProblems(getInfos(), file, myHasErrorElement);
    WolfTheProblemSolver wolf = WolfTheProblemSolver.getInstance(project);
    boolean hasErrors = DaemonCodeAnalyzerEx.hasErrors(project, getDocument());
    if (!hasErrors || isWholeFileHighlighting()) {
        wolf.reportProblems(file, problems);
    } else {
        wolf.weHaveGotProblems(file, problems);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Problem(com.intellij.problems.Problem) WolfTheProblemSolver(com.intellij.problems.WolfTheProblemSolver)

Example 4 with Problem

use of com.intellij.problems.Problem in project intellij-community by JetBrains.

the class GeneralHighlightingPass method convertToProblems.

private static List<Problem> convertToProblems(@NotNull Collection<HighlightInfo> infos, @NotNull VirtualFile file, final boolean hasErrorElement) {
    List<Problem> problems = new SmartList<>();
    for (HighlightInfo info : infos) {
        if (info.getSeverity() == HighlightSeverity.ERROR) {
            Problem problem = new ProblemImpl(file, info, hasErrorElement);
            problems.add(problem);
        }
    }
    return problems;
}
Also used : ProblemImpl(com.intellij.codeInsight.problems.ProblemImpl) Problem(com.intellij.problems.Problem) SmartList(com.intellij.util.SmartList)

Example 5 with Problem

use of com.intellij.problems.Problem 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
    }
}
Also used : CompilerMessageCategory(com.intellij.openapi.compiler.CompilerMessageCategory) VirtualFile(com.intellij.openapi.vfs.VirtualFile) WolfTheProblemSolver(com.intellij.problems.WolfTheProblemSolver) JavacOutputParser(com.intellij.compiler.impl.javaCompiler.javac.JavacOutputParser) StringTokenizer(com.intellij.util.text.StringTokenizer) Problem(com.intellij.problems.Problem) JavacOutputParser(com.intellij.compiler.impl.javaCompiler.javac.JavacOutputParser)

Aggregations

Problem (com.intellij.problems.Problem)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 WolfTheProblemSolver (com.intellij.problems.WolfTheProblemSolver)2 ProblemImpl (com.intellij.codeInsight.problems.ProblemImpl)1 JavacOutputParser (com.intellij.compiler.impl.javaCompiler.javac.JavacOutputParser)1 CompilerMessageCategory (com.intellij.openapi.compiler.CompilerMessageCategory)1 Project (com.intellij.openapi.project.Project)1 SmartList (com.intellij.util.SmartList)1 StringTokenizer (com.intellij.util.text.StringTokenizer)1