Java Code Examples for com.intellij.pom.Navigatable#canNavigateToSource()

The following examples show how to use com.intellij.pom.Navigatable#canNavigateToSource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UsageViewImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private static Navigatable getNavigatableForNode(@Nonnull DefaultMutableTreeNode node, boolean allowRequestFocus) {
  Object userObject = node.getUserObject();
  if (userObject instanceof Navigatable) {
    final Navigatable navigatable = (Navigatable)userObject;
    return navigatable.canNavigate() ? new Navigatable() {
      @Override
      public void navigate(boolean requestFocus) {
        navigatable.navigate(allowRequestFocus && requestFocus);
      }

      @Override
      public boolean canNavigate() {
        return navigatable.canNavigate();
      }

      @Override
      public boolean canNavigateToSource() {
        return navigatable.canNavigateToSource();
      }
    } : null;
  }
  return null;
}
 
Example 2
Source File: StructureViewComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void scrollToSource(Component tree) {
  if (isDisposed()) return;
  myAutoscrollFeedback = true;

  Navigatable navigatable = DataManager.getInstance().getDataContext(getTree()).getData(CommonDataKeys.NAVIGATABLE);
  if (myFileEditor != null && navigatable != null && navigatable.canNavigateToSource()) {
    navigatable.navigate(false);
  }
}
 
Example 3
Source File: ClassSearchEverywhereContributor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected Navigatable createExtendedNavigatable(PsiElement psi, String searchText, int modifiers) {
  Navigatable res = super.createExtendedNavigatable(psi, searchText, modifiers);
  if (res != null) {
    return res;
  }

  VirtualFile file = PsiUtilCore.getVirtualFile(psi);
  String memberName = getMemberName(searchText);
  if (file != null && memberName != null) {
    Navigatable delegate = GotoClassAction.findMember(memberName, searchText, psi, file);
    if (delegate != null) {
      return new Navigatable() {
        @Override
        public void navigate(boolean requestFocus) {
          NavigationUtil.activateFileWithPsiElement(psi, openInCurrentWindow(modifiers));
          delegate.navigate(true);

        }

        @Override
        public boolean canNavigate() {
          return delegate.canNavigate();
        }

        @Override
        public boolean canNavigateToSource() {
          return delegate.canNavigateToSource();
        }
      };
    }
  }

  return null;
}
 
Example 4
Source File: XBreakpointItem.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canNavigateToSource() {
  Navigatable navigatable = myBreakpoint.getNavigatable();
  return navigatable != null && navigatable.canNavigateToSource();
}
 
Example 5
Source File: PsiElementBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canNavigateToSource() {
  final Navigatable descriptor = PsiNavigationSupport.getInstance().getDescriptor(this);
  return descriptor != null && descriptor.canNavigateToSource();
}