Resource roots in WebStorm

Hi,

I'm working on plugin for Google Protobuf and one of user created an issue for WebStorm - imports are not working there: https://github.com/protostuff/protobuf-jetbrains-plugin/issues/30

In protobuf you can import one proto file from another, using import statement. Example:

import "foo/bar.proto";

My plugin tries to resolve imports against module source roots:

VirtualFile[] sourceRoots = moduleRootManager.orderEntries().getAllSourceRoots()

However, this way does not work in WebStorm: if folder is marked as "Resource Root". ModuleRootManager does not have information about this folder at all.

I found a way to get "Resource Root" locations in WebStorm using com.intellij.webcore.resourceRoots.WebResourcesPathsConfiguration#getResourceRoots:

MultiMap<String, String> resourceRoots = WebResourcesPathsConfiguration.getInstance(thisModule.getProject()).getResourceRoots()

But I'm not sure that this is the right way solve this issue.

My questions are:

1. WebResourcesPathsConfiguration - it is the only way to get resource roots in WebStorm? This class is not available in IntelliJ IDEA, maybe there is something that works for all IDEs?

2. If it is the only way - is it safe to use it? I can wrap access to this class and catch ClassNotFoundException.

2 comments

Unfortunately, there's no generic way to do so, we plan to address that at some point, but can't promise that it will happen anytime soon.

So you can use Resource roots 

0

Please sign in to leave a comment.