mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
remove LighterAst#disposeChildren which leads to inefficiencies and possibility of dangling references when multiple indices use the same AST
This commit is contained in:
@@ -57,18 +57,6 @@ public class FCTSBackedLighterAST extends LighterAST {
|
||||
return new LighterASTNodeList(numKids, elements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeChildren(@NotNull List<LighterASTNode> children) {
|
||||
if (children instanceof LighterASTNodeList) {
|
||||
LighterASTNodeList nodes = (LighterASTNodeList)children;
|
||||
myTreeStructure.disposeChildren(nodes.myElements, nodes.mySize);
|
||||
}
|
||||
else {
|
||||
LighterASTNode[] astNodes = new LighterASTNode[children.size()];
|
||||
myTreeStructure.disposeChildren(children.toArray(astNodes), astNodes.length);
|
||||
}
|
||||
}
|
||||
|
||||
private static class LighterASTNodeList extends AbstractList<LighterASTNode> {
|
||||
private final int mySize;
|
||||
private final LighterASTNode[] myElements;
|
||||
|
||||
@@ -44,7 +44,4 @@ public abstract class LighterAST {
|
||||
|
||||
@NotNull
|
||||
public abstract List<LighterASTNode> getChildren(@NotNull final LighterASTNode parent);
|
||||
|
||||
public abstract void disposeChildren(@NotNull List<LighterASTNode> children);
|
||||
|
||||
}
|
||||
@@ -55,9 +55,6 @@ public class TreeBackedLighterAST extends LighterAST {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void disposeChildren(@NotNull List<LighterASTNode> children) {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static LighterASTNode wrap(@NotNull ASTNode node) {
|
||||
return node.getFirstChildNode() == null && node.getTextLength() > 0 ? new TokenNodeWrapper(node) : new NodeWrapper(node);
|
||||
|
||||
Reference in New Issue
Block a user