Fix compilation for 183 after adding support incremental analysis of comment and kdoc

Relates to #KT-35189

GitOrigin-RevId: cbef4a8f4fc5dca91862c52d683e43a64b4717cf
This commit is contained in:
Vladimir Dolzhenko
2019-11-30 20:50:44 +03:00
committed by intellij-monorepo-bot
parent 4a21ec8472
commit 2a256fa9dc
3 changed files with 20 additions and 8 deletions
@@ -197,23 +197,24 @@ class KotlinCodeBlockModificationListener(
return inBlockElements.isNotEmpty()
}
fun isFormattingChange(changeSet: TreeChangeEvent): Boolean =
changeSet.changedElements.all {
changeSet.getChangesByElement(it).affectedChildren.all { c -> c is PsiWhiteSpace }
}
fun isCommentChange(changeSet: TreeChangeEvent): Boolean =
private fun isCommentChange(changeSet: TreeChangeEvent): Boolean =
changeSet.changedElements.all { changedElement ->
val changesByElement = changeSet.getChangesByElement(changedElement)
changesByElement.affectedChildren.all { affectedChild ->
if (!(affectedChild is PsiComment || affectedChild is KDoc)) return@all false
val changeByChild = changesByElement.getChangeByChild(affectedChild)
return@all if (changeByChild is ChangeInfoImpl) {
changeByChild.oldChild is PsiComment && changeByChild.newChild is PsiComment ||
changeByChild.oldChild is KDoc && changeByChild.newChild is KDoc
val oldChild = changeByChild.oldChild
oldChild is PsiComment || oldChild is KDoc
} else false
}
}
private fun isFormattingChange(changeSet: TreeChangeEvent): Boolean =
changeSet.changedElements.all {
changeSet.getChangesByElement(it).affectedChildren.all { c -> c is PsiWhiteSpace }
}
fun getInsideCodeBlockModificationScope(element: PsiElement): BlockModificationScopeElement? {
val lambda = element.getTopmostParentOfType<KtLambdaExpression>()
if (lambda is KtLambdaExpression) {
@@ -348,6 +348,11 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
runTest("idea/testData/codeInsight/outOfBlock/StringInSuperConstroctorCall.kt");
}
@TestMetadata("Uncomment.kt")
public void testUncomment() throws Exception {
runTest("idea/testData/codeInsight/outOfBlock/Uncomment.kt");
}
@TestMetadata("WholeFileChanged.kt")
public void testWholeFileChanged() throws Exception {
runTest("idea/testData/codeInsight/outOfBlock/WholeFileChanged.kt");
@@ -0,0 +1,6 @@
// OUT_OF_CODE_BLOCK: FALSE
// TYPE: '\b\b'
fun uncomment(): String {
//<caret>return ""
}