Search in sources :

Example 1 with ExceptionWorker

use of com.intellij.execution.filters.ExceptionWorker in project intellij-community by JetBrains.

the class ExceptionFilterTest method testNonClassInTheLine.

public void testNonClassInTheLine() throws Exception {
    ExceptionWorker worker = new ExceptionWorker(new ExceptionInfoCache(GlobalSearchScope.allScope(getProject())));
    String line = "2016-12-20 10:58:36,617 [   5740]   INFO - llij.ide.plugins.PluginManager - Loaded bundled plugins: Android Support (10.2.2), Ant Support (1.0), Application Servers View (0.2.0), AspectJ Support (1.2), CFML Support (3.53), CSS Support (163.7743.44), CVS Integration (11), Cloud Foundry integration (1.0), CloudBees integration (1.0), Copyright (8.1), Coverage (163.7743.44), DSM Analysis (1.0.0), Database Tools and SQL (1.0), Eclipse Integration (3.0), EditorConfig (163.7743.44), Emma (163.7743.44), Flash/Flex Support (163.7743.44)";
    worker.execute(line, line.length());
    assertNull(worker.getPsiClass());
}
Also used : ExceptionInfoCache(com.intellij.execution.filters.ExceptionInfoCache) ExceptionWorker(com.intellij.execution.filters.ExceptionWorker)

Example 2 with ExceptionWorker

use of com.intellij.execution.filters.ExceptionWorker in project intellij-community by JetBrains.

the class ExceptionFilterTest method testJava9ModulePrefixed.

public void testJava9ModulePrefixed() throws Throwable {
    PsiClass psiClass = myFixture.addClass("package p; public class A {\n" + "  public void foo() {}\n" + "}");
    ExceptionWorker worker = new ExceptionWorker(new ExceptionInfoCache(GlobalSearchScope.projectScope(getProject())));
    String line = "at mod.name/p.A.foo(A.java:2)";
    worker.execute(line, line.length());
    PsiClass aClass = worker.getPsiClass();
    assertNotNull(aClass);
    assertEquals(psiClass, aClass);
}
Also used : ExceptionInfoCache(com.intellij.execution.filters.ExceptionInfoCache) ExceptionWorker(com.intellij.execution.filters.ExceptionWorker) PsiClass(com.intellij.psi.PsiClass)

Example 3 with ExceptionWorker

use of com.intellij.execution.filters.ExceptionWorker in project intellij-community by JetBrains.

the class VcsContentAnnotationExceptionFilter method applyHeavyFilter.

@Override
public void applyHeavyFilter(@NotNull final Document copiedFragment, int startOffset, int startLineNumber, @NotNull Consumer<AdditionalHighlight> consumer) {
    VcsContentAnnotation vcsContentAnnotation = VcsContentAnnotationImpl.getInstance(myProject);
    final LocalChangesCorrector localChangesCorrector = new LocalChangesCorrector(myProject);
    Trinity<PsiClass, PsiFile, String> previousLineResult = null;
    for (int i = 0; i < copiedFragment.getLineCount(); i++) {
        final int lineStartOffset = copiedFragment.getLineStartOffset(i);
        final int lineEndOffset = copiedFragment.getLineEndOffset(i);
        final ExceptionWorker worker = new ExceptionWorker(myCache);
        final String lineText = copiedFragment.getText(new TextRange(lineStartOffset, lineEndOffset));
        if (ReadAction.compute(() -> worker.execute(lineText, lineEndOffset)) != null) {
            VirtualFile vf = worker.getFile().getVirtualFile();
            if (vf.getFileSystem().isReadOnly())
                continue;
            VcsRevisionNumber recentChangeRevision = myRevNumbersCache.get(vf);
            if (recentChangeRevision == null) {
                recentChangeRevision = vcsContentAnnotation.fileRecentlyChanged(vf);
                if (recentChangeRevision == null) {
                    myRevNumbersCache.put(vf, VcsRevisionNumber.NULL);
                } else {
                    myRevNumbersCache.put(vf, recentChangeRevision);
                }
            }
            if (VcsRevisionNumber.NULL.equals(recentChangeRevision)) {
                recentChangeRevision = null;
            }
            if (localChangesCorrector.isFileAlreadyIdentifiedAsChanged(vf) || ChangeListManager.isFileChanged(myProject, vf) || recentChangeRevision != null) {
                final Document document = getDocumentForFile(worker);
                if (document == null)
                    return;
                int startFileOffset = worker.getInfo().getThird().getStartOffset();
                int idx = lineText.indexOf(':', startFileOffset);
                int endIdx = idx == -1 ? worker.getInfo().getThird().getEndOffset() : idx;
                consumer.consume(new MyAdditionalHighlight(startOffset + lineStartOffset + startFileOffset + 1, startOffset + lineStartOffset + endIdx));
                if (worker.getPsiClass() != null) {
                    // also check method
                    final List<TextRange> ranges = findMethodRange(worker, document, previousLineResult);
                    if (ranges != null) {
                        boolean methodChanged = false;
                        for (TextRange range : ranges) {
                            if (localChangesCorrector.isRangeChangedLocally(vf, document, range)) {
                                methodChanged = true;
                                break;
                            }
                            final TextRange correctedRange = localChangesCorrector.getCorrectedRange(vf, document, range);
                            if (vcsContentAnnotation.intervalRecentlyChanged(vf, correctedRange, recentChangeRevision)) {
                                methodChanged = true;
                                break;
                            }
                        }
                        if (methodChanged) {
                            consumer.consume(new MyAdditionalHighlight(startOffset + lineStartOffset + worker.getInfo().getSecond().getStartOffset(), startOffset + lineStartOffset + worker.getInfo().getSecond().getEndOffset()));
                        }
                    }
                }
            }
        }
        previousLineResult = worker.getResult() == null ? null : new Trinity<>(worker.getPsiClass(), worker.getFile(), worker.getMethod());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Trinity(com.intellij.openapi.util.Trinity) TextRange(com.intellij.openapi.util.TextRange) Document(com.intellij.openapi.editor.Document) ExceptionWorker(com.intellij.execution.filters.ExceptionWorker) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber)

Aggregations

ExceptionWorker (com.intellij.execution.filters.ExceptionWorker)3 ExceptionInfoCache (com.intellij.execution.filters.ExceptionInfoCache)2 Document (com.intellij.openapi.editor.Document)1 TextRange (com.intellij.openapi.util.TextRange)1 Trinity (com.intellij.openapi.util.Trinity)1 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiClass (com.intellij.psi.PsiClass)1