[英]How to get the current file name in plugin action class
In the IntelliJ IDEA plugin action class, I want to get the Java class file name which user is currently viewing. 在IntelliJ IDEA插件操作类中,我想获取用户当前正在查看的Java类文件名。 How would I get that?
我将如何获得?
In IntelliJ IDEA, if we click Analyse -> Inspect Code
, it will show a window to choose scope, in that it will show the current file name also. 在IntelliJ IDEA中,如果单击
Analyse -> Inspect Code
,它将显示一个窗口来选择范围,因为它还将显示当前文件名。 Similar to that view, I want to get the current file name in plugin action class. 类似于该视图,我想在插件操作类中获取当前文件名。 How could I do that?
我该怎么办?
public class MyAction extends AnAction {
public void actionPerformed(AnActionEvent e) {
VirtualFile vFile = e.getData(PlatformDataKeys.VIRTUAL_FILE);
String fileName = vFile != null ? vFile.getName() : null;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.