use of org.intellij.plugins.relaxNG.model.Grammar in project intellij-community by JetBrains.
the class OverriddenDefineRenderer method getClickAction.
@Override
@Nullable
public AnAction getClickAction() {
return new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
final PsiElement element = myDefine.getPsiElement();
if (element == null || !element.isValid())
return;
final PsiElementProcessor.CollectElements<XmlFile> collector = new PsiElementProcessor.CollectElements<>();
final XmlFile localFile = (XmlFile) element.getContainingFile();
RelaxIncludeIndex.processBackwardDependencies(localFile, collector);
final Collection<XmlFile> files = collector.getCollection();
final List<Define> result = new SmartList<>();
final OverriddenDefineSearcher searcher = new OverriddenDefineSearcher(myDefine, localFile, result);
for (XmlFile file : files) {
final Grammar grammar = GrammarFactory.getGrammar(file);
if (grammar == null)
continue;
grammar.acceptChildren(searcher);
}
if (result.size() > 0) {
OverridingDefineRenderer.doClickAction(e, result, "Go to overriding define(s)");
}
}
};
}
use of org.intellij.plugins.relaxNG.model.Grammar in project intellij-community by JetBrains.
the class RelaxSymbolIndex method getSymbolsByName.
public static NavigationItem[] getSymbolsByName(final String name, Project project, boolean includeNonProjectItems) {
final GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
final Collection<NavigationItem> result = new ArrayList<>();
PsiManager psiManager = PsiManager.getInstance(project);
for (VirtualFile file : FileBasedIndex.getInstance().getContainingFiles(NAME, name, scope)) {
final PsiFile psiFile = psiManager.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 (name.equals(define.getName())) {
final PsiElement psi = define.getPsiElement();
if (psi != null) {
MyNavigationItem.add((NavigationItem) define.getPsiElement(), result);
}
}
}
});
}
}
}
return result.toArray(new NavigationItem[result.size()]);
}
Aggregations