当前位置: 首页>>代码示例>>Java>>正文


Java NavigationUtil类代码示例

本文整理汇总了Java中com.intellij.codeInsight.navigation.NavigationUtil的典型用法代码示例。如果您正苦于以下问题:Java NavigationUtil类的具体用法?Java NavigationUtil怎么用?Java NavigationUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NavigationUtil类属于com.intellij.codeInsight.navigation包,在下文中一共展示了NavigationUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invoke

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @NotNull Editor editor, @NotNull PsiFile file) {
  PsiDocumentManager.getInstance(project).commitAllDocuments();

  DumbService.getInstance(project).setAlternativeResolveEnabled(true);
  try {
    int offset = editor.getCaretModel().getOffset();
    PsiElement[] symbolTypes = findSymbolTypes(editor, offset);
    if (symbolTypes == null || symbolTypes.length == 0) return;
    if (symbolTypes.length == 1) {
      navigate(project, symbolTypes[0]);
    }
    else {
      NavigationUtil.getPsiElementPopup(symbolTypes, CodeInsightBundle.message("choose.type.popup.title")).showInBestPositionFor(editor);
    }
  }
  catch (IndexNotReadyException e) {
    DumbService.getInstance(project).showDumbModeNotification("Navigation is not available here during index update");
  }
  finally {
    DumbService.getInstance(project).setAlternativeResolveEnabled(false);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GotoTypeDeclarationAction.java

示例2: handleLink

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
@Override
public boolean handleLink(@NotNull String refSuffix, @NotNull Editor editor) {
  Project project = editor.getProject();
  if (project == null) return false;
  PsiElement aClass = JavaPsiFacade.getInstance(project).findClass(refSuffix, GlobalSearchScope.allScope(project));
  if (aClass == null) return false;
  NavigationUtil.activateFileWithPsiElement(aClass);
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:JavaClassTooltipLinkHandler.java

示例3: testGotoClass

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
public void testGotoClass() throws Exception {

    PsiJavaFile file = (PsiJavaFile)myFixture.configureByText("Foo.java", "public class Foo {\n" +
                                                         "}\n" +
                                                         "\n" +
                                                         "class Bar {}\n");

    VirtualFile virtualFile = file.getVirtualFile();
    assertNotNull(virtualFile);
    myManager.openFile(virtualFile, true);
    assertEquals(0, getOffset(virtualFile));
    myManager.closeAllFiles();

    PsiClass psiClass = file.getClasses()[1];
    int identifierOffset = psiClass.getNameIdentifier().getTextOffset();
    NavigationUtil.activateFileWithPsiElement(psiClass);
    assertEquals(identifierOffset, getOffset(virtualFile));

    getEditor(virtualFile).getCaretModel().moveToOffset(identifierOffset + 3); // it's still inside the class, so keep it

    myManager.closeAllFiles();
    NavigationUtil.activateFileWithPsiElement(psiClass);
    assertEquals(identifierOffset + 3, getOffset(virtualFile));

    getEditor(virtualFile).getCaretModel().moveToOffset(0);
    NavigationUtil.activateFileWithPsiElement(psiClass);
    assertEquals(identifierOffset, getOffset(virtualFile));

    myManager.closeAllFiles();
    NavigationUtil.activateFileWithPsiElement(file); // GoTo file should keep offset
    assertEquals(identifierOffset, getOffset(virtualFile));
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:GotoClassTest.java

示例4: testSelectFileOnNavigation

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
public void testSelectFileOnNavigation() throws Exception {
  VirtualFile file1 = getFile("/src/1.txt");
  myManager.openFile(file1, true);
  VirtualFile file2 = getFile("/src/2.txt");
  myManager.openFile(file2, true);
  NavigationUtil.activateFileWithPsiElement(PsiManager.getInstance(getProject()).findFile(file1));
  VirtualFile[] files = myManager.getSelectedFiles();
  assertEquals(1, files.length);
  assertEquals("1.txt", files[0].getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:NewDocumentHistoryTest.java

示例5: invokeHint

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
public void invokeHint(Runnable hideRunnable) {
  myHideRunnable = hideRunnable;

  if (!canShowHint()) {
    hideHint();
    return;
  }

  if (myType == ValueHintType.MOUSE_ALT_OVER_HINT) {
    EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
    TextAttributes attributes = scheme.getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR);
    attributes = NavigationUtil.patchAttributesColor(attributes, myCurrentRange, myEditor);

    myHighlighter = myEditor.getMarkupModel().addRangeHighlighter(myCurrentRange.getStartOffset(), myCurrentRange.getEndOffset(),
                                                                  HighlighterLayer.SELECTION + 1, attributes,
                                                                  HighlighterTargetArea.EXACT_RANGE);
    Component internalComponent = myEditor.getContentComponent();
    myStoredCursor = internalComponent.getCursor();
    internalComponent.addKeyListener(myEditorKeyListener);
    internalComponent.setCursor(hintCursor());
    if (LOG.isDebugEnabled()) {
      LOG.debug("internalComponent.setCursor(hintCursor())");
    }
  }
  else {
    evaluateAndShowHint();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:AbstractValueHint.java

示例6: navigateToElement

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
@Override
protected void navigateToElement(Navigatable element) {
  if (element instanceof PsiElement) {
    NavigationUtil.activateFileWithPsiElement((PsiElement)element, true);
  }
  else {
    element.navigate(true);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GotoTestOrCodeHandler.java

示例7: actionPerformed

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
  PsiElement element = getContextElement(e.getDataContext());
  if (element == null) return;

  List<GotoRelatedItem> items = NavigationUtil.collectRelatedItems(element, e.getDataContext());
  if (items.isEmpty()) return;

  if (items.size() == 1 && items.get(0).getElement() != null) {
    items.get(0).navigate();
    return;
  }
  NavigationUtil.getRelatedItemsPopup(items, "Choose Target").showInBestPositionFor(e.getDataContext());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GotoRelatedSymbolAction.java

示例8: navigate

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
@Override
public void navigate(boolean requestFocus, boolean preserveState) {
  if (canNavigate()) {
    if (requestFocus || preserveState) {
      NavigationUtil.openFileWithPsiElement(extractPsiFromValue(), requestFocus, requestFocus);
    }
    else {
      getNavigationItem().navigate(requestFocus);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:AbstractPsiBasedNode.java

示例9: navigateOrChoose

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
private static void navigateOrChoose(Editor editor, Collection<? extends NavigatablePsiElement> superElements, final String title) {
  if (!superElements.isEmpty()) {
    NavigatablePsiElement[] superElementArray = superElements.toArray(new NavigatablePsiElement[superElements.size()]);
    if (superElementArray.length == 1) {
      superElementArray[0].navigate(true);
    }
    else {
      NavigationUtil.getPsiElementPopup(superElementArray, title).showInBestPositionFor(editor);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:PyGotoSuperHandler.java

示例10: doClickAction

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
static void doClickAction(AnActionEvent e, Collection<Define> set, String title) {
  if (set.size() == 1) {
    final Navigatable n = (Navigatable)set.iterator().next().getPsiElement();
    OpenSourceUtil.navigate(true, n);
  } else {
    final Define[] array = set.toArray(new Define[set.size()]);
    NavigationUtil.getPsiElementPopup(ContainerUtil.map(array, new Function<Define, PsiElement>() {
      @Override
      public PsiElement fun(Define define) {
        return define.getPsiElement();
      }
    }, PsiElement.EMPTY_ARRAY), title).show(new RelativePoint((MouseEvent)e.getInputEvent()));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:OverridingDefineRenderer.java

示例11: navigate

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
@Override
public void navigate(MouseEvent e, PsiElement elt) {
  final List<GotoRelatedItem> items = doComputeItems();

  if (items.size() == 1) {
    items.get(0).navigate();
  }
  else {
    NavigationUtil.getRelatedItemsPopup(items, "Go to Related Files").show(new RelativePoint(e));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:AndroidLineMarkerProvider.java

示例12: showScopeChooser

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
@Override
protected void showScopeChooser(PsiClass[] scopes, final Pass<PsiClass> callback, Editor editor) {
  PsiElementProcessor<PsiClass> processor = new PsiElementProcessor<PsiClass>() {
    @Override
    public boolean execute(@NotNull PsiClass element) {
      callback.pass(element);
      return false;
    }
  };

  NavigationUtil.getPsiElementPopup(scopes, new PsiClassListCellRenderer(), "Choose class to introduce field", processor).showInBestPositionFor(editor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:GrIntroduceFieldHandlerBase.java

示例13: navigate

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
@Override
public void navigate(MouseEvent e, PsiField field) {
  final ArrayList<PsiElement> relatedItems = new ArrayList<PsiElement>();
  collectTargets(field, relatedItems, Function.ID, false);
  if (relatedItems.size() == 1) {
    NavigationUtil.activateFileWithPsiElement(relatedItems.get(0));
    return;
  }
  final JBPopup popup = NavigationUtil
    .getPsiElementPopup(relatedItems.toArray(new PsiElement[relatedItems.size()]), "<html>Choose component with fx:id <b>" + field.getName() + "<b></html>");
  popup.show(new RelativePoint(e));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JavaFxRelatedItemLineMarkerProvider.java

示例14: navigate

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
@Override
public void navigate(boolean requestFocus) {
  if (canNavigate()) {
    final PsiNamedElement value = (PsiNamedElement)getValue();
    if (requestFocus) {
      NavigationUtil.activateFileWithPsiElement(value, true);
    }
    else if (value instanceof NavigationItem) {
      ((NavigationItem)value).navigate(requestFocus);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CoverageListNode.java

示例15: navigate

import com.intellij.codeInsight.navigation.NavigationUtil; //导入依赖的package包/类
public void navigate(MouseEvent e, PsiElement elt) {
    Collection<GotoRelatedItem>  items = this.items;
    if (items.size() == 1) {
        items.iterator().next().navigate();
    } else {
        NavigationUtil.getRelatedItemsPopup(new ArrayList<>(items), "Go to Related Files").show(new RelativePoint(e));
    }
}
 
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:9,代码来源:RelatedPopupGotoLineMarker.java


注:本文中的com.intellij.codeInsight.navigation.NavigationUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。