Fix handling non ctor elements in SECONDARY_CONSTRUCTOR_DELEGATION_CALL
#KT-45339 Fixed
This commit is contained in:
committed by
Space
parent
3d236b7171
commit
8068a5439f
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.KtNodeTypes
|
|||||||
import org.jetbrains.kotlin.cfg.UnreachableCode
|
import org.jetbrains.kotlin.cfg.UnreachableCode
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors.ACTUAL_WITHOUT_EXPECT
|
import org.jetbrains.kotlin.diagnostics.Errors.ACTUAL_WITHOUT_EXPECT
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors.NO_ACTUAL_FOR_EXPECT
|
import org.jetbrains.kotlin.diagnostics.Errors.NO_ACTUAL_FOR_EXPECT
|
||||||
import org.jetbrains.kotlin.diagnostics.PositioningStrategies.INNER_MODIFIER
|
|
||||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens.MODALITY_MODIFIERS
|
import org.jetbrains.kotlin.lexer.KtTokens.MODALITY_MODIFIERS
|
||||||
@@ -637,10 +636,10 @@ object PositioningStrategies {
|
|||||||
val SECONDARY_CONSTRUCTOR_DELEGATION_CALL: PositioningStrategy<PsiElement> =
|
val SECONDARY_CONSTRUCTOR_DELEGATION_CALL: PositioningStrategy<PsiElement> =
|
||||||
object : PositioningStrategy<PsiElement>() {
|
object : PositioningStrategy<PsiElement>() {
|
||||||
override fun mark(element: PsiElement): List<TextRange> {
|
override fun mark(element: PsiElement): List<TextRange> {
|
||||||
when (element) {
|
return when (element) {
|
||||||
is KtSecondaryConstructor -> {
|
is KtSecondaryConstructor -> {
|
||||||
val valueParameterList = element.valueParameterList ?: return markElement(element)
|
val valueParameterList = element.valueParameterList ?: return markElement(element)
|
||||||
return markRange(element.getConstructorKeyword(), valueParameterList.lastChild)
|
markRange(element.getConstructorKeyword(), valueParameterList.lastChild)
|
||||||
}
|
}
|
||||||
is KtConstructorDelegationCall -> {
|
is KtConstructorDelegationCall -> {
|
||||||
if (element.isImplicit) {
|
if (element.isImplicit) {
|
||||||
@@ -650,9 +649,9 @@ object PositioningStrategies {
|
|||||||
val valueParameterList = constructor.valueParameterList ?: return markElement(constructor)
|
val valueParameterList = constructor.valueParameterList ?: return markElement(constructor)
|
||||||
return markRange(constructor.getConstructorKeyword(), valueParameterList.lastChild)
|
return markRange(constructor.getConstructorKeyword(), valueParameterList.lastChild)
|
||||||
}
|
}
|
||||||
return markElement(element.calleeExpression ?: element)
|
markElement(element.calleeExpression ?: element)
|
||||||
}
|
}
|
||||||
else -> error("unexpected element $element")
|
else -> markElement(element)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+5
@@ -71,6 +71,11 @@ public class FirHighlightingTestGenerated extends AbstractFirHighlightingTest {
|
|||||||
runTest("idea/testData/highlighter/Functions.kt");
|
runTest("idea/testData/highlighter/Functions.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("InaccessibleExpression.kt")
|
||||||
|
public void testInaccessibleExpression() throws Exception {
|
||||||
|
runTest("idea/testData/highlighter/InaccessibleExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("InvokeCall.kt")
|
@TestMetadata("InvokeCall.kt")
|
||||||
public void testInvokeCall() throws Exception {
|
public void testInvokeCall() throws Exception {
|
||||||
runTest("idea/testData/highlighter/InvokeCall.kt");
|
runTest("idea/testData/highlighter/InvokeCall.kt");
|
||||||
|
|||||||
Generated
+5
@@ -69,6 +69,11 @@ public class PerformanceHighlightingTestGenerated extends AbstractPerformanceHig
|
|||||||
runTest("idea/testData/highlighter/Functions.kt");
|
runTest("idea/testData/highlighter/Functions.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("InaccessibleExpression.kt")
|
||||||
|
public void testInaccessibleExpression() throws Exception {
|
||||||
|
runTest("idea/testData/highlighter/InaccessibleExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("InvokeCall.kt")
|
@TestMetadata("InvokeCall.kt")
|
||||||
public void testInvokeCall() throws Exception {
|
public void testInvokeCall() throws Exception {
|
||||||
runTest("idea/testData/highlighter/InvokeCall.kt");
|
runTest("idea/testData/highlighter/InvokeCall.kt");
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// IGNORE_FIR
|
||||||
|
|
||||||
|
interface <info textAttributesKey="KOTLIN_TRAIT">Zoo</info><<info textAttributesKey="KOTLIN_TYPE_PARAMETER">T</info>> {
|
||||||
|
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION"><error descr="[WRONG_MODIFIER_TARGET] Modifier 'inner' is not applicable to 'enum class'" textAttributesKey="ERRORS_ATTRIBUTES">inner</error></info> <info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">enum</info> class <info textAttributesKey="KOTLIN_ENUM">Var</info> : <info textAttributesKey="KOTLIN_TRAIT">Zoo</info><<error descr="[INACCESSIBLE_OUTER_CLASS_EXPRESSION] Expression is inaccessible from a nested class 'Var'" textAttributesKey="ERRORS_ATTRIBUTES">T</error>>
|
||||||
|
}
|
||||||
|
|
||||||
|
object <info textAttributesKey="KOTLIN_OBJECT">Outer</info> {
|
||||||
|
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">bar</info>() = <info textAttributesKey="KOTLIN_OBJECT">Unit</info>
|
||||||
|
class <info textAttributesKey="KOTLIN_CLASS">Inner</info> {
|
||||||
|
fun <info textAttributesKey="KOTLIN_FUNCTION_DECLARATION">foo</info>() = this<info textAttributesKey="KOTLIN_LABEL"><error descr="[INACCESSIBLE_OUTER_CLASS_EXPRESSION] Expression is inaccessible from a nested class 'Inner'" textAttributesKey="ERRORS_ATTRIBUTES">@Outer</error></info>.<error descr="[DEBUG] Reference is not resolved to anything, but is not marked unresolved" textAttributesKey="KOTLIN_DEBUG_INFO">bar</error>()
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -69,6 +69,11 @@ public class HighlightingTestGenerated extends AbstractHighlightingTest {
|
|||||||
runTest("idea/testData/highlighter/Functions.kt");
|
runTest("idea/testData/highlighter/Functions.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("InaccessibleExpression.kt")
|
||||||
|
public void testInaccessibleExpression() throws Exception {
|
||||||
|
runTest("idea/testData/highlighter/InaccessibleExpression.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("InvokeCall.kt")
|
@TestMetadata("InvokeCall.kt")
|
||||||
public void testInvokeCall() throws Exception {
|
public void testInvokeCall() throws Exception {
|
||||||
runTest("idea/testData/highlighter/InvokeCall.kt");
|
runTest("idea/testData/highlighter/InvokeCall.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user