Add secondary ctors to incremental analysis
#KT-35121 Fixed
This commit is contained in:
+15
-1
@@ -26,6 +26,7 @@ import com.intellij.psi.impl.PsiTreeChangeEventImpl.PsiEventType.CHILD_MOVED
|
||||
import com.intellij.psi.impl.PsiTreeChangeEventImpl.PsiEventType.PROPERTY_CHANGED
|
||||
import com.intellij.psi.impl.PsiTreeChangePreprocessor
|
||||
import com.intellij.psi.util.PsiModificationTracker
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.kdoc.psi.api.KDoc
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -283,12 +284,24 @@ class KotlinCodeBlockModificationListener(
|
||||
blockDeclaration
|
||||
.takeIf { it.isAncestor(element) }
|
||||
?.let { ktClassInitializer ->
|
||||
(KtPsiUtil.getTopmostParentOfTypes(blockDeclaration, KtClass::class.java) as? KtElement)?.let {
|
||||
(PsiTreeUtil.getParentOfType(blockDeclaration, KtClass::class.java) as? KtElement)?.let {
|
||||
return BlockModificationScopeElement(it, ktClassInitializer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is KtSecondaryConstructor -> {
|
||||
blockDeclaration
|
||||
?.takeIf {
|
||||
it.bodyExpression?.isAncestor(element) ?: false || it.getDelegationCallOrNull()?.isAncestor(element) ?: false
|
||||
}
|
||||
?.let { ktConstructor ->
|
||||
(PsiTreeUtil.getParentOfType(blockDeclaration, KtClass::class.java) as? KtElement)?.let {
|
||||
return BlockModificationScopeElement(it, ktConstructor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: still under consideration - is it worth to track changes of private properties / methods
|
||||
// problem could be in diagnostics - it is worth to manage it with modTracker
|
||||
// is KtClass -> {
|
||||
@@ -315,6 +328,7 @@ class KotlinCodeBlockModificationListener(
|
||||
KtProperty::class.java,
|
||||
KtNamedFunction::class.java,
|
||||
KtClassInitializer::class.java,
|
||||
KtSecondaryConstructor::class.java,
|
||||
KtScriptInitializer::class.java
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// TYPE: 'n.toString()'
|
||||
// OUT_OF_CODE_BLOCK: FALSE
|
||||
|
||||
class InSecondaryConstructor(val name: String) {
|
||||
init {
|
||||
}
|
||||
|
||||
constructor(n: Int): this(<caret>) {
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// TYPE: '4'
|
||||
// OUT_OF_CODE_BLOCK: FALSE
|
||||
|
||||
fun bar() {
|
||||
class InnerBoo(val someValue: Int) {
|
||||
constructor() : this(<caret>) {
|
||||
}
|
||||
}
|
||||
|
||||
val b = InnerBoo()
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// TYPE: 'z'
|
||||
// OUT_OF_CODE_BLOCK: TRUE
|
||||
// TODO: Investigate
|
||||
// SKIP_ANALYZE_CHECK
|
||||
|
||||
data class Intz(val q: String)
|
||||
|
||||
class InPrimaryConstructor(val x: Int<caret>) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// TYPE: 'n'
|
||||
// OUT_OF_CODE_BLOCK: FALSE
|
||||
|
||||
fun println(s: String) {
|
||||
|
||||
}
|
||||
|
||||
class InSecondaryConstructor {
|
||||
init {
|
||||
println("Init block")
|
||||
}
|
||||
|
||||
constructor(i: Int) {
|
||||
printl<caret>("Constructor")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// TYPE: 'z'
|
||||
// OUT_OF_CODE_BLOCK: TRUE
|
||||
|
||||
data class Intz(val q: String)
|
||||
|
||||
class InSecondaryConstructor {
|
||||
init {
|
||||
}
|
||||
|
||||
constructor(i: Int<caret>) {
|
||||
}
|
||||
}
|
||||
// SKIP_ANALYZE_CHECK
|
||||
@@ -0,0 +1,14 @@
|
||||
// OUT_OF_CODE_BLOCK: FALSE
|
||||
// TYPE: '4'
|
||||
|
||||
fun boo() {
|
||||
class InnerBoo() {
|
||||
val someValue: Int
|
||||
|
||||
init {
|
||||
someValue = <caret>
|
||||
}
|
||||
}
|
||||
|
||||
val b = InnerBoo()
|
||||
}
|
||||
Reference in New Issue
Block a user