idea的插件读取输入文件路径
时间: 2023-09-16 09:10:13 浏览: 291
取得input要素的文件路径
在IntelliJ IDEA的插件开发中,可以通过以下方式获取输入文件的路径。首先,通过插件的id获取插件的路径,可以使用以下代码获取插件的绝对路径:
```java
PluginId pluginId = PluginId.getId("com.your.company.unique.plugin.id");
IdeaPluginDescriptor plugin = PluginManager.getPlugin(pluginId);
File pluginPath = plugin.getPath();
```
然后,可以使用以下代码获取当前操作的类文件的路径:
```java
PsiFile psiFile = e.getData(CommonDataKeys.PSI_FILE);
String classPath = psiFile.getVirtualFile().getPath();
```
这样就可以获取到输入文件的路径了。
#### 引用[.reference_title]
- *1* [IntelliJ IDEA 开发插件,获取插件的绝对路径](https://blog.csdn.net/bawomingtian123/article/details/114407858)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [IDEA插件开发-学习](https://blog.csdn.net/bingo199/article/details/127028416)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [IDEA配置文件路径问题小提示](https://blog.csdn.net/weixin_29795623/article/details/115065458)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文