當前位置: 首頁>>代碼示例>>Java>>正文


Java NavigationItem類代碼示例

本文整理匯總了Java中com.intellij.navigation.NavigationItem的典型用法代碼示例。如果您正苦於以下問題:Java NavigationItem類的具體用法?Java NavigationItem怎麽用?Java NavigationItem使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NavigationItem類屬於com.intellij.navigation包,在下文中一共展示了NavigationItem類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findTargetElement

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
private static PsiElement findTargetElement(@NotNull Editor editor, @NotNull PsiFile file) {
    PsiElement targetElement = TargetElementUtil.findTargetElement(editor,
            TargetElementUtil.getInstance().getReferenceSearchFlags());
    
    if (targetElement != null && targetElement != file) {
        if (targetElement instanceof NavigationItem) {
            targetElement = (targetElement).getNavigationElement();
        }
        
        if (targetElement instanceof NavigationItem) {
            return targetElement;
        }
    }
    
    return null;
}
 
開發者ID:huoguangjin,項目名稱:MultiHighlight,代碼行數:17,代碼來源:MultiHighlightHandler.java

示例2: getCanonicalText

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
@NotNull
public String getCanonicalText() {
    LuaCompoundIdentifier element = (LuaCompoundIdentifier) getElement();


    final PsiElement scopeIdentifier = element.getScopeIdentifier();

    final String definedName = element.getDefinedName();
    if (scopeIdentifier instanceof LuaGlobal) {
        final String moduleName = ((LuaGlobal) scopeIdentifier).getModuleName();

        final String name = ((NavigationItem) scopeIdentifier).getName();
        final boolean hasModule = StringUtil.isNotEmpty(moduleName);
        if ("_M".equals(name))
            return moduleName + definedName.substring(2);

        if (hasModule)
            return moduleName + "." + definedName;
    }

    return definedName;
}
 
開發者ID:internetisalie,項目名稱:lua-for-idea,代碼行數:23,代碼來源:LuaCompoundReferenceElementImpl.java

示例3: getItemsByName

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
@Override 
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
    GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);

    final Collection<LuaDeclarationExpression> globals = ResolveUtil.getFilteredGlobals(project, scope);
    List<NavigationItem> symbols = new ArrayList<NavigationItem>();

    for (LuaDeclarationExpression global : globals) {
        if (!includeNonProjectItems && !scope.contains(global.getContainingFile().getVirtualFile()))
            continue;

        if (global.getDefinedName().startsWith(pattern))
            symbols.add(new GoToSymbolProvider.BaseNavigationItem(global, global.getDefinedName(), global.getIcon(0)));
    }

    //symbols.addAll(StubIndex.getInstance().get(LuaGlobalDeclarationIndex.KEY, name, project, scope));

    return symbols.toArray(new NavigationItem[symbols.size()]);
}
 
開發者ID:internetisalie,項目名稱:lua-for-idea,代碼行數:20,代碼來源:LuaGotoSymbolContributor.java

示例4: getPresentation

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
@Override
public ItemPresentation getPresentation() {
    if(element instanceof SmcMap){
        return PresentationFactory.forMapInStructure((SmcMap) element);
    }else if(element instanceof SmcState){
        return PresentationFactory.forStateInStructure((SmcState) element);
    } else if(element instanceof SmcTransition){
        return PresentationFactory.forTransitionInStructure((SmcTransition) element);
    }else if(element instanceof SmcEntry){
        return PresentationFactory.forEntryInStructure((SmcEntry) element);
    }else if(element instanceof SmcExit){
        return PresentationFactory.forExitInStructure((SmcExit) element);
    }
    return element instanceof NavigationItem ?
            ((NavigationItem) element).getPresentation() : null;
}
 
開發者ID:menshele,項目名稱:smcplugin,代碼行數:17,代碼來源:SmcStructureViewElement.java

