YAML/JSON/XML Xpath evaluation

Hi there!

There is https://plugins.jetbrains.com/plugin/12478-xpathview--xslt plugin to use XPath expression to find the PSI nodes.
It uses adapters for PSI XML elements and uses java jaxen module to evaluate the result of the xpath expression.

I’ve tried to implement another adapter for JSON PSI elements, but got lost in tons of lines of duplicated code.

I’ve thought it could be great idea to create JSON->XML adapter to reuse the plugin logic, but there are a lot of interfaces methods in the PSI elements, so adapters are blowing again.

I’ve researched YAML schema building and there are YAML->JSON adapters not to duplicate the same code for YAML and JSON.

Dedicated java modules for xpath aren’t suitable for me, because they use internal tree presentation that’s impossible to map to PSI tree to find the resulting nodes.

Does anyone tried to achieve the same goal? Any progress? Any reusable code?