use of com.intellij.navigation.NavigationItem in project intellij-plugins by JetBrains.
the class FlexHighlightingTest method checkNavigatableSymbols.
private void checkNavigatableSymbols(String s) {
JavaScriptIndex scriptIndex = JavaScriptIndex.getInstance(myProject);
String[] strings = scriptIndex.getSymbolNames();
Arrays.sort(strings);
assertTrue(Arrays.binarySearch(strings, s) >= 0);
NavigationItem[] navigationItems = scriptIndex.getSymbolsByName(s, true);
assertTrue(navigationItems.length > 0);
boolean containedInLibrarySwf = false;
for (NavigationItem navigationItem : navigationItems) {
if (navigationItem instanceof JSNamedElement && "library.swf".equals(((PsiElement) navigationItem).getContainingFile().getName())) {
containedInLibrarySwf = true;
break;
}
}
assertTrue(containedInLibrarySwf);
}
use of com.intellij.navigation.NavigationItem in project intellij-plugins by JetBrains.
the class FlexXmlBackedMembersIndex method getItemsByName.
public static Collection<NavigationItem> getItemsByName(final String name, Project project) {
Collection<VirtualFile> files = FileBasedIndex.getInstance().getContainingFiles(NAME, name, GlobalSearchScope.projectScope(project));
final Collection<NavigationItem> result = new ArrayList<>();
for (VirtualFile vFile : files) {
PsiFile file = PsiManager.getInstance(project).findFile(vFile);
if (!(file instanceof XmlFile)) {
continue;
}
process((XmlFile) file, element -> {
if (name.equals(getName(element))) {
if (element instanceof JSNamedElement) {
result.add((JSNamedElement) element);
} else {
XmlAttribute id = ((XmlTag) element).getAttribute("id");
if (id != null) {
XmlAttributeValue valueElement = id.getValueElement();
PsiElement[] children;
if (valueElement != null && (children = valueElement.getChildren()).length == 3) {
result.add(new TagNavigationItem(children[1], name));
}
}
}
}
}, true);
}
return result;
}
use of com.intellij.navigation.NavigationItem in project intellij-elixir by KronicDeth.
the class GotoSymbolContributor method getItemsByName.
/*
* Instance Methods
*/
/**
* Returns the list of navigation items matching the specified name.
*
* @param name the name selected from the list.
* @param pattern the original pattern entered in the dialog
* @param project the project in which the navigation is performed.
* @param includeNonProjectItems if true, the navigation items for non-project items (for example,
* library classes) should be included in the returned array.
* @return the array of navigation items.
*/
@NotNull
@Override
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
GlobalSearchScope scope = globalSearchScope(project, includeNonProjectItems);
Collection<NamedElement> result = StubIndex.getElements(AllName.KEY, name, project, scope, NamedElement.class);
List<NavigationItem> items = ContainerUtil.newArrayListWithCapacity(result.size());
EnclosingModularByCall enclosingModularByCall = new EnclosingModularByCall();
Map<CallDefinition.Tuple, CallDefinition> callDefinitionByTuple = new HashMap<CallDefinition.Tuple, CallDefinition>();
for (final NamedElement element : result) {
// Use navigation element so that source element is used for compiled elements
PsiElement sourceElement = element.getNavigationElement();
if (sourceElement instanceof Call) {
getItemsByNameFromCall(name, items, enclosingModularByCall, callDefinitionByTuple, (Call) sourceElement);
}
}
return items.toArray(new NavigationItem[items.size()]);
}
use of com.intellij.navigation.NavigationItem in project intellij-plugins by JetBrains.
the class FlexXmlBackedSymbolContributor method getItemsByName.
@NotNull
public NavigationItem[] getItemsByName(String name, final String pattern, Project project, boolean includeNonProjectItems) {
Collection<NavigationItem> result = new THashSet<>();
result.addAll(FlexXmlBackedMembersIndex.getItemsByName(name, project));
for (NavigationItem item : JavaScriptClassContributor.getItemsByNameStatic(name, project, includeNonProjectItems)) {
if (item instanceof XmlBackedJSClassImpl) {
result.add(item);
}
}
return result.toArray(new NavigationItem[result.size()]);
}
use of com.intellij.navigation.NavigationItem in project intellij-community by JetBrains.
the class GotoFileCellRenderer method customizeNonPsiElementLeftRenderer.
@Override
protected boolean customizeNonPsiElementLeftRenderer(ColoredListCellRenderer renderer, JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (!(value instanceof NavigationItem))
return false;
NavigationItem item = (NavigationItem) value;
TextAttributes attributes = getNavigationItemAttributes(item);
SimpleTextAttributes nameAttributes = attributes != null ? SimpleTextAttributes.fromTextAttributes(attributes) : null;
Color color = list.getForeground();
if (nameAttributes == null)
nameAttributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, color);
renderer.append(item + " ", nameAttributes);
ItemPresentation itemPresentation = item.getPresentation();
assert itemPresentation != null;
renderer.setIcon(itemPresentation.getIcon(true));
String locationString = itemPresentation.getLocationString();
if (!StringUtil.isEmpty(locationString)) {
renderer.append(locationString, new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, JBColor.GRAY));
}
return true;
}
Aggregations