示例5: getSymbolContainerText

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
@Nullable
public static String getSymbolContainerText(PsiElement element) {
  if (element instanceof NavigationItem) {
    final ItemPresentation presentation = ((NavigationItem)element).getPresentation();
    if (presentation != null){
      return presentation.getLocationString();
    } else {
      PsiFile file = element.getContainingFile();
      if (file != null) {
        VirtualFile virtualFile = file.getVirtualFile();
        if (virtualFile != null) return virtualFile.getPath();
      }
    }
  }

  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:SymbolPresentationUtil.java

示例6: getDescriptorKey

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
private static String getDescriptorKey(final NodeDescriptor nodeDescriptor) {
  if (nodeDescriptor instanceof AbstractTreeNode) {
    Object value;
    if (nodeDescriptor instanceof NodeDescriptorProvidingKey) {
      value = ((NodeDescriptorProvidingKey)nodeDescriptor).getKey();
    }
    else {
      value = ((AbstractTreeNode)nodeDescriptor).getValue();
    }

    if (value instanceof NavigationItem) {
      try {
        final String name = ((NavigationItem)value).getName();
        return name != null ? name : value.toString();
      }
      catch (Exception e) {
        //ignore for invalid psi element
      }
    }
  }
  return nodeDescriptor.toString();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:TreeState.java

示例7: openFileWithPsiElement

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
public static boolean openFileWithPsiElement(PsiElement element, boolean searchForOpen, boolean requestFocus) {
  boolean openAsNative = false;
  if (element instanceof PsiFile) {
    VirtualFile virtualFile = ((PsiFile)element).getVirtualFile();
    if (virtualFile != null) {
      openAsNative = ElementBase.isNativeFileType(virtualFile.getFileType());
    }
  }

  if (searchForOpen) {
    element.putUserData(FileEditorManager.USE_CURRENT_WINDOW, null);
  }
  else {
    element.putUserData(FileEditorManager.USE_CURRENT_WINDOW, true);
  }

  if (openAsNative || !activatePsiElementIfOpen(element, searchForOpen, requestFocus)) {
    final NavigationItem navigationItem = (NavigationItem)element;
    if (!navigationItem.canNavigate()) return false;
    navigationItem.navigate(requestFocus);
    return true;
  }

  element.putUserData(FileEditorManager.USE_CURRENT_WINDOW, null);
  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:NavigationUtil.java

示例8: getItemsByName

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
@Override
@NotNull
public NavigationItem[] getItemsByName(String name, final String pattern, Project project, boolean includeNonProjectItems) {
  final PsiManager psiManager = PsiManager.getInstance(project);
  final VirtualFile baseDir = project.getBaseDir();
  if (baseDir == null) return NavigationItem.EMPTY_NAVIGATION_ITEM_ARRAY;
  final VirtualFile[] files = baseDir.getChildren();
  final ArrayList<PsiFile> list = new ArrayList<PsiFile>();
  for (VirtualFile file : files) {
    if (isEditable(file, includeNonProjectItems) && Comparing.strEqual(name, file.getName())) {
      final PsiFile psiFile = psiManager.findFile(file);
      if (psiFile != null) {
        list.add(psiFile);
      }
    }
  }
  return PsiUtilCore.toPsiFileArray(list);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:ProjectBaseDirNavigationContributor.java

示例9: getFullName

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
@Override
public String getFullName(final Object element) {
  for(ChooseByNameContributor c: getContributors()) {
    if (c instanceof GotoClassContributor) {
      String result = ((GotoClassContributor) c).getQualifiedName((NavigationItem) element);
      if (result != null) {
        return result;
      }
    }
  }

  String elementName = getElementName(element);
  if (elementName == null) return null;
  
  if (element instanceof PsiElement) {
    return SymbolPresentationUtil.getSymbolContainerText((PsiElement)element) + "." + elementName;
  }

  return elementName;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:GotoSymbolModel2.java

示例10: acceptItem

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
@Override
protected boolean acceptItem(final NavigationItem item) {
  if (item instanceof PsiFile) {
    final PsiFile file = (PsiFile)item;
    final Collection<FileType> types = getFilterItems();
    // if language substitutors are used, PsiFile.getFileType() can be different from
    // PsiFile.getVirtualFile().getFileType()
    if (types != null) {
      if (types.contains(file.getFileType())) return true;
      VirtualFile vFile = file.getVirtualFile();
      if (vFile != null && types.contains(vFile.getFileType())) return true;
      return false;
    }
    return true;
  }
  else {
    return super.acceptItem(item);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:GotoFileModel.java

示例11: addVariantsFromIndex

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
private static <T extends PsiNamedElement> void addVariantsFromIndex(final CompletionResultSet resultSet,
                                                                     final PsiFile targetFile,
                                                                     final StubIndexKey<String, T> key,
                                                                     final InsertHandler<LookupElement> insertHandler,
                                                                     final Condition<? super T> condition, Class<T> elementClass) {
  final Project project = targetFile.getProject();
  GlobalSearchScope scope = PyProjectScopeBuilder.excludeSdkTestsScope(targetFile);

  Collection<String> keys = StubIndex.getInstance().getAllKeys(key, project);
  for (final String elementName : CompletionUtil.sortMatching(resultSet.getPrefixMatcher(), keys)) {
    for (T element : StubIndex.getElements(key, elementName, project, scope, elementClass)) {
      if (condition.value(element)) {
        resultSet.addElement(LookupElementBuilder.createWithIcon(element)
                               .withTailText(" " + ((NavigationItem)element).getPresentation().getLocationString(), true)
                               .withInsertHandler(insertHandler));
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:PyClassNameCompletionContributor.java

示例12: process

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
@Override
public boolean process(VirtualFile file, Void kind) {
  if (myScope.contains(file)) {
    final PsiFile psiFile = myMgr.findFile(file);
    if (psiFile instanceof XmlFile) {
      final Grammar grammar = GrammarFactory.getGrammar((XmlFile)psiFile);
      if (grammar != null) {
        grammar.acceptChildren(new CommonElement.Visitor() {
          @Override
          public void visitDefine(Define define) {
            if (myName.equals(define.getName())) {
              final PsiElement psi = define.getPsiElement();
              if (psi != null) {
                MyNavigationItem.add((NavigationItem)define.getPsiElement(), myResult);
              }
            }
          }
        });
      }
    }
  }
  return true;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:RelaxSymbolIndex.java

示例13: getPresentation

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
@Override
public ItemPresentation getPresentation() {
  return new ItemPresentation() {
    @Override
    @Nullable
    public String getPresentableText() {
      String name = ((NavigationItem)myWrappee).getName();
      if (myDirName == null || myFileName == null) {
        return name;
      }
      return name + " (..." + File.separatorChar + myDirName +
             File.separatorChar + myFileName + ')';
    }

    @Override
    public String getLocationString() {
      return null;
    }

    @Override
    public Icon getIcon(boolean open) {
      return null;
    }
  };
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:ValueResourceElementWrapper.java

示例14: getPresentation

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
@Override
public ItemPresentation getPresentation() {
  final PsiElement parent = getParent();
  if (parent instanceof NavigationItem) {
    return ((NavigationItem) parent).getPresentation();
  }
  return null;
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:9,代碼來源:AppleScriptNamedElementImpl.java

示例15: getPresentation

import com.intellij.navigation.NavigationItem; //導入依賴的package包/類
@NotNull
@Override
public ItemPresentation getPresentation() {
    if (m_element instanceof NavigationItem) {
        ItemPresentation presentation = ((NavigationItem) m_element).getPresentation();
        if (presentation != null) {
            return presentation;
        }
    }
    throw new RuntimeException("Unknown presentation");
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:12,代碼來源:StructureViewElement.java


注:本文中的com.intellij.navigation.NavigationItem類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。