예제 #1
0
  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;
 }
예제 #3
0
파일: TreeView.java 프로젝트: jexp/idea2
 @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;
 }
 @Override
 public void navigate(boolean requestFocus) {
   OpenFileDescriptor fileDescriptor =
       new OpenFileDescriptor(myPsiFile.getProject(), myPsiFile.getVirtualFile(), myLineNumber);
   fileDescriptor.navigate(requestFocus);
 }
예제 #5
0
 public static void doNavigate(FileUsage fileUsage, OurUsage ourUsage, Project project) {
   final OpenFileDescriptor openFileDescriptor =
       new OpenFileDescriptor(project, fileUsage.findVirtualFile(), ourUsage.getStart());
   openFileDescriptor.navigate(true);
 }
 @Override
 public void navigateTo(@NotNull final Navigatable navigatable) {
   ((OpenFileDescriptor) navigatable).navigateIn(getEditor());
 }