mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 18:27:49 +08:00
symbols.md: minor
This commit is contained in:
parent
a102a3431f
commit
579116dd77
@ -23,13 +23,13 @@ Declarations in PSI elements are implementations of
|
||||
To report a declaration in a PSI element, either:
|
||||
|
||||
- implement and register
|
||||
[`PsiSymbolDeclarationProvider`](%gh-ic%/platform/core-api/src/com/intellij/model/psi/PsiSymbolDeclarationProvider.java) in `com.intellij.psi.declarationProvider` EP;
|
||||
- or implement `PsiSymbolDeclaration` directly in the `PsiElement`.
|
||||
[`PsiSymbolDeclarationProvider`](%gh-ic%/platform/core-api/src/com/intellij/model/psi/PsiSymbolDeclarationProvider.java) in `com.intellij.psi.declarationProvider` extension point
|
||||
- implement `PsiSymbolDeclaration` directly in the `PsiElement`.
|
||||
|
||||
## References
|
||||
|
||||
References from PSI elements are implementations of
|
||||
[`PsiSymbolReference`](%gh-ic%/platform/core-api/src/com/intellij/model/psi/PsiSymbolReference.java) interface.
|
||||
[`PsiSymbolReference`](%gh-ic%/platform/core-api/src/com/intellij/model/psi/PsiSymbolReference.java).
|
||||
|
||||
The main method of `PsiSymbolReference` is `resolveReference()`, which returns the collection of symbols to which the reference points,
|
||||
plus additional data.
|
||||
@ -38,7 +38,7 @@ A counterpart to the `resolveReference()` method is `PsiSymbolReference.resolves
|
||||
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 to a single symbol without additional data, then it might be extended from
|
||||
For convenience, if the reference can possibly be resolved to a single symbol without additional data, then it can extend from
|
||||
[`SingleTargetReference`](%gh-ic%/platform/core-api/src/com/intellij/model/SingleTargetReference.java).
|
||||
|
||||
### Own References
|
||||
@ -51,16 +51,16 @@ because this is a reference from Java language point of view, and Java language
|
||||
|
||||
To provide Own references by the `PsiElement`, implement
|
||||
[`PsiElement.getOwnReferences()`](%gh-ic%/platform/core-api/src/com/intellij/psi/PsiElement.java) in the `PsiElement`.
|
||||
If the element contains a single reference, `Collections.singletonList()` can be used.
|
||||
For a single reference, use `Collections.singletonList()`.
|
||||
|
||||
### External References
|
||||
|
||||
External references are the references which are not considered as references by the host language.
|
||||
External references are the references that are not considered as references by the host language.
|
||||
The language support should not rely on their existence/absence, because they might be contributed by other plugins.
|
||||
|
||||
**Example:**
|
||||
PSI element representing `"users.txt"` in `new File("users.txt")` Java expression is a string literal from Java language point of view,
|
||||
but there is a plugin which _knows_ that this literal references a file name, and provides such reference.
|
||||
but there is a plugin which _knows_ that this literal references a file name, and provides such a reference.
|
||||
|
||||
External references might be contributed to PSI elements
|
||||
that implement [`PsiExternalReferenceHost`](%gh-ic%/platform/core-api/src/com/intellij/model/psi/PsiExternalReferenceHost.java).
|
||||
@ -70,7 +70,7 @@ To contribute an External reference to the existing `PsiExternalReferenceHost`,
|
||||
|
||||
### Implicit References
|
||||
|
||||
Implicit references are the references which should be part of the mechanism to obtain a target by a reference,
|
||||
Implicit references are the references that should be part of the mechanism to obtain a target by a reference,
|
||||
without the inverse ability to search or rename such references by a target.
|
||||
|
||||
**Example:**
|
||||
|
@ -27,11 +27,13 @@ Examples:
|
||||
- Spring Bean is a symbol in [Spring framework model](spring_api.md), it's defined on-the-fly by framework support (not backed by a `PsiElement`) and bound to a `Project`.
|
||||
- Database column is a symbol defined by data source (not backed by a `PsiElement`) and not bound to a `Project` since database elements might be shared between projects.
|
||||
|
||||
See also [](websymbols.md).
|
||||
|
||||
## Lifecycle
|
||||
|
||||
The `Symbol` instance is expected to stay valid within a single read action, which means it's safe to pass the instance to different APIs.
|
||||
The `Symbol` instance is expected to stay valid within a single [read action](general_threading_rules.md), which means it's safe to pass the instance to different APIs.
|
||||
A `Symbol` instance should not be referenced between read actions.
|
||||
One should create a pointer via `Symbol.createPointer()` in the current read action, and then call `Pointer.dereference()` to obtain a `Symbol` instance in the subsequent read action.
|
||||
One should create a pointer via `Symbol.createPointer()` in the current read action, and then call `Pointer.dereference()` to obtain a `Symbol` instance in the subsequent read action.
|
||||
|
||||
## Sample plugins
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user