[platform] add new GotoDeclarationProvider and NavigationTarget APIs (IDEA-198180)

This commit is contained in:
Daniil Ovchinnikov
2019-02-05 18:54:00 +03:00
parent 21ff2883bc
commit ea604652c6
3 changed files with 64 additions and 0 deletions
@@ -0,0 +1,42 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.navigation;
import com.intellij.pom.Navigatable;
import org.jetbrains.annotations.ApiStatus.Experimental;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Experimental
public interface NavigationTarget {
/**
* @return {@code true} if it's safe to call other methods of this instance
*/
boolean isValid();
/**
* This method is called only if {@link #isValid()} returns {@code true}.
*
* @return navigatable instance to use when this target is selected
*/
@Nullable
Navigatable getNavigatable();
/**
* This method is called only if {@link #isValid()} returns {@code true}.
*
* @return presentation to render this target in navigation popup
*/
@NotNull
TargetPresentation getTargetPresentation();
/**
* Two different symbols may have the same navigation target.
* #equals and #hashCode are used to filter out same targets to hide them in navigation popup.
*/
@Override
boolean equals(Object obj);
@Override
int hashCode();
}
@@ -0,0 +1,20 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight.navigation;
import com.intellij.navigation.NavigationTarget;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.ApiStatus.Experimental;
import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;
@Experimental
public interface GotoDeclarationProvider {
void collectTargets(@NotNull Project project,
@NotNull Editor editor,
@NotNull PsiFile file,
@NotNull Consumer<? super NavigationTarget> consumer);
}
@@ -601,6 +601,8 @@
interface="com.intellij.codeInsight.navigation.actions.TypeDeclarationProvider"/>
<extensionPoint name="gotoTargetRendererProvider"
interface="com.intellij.codeInsight.navigation.GotoTargetRendererProvider"/>
<extensionPoint name="gotoDeclaration"
interface="com.intellij.codeInsight.navigation.GotoDeclarationProvider"/>
<extensionPoint name="navbar" interface="com.intellij.ide.navigationToolbar.NavBarModelExtension"/>