redhat-developer / vscode-xml

Editing XML in Visual Studio Code made easy
Eclipse Public License 2.0
258 stars 80 forks source link

No autocompletion with Unity UIElements XML schemas #129

Closed bsymon closed 5 years ago

bsymon commented 5 years ago

Hello,

I'm a Unity developer, and started using their new UIElements tech for editor extensions UI. I'm using VSCode and I've installed the XML extension to get autocompletion, but it doesn't work.

The extension is loaded and I've a bit of document validation. I get errors for unknown element, but I'm not sure if it works well too. It only check elements name and attributes value. If I add an unknown attribute I don't get error. And autocompletion is not working at all.

Here is the log of the extension avr. 28, 2019 9:04:44 AM org.eclipse.lsp4xml.XMLLanguageServer initialize INFOS: Initializing LSP4XML server 0.5.1-20190408-2230

Here is a Unity project : VisualElementTests.zip It contains a couple of scripts and XML files (located in Assets/Editor/Resources/UIElements). All this project does it creating a custom editor window. You can open it in Tools > Test Window.

VSCode Informations :

Installed extensions : Screenshot

Java version : OpenJDK by RedHat (jdk-11.0.2-x64)

Unity Informations :

Thank you for your help :) I hope I've provided enough informations but if you need more, just ask me !

fbricon commented 5 years ago

@bsymon thanks for the sample files, that'll be helpful. At first glance, my gut feeling is composite schemas like

<xs:schema xmlns:editor="UnityEditor.UIElements" xmlns:upm="UnityEditor.PackageManager.UI" xmlns:engine="UnityEngine.UIElements" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:import schemaLocation="UnityEngine.UIElements.xsd" namespace="UnityEngine.UIElements" />
  <xs:import schemaLocation="UnityEditor.PackageManager.UI.xsd" namespace="UnityEditor.PackageManager.UI" />
  <xs:import schemaLocation="UnityEditor.UIElements.xsd" namespace="UnityEditor.UIElements" />
</xs:schema>

might not be properly supported by lsp4xml. But I might be wrong. @NikolasKomonen or @angelozerr might know better.

angelozerr commented 5 years ago

After playing quickly with your project, there are some completion which is working land some case which doesn't work. For instance with WTP XML Editor we have

image

although with lsp4xml it doesn't work. We should fix it.

@bsymon it should be very cool to list all problems that you have please. Thanks!

angelozerr commented 5 years ago

@bsymon in your XML you use xsi:noNamespaceSchemaLocation and xsi:schemaLocation both and I'm not sure it's possible. It seems Xerces processor doesn't throw error and WTP XML Editor completion accept that.

In lsp4xml if you defines xsi:noNamespaceSchemaLocation it ignores the xsi:schemaLocation (it's your problem). If you remove xsi:noNamespaceSchemaLocation completion should work better:

image

Perhaps lsp4xml completion should be more tolerant and accept the 2 xsi declaration?

@fbricon what do you think about that?

NikolasKomonen commented 5 years ago

I think if it is valid then it should be fine to provide both.

angelozerr commented 5 years ago

Thanks @NikolasKomonen for your feedback, even if I'm not sure it's valid you are right lsp4xml should support it (like WTP XML Editor)