platform: normalize descriptor paths to find paths starting with './'

That will sync behavior of IDE started from sources (where descriptors are loaded from files) and built IDE (where descriptors are loaded from jar files).
Also, that will allow to specify paths uniformly in `xi:include` and `depends`, e.g.
  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="./jest.xml" xpointer="xpointer(/idea-plugin/*)"/>
  <depends optional="true" config-file="./jest-coverage.xml">com.intellij.modules.coverage</depends>
This commit is contained in:
Sergey Simonchik
2017-10-12 21:13:36 +03:00
parent 94adcce99f
commit 5d05ab6d98
@@ -57,10 +57,7 @@ import org.jetbrains.annotations.TestOnly;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.*;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -680,7 +677,7 @@ public class PluginManagerCore {
@NotNull JDOMXIncluder.PathResolver pathResolver,
@NotNull LoadingContext context) {
try {
URL jarURL = URLUtil.getJarEntryURL(file, META_INF + '/' + fileName);
URL jarURL = URLUtil.getJarEntryURL(file, getNormalizedPathInJar(fileName));
ZipFile zipFile = context.myOpenedFiles.get(file);
if (zipFile == null) {
@@ -707,6 +704,17 @@ public class PluginManagerCore {
return null;
}
@NotNull
private static String getNormalizedPathInJar(@NotNull String pathInJar) {
String absolutePathInJar = META_INF + '/' + pathInJar;
try {
return new URI(absolutePathInJar).normalize().getPath();
}
catch (URISyntaxException ignored) {
}
return absolutePathInJar;
}
@Nullable
public static IdeaPluginDescriptorImpl loadDescriptor(@NotNull final File file, @NotNull String fileName) {
try (LoadingContext context = new LoadingContext()) {