mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-73793
This commit is contained in:
@@ -66,7 +66,7 @@ public class CompositeElement extends TreeElement {
|
||||
return myModificationsCount;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
public CompositeElement clone() {
|
||||
CompositeElement clone = (CompositeElement)super.clone();
|
||||
|
||||
synchronized (PsiLock.LOCK) {
|
||||
@@ -109,8 +109,8 @@ public class CompositeElement extends TreeElement {
|
||||
PsiFile psiFile = null;
|
||||
boolean ok = ApplicationManager.getApplication().isWriteAccessAllowed() ||
|
||||
Thread.holdsLock(START_OFFSET_LOCK) ||
|
||||
wrapper != null && !wrapper.isPhysical() ||
|
||||
(fileElement = TreeUtil.getFileElement(this)) == null ||
|
||||
wrapper != null && !wrapper.isPhysical() ||
|
||||
(psiFile = (PsiFile)fileElement.getPsi()) == null ||
|
||||
psiFile instanceof DummyHolder ||
|
||||
psiFile.getViewProvider() instanceof FreeThreadedFileViewProvider ||
|
||||
|
||||
@@ -43,6 +43,14 @@ public abstract class CompositePsiElement extends CompositeElement implements Ps
|
||||
|
||||
protected CompositePsiElement(IElementType type) {
|
||||
super(type);
|
||||
setPsi(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompositePsiElement clone() {
|
||||
CompositePsiElement clone = (CompositePsiElement)super.clone();
|
||||
clone.setPsi(clone);
|
||||
return clone;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -259,11 +267,6 @@ public abstract class CompositePsiElement extends CompositeElement implements Ps
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement createPsiNoLock() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private PsiElement addInnerBefore(final PsiElement element, final PsiElement anchor) throws IncorrectOperationException {
|
||||
CheckUtil.checkWritable(this);
|
||||
TreeElement elementCopy = ChangeUtil.copyToElement(element);
|
||||
@@ -276,3 +279,4 @@ public abstract class CompositePsiElement extends CompositeElement implements Ps
|
||||
return this == another;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+19
-21
@@ -146,38 +146,36 @@ public class LazyParseableElement extends CompositeElement {
|
||||
}
|
||||
|
||||
private void ensureParsed() {
|
||||
ASTNode parsedNode;
|
||||
CharSequence text = myText();
|
||||
if (text == null) return;
|
||||
|
||||
if (TreeUtil.getFileElement(this) == null) {
|
||||
LOG.error("Chameleons must not be parsed till they're in file tree: " + this);
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
|
||||
ILazyParseableElementType type = (ILazyParseableElementType)getElementType();
|
||||
ASTNode parsedNode = type.parseContents(this);
|
||||
|
||||
if (parsedNode == null && text.length() > 0) {
|
||||
CharSequence diagText = ApplicationManager.getApplication().isInternal() ? text : "";
|
||||
LOG.error("No parse for a non-empty string: " + diagText + "; type=" + LogUtil.objectAndClass(type));
|
||||
}
|
||||
|
||||
synchronized (lock) {
|
||||
if (myText == null) return;
|
||||
if (rawFirstChild() != null) {
|
||||
LOG.error("Reentrant parsing?");
|
||||
}
|
||||
|
||||
if (TreeUtil.getFileElement(this) == null) {
|
||||
LOG.error("Chameleons must not be parsed till they're in file tree: " + this);
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
|
||||
ILazyParseableElementType type = (ILazyParseableElementType)getElementType();
|
||||
parsedNode = type.parseContents(this);
|
||||
|
||||
if (parsedNode == null && myText.length() > 0) {
|
||||
if (ApplicationManager.getApplication().isInternal() && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
LOG.error("No parse for a non-empty string: " + myText + "; type=" + LogUtil.objectAndClass(type));
|
||||
} else {
|
||||
LOG.error("No parse for a non-empty string: type=" + LogUtil.objectAndClass(type));
|
||||
}
|
||||
}
|
||||
|
||||
//CharSequence text = myText;
|
||||
myText = null;
|
||||
|
||||
if (parsedNode == null) return;
|
||||
rawAddChildrenWithoutNotifications((TreeElement)parsedNode);
|
||||
super.rawAddChildrenWithoutNotifications((TreeElement)parsedNode);
|
||||
|
||||
//if (getNotCachedLength() != text.length()) {
|
||||
// if (ApplicationManagerEx.getApplicationEx().isInternal()) {
|
||||
// if (ApplicationManager.getApplication().isInternal()) {
|
||||
// LOG.error("Inconsistent reparse: type=" + getElementType() + "; text=" + text + "; treeText=" + getText());
|
||||
// } else {
|
||||
// LOG.error("Inconsistent reparse: type=" + getElementType());
|
||||
|
||||
+9
-6
@@ -51,6 +51,14 @@ public class LazyParseablePsiElement extends LazyParseableElement implements Psi
|
||||
|
||||
public LazyParseablePsiElement(@NotNull IElementType type, CharSequence buffer) {
|
||||
super(type, buffer);
|
||||
setPsi(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LazyParseablePsiElement clone() {
|
||||
LazyParseablePsiElement clone = (LazyParseablePsiElement)super.clone();
|
||||
clone.setPsi(clone);
|
||||
return clone;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -72,7 +80,7 @@ public class LazyParseablePsiElement extends LazyParseableElement implements Psi
|
||||
for (PsiElement cur = getFirstChild(); cur != null; cur = cur.getNextSibling()) {
|
||||
if (ReflectionCache.isInstance(cur, aClass)) result.add((T)cur);
|
||||
}
|
||||
return result.toArray((T[]) Array.newInstance(aClass, result.size()));
|
||||
return result.toArray((T[])Array.newInstance(aClass, result.size()));
|
||||
}
|
||||
|
||||
public PsiElement getFirstChild() {
|
||||
@@ -287,11 +295,6 @@ public class LazyParseablePsiElement extends LazyParseableElement implements Psi
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement createPsiNoLock() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private PsiElement addInnerBefore(final PsiElement element, final PsiElement anchor) throws IncorrectOperationException {
|
||||
CheckUtil.checkWritable(this);
|
||||
TreeElement elementCopy = ChangeUtil.copyToElement(element);
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiCachedValueImpl;
|
||||
import com.intellij.psi.impl.meta.MetaRegistry;
|
||||
import com.intellij.psi.impl.source.html.dtd.HtmlNSDescriptorImpl;
|
||||
import com.intellij.psi.impl.source.tree.CompositePsiElement;
|
||||
import com.intellij.psi.impl.source.tree.TreeElement;
|
||||
import com.intellij.psi.meta.PsiMetaData;
|
||||
import com.intellij.psi.meta.PsiMetaOwner;
|
||||
@@ -287,7 +288,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
public CompositePsiElement clone() {
|
||||
HashMap<String, CachedValue<XmlNSDescriptor>> cacheStrict = new HashMap<String, CachedValue<XmlNSDescriptor>>(
|
||||
myDefaultDescriptorsCacheStrict
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user