当前位置: 首页>>代码示例>>Java>>正文


Java NavigatablePsiElement类代码示例

本文整理汇总了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);
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:18,代码来源:PathFinder.java

示例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();
}
 
开发者ID:zalando,项目名称:intellij-swagger,代码行数:24,代码来源:PathFinder.java

示例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);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PsiElementListNavigator.java

示例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);
      }
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:PsiElementListNavigator.java

示例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));
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:18,代码来源:CSharpLineMarkerUtil.java

示例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());
  }
}
 
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:22,代码来源:HaxeGotoSuperHandler.java

示例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());
  }
}
 
开发者ID:consulo,项目名称:consulo-haxe,代码行数:22,代码来源:HaxeGotoSuperHandler.java

示例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));
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:PsiElementListNavigator.java

示例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());
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:25,代码来源:JavaScriptLineMarkerProvider.java

示例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();
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:8,代码来源:AppleScriptStructureViewElement.java

示例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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:PsiElementListNavigator.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:HierarchyBrowserBase.java

示例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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:PyLineMarkerNavigator.java

示例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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:PyGotoSuperHandler.java

示例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);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:16,代码来源:OpenCorrespondingBuildFile.java


注:本文中的com.intellij.psi.NavigatablePsiElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。