Make code fragments files non-physical with event system disabled (KT-12232)

Fix "File copy should be non-physical and non-event-system-enabled! Language=Language:
kotlin; file=JetFile: fragment.kt of class org.jetbrains.kotlin.psi.KtExpressionCodeFragment" assert.

Inspired by Java fragment files

 #KT-12232 Fixed
This commit is contained in:
Nikolay Krasko
2016-04-14 21:13:57 +03:00
committed by Nikolay Krasko
parent 9c2ceca4b8
commit 1a1c10251a
@@ -53,6 +53,7 @@ abstract class KtCodeFragment(
private var thisType: PsiType? = null
private var superType: PsiType? = null
private var exceptionHandler: JavaCodeFragment.ExceptionHandler? = null
private var isPhysical = true
abstract fun getContentElement(): KtElement?
@@ -62,7 +63,7 @@ abstract class KtCodeFragment(
override fun getForcedResolveScope() = resolveScope
override fun isPhysical() = true
override fun isPhysical() = isPhysical
override fun isValid() = true
@@ -72,9 +73,10 @@ abstract class KtCodeFragment(
override fun clone(): KtCodeFragment {
val clone = cloneImpl(calcTreeElement().clone() as FileElement) as KtCodeFragment
clone.isPhysical = false
clone.originalFile = this
clone.imports = imports
clone.viewProvider = SingleRootFileViewProvider(PsiManager.getInstance(_project), LightVirtualFile(name, KotlinFileType.INSTANCE, text), true)
clone.viewProvider = SingleRootFileViewProvider(PsiManager.getInstance(_project), LightVirtualFile(name, KotlinFileType.INSTANCE, text), false)
clone.viewProvider.forceCachedPsi(clone)
return clone
}