eclipse-wildwebdeveloper / wildwebdeveloper

Simple and productive Web Development Tools in the Eclipse IDE
https://projects.eclipse.org/projects/tools.wildwebdeveloper
Eclipse Public License 2.0
189 stars 70 forks source link

extensions for XML support #266

Closed jtydhr88 closed 4 years ago

jtydhr88 commented 5 years ago

Hey guys, Is there any ways to add my own lsp4xml extension jars into Wild Editor? I checked the lsp4xml and it allows me to extend capabilities by extension jars, see here https://github.com/angelozerr/lsp4xml/tree/master/extensions I am wondering that how wild editor support this way if I install it in my eclipse enviroment. Thanks.

angelozerr commented 5 years ago

Is there any ways to add my own lsp4xml extension jars into Wild Editor?

No it's not possible, since java start is hard coded with the lsp4xml uber jar https://github.com/eclipse/wildwebdeveloper/blob/master/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/XMLLanguageServer.java#L39

To support this feature, the wwd xml plugin https://github.com/eclipse/wildwebdeveloper/blob/master/org.eclipse.wildwebdeveloper.xml/plugin.xml should provide an Eclipse extension point to register your own JAR (which use SPI to regsiter your own lsp'xml completion, hover, etc) and when lsp4xml is started it should declare your own JAR in java start.

I never tried that and I don't know if we will have some class loader problem.

Just one question, why do you want to write your own xml extension?

angelozerr commented 5 years ago

@mickaelistria this topic interested me (I could create a PR which provides this extension point) are you interested with this extension point?

I'm very interested because I would like to support advanced maven support (ex : completion for artifactid) by using lsp4xml which will work on Eclipse IDE (with only m2e) and vscode (with JDT LS & m2e).

This extension point to add lsp4xml SPI completion is the first part of my idea (server side). The client side is an another part (how to add dynamicly new lsp4j @JsonRequest dynamicly in a given language client).

jtydhr88 commented 5 years ago

Thanks @angelozerr I work for Liferay Inc, and I am trying to use LSP to make support for portlet specification and liferay features which are petty simple but special. For instance, the values of tag portlet-name in both portlet.xml and liferay-portlet.xml should been matched, otherwise, I need to throw warnings. I think these custom requirements/logic which not provided in xsd or dtd should be written by myself in extension jars, and register them into Wild Editor.

angelozerr commented 5 years ago

I think these custom requirements/logic which not provided in xsd or dtd should be written by myself in extension jars, and register them into Wild Editor.

Indeed. I never done this kind of validation in lsp4xml (retrieving a DOM document (ex: liferay-portlet.xml) from an another DOM document (ex: portlet.xml) which is validating. It's an interesting use cases.

If @mickaelistria like the idea with extension point to register external JAR for lsp4xml, I could try to create a PR when I will have time.

For the moment you could start to write your own lsp4xml extension, built your JAR and change the source https://github.com/eclipse/wildwebdeveloper/blob/master/org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/XMLLanguageServer.java#L39 to add in the commands your JAR.

akurtakov commented 5 years ago

I'm especially interested in the maven pom.xml smartness so your offer to have it as proof sounds even more interesting to me.

mickaelistria commented 5 years ago

Yes, making the XML support in Wild Web Developer open to LSP4XML extensions would be great. Before we jump on an extension point, I have some preliminary questions:

angelozerr commented 5 years ago

I'm especially interested in the maven pom.xml smartness so your offer to have it as proof sounds even more interesting to me.

I know @akurtakov that :) But I do that for the moment in my spare time, so it's difficult for me to find time to work on it. For the moment I try to experiment some ideas how to implement that.

Would replacing usage of uber-jar with a set of jar make it easier to plug extensions?

No I don't think.

Would starting XML-LS as a thread rather than as a process help?

I though that but after writting my POC with Quarkus https://github.com/angelozerr/quarkus-lsp4e we can use process. The basic idea is to customize the language client https://github.com/angelozerr/quarkus-lsp4e/blob/master/com.redhat.quarkus.lsp4e/src/com/redhat/quarkus/lsp4e/QuarkusLanguageClient.java#L40

But in case of lsp4xml, we need more dynamic services. I think LSP4E should support a extension point to add dynamicly new language client services for a given language (is LSP4J supports that?).

Would "OSGi-fied" version (ie we add a MANIFEST.MF with the Import-Package and make it a bundle instead of an embedded jar) of XML-LS help?

To be honnest with you, I don't know. We need to experiment this solution.

The extension idea with lsp4xml is to register completion, hover extension with SPI. So when you start lsp4xml server, you just need to add custom JAR in the java start classpath.

// 1) register lsp4xml JAR
URL url = FileLocator.toFileURL(getClass().getResource("/language-servers/server/org.eclipse.lsp4xml-0.8.0-uber.jar"));
commands.add(new java.io.File(url.getPath()).getAbsolutePath());

// Get JAR extensions from extension point
commands.add($liferay-plugin + "liferay-extension.jar");

For the case of @jtydhr88 it is enough. But for maven topic, The lsp4xml maven extension needs to work with the language client (not supported for the moment). The idea is to cast the the language client with an IMavenCustomServices which will provide maven services inside the lsp4xml maven extension. On LSP4E side we need an new extension point to cast the language client instance with the IMavenCustomServices and implements this interface with m2e call to retrieve dependencies and other things.

angelozerr commented 5 years ago

@jtydhr88 perhaps you could start lsp4xml with a launch and bind the launch to the xml content type.

To do that:

image

(choose XMLServerLauncher as launcher)

image

mickaelistria commented 5 years ago

@angelozerr indeed, dynamic definition of language servers is a way to test it already. @jtydhr88 Do you already have the LSP4XML extension working (at all or with some other clients)?

Some possibilities for extensions:

I'm still unsure which one is best as it really depends on how we ultimately want to ship the LSP4XML. The uber.jar was IMO the quick and dirty way, and I'd like to see it a bit improved.

jtydhr88 commented 5 years ago

Thanks @angelozerr I will try this later.

jtydhr88 commented 5 years ago

@mickaelistria I am working on lsp4xml extension on IntelliJ Plugin and VS Code as well, but I don't finish yet, once I get them done, I can give some tries back into Eclipse.

angelozerr commented 5 years ago

i'm still unsure which one is best as it really depends on how we ultimately want to ship the LSP4XML. The uber.jar was IMO the quick and dirty way, and I'd like to see it a bit improved.

I agree with you, if some change should be done in lsp4xml there are no problem if it continue to work without OSGi.

angelozerr commented 5 years ago

@mickaelistria I think a better integration in LSP4XML should be that it is OSGFied. After discussing with @fbricon we are opened to have this feature but it should be very nice if someone could create a PR for that. Thanks!

angelozerr commented 4 years ago

@mickaelistria you have already support OSGI with https://github.com/angelozerr/lsp4xml/pull/301 no?

angelozerr commented 4 years ago

For ideas about loading LSP4XML extension in WWD, please read https://github.com/angelozerr/lsp4xml-extensions-maven#eclipse-ide-context

IMHO I think classpath building should me better than OSGi support with fragment, because it gives the capability to activate/descative XML extension by the user and even add a custom extension by the user.

AObuchow commented 4 years ago

Can we mark this as closed by 755bed6?

mickaelistria commented 4 years ago

Can we mark this as closed by 755bed6?

Yes.