mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 01:07:49 +08:00
psi_cookbook.md: JavaLibraryUtil
This commit is contained in:
parent
0f76642764
commit
d6e4a8e848
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
# Notable Changes in IntelliJ Platform and Plugins API 2023.*
|
# Notable Changes in IntelliJ Platform and Plugins API 2023.*
|
||||||
|
|
||||||
|
|
||||||
<link-summary>List of known Notable API Changes in 2023.*</link-summary>
|
<link-summary>List of known Notable API Changes in 2023.*</link-summary>
|
||||||
|
|
||||||
_Early Access Program_ (EAP) releases of upcoming versions are available [here](https://eap.jetbrains.com).
|
_Early Access Program_ (EAP) releases of upcoming versions are available [here](https://eap.jetbrains.com).
|
||||||
@ -14,6 +13,9 @@ _Early Access Program_ (EAP) releases of upcoming versions are available [here](
|
|||||||
|
|
||||||
### IntelliJ Platform 2023.2
|
### IntelliJ Platform 2023.2
|
||||||
|
|
||||||
|
Check presence of JVM library
|
||||||
|
: Use [dedicated API](psi_cookbook.md#how-do-i-check-the-presence-of-a-jvm-library) to check presence via class FQN or Maven coordinates.
|
||||||
|
|
||||||
## 2023.1
|
## 2023.1
|
||||||
|
|
||||||
### IntelliJ Platform 2023.1
|
### IntelliJ Platform 2023.1
|
||||||
|
@ -56,9 +56,9 @@ Unlike [Developing Custom Language Plugins](custom_language_support.md), it is a
|
|||||||
### How do I get a reference to the containing package of a Java class?
|
### How do I get a reference to the containing package of a Java class?
|
||||||
|
|
||||||
```java
|
```java
|
||||||
PsiJavaFile javaFile = (PsiJavaFile) psiClass.getContainingFile();
|
PsiJavaFile javaFile = (PsiJavaFile)psiClass.getContainingFile();
|
||||||
PsiPackage psiPackage = JavaPsiFacade.getInstance(project)
|
PsiPackage psiPackage = JavaPsiFacade.getInstance(project)
|
||||||
.findPackage(javaFile.getPackageName());
|
.findPackage(javaFile.getPackageName());
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
or
|
||||||
@ -68,3 +68,12 @@ or
|
|||||||
### How do I find the methods overriding a specific method?
|
### How do I find the methods overriding a specific method?
|
||||||
|
|
||||||
[`OverridingMethodsSearch.search()`](%gh-ic%/java/java-indexing-api/src/com/intellij/psi/search/searches/OverridingMethodsSearch.java)
|
[`OverridingMethodsSearch.search()`](%gh-ic%/java/java-indexing-api/src/com/intellij/psi/search/searches/OverridingMethodsSearch.java)
|
||||||
|
|
||||||
|
### How do I check the presence of a JVM library?
|
||||||
|
|
||||||
|
_2023.2_
|
||||||
|
|
||||||
|
Use dedicated (and heavily cached) methods from [`JavaLibraryUtil`](%gh-ic-master%/java/openapi/src/com/intellij/java/library/JavaLibraryUtil.java):
|
||||||
|
|
||||||
|
- `hasLibraryClass()` to check presence via known library class FQN
|
||||||
|
- `hasLibraryJar()` using Maven coordinates (for example, `io.micronaut:micronaut-core`).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user