mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-37379 - SOE: XsltContextProviderBase.processElementDescriptors
This commit is contained in:
+7
-7
@@ -116,9 +116,6 @@ public abstract class XsltContextProviderBase extends ContextProvider {
|
||||
final Map<String, String> namespaceDeclarations = rootTag.getLocalNamespaceDeclarations();
|
||||
final Collection<String> prefixes = namespaceDeclarations.keySet();
|
||||
|
||||
//noinspection unchecked
|
||||
final Set<XmlElementDescriptor> history = new THashSet<XmlElementDescriptor>();
|
||||
|
||||
final XmlElementFactory ef = XmlElementFactory.getInstance(file.getProject());
|
||||
int noSchemaNamespaces = 0;
|
||||
for (String prefix : prefixes) {
|
||||
@@ -141,9 +138,12 @@ public abstract class XsltContextProviderBase extends ContextProvider {
|
||||
//noinspection unchecked
|
||||
names.dependencies.add(rootDescriptor.getDescriptorFile());
|
||||
|
||||
//noinspection unchecked
|
||||
final Set<XmlElementDescriptor> history = new THashSet<XmlElementDescriptor>();
|
||||
|
||||
final XmlElementDescriptor[] e = rootDescriptor.getRootElementsDescriptors(document);
|
||||
for (XmlElementDescriptor descriptor : e) {
|
||||
processElementDescriptors(descriptor, tag, names, history);
|
||||
processElementDescriptors(descriptor, tag, names, history, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,8 +161,8 @@ public abstract class XsltContextProviderBase extends ContextProvider {
|
||||
return IGNORED_URIS.contains(namespace) || prefix.length() == 0 || "xmlns".equals(prefix);
|
||||
}
|
||||
|
||||
private static void processElementDescriptors(XmlElementDescriptor descriptor, XmlTag tag, ElementNames names, Set<XmlElementDescriptor> history) {
|
||||
if (!history.add(descriptor)) {
|
||||
private static void processElementDescriptors(XmlElementDescriptor descriptor, XmlTag tag, ElementNames names, Set<XmlElementDescriptor> history, int depth) {
|
||||
if (!history.add(descriptor) || ++depth == 200) {
|
||||
return;
|
||||
}
|
||||
final String namespace = descriptor instanceof XmlElementDescriptorImpl
|
||||
@@ -178,7 +178,7 @@ public abstract class XsltContextProviderBase extends ContextProvider {
|
||||
|
||||
final XmlElementDescriptor[] descriptors = descriptor.getElementsDescriptors(tag);
|
||||
for (XmlElementDescriptor elem : descriptors) {
|
||||
processElementDescriptors(elem, tag, names, history);
|
||||
processElementDescriptors(elem, tag, names, history, depth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-16
@@ -27,18 +27,21 @@ import org.kohsuke.rngom.digested.*;
|
||||
* Date: 19.07.2007
|
||||
*/
|
||||
public class RecursionSaveWalker extends DPatternWalker {
|
||||
private THashSet<DRefPattern> myVisited;
|
||||
private THashSet<DPattern> myVisited;
|
||||
|
||||
protected RecursionSaveWalker() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void onGrammar(DGrammarPattern p) {
|
||||
try {
|
||||
return super.onGrammar(p);
|
||||
} catch (NullPointerException e) {
|
||||
return null; // missing start pattern
|
||||
if (myVisited.add(p)) {
|
||||
try {
|
||||
return super.onGrammar(p);
|
||||
} catch (NullPointerException e) {
|
||||
return null; // missing start pattern
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void onRef(DRefPattern p) {
|
||||
@@ -53,11 +56,14 @@ public class RecursionSaveWalker extends DPatternWalker {
|
||||
}
|
||||
|
||||
protected Void onUnary(DUnaryPattern p) {
|
||||
try {
|
||||
return super.onUnary(p);
|
||||
} catch (NullPointerException e) {
|
||||
return null; // empty element
|
||||
if (myVisited.add(p)) {
|
||||
try {
|
||||
return super.onUnary(p);
|
||||
} catch (NullPointerException e) {
|
||||
return null; // empty element
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void doAccept(DPattern... p) {
|
||||
@@ -72,24 +78,24 @@ public class RecursionSaveWalker extends DPatternWalker {
|
||||
}
|
||||
}
|
||||
|
||||
private static final SpinAllocator<THashSet<DRefPattern>> ourAllocator = new SpinAllocator<THashSet<DRefPattern>>(
|
||||
new SpinAllocator.ICreator<THashSet<DRefPattern>>() {
|
||||
private static final SpinAllocator<THashSet<DPattern>> ourAllocator = new SpinAllocator<THashSet<DPattern>>(
|
||||
new SpinAllocator.ICreator<THashSet<DPattern>>() {
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public THashSet<DRefPattern> createInstance() {
|
||||
return new THashSet<DRefPattern>(64, TObjectHashingStrategy.IDENTITY) {
|
||||
public THashSet<DPattern> createInstance() {
|
||||
return new THashSet<DPattern>(256, TObjectHashingStrategy.IDENTITY) {
|
||||
public void clear() {
|
||||
if (size() == 0) return;
|
||||
super.clear();
|
||||
final int c = capacity();
|
||||
if (c > 64) {
|
||||
if (c > 256) {
|
||||
super.compact();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
new SpinAllocator.IDisposer<THashSet<DRefPattern>>() {
|
||||
public void disposeInstance(THashSet<DRefPattern> instance) {
|
||||
new SpinAllocator.IDisposer<THashSet<DPattern>>() {
|
||||
public void disposeInstance(THashSet<DPattern> instance) {
|
||||
instance.clear();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user