Make code fragments files non-physical with event system disabled
As a side effect it will disable write checks for fragments files This allows completion work without write action. Inspired by Java fragment files
This commit is contained in:
committed by
Nikolay Krasko
parent
df46a8c67a
commit
d02b89a7a0
@@ -53,6 +53,7 @@ abstract class KtCodeFragment(
|
|||||||
private var thisType: PsiType? = null
|
private var thisType: PsiType? = null
|
||||||
private var superType: PsiType? = null
|
private var superType: PsiType? = null
|
||||||
private var exceptionHandler: JavaCodeFragment.ExceptionHandler? = null
|
private var exceptionHandler: JavaCodeFragment.ExceptionHandler? = null
|
||||||
|
private var isPhysical = true
|
||||||
|
|
||||||
abstract fun getContentElement(): KtElement?
|
abstract fun getContentElement(): KtElement?
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ abstract class KtCodeFragment(
|
|||||||
|
|
||||||
override fun getForcedResolveScope() = resolveScope
|
override fun getForcedResolveScope() = resolveScope
|
||||||
|
|
||||||
override fun isPhysical() = true
|
override fun isPhysical() = isPhysical
|
||||||
|
|
||||||
override fun isValid() = true
|
override fun isValid() = true
|
||||||
|
|
||||||
@@ -72,9 +73,10 @@ abstract class KtCodeFragment(
|
|||||||
|
|
||||||
override fun clone(): KtCodeFragment {
|
override fun clone(): KtCodeFragment {
|
||||||
val clone = cloneImpl(calcTreeElement().clone() as FileElement) as KtCodeFragment
|
val clone = cloneImpl(calcTreeElement().clone() as FileElement) as KtCodeFragment
|
||||||
|
clone.isPhysical = false
|
||||||
clone.originalFile = this
|
clone.originalFile = this
|
||||||
clone.imports = imports
|
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)
|
clone.viewProvider.forceCachedPsi(clone)
|
||||||
return clone
|
return clone
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user