Skip to content

Commit 5f95e76

Browse files
committed
Resolve XML catalogs platform:/ URIs to file:/
LemMinX only accepts file:/ URIs for catalog entries, so we try to convert everything that's not a file.
1 parent 67efc99 commit 5f95e76

File tree

1 file changed

+12
-4
lines changed
  • org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences

1 file changed

+12
-4
lines changed

org.eclipse.wildwebdeveloper.xml/src/org/eclipse/wildwebdeveloper/xml/internal/ui/preferences/XMLCatalogs.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.io.File;
1515
import java.io.IOException;
1616
import java.net.URI;
17+
import java.net.URISyntaxException;
1718
import java.nio.file.Files;
1819
import java.util.Arrays;
1920
import java.util.Comparator;
@@ -61,11 +62,18 @@ private static File getWTPExtensionCatalog() {
6162
.flatMap(element -> Arrays.stream(element.getChildren("system")))
6263
.forEach(element -> {
6364
String namespace = element.getAttribute("systemId");
64-
String uri = element.getAttribute("uri");
65-
if (!URI.create(uri).isAbsolute()) {
65+
URI uri = URI.create(element.getAttribute("uri"));
66+
if (!uri.isAbsolute()) {
6667
try {
67-
uri = FileLocator.toFileURL(FileLocator.find(Platform.getBundle(element.getContributor().getName()), Path.fromPortableString(uri.toString()))).toString();
68-
} catch (InvalidRegistryObjectException | IOException e) {
68+
uri = FileLocator.find(Platform.getBundle(element.getContributor().getName()), Path.fromPortableString(uri.toString())).toURI();
69+
} catch (InvalidRegistryObjectException | URISyntaxException e) {
70+
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
71+
}
72+
}
73+
if (!"file".equals(uri.getScheme())) { // are some other scheme supported directly by LemMinX ?
74+
try {
75+
uri = FileLocator.toFileURL(uri.toURL()).toURI();
76+
} catch (InvalidRegistryObjectException | IOException | URISyntaxException e) {
6977
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
7078
}
7179
}

0 commit comments

Comments
 (0)