本文整理汇总了Java中com.intellij.psi.NavigatablePsiElement类的典型用法代码示例。如果您正苦于以下问题:Java NavigatablePsiElement类的具体用法?Java NavigatablePsiElement怎么用?Java NavigatablePsiElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NavigatablePsiElement类属于com.intellij.psi包,在下文中一共展示了NavigatablePsiElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNamedChildren
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
private List<? extends PsiNamedElement> getNamedChildren(final PsiElement psiElement) {
List<PsiNamedElement> children = Arrays.stream(psiElement.getChildren())
.filter(child -> child instanceof PsiNamedElement)
.map(child -> (PsiNamedElement) child)
.collect(Collectors.toList());
if (children.isEmpty()) {
Optional<PsiElement> navigatablePsiElement = Arrays.stream(psiElement.getChildren())
.filter(child -> child instanceof NavigatablePsiElement)
.filter(child -> !(child instanceof JsonStringLiteral))
.findFirst();
return navigatablePsiElement.isPresent() ? getNamedChildren(navigatablePsiElement.get()) : new ArrayList<>();
}
return new ArrayList<>(children);
}
示例2: getChildByName
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
private Optional<? extends PsiElement> getChildByName(final PsiElement psiElement, final String name) {
if (ROOT_PATH.equals(name)) {
return Optional.of(psiElement);
}
List<PsiNamedElement> children = Arrays.stream(psiElement.getChildren())
.filter(child -> child instanceof PsiNamedElement)
.map(child -> (PsiNamedElement) child)
.collect(Collectors.toList());
if (children.isEmpty()) {
Optional<PsiElement> navigatablePsiElement = Arrays.stream(psiElement.getChildren())
.filter(child -> child instanceof NavigatablePsiElement)
.filter(child -> !(child instanceof JsonStringLiteral))
.findFirst();
return navigatablePsiElement.isPresent() ? getChildByName(navigatablePsiElement.get(), name) : Optional.empty();
}
return children.stream()
.filter(child -> name.equals(child.getName()))
.findFirst();
}
示例3: navigateOrCreatePopup
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
@Nullable
private static JBPopup navigateOrCreatePopup(final NavigatablePsiElement[] targets,
final String title,
final String findUsagesTitle,
final ListCellRenderer listRenderer,
@Nullable final ListBackgroundUpdaterTask listUpdaterTask) {
return navigateOrCreatePopup(targets, title, findUsagesTitle, listRenderer, listUpdaterTask, new Consumer<Object[]>() {
@Override
public void consume(Object[] selectedElements) {
for (Object element : selectedElements) {
PsiElement selected = (PsiElement)element;
LOG.assertTrue(selected.isValid());
((NavigatablePsiElement)selected).navigate(true);
}
}
});
}
示例4: navigateOrCreatePopup
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
@Nullable
private static JBPopup navigateOrCreatePopup(final NavigatablePsiElement[] targets,
final String title,
final String findUsagesTitle,
final ListCellRenderer listRenderer,
final @Nullable ListBackgroundUpdaterTask listUpdaterTask) {
return navigateOrCreatePopup(targets, title, findUsagesTitle, listRenderer, listUpdaterTask, new Consumer<Object[]>() {
@Override
public void consume(Object[] selectedElements) {
for (Object element : selectedElements) {
PsiElement selected = (PsiElement)element;
LOG.assertTrue(selected.isValid());
((NavigatablePsiElement)selected).navigate(true);
}
}
});
}
示例5: openTargets
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
@RequiredReadAction
public static void openTargets(@NotNull Collection<? extends PsiElement> members, @NotNull MouseEvent mouseEvent, @NotNull String text, @NotNull final Function<PsiElement, PsiElement> map)
{
NavigatablePsiElement[] navigatablePsiElements = members.toArray(new NavigatablePsiElement[members.size()]);
ContainerUtil.sort(navigatablePsiElements, (o1, o2) ->
{
PsiElement map1 = map.fun(o1);
PsiElement map2 = map.fun(o2);
if(map1 instanceof PsiNamedElement && map2 instanceof PsiNamedElement)
{
return Comparing.compare(((PsiNamedElement) map1).getName(), ((PsiNamedElement) map2).getName());
}
return 0;
});
PsiElementListNavigator.openTargets(mouseEvent, navigatablePsiElements, text, text, new PsiMappedElementListCellRender(map));
}
示例6: tryNavigateToSuperMethod
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
private static void tryNavigateToSuperMethod(Editor editor,
HaxeMethod methodDeclaration,
List<HaxeNamedComponent> superItems) {
final String methodName = methodDeclaration.getName();
if (methodName == null) {
return;
}
final List<HaxeNamedComponent> filteredSuperItems = ContainerUtil.filter(superItems, new Condition<HaxeNamedComponent>() {
@Override
public boolean value(HaxeNamedComponent component) {
return methodName.equals(component.getName());
}
});
if (!filteredSuperItems.isEmpty()) {
PsiElementListNavigator.openTargets(editor, HaxeResolveUtil.getComponentNames(filteredSuperItems)
.toArray(new NavigatablePsiElement[filteredSuperItems.size()]),
DaemonBundle.message("navigation.title.super.method", methodName),
null,
new DefaultPsiElementCellRenderer());
}
}
示例7: tryNavigateToSuperMethod
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
private static void tryNavigateToSuperMethod(Editor editor,
HaxeComponentWithDeclarationList methodDeclaration,
List<HaxeNamedComponent> superItems) {
final String methodName = methodDeclaration.getName();
if (methodName == null) {
return;
}
final List<HaxeNamedComponent> filteredSuperItems = ContainerUtil.filter(superItems, new Condition<HaxeNamedComponent>() {
@Override
public boolean value(HaxeNamedComponent component) {
return methodName.equals(component.getName());
}
});
if (!filteredSuperItems.isEmpty()) {
PsiElementListNavigator.openTargets(editor, HaxeResolveUtil.getComponentNames(filteredSuperItems)
.toArray(new NavigatablePsiElement[filteredSuperItems.size()]),
DaemonBundle.message("navigation.title.super.method", methodName),
null,
new DefaultPsiElementCellRenderer());
}
}
示例8: openTargets
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
public static void openTargets(MouseEvent e,
NavigatablePsiElement[] targets,
String title,
final String findUsagesTitle,
ListCellRenderer listRenderer,
@Nullable ListBackgroundUpdaterTask listUpdaterTask) {
JBPopup popup = navigateOrCreatePopup(targets, title, findUsagesTitle, listRenderer, listUpdaterTask);
if (popup != null) {
if (listUpdaterTask != null) {
Alarm alarm = new Alarm(popup);
alarm.addRequest(() -> popup.show(new RelativePoint(e)), 300);
ProgressManager.getInstance().run(listUpdaterTask);
}
else {
popup.show(new RelativePoint(e));
}
}
}
示例9: navigate
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
@Override
public void navigate(final MouseEvent e, final T elt)
{
final List<NavigatablePsiElement> navElements = new ArrayList<NavigatablePsiElement>();
Query<T> elementQuery = search(elt);
if(elementQuery == null)
{
return;
}
elementQuery.forEach(new Processor<T>()
{
@Override
public boolean process(final T psiElement)
{
if(psiElement instanceof NavigatablePsiElement)
{
navElements.add((NavigatablePsiElement) psiElement);
}
return true;
}
});
final NavigatablePsiElement[] methods = navElements.toArray(new NavigatablePsiElement[navElements.size()]);
PsiElementListNavigator.openTargets(e, methods, getTitle(elt), "", new DefaultPsiElementCellRenderer());
}
示例10: getPresentableText
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
@Nullable
@Override
public String getPresentableText() {
final NavigatablePsiElement element = getElement();
final ItemPresentation presentation = element == null ? null : element.getPresentation();
return presentation == null ? null : presentation.getPresentableText();
}
示例11: openTargets
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
public static void openTargets(MouseEvent e,
NavigatablePsiElement[] targets,
String title,
final String findUsagesTitle,
ListCellRenderer listRenderer,
@Nullable ListBackgroundUpdaterTask listUpdaterTask) {
JBPopup popup = navigateOrCreatePopup(targets, title, findUsagesTitle, listRenderer, listUpdaterTask);
if (popup != null) popup.show(new RelativePoint(e));
}
示例12: getNavigatable
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
private Navigatable getNavigatable(HierarchyNodeDescriptor descriptor) {
if (descriptor instanceof Navigatable && descriptor.isValid()) {
return (Navigatable)descriptor;
}
PsiElement element = getElementFromDescriptor(descriptor);
if (element instanceof NavigatablePsiElement && element.isValid()) {
return (NavigatablePsiElement)element;
}
return null;
}
示例13: navigate
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
public void navigate(final MouseEvent e, final T elt) {
final List<NavigatablePsiElement> navElements = new ArrayList<NavigatablePsiElement>();
Query<T> elementQuery = search(elt);
if (elementQuery == null) return;
elementQuery.forEach(new Processor<T>() {
public boolean process(final T psiElement) {
if (psiElement instanceof NavigatablePsiElement) {
navElements.add((NavigatablePsiElement)psiElement);
}
return true;
}
});
final NavigatablePsiElement[] methods = navElements.toArray(new NavigatablePsiElement[navElements.size()]);
PsiElementListNavigator.openTargets(e, methods, getTitle(elt), null, new DefaultPsiElementCellRenderer());
}
示例14: navigateOrChoose
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
private static void navigateOrChoose(Editor editor, Collection<? extends NavigatablePsiElement> superElements, final String title) {
if (!superElements.isEmpty()) {
NavigatablePsiElement[] superElementArray = superElements.toArray(new NavigatablePsiElement[superElements.size()]);
if (superElementArray.length == 1) {
superElementArray[0].navigate(true);
}
else {
NavigationUtil.getPsiElementPopup(superElementArray, title).showInBestPositionFor(editor);
}
}
}
示例15: navigateToTargetOrFile
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
/** Returns true if a target or BUILD file could be found and navigated to. */
private static void navigateToTargetOrFile(Project project, VirtualFile vf) {
// First, find the parent BUILD file. We don't want to navigate to labels in other packages
BlazePackage parentPackage = getBuildFile(project, vf);
if (parentPackage == null) {
return;
}
// first, look for a specific target which includes this source file
PsiElement target = findBuildTarget(project, parentPackage, new File(vf.getPath()));
if (target instanceof NavigatablePsiElement) {
((NavigatablePsiElement) target).navigate(true);
return;
}
OpenFileAction.openFile(parentPackage.buildFile.getFile().getPath(), project);
}