use of com.intellij.lang.PsiStructureViewFactory in project intellij-community by JetBrains.
the class XmlStructureViewBuilderFactory method getStructureViewBuilderForExtensions.
@Nullable
private static StructureViewBuilder getStructureViewBuilderForExtensions(final PsiFile psiFile) {
for (Language language : XMLLanguage.INSTANCE.getLanguageExtensionsForFile(psiFile)) {
PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language);
if (factory == null)
continue;
final StructureViewBuilder builder = factory.getStructureViewBuilder(psiFile);
if (builder != null) {
return builder;
}
}
return null;
}
use of com.intellij.lang.PsiStructureViewFactory in project intellij-community by JetBrains.
the class LanguageFileTypeStructureViewBuilderProvider method getStructureViewBuilder.
@Override
@Nullable
public StructureViewBuilder getStructureViewBuilder(@NotNull final FileType fileType, @NotNull final VirtualFile file, @NotNull 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);
}
use of com.intellij.lang.PsiStructureViewFactory in project intellij-community by JetBrains.
the class GotoClassAction method findMember.
@Nullable
private static Navigatable findMember(String pattern, 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;
}
final MinusculeMatcher matcher = NameUtil.buildMatcher(pattern).build();
int max = Integer.MIN_VALUE;
Object target = null;
for (TreeElement treeElement : element.getChildren()) {
if (treeElement instanceof StructureViewTreeElement) {
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);
}
}
use of com.intellij.lang.PsiStructureViewFactory in project intellij-community by JetBrains.
the class TemplateLanguageStructureViewBuilder method createBaseLanguageStructureView.
@Nullable
private StructureViewComposite.StructureViewDescriptor createBaseLanguageStructureView(final FileEditor fileEditor, final Language language) {
if (!myVirtualFile.isValid())
return null;
final FileViewProvider viewProvider = getViewProvider();
if (viewProvider == null)
return null;
final PsiFile dataFile = viewProvider.getPsi(language);
if (dataFile == null || !isAcceptableBaseLanguageFile(dataFile))
return null;
final PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(language);
if (factory == null)
return null;
final StructureViewBuilder builder = factory.getStructureViewBuilder(dataFile);
if (builder == null)
return null;
StructureView structureView = builder.createStructureView(fileEditor, myProject);
return new StructureViewComposite.StructureViewDescriptor(IdeBundle.message("tab.structureview.baselanguage.view", language.getDisplayName()), structureView, findFileType(language).getIcon());
}
Aggregations