mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-29 01:37:51 +08:00
* LAB-21 Symbols, Declarations and References, Completion 2020.3 * LAB-21 Go to Declaration or Usages 2020.3 * fixes (squash with LAB-21 Symbols, Declarations and References, Completion 2020.3) * fixes (squash with LAB-21 Go to Declaration or Usages 2020.3) * new PsiCompletableReference location (squash with LAB-21 Symbols, Declarations and References, Completion 2020.3) * Apply suggestions from code review Co-authored-by: John Hake <39627202+JohnHake@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: John Hake <39627202+JohnHake@users.noreply.github.com> * "Own reference", "External reference", "Implicit reference" * move examples before api links * IDE -> IntelliJ Platform * articles * explicit upsource link * linebreaks * element -> symbol * remove jvm package example * parent links (squash with LAB-21 Symbols, Declarations and References, Completion 2020.3) * parent links (squash with LAB-21 Go to Declaration or Usages 2020.3) * platform -> IntelliJ Platform * reword symbol navigation a bit Co-authored-by: John Hake <39627202+JohnHake@users.noreply.github.com>
45 lines
2.2 KiB
Markdown
45 lines
2.2 KiB
Markdown
---
|
|
title: Navigation
|
|
---
|
|
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
|
|
|
|
> **WARNING** This API is available starting from 2020.3 and currently in development and thus in experimental state.
|
|
|
|
The _Go to Declaration or Usages_ action is performed in several steps.
|
|
|
|
## Direct Navigation
|
|
|
|
Direct navigation is the navigation from `PsiElement` to another `PsiElement`,
|
|
such as navigation from `break` keyword to the end of a loop in Java, without showing any popups.
|
|
|
|
To provide `PsiElement` for direct navigation, implement and register
|
|
[`DirectNavigationProvider`](upsource:///platform/core-api/src/com/intellij/navigation/DirectNavigationProvider.java).
|
|
|
|
|
|
## Symbol Navigation
|
|
|
|
If there is no Direct navigation available under the caret, then the IntelliJ Platform proceeds with `Symbol` navigation.
|
|
In this step the IntelliJ Platform computes the navigation targets based on target symbols,
|
|
which it obtains by resolving a [reference](declarations_and_references.md#references).
|
|
If there are several target symbols or several navigation targets defined for a symbol,
|
|
then the IDE shows the navigation popup to ask the user to choose where to go.
|
|
|
|
The [`NavigationTarget`](upsource:///platform/core-api/src/com/intellij/navigation/NavigationTarget.java)
|
|
is essentially a pair of a `Navigatable` and
|
|
a [`TargetPopupPresentation`](upsource:///platform/core-api/src/com/intellij/navigation/TargetPopupPresentation.java)
|
|
instances (where to go and what to show in the popup).
|
|
|
|
To provide navigation targets by a `Symbol`, either:
|
|
- implement and register
|
|
[`SymbolNavigationProvider`](upsource:///platform/core-api/src/com/intellij/navigation/SymbolNavigationProvider.java);
|
|
- or implement
|
|
[`NavigatableSymbol`](upsource:///platform/core-api/src/com/intellij/navigation/NavigatableSymbol.java)
|
|
in the `Symbol`.
|
|
|
|
|
|
## Showing Usages
|
|
|
|
If there are no navigation targets available, then the IntelliJ Platform starts finding usages of the target symbol
|
|
obtained by resolving a [reference](declarations_and_references.md#references)
|
|
or from a [declaration](declarations_and_references.md#declarations).
|