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

Relates to #KT-35189
This commit is contained in:
Vladimir Dolzhenko
2019-11-30 09:51:45 +01:00
parent a923e0d130
commit f8a6217fb5
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) {
+6
View File
@@ -0,0 +1,6 @@
// OUT_OF_CODE_BLOCK: FALSE
// TYPE: '\b\b'
fun uncomment(): String {
//<caret>return ""
}
@@ -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");