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 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user