use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.
the class Bookmark method getQualifiedName.
public String getQualifiedName() {
String presentableUrl = myFile.getPresentableUrl();
if (myFile.isDirectory())
return presentableUrl;
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(myFile);
if (psiFile == null)
return presentableUrl;
StructureViewBuilder builder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(psiFile);
if (builder instanceof TreeBasedStructureViewBuilder) {
StructureViewModel model = ((TreeBasedStructureViewBuilder) builder).createStructureViewModel(null);
Object element;
try {
element = model.getCurrentEditorElement();
} finally {
model.dispose();
}
if (element instanceof NavigationItem) {
ItemPresentation presentation = ((NavigationItem) element).getPresentation();
if (presentation != null) {
presentableUrl = ((NavigationItem) element).getName() + " " + presentation.getLocationString();
}
}
}
return IdeBundle.message("bookmark.file.X.line.Y", presentableUrl, getLine() + 1);
}
use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.
the class GotoSymbolAction method gotoActionPerformed.
@Override
public void gotoActionPerformed(AnActionEvent e) {
FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.popup.symbol");
Project project = e.getProject();
if (project == null)
return;
GotoSymbolModel2 model = new GotoSymbolModel2(project);
PsiDocumentManager.getInstance(project).commitAllDocuments();
showNavigationPopup(e, model, new GotoActionCallback<Language>() {
@Override
protected ChooseByNameFilter<Language> createFilter(@NotNull ChooseByNamePopup popup) {
return new ChooseByNameLanguageFilter(popup, model, GotoClassSymbolConfiguration.getInstance(project), project);
}
@Override
public void elementChosen(ChooseByNamePopup popup, Object element) {
EditSourceUtil.navigate((NavigationItem) element, true, popup.isOpenInCurrentWindowRequested());
}
}, "Symbols matching patterns", true);
}
use of com.intellij.navigation.NavigationItem 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()]);
}
use of com.intellij.navigation.NavigationItem in project intellij-elixir by KronicDeth.
the class GotoSymbolContributorTest method testIssue472.
/*
* Tests
*/
public void testIssue472() {
myFixture.configureByFile("issue_472.ex");
ChooseByNameContributor[] symbolModelContributors = ChooseByNameRegistry.getInstance().getSymbolModelContributors();
GotoSymbolContributor gotoSymbolContributor = null;
for (ChooseByNameContributor symbolModelContributor : symbolModelContributors) {
if (symbolModelContributor instanceof GotoSymbolContributor) {
gotoSymbolContributor = (GotoSymbolContributor) symbolModelContributor;
}
}
assertNotNull(gotoSymbolContributor);
NavigationItem[] itemsByName = gotoSymbolContributor.getItemsByName("decode_auth_type", "decode_a", myFixture.getProject(), false);
assertEquals(2, itemsByName.length);
assertInstanceOf(itemsByName[0], CallDefinition.class);
CallDefinition callDefinition = (CallDefinition) itemsByName[0];
assertEquals("decode_auth_type", callDefinition.name());
assertInstanceOf(itemsByName[1], CallDefinitionClause.class);
CallDefinitionClause callDefinitionClause = (CallDefinitionClause) itemsByName[1];
assertEquals("decode_auth_type", callDefinitionClause.getName());
}
use of com.intellij.navigation.NavigationItem in project intellij-plugins by JetBrains.
the class GoToActionSymbolProvider method addItems.
protected void addItems(@NotNull final Module module, final String name, final List<NavigationItem> result) {
final StrutsModel strutsModel = StrutsManager.getInstance(module.getProject()).getCombinedModel(module);
if (strutsModel == null) {
return;
}
final List<Action> actions = strutsModel.findActionsByName(name, null);
for (final Action action : actions) {
final NavigationItem item = createNavigationItem(action.getXmlTag(), action.getName().getStringValue() + " [" + action.getNamespace() + "]", Struts2Icons.Action);
result.add(item);
}
}
Aggregations