mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-28 01:07:49 +08:00
psi_cookbook.md: Format code snippet
This commit is contained in:
parent
0b9985dfb4
commit
1d13a1ff1a
@ -1,7 +1,7 @@
|
|||||||
# PSI Cookbook
|
|
||||||
|
|
||||||
<!-- Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
<!-- Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -->
|
||||||
|
|
||||||
|
# PSI Cookbook
|
||||||
|
|
||||||
<link-summary rel="excerpt"/>
|
<link-summary rel="excerpt"/>
|
||||||
<p id="excerpt">
|
<p id="excerpt">
|
||||||
This page gives recipes for the most common operations for working with the PSI (Program Structure Interface).
|
This page gives recipes for the most common operations for working with the PSI (Program Structure Interface).
|
||||||
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user