com.intellij.lang.PsiStructureViewFactory Java Examples
The following examples show how to use
com.intellij.lang.PsiStructureViewFactory.
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: TemplateLanguageStructureViewBuilder.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private StructureViewBuilder getBuilder(@Nonnull PsiFile psiFile, @Nonnull Language language) { FileViewProvider viewProvider = psiFile.getViewProvider(); Language baseLanguage = viewProvider.getBaseLanguage(); PsiFile psi = viewProvider.getPsi(language); if (psi == null) return null; if (language == baseLanguage) return createMainBuilder(psi); if (!isAcceptableBaseLanguageFile(psi)) return null; PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language); return factory == null ? null : factory.getStructureViewBuilder(psi); }
Example #2
Source File: LanguageFileTypeStructureViewBuilderProvider.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nullable public StructureViewBuilder getStructureViewBuilder(@Nonnull final FileType fileType, @Nonnull final VirtualFile file, @Nonnull final Project project) { if (!(fileType instanceof LanguageFileType)) return null; final PsiFile psiFile = PsiManager.getInstance(project).findFile(file); if (psiFile == null) return null; final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(psiFile.getLanguage()); return factory == null ? null : factory.getStructureViewBuilder(psiFile); }
Example #3
Source File: GotoClassAction.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public static Navigatable findMember(String memberPattern, String fullPattern, PsiElement psiElement, VirtualFile file) { final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(psiElement.getLanguage()); final StructureViewBuilder builder = factory == null ? null : factory.getStructureViewBuilder(psiElement.getContainingFile()); final FileEditor[] editors = FileEditorManager.getInstance(psiElement.getProject()).getEditors(file); if (builder == null || editors.length == 0) { return null; } final StructureView view = builder.createStructureView(editors[0], psiElement.getProject()); try { final StructureViewTreeElement element = findElement(view.getTreeModel().getRoot(), psiElement, 4); if (element == null) { return null; } MinusculeMatcher matcher = NameUtil.buildMatcher(memberPattern).build(); int max = Integer.MIN_VALUE; Object target = null; for (TreeElement treeElement : element.getChildren()) { if (treeElement instanceof StructureViewTreeElement) { Object value = ((StructureViewTreeElement)treeElement).getValue(); if (value instanceof PsiElement && value instanceof Navigatable && fullPattern.equals(CopyReferenceAction.elementToFqn((PsiElement)value))) { return (Navigatable)value; } String presentableText = treeElement.getPresentation().getPresentableText(); if (presentableText != null) { final int degree = matcher.matchingDegree(presentableText); if (degree > max) { max = degree; target = ((StructureViewTreeElement)treeElement).getValue(); } } } } return target instanceof Navigatable ? (Navigatable)target : null; } finally { Disposer.dispose(view); } }