mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
allow AST to garbage-collected when holding strong references to stub-based PSI
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.psi
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.openapi.vfs.VfsUtil
|
||||
@@ -23,6 +24,7 @@ import com.intellij.psi.search.searches.OverridingMethodsSearch
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.reference.SoftReference
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import com.intellij.util.GCUtil
|
||||
|
||||
import java.util.concurrent.CountDownLatch
|
||||
/**
|
||||
@@ -136,4 +138,22 @@ class B {
|
||||
|
||||
assert bClass == override.containingClass.superClass
|
||||
}
|
||||
|
||||
public void "test AST can be gc-ed and recreated"() {
|
||||
def psiClass = myFixture.addClass("class Foo {}")
|
||||
def file = psiClass.containingFile as PsiFileImpl
|
||||
assert file.stub
|
||||
|
||||
assert psiClass.nameIdentifier
|
||||
assert !file.stub
|
||||
assert file.treeElement
|
||||
|
||||
GCUtil.tryGcSoftlyReachableObjects()
|
||||
assert !file.stub
|
||||
assert !file.treeElement
|
||||
|
||||
assert psiClass.nameIdentifier
|
||||
assert !file.stub
|
||||
assert file.treeElement
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user