mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 01:07:49 +08:00
Update Symbol API docs for 2021.2 (#611)
* clean up * update Symbol API docs for 2021.2
This commit is contained in:
parent
9baca27a37
commit
0be97abd25
@ -14,8 +14,6 @@ Each [symbol](symbols.md) may be declared in zero or more places, for example:
|
||||
- a Java local variable is a symbol with a single declaration;
|
||||
- and a file is a symbol without declarations; it has only references.
|
||||
|
||||
Declarations are implementations of
|
||||
[`SymbolDeclaration`](upsource:///platform/core-api/src/com/intellij/model/SymbolDeclaration.java).
|
||||
Declarations in PSI elements are implementations of
|
||||
[`PsiSymbolDeclaration`](upsource:///platform/core-api/src/com/intellij/model/psi/PsiSymbolDeclaration.java).
|
||||
|
||||
@ -26,25 +24,18 @@ To report a declaration in a PSI element, either:
|
||||
|
||||
## References
|
||||
|
||||
References are implementations of
|
||||
[`SymbolReference`](upsource:///platform/core-api/src/com/intellij/model/SymbolReference.java) interface.
|
||||
References from PSI elements are implementations of
|
||||
[`PsiSymbolReference`](upsource:///platform/core-api/src/com/intellij/model/psi/PsiSymbolReference.java) interface.
|
||||
|
||||
The main method of `SymbolReference` is `resolveReference()`, which returns the collection of symbols to which the reference points,
|
||||
The main method of `PsiSymbolReference` is `resolveReference()`, which returns the collection of symbols to which the reference points,
|
||||
plus additional data.
|
||||
If it is not possible to resolve the reference, for example, if it points to an undefined class, an empty collection gets returned.
|
||||
A counterpart to the `resolveReference()` method is `SymbolReference.resolvesTo()`,
|
||||
A counterpart to the `resolveReference()` method is `PsiSymbolReference.resolvesTo()`,
|
||||
which checks if the reference resolves to the specified symbol.
|
||||
This method can be implemented to walk the tree only if the element's text is equal to the reference's text.
|
||||
|
||||
For convenience, if the reference can possibly be resolved:
|
||||
- with a single result, then it might be extended from
|
||||
[`SingleResultReference`](upsource:///platform/core-api/src/com/intellij/model/SingleResultReference.java);
|
||||
- to a single symbol without additional data, then it might be extended from
|
||||
[`SingleTargetReference`](upsource:///platform/core-api/src/com/intellij/model/SingleTargetReference.java);
|
||||
- to multiple symbols without additional data, then
|
||||
[`SymbolResolveResult.fromSymbol()`](upsource:///platform/core-api/src/com/intellij/model/SymbolResolveResult.java) might be used.
|
||||
For convenience, if the reference can possibly be resolved to a single symbol without additional data, then it might be extended from
|
||||
[`SingleTargetReference`](upsource:///platform/core-api/src/com/intellij/model/SingleTargetReference.java).
|
||||
|
||||
### Own References
|
||||
|
||||
|
@ -26,7 +26,7 @@ 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.kt`](upsource:///platform/core-api/src/com/intellij/navigation/TargetPopupPresentation.kt)
|
||||
a [`TargetPresentation`](upsource:///platform/core-api/src/com/intellij/navigation/TargetPresentation.kt)
|
||||
instances (where to go and what to show in the popup).
|
||||
|
||||
To provide navigation targets by a `Symbol`, either:
|
||||
|
Loading…
x
Reference in New Issue
Block a user