mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IdeaPluginDescriptorImpl — avoid document clone, resolve using root element
root element always `!isIncludeElement` and it means that result always is a singleton list Also, plugin xml describes one plugin, this descriptor is not able to represent several plugins — we cannot in any case read several elements into descriptor
This commit is contained in:
@@ -146,10 +146,10 @@ public class IdeaPluginDescriptorImpl implements IdeaPluginDescriptor {
|
||||
}
|
||||
|
||||
public void readExternal(@NotNull Document document, @NotNull URL url, boolean ignoreMissingInclude, @NotNull JDOMXIncluder.PathResolver pathResolver) throws InvalidDataException {
|
||||
document = JDOMXIncluder.resolve(document, url.toExternalForm(), ignoreMissingInclude, pathResolver);
|
||||
Element rootElement = document.getRootElement();
|
||||
Element newElement = JDOMUtil.internElement(rootElement);
|
||||
readExternal(newElement);
|
||||
// root element always `!isIncludeElement` and it means that result always is a singleton list
|
||||
// (also, plugin xml describes one plugin, this descriptor is not able to represent several plugins)
|
||||
Element rootElement = JDOMXIncluder.resolveNonXIncludeElement(document.getRootElement(), url.toExternalForm(), ignoreMissingInclude, pathResolver);
|
||||
readExternal(JDOMUtil.internElement(rootElement));
|
||||
}
|
||||
|
||||
public void readExternal(@NotNull URL url) throws InvalidDataException, FileNotFoundException {
|
||||
|
||||
@@ -82,6 +82,17 @@ public class JDOMXIncluder {
|
||||
return new JDOMXIncluder(ignoreMissing, pathResolver).doResolve(original, base);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Element resolveNonXIncludeElement(@NotNull Element original, @Nullable String base, boolean ignoreMissing, PathResolver pathResolver) throws XIncludeException {
|
||||
LOG.assertTrue(!isIncludeElement(original));
|
||||
|
||||
Stack<String> bases = new Stack<String>();
|
||||
if (base != null) {
|
||||
bases.push(base);
|
||||
}
|
||||
return new JDOMXIncluder(ignoreMissing, pathResolver).resolveNonXIncludeElement(original, bases);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<Content> resolve(@NotNull Element original, String base) throws XIncludeException {
|
||||
return new JDOMXIncluder(false, DEFAULT_PATH_RESOLVER).doResolve(original, base);
|
||||
@@ -176,9 +187,7 @@ public class JDOMXIncluder {
|
||||
bases.push(base);
|
||||
}
|
||||
|
||||
List<Content> result = resolve(original, bases);
|
||||
bases.pop();
|
||||
return result;
|
||||
return resolve(original, bases);
|
||||
}
|
||||
|
||||
private static boolean isIncludeElement(Element element) {
|
||||
|
||||
Reference in New Issue
Block a user