Make changes in super call lambda not cause out-of-block modification (KT-13474)
#KT-13474 Fixed
This commit is contained in:
+7
-1
@@ -68,7 +68,13 @@ class KotlinCodeBlockModificationListener(
|
||||
}
|
||||
|
||||
private fun isInsideCodeBlock(element: PsiElement): Boolean {
|
||||
//TODO: other types
|
||||
val lambda = KtPsiUtil.getTopmostParentOfTypes(element, KtLambdaExpression::class.java)
|
||||
if (lambda is KtLambdaExpression) {
|
||||
if (KtPsiUtil.getTopmostParentOfTypes(lambda, KtSuperTypeCallEntry::class.java) != null) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
val blockDeclaration = KtPsiUtil.getTopmostParentOfTypes(element, *BLOCK_DECLARATION_TYPES) ?: return false
|
||||
if (blockDeclaration.parents.any { it !is KtClassBody && it !is KtClassOrObject && it !is KtFile }) return false // should not be local declaration
|
||||
|
||||
|
||||
@@ -60,12 +60,15 @@ class ResolveElementCache(
|
||||
|
||||
private fun modificationStamp(resolveElement: KtElement): Long? {
|
||||
val file = resolveElement.containingFile
|
||||
return if (!file.isPhysical) // for non-physical file we don't get OUT_OF_CODE_BLOCK_MODIFICATION_COUNT increased and must reset data on any modification of the file
|
||||
file.modificationStamp
|
||||
else if (resolveElement is KtDeclaration && KotlinCodeBlockModificationListener.isBlockDeclaration(resolveElement))
|
||||
resolveElement.getModificationStamp()
|
||||
else
|
||||
null
|
||||
return when {
|
||||
// for non-physical file we don't get OUT_OF_CODE_BLOCK_MODIFICATION_COUNT increased and must reset
|
||||
// data on any modification of the file
|
||||
!file.isPhysical -> file.modificationStamp
|
||||
|
||||
resolveElement is KtDeclaration && KotlinCodeBlockModificationListener.isBlockDeclaration(resolveElement) -> resolveElement.getModificationStamp()
|
||||
resolveElement is KtSuperTypeList -> resolveElement.modificationStamp
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user