[英]Get the project of a project level service in IntelliJ IDEA plugin
I have a service class, which is registered in the plugin.xml as project level service: 我有一个服务类,该服务类在plugin.xml中注册为项目级服务:
<extensions defaultExtensionNs="com.intellij">
<projectService
serviceInterface="MyService"
serviceImplementation="MyService">
</projectService>
</extensions>
I can get the project level service for the project myProject with: 我可以通过以下方式获得项目myProject的项目级别服务:
ServiceManager.getService(myProject, MyService.class);
But how can I retrieve the project for which the service has been instantiated in the serviceclass MyService? 但是,如何在服务类MyService中检索已为其实例化服务的项目?
将Project project
添加为构造函数参数(将被注入),然后将其保存到字段中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.