mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
allow getStub to return something after AST is GC-ed
This commit is contained in:
@@ -27,6 +27,7 @@ import com.intellij.psi.stubs.StubElement
|
||||
import com.intellij.psi.stubs.StubTree
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.reference.SoftReference
|
||||
import com.intellij.testFramework.LeakHunter
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import com.intellij.util.GCUtil
|
||||
|
||||
@@ -161,8 +162,8 @@ class B {
|
||||
assert file.treeElement
|
||||
|
||||
GCUtil.tryGcSoftlyReachableObjects()
|
||||
assert !file.stub
|
||||
assert !file.treeElement
|
||||
assert file.stub
|
||||
|
||||
assert psiClass.nameIdentifier
|
||||
assert !file.stub
|
||||
@@ -190,8 +191,8 @@ class B {
|
||||
assert file.classes[0].nameIdentifier
|
||||
GCUtil.tryGcSoftlyReachableObjects()
|
||||
|
||||
assert !((PsiFileImpl)file).getTreeElement()
|
||||
assert !((PsiFileImpl)file).getStub()
|
||||
assert !((PsiFileImpl)file).treeElement
|
||||
assertNoStubLoaded(file)
|
||||
|
||||
assert file.classes[0].methods[0].modifierList.hasExplicitModifier(PsiModifier.STATIC)
|
||||
assert !((PsiFileImpl)file).getTreeElement()
|
||||
@@ -204,11 +205,12 @@ class B {
|
||||
GCUtil.tryGcSoftlyReachableObjects()
|
||||
|
||||
assert !file.treeElement
|
||||
assert !file.greenStub
|
||||
|
||||
assert PsiAnchor.create(psiClass) instanceof PsiAnchor.StubIndexReference
|
||||
assertNoStubLoaded(file)
|
||||
StubElement hardRefToStub = file.greenStub
|
||||
assert hardRefToStub
|
||||
assert hardRefToStub == file.stub
|
||||
|
||||
assert file.node
|
||||
|
||||
GCUtil.tryGcSoftlyReachableObjects()
|
||||
assert !file.treeElement
|
||||
@@ -218,6 +220,10 @@ class B {
|
||||
assert !file.treeElement
|
||||
}
|
||||
|
||||
private static assertNoStubLoaded(PsiFile file) {
|
||||
LeakHunter.checkLeak(file, StubTree) { candidate -> candidate.root.psi == file }
|
||||
}
|
||||
|
||||
void "test node is not deeply parsed when loaded in green stub presence"() {
|
||||
PsiFileImpl file = (PsiFileImpl)myFixture.addFileToProject("a.java", "class A<T>{}")
|
||||
def stubTree = file.stubTree
|
||||
|
||||
Reference in New Issue
Block a user