本文整理汇总了Java中com.intellij.psi.NavigatablePsiElement类的典型用法代码示例。如果您正苦于以下问题:Java NavigatablePsiElement类的具体用法?Java NavigatablePsiElement怎么用?Java NavigatablePsiElement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NavigatablePsiElement类属于com.intellij.psi包,在下文中一共展示了NavigatablePsiElement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: applyFilter
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
@Nullable
@Override
public Result applyFilter(String line, int entireLength) {
Matcher matcher = TARGET_PATTERN.matcher(line);
List<ResultItem> results = new ArrayList<>();
while (matcher.find()) {
String labelString = matcher.group();
String prefix = matcher.group(1);
if (prefix != null) {
labelString = labelString.substring(prefix.length());
}
Label label = LabelUtils.createLabelFromString(null, labelString);
if (label == null) {
continue;
}
PsiElement psi = BuildReferenceManager.getInstance(project).resolveLabel(label);
if (!(psi instanceof NavigatablePsiElement)) {
continue;
}
HyperlinkInfo link = project -> ((NavigatablePsiElement) psi).navigate(true);
int offset = entireLength - line.length();
results.add(
new ResultItem(
matcher.start() + offset, matcher.end() + offset, link, highlightAttributes));
}
return results.isEmpty() ? null : new Result(results);
}
开发者ID:bazelbuild,项目名称:intellij,代码行数:28,代码来源:BlazeTargetFilter.java
示例17: invoke
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
final PsiElement at = file.findElementAt(editor.getCaretModel().getOffset());
final HaxeComponentName componentName = PsiTreeUtil.getParentOfType(at, HaxeComponentName.class);
final HaxeClass haxeClass = PsiTreeUtil.getParentOfType(at, HaxeClass.class);
final HaxeNamedComponent namedComponent = componentName == null ? haxeClass : (HaxeNamedComponent)componentName.getParent();
if (at == null || haxeClass == null || namedComponent == null) return;
final List<HaxeClass> supers = HaxeResolveUtil.tyrResolveClassesByQName(haxeClass.getHaxeExtendsList());
supers.addAll(HaxeResolveUtil.tyrResolveClassesByQName(haxeClass.getHaxeImplementsList()));
final List<HaxeNamedComponent> superItems = HaxeResolveUtil.findNamedSubComponents(false, supers.toArray(new HaxeClass[supers.size()]));
final HaxeComponentType type = HaxeComponentType.typeOf(namedComponent);
if (type == HaxeComponentType.METHOD) {
final HaxeMethod methodDeclaration = (HaxeMethod)namedComponent;
tryNavigateToSuperMethod(editor, methodDeclaration, superItems);
}
else if (!supers.isEmpty() && namedComponent instanceof HaxeClass) {
PsiElementListNavigator.openTargets(
editor,
HaxeResolveUtil.getComponentNames(supers).toArray(new NavigatablePsiElement[supers.size()]),
DaemonBundle.message("navigation.title.subclass", namedComponent.getName(), supers.size()),
"Subclasses of " + namedComponent.getName(),
new DefaultPsiElementCellRenderer()
);
}
}
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:29,代码来源:HaxeGotoSuperHandler.java
示例18: createImplementationMarker
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
@Nullable
private static LineMarkerInfo createImplementationMarker(final HaxeClass componentWithDeclarationList,
final List<HaxeClass> items) {
final HaxeComponentName componentName = componentWithDeclarationList.getComponentName();
if (componentName == null) {
return null;
}
final PsiElement element = componentName.getIdentifier().getFirstChild();
return new LineMarkerInfo<>(
element,
element.getTextRange(),
componentWithDeclarationList instanceof HaxeInterfaceDeclaration
? AllIcons.Gutter.ImplementedMethod
: AllIcons.Gutter.OverridenMethod,
Pass.UPDATE_ALL,
item -> DaemonBundle.message("method.is.implemented.too.many"),
new GutterIconNavigationHandler<PsiElement>() {
@Override
public void navigate(MouseEvent e, PsiElement elt) {
PsiElementListNavigator.openTargets(
e, HaxeResolveUtil.getComponentNames(items).toArray(new NavigatablePsiElement[items.size()]),
DaemonBundle.message("navigation.title.subclass", componentWithDeclarationList.getName(), items.size()),
"Subclasses of " + componentWithDeclarationList.getName(),
new DefaultPsiElementCellRenderer()
);
}
},
GutterIconRenderer.Alignment.RIGHT
);
}
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:31,代码来源:HaxeLineMarkerProvider.java
示例19: invoke
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
final PsiElement at = file.findElementAt(editor.getCaretModel().getOffset());
final HaxeComponentName componentName = PsiTreeUtil.getParentOfType(at, HaxeComponentName.class);
final HaxeClass haxeClass = PsiTreeUtil.getParentOfType(at, HaxeClass.class);
final HaxeNamedComponent namedComponent = componentName == null ? haxeClass : (HaxeNamedComponent)componentName.getParent();
if (at == null || haxeClass == null || namedComponent == null) return;
final List<HaxeClass> supers = HaxeResolveUtil.tyrResolveClassesByQName(haxeClass.getExtendsList());
supers.addAll(HaxeResolveUtil.tyrResolveClassesByQName(haxeClass.getImplementsList()));
final List<HaxeNamedComponent> superItems = HaxeResolveUtil.findNamedSubComponents(false, supers.toArray(new HaxeClass[supers.size()]));
final HaxeComponentType type = HaxeComponentType.typeOf(namedComponent);
if (type == HaxeComponentType.METHOD) {
final HaxeComponentWithDeclarationList methodDeclaration = (HaxeComponentWithDeclarationList)namedComponent;
tryNavigateToSuperMethod(editor, methodDeclaration, superItems);
}
else if (!supers.isEmpty() && namedComponent instanceof HaxeClass) {
PsiElementListNavigator.openTargets(
editor,
HaxeResolveUtil.getComponentNames(supers).toArray(new NavigatablePsiElement[supers.size()]),
DaemonBundle.message("navigation.title.subclass", namedComponent.getName(), supers.size()),
"Subclasses of " + namedComponent.getName(),
new DefaultPsiElementCellRenderer()
);
}
}
开发者ID:consulo,项目名称:consulo-haxe,代码行数:29,代码来源:HaxeGotoSuperHandler.java
示例20: createImplementationMarker
import com.intellij.psi.NavigatablePsiElement; //导入依赖的package包/类
@Nullable
private static LineMarkerInfo createImplementationMarker(final HaxeClass componentWithDeclarationList,
final List<HaxeClass> items) {
final HaxeComponentName componentName = componentWithDeclarationList.getComponentName();
if (componentName == null) {
return null;
}
return new LineMarkerInfo<PsiElement>(
componentName,
componentName.getTextRange(),
componentWithDeclarationList instanceof HaxeInterfaceDeclaration
? AllIcons.Gutter.ImplementedMethod
: AllIcons.Gutter.OverridenMethod,
Pass.UPDATE_ALL,
new Function<PsiElement, String>() {
@Override
public String fun(PsiElement element) {
return DaemonBundle.message("method.is.implemented.too.many");
}
},
new GutterIconNavigationHandler<PsiElement>() {
@Override
public void navigate(MouseEvent e, PsiElement elt) {
PsiElementListNavigator.openTargets(
e, HaxeResolveUtil.getComponentNames(items).toArray(new NavigatablePsiElement[items.size()]),
DaemonBundle.message("navigation.title.subclass", componentWithDeclarationList.getName(), items.size()),
"Subclasses of " + componentWithDeclarationList.getName(),
new DefaultPsiElementCellRenderer()
);
}
},
GutterIconRenderer.Alignment.RIGHT
);
}
开发者ID:consulo,项目名称:consulo-haxe,代码行数:35,代码来源:HaxeLineMarkerProvider.java
注:本文中的com.intellij.psi.NavigatablePsiElement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论