mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
expand chameleons under lock
to avoid multiple threads doing the same work originally parsing was moved out of lock for IDEA-73793 which is no longer actual
This commit is contained in:
+17
-19
@@ -178,27 +178,25 @@ public class LazyParseableElement extends CompositeElement {
|
||||
CharSequence text;
|
||||
synchronized (lock) {
|
||||
if (myParsed) return;
|
||||
|
||||
text = myText.get();
|
||||
assert text != null;
|
||||
}
|
||||
|
||||
FileElement fileElement = TreeUtil.getFileElement(this);
|
||||
if (fileElement == null) {
|
||||
LOG.error("Chameleons must not be parsed till they're in file tree: " + this);
|
||||
}
|
||||
else {
|
||||
fileElement.assertReadAccessAllowed();
|
||||
}
|
||||
FileElement fileElement = TreeUtil.getFileElement(this);
|
||||
if (fileElement == null) {
|
||||
LOG.error("Chameleons must not be parsed till they're in file tree: " + this);
|
||||
}
|
||||
else {
|
||||
fileElement.assertReadAccessAllowed();
|
||||
}
|
||||
|
||||
DebugUtil.performPsiModification("lazy-parsing", () -> {
|
||||
TreeElement parsedNode = (TreeElement)((ILazyParseableElementTypeBase)getElementType()).parseContents(this);
|
||||
assertTextLengthIntact(text, parsedNode);
|
||||
if (rawFirstChild() != null) {
|
||||
LOG.error("Reentrant parsing?");
|
||||
}
|
||||
|
||||
synchronized (lock) {
|
||||
if (myParsed) return;
|
||||
if (rawFirstChild() != null) {
|
||||
LOG.error("Reentrant parsing?");
|
||||
}
|
||||
DebugUtil.performPsiModification("lazy-parsing", () -> {
|
||||
TreeElement parsedNode = (TreeElement)((ILazyParseableElementTypeBase)getElementType()).parseContents(this);
|
||||
assertTextLengthIntact(text, parsedNode);
|
||||
|
||||
if (parsedNode != null) {
|
||||
setChildren(parsedNode);
|
||||
@@ -206,9 +204,9 @@ public class LazyParseableElement extends CompositeElement {
|
||||
|
||||
myParsed = true;
|
||||
myText = new SoftReference<>(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void assertTextLengthIntact(CharSequence text, TreeElement child) {
|
||||
int length = 0;
|
||||
|
||||
Reference in New Issue
Block a user