stub_indexes.md: more clarification, sample

This commit is contained in:
Yann Cébron 2023-01-18 15:50:01 +01:00
parent 053b2e9703
commit 97a513402b

View File

@ -83,7 +83,7 @@ Stub index implementation classes are registered in the `com.intellij.stubIndex`
To put data into an index, you implement the method `IStubElementType.indexStub()` ([example: `JavaClassElementType.indexStub()`](%gh-ic%/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaClassElementType.java)). To put data into an index, you implement the method `IStubElementType.indexStub()` ([example: `JavaClassElementType.indexStub()`](%gh-ic%/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaClassElementType.java)).
This method accepts an `IndexSink` as a parameter and puts in the index ID and the key for each index in which the element should be stored. This method accepts an `IndexSink` as a parameter and puts in the index ID and the key for each index in which the element should be stored.
To access the data from an index, the following instance methods are used: To access the data from an index, the following instance methods are used on the singleton instance managed by the implementation:
* `AbstractStubIndex.getAllKeys()/processAllKeys()` returns the list of all keys (processes all keys) in the index for the specified project (for example, the list of all class names found in the project). * `AbstractStubIndex.getAllKeys()/processAllKeys()` returns the list of all keys (processes all keys) in the index for the specified project (for example, the list of all class names found in the project).
@ -91,6 +91,8 @@ To access the data from an index, the following instance methods are used:
* `AbstractStubIndex.get()` returns the collection of PSI elements corresponding to a certain key (for example, classes with the specified short name) in the specified scope. * `AbstractStubIndex.get()` returns the collection of PSI elements corresponding to a certain key (for example, classes with the specified short name) in the specified scope.
**Example**: [`JavaAnnotationIndex`](%gh-ic%/java/java-indexing-impl/src/com/intellij/psi/impl/java/stubs/index/JavaAnnotationIndex.java)
## Related Forum Discussions ## Related Forum Discussions
* [Lifecycle of stub creation](https://intellij-support.jetbrains.com/hc/en-us/community/posts/206121959-Lifecycle-of-stub-creation/comments/206143885) * [Lifecycle of stub creation](https://intellij-support.jetbrains.com/hc/en-us/community/posts/206121959-Lifecycle-of-stub-creation/comments/206143885)