private void doTest(
      @NotNull String fileName, int lineNumber, @NotNull Function1<VirtualFile, String> className) {
    if (rootDir == null) {
      configure();
    }
    assert rootDir != null;

    Filter filter = new JetExceptionFilterFactory().create(GlobalSearchScope.allScope(myProject));

    VirtualFile expectedFile = VfsUtilCore.findRelativeFile(fileName, rootDir);
    assertNotNull(expectedFile);

    String line = createStackTraceElementLine(fileName, className.invoke(expectedFile), lineNumber);
    Filter.Result result = filter.applyFilter(line, 0);

    assertNotNull(result);
    HyperlinkInfo info = result.getFirstHyperlinkInfo();
    assertNotNull(info);
    assertInstanceOf(info, OpenFileHyperlinkInfo.class);
    OpenFileDescriptor descriptor = ((OpenFileHyperlinkInfo) info).getDescriptor();
    assertNotNull(descriptor);

    assertEquals(expectedFile, descriptor.getFile());

    Document document = FileDocumentManager.getInstance().getDocument(expectedFile);
    assertNotNull(document);
    int expectedOffset = document.getLineStartOffset(lineNumber - 1);
    assertEquals(expectedOffset, descriptor.getOffset());
  }
 @Nullable
 @CalledWithReadLock
 private static VirtualFile getHyperlinkVirtualFile(@NotNull List<RangeHighlighter> links) {
   RangeHighlighter key = ContainerUtil.getLastItem(links);
   if (key == null) return null;
   HyperlinkInfo info = EditorHyperlinkSupport.getHyperlinkInfo(key);
   if (!(info instanceof FileHyperlinkInfo)) return null;
   OpenFileDescriptor descriptor = ((FileHyperlinkInfo) info).getDescriptor();
   return descriptor != null ? descriptor.getFile() : null;
 }
Beispiel #3
0
 @Nullable
 public Object getData(String dataId) {
   if (DataConstants.NAVIGATABLE.equals(dataId)) {
     MessageNode item = getSelectedItem();
     if (item == null) return null;
     if (isValid(item.getFile())) {
       return new OpenFileDescriptor(myProject, item.getFile(), item.getOffset());
     }
     if (item.getType() == AntBuildMessageView.MessageType.TARGET) {
       final OpenFileDescriptor descriptor = getDescriptorForTargetNode(item);
       if (descriptor != null && isValid(descriptor.getFile())) {
         return descriptor;
       }
     }
     if (item.getType() == AntBuildMessageView.MessageType.TASK) {
       final OpenFileDescriptor descriptor = getDescriptorForTaskNode(item);
       if (descriptor != null && isValid(descriptor.getFile())) {
         return descriptor;
       }
     }
   }
   return null;
 }