eclipse-lemminx / lemminx

XML Language Server
Eclipse Public License 2.0
272 stars 93 forks source link

Manage custom completion, validation, hyperlink with XPath system #168

Open angelozerr opened 6 years ago

angelozerr commented 6 years ago

Managing custom completion, validation, hyperlink is often the same thing (ex: completion on files, on other XML elements, etc).

Using a system XPath can be really easy to add completion. Takes a sample:

<servlet>
        <servlet-name>ssi</servlet-name>
        <servlet-class>
          org.apache.catalina.ssi.SSIServlet
        </servlet-class>
</servlet>

<servlet-mapping>
        <servlet-name>ssi</servlet-name>
        <url-pattern>*.shtml</url-pattern>
</servlet-mapping>

here we wish to manage

We could declare this behaviour with some path like this:

<path from="servlet-mapping/servlet-name/#text"
           to="servlet/servlet-name" />

which could manage directly those 3 features without coding something.

I had implemented this idea for WTP XML Editor in the project https://github.com/angelozerr/eclipse-wtp-xml-search and you have some examples:

angelozerr commented 6 years ago

@fbricon @NikolasKomonen I will try to study this issue. If I can implement it, I think it will be easy to add advanced features for a lot of XML files (web.xml, pom.xml, etc).

Please give me your feedback.

mickaelistria commented 5 years ago

FWIW, as I'm likely to write extensions for XML-LS one day, I'd rather not see XPath involved as it's not so fun to use and test and debug. Instead, I would like the extension "service" to just give me the current node I may extend or not, and -in Java- I'll code on 1st line whether I extend or not. A canProcess(Node node) in the extension interface would be welcome and more comfortable than XPath-based queries. So -as a XPath hater- I suggest that unless you have a specific request, you ignore or close this ticket.