mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 18:27:49 +08:00
clarify e
-> AnActionEvent
This commit is contained in:
parent
51536e8813
commit
9dfdd8b740
@ -13,7 +13,7 @@ The [`PsiElement`](upsource:///platform/core-api/src/com/intellij/psi/PsiElement
|
||||
|
||||
## How do I get a PSI element?
|
||||
|
||||
* From an Action: `e.getData(CommonDataKeys.PSI_ELEMENT)`.
|
||||
* From an Action: `AnActionEvent.getData(CommonDataKeys.PSI_ELEMENT)`.
|
||||
Note: if an editor is currently open and the element under caret is a [reference](psi_references.md), this will return the result of resolving the reference.
|
||||
This may or may not be what you need.
|
||||
* From a file by offset: `PsiFile.findElementAt()`.
|
||||
|
@ -10,7 +10,7 @@ Unlike `VirtualFile` and `Document`, which have application scope (even if multi
|
||||
|
||||
## How do I get a PSI file?
|
||||
|
||||
* From an Action: `e.getData(CommonDataKeys.PSI_FILE)`.
|
||||
* From an Action: `AnActionEvent.getData(CommonDataKeys.PSI_FILE)`.
|
||||
* From a VirtualFile: `PsiManager.getInstance(project).findFile()`
|
||||
* From a Document: `PsiDocumentManager.getInstance(project).getPsiFile()`
|
||||
* From an element inside the file: `PsiElement.getContainingFile()`
|
||||
|
@ -13,7 +13,7 @@ Contents of a `VirtualFile` are treated as a stream of bytes, but concepts like
|
||||
## How do I get a virtual file?
|
||||
|
||||
#### From an Action
|
||||
`e.getData(PlatformDataKeys.VIRTUAL_FILE)` or `e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY)` for multiple selection
|
||||
`AnActionEvent.getData(PlatformDataKeys.VIRTUAL_FILE)` or `AnActionEvent.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY)` for multiple selection
|
||||
|
||||
#### From Path in Local File System
|
||||
- `LocalFileSystem.getInstance().findFileByIoFile()`
|
||||
|
Loading…
x
Reference in New Issue
Block a user