Report WRONG_MODIFIER_TARGET on the modifier instead of the declaration
in ExternalFunChecker. This allows RemoveModifierFix to provide a quickfix to remove it.
This commit is contained in:
committed by
Ilya Kirillov
parent
c680ee8525
commit
dd20dd9806
+4
-2
@@ -23,8 +23,8 @@ import org.jetbrains.kotlin.psi.KtDeclaration
|
|||||||
import org.jetbrains.kotlin.psi.KtDeclarationWithBody
|
import org.jetbrains.kotlin.psi.KtDeclarationWithBody
|
||||||
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
|
||||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
|
import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
|
||||||
|
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
||||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||||
|
|
||||||
@@ -39,7 +39,9 @@ class ExternalFunChecker : DeclarationChecker {
|
|||||||
is ClassDescriptor -> "class"
|
is ClassDescriptor -> "class"
|
||||||
else -> "non-function declaration"
|
else -> "non-function declaration"
|
||||||
}
|
}
|
||||||
trace.report(Errors.WRONG_MODIFIER_TARGET.on(declaration, KtTokens.EXTERNAL_KEYWORD, target))
|
declaration.modifierList?.getModifier(KtTokens.EXTERNAL_KEYWORD)?.let {
|
||||||
|
trace.report(Errors.WRONG_MODIFIER_TARGET.on(it, KtTokens.EXTERNAL_KEYWORD, target))
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<!WRONG_MODIFIER_TARGET!>external class A<!>
|
<!WRONG_MODIFIER_TARGET!>external<!> class A
|
||||||
|
|
||||||
<!WRONG_MODIFIER_TARGET!>external val foo: Int = 23<!>
|
<!WRONG_MODIFIER_TARGET!>external<!> val foo: Int = 23
|
||||||
|
|
||||||
class B {
|
class B {
|
||||||
<!WRONG_MODIFIER_TARGET!>external class A<!>
|
<!WRONG_MODIFIER_TARGET!>external<!> class A
|
||||||
|
|
||||||
<!WRONG_MODIFIER_TARGET!>external val foo: Int = 23<!>
|
<!WRONG_MODIFIER_TARGET!>external<!> val foo: Int = 23
|
||||||
}
|
}
|
||||||
Generated
+5
@@ -650,6 +650,11 @@ public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTes
|
|||||||
runTest("idea/testData/quickfix/modifiers/removeConst.kt");
|
runTest("idea/testData/quickfix/modifiers/removeConst.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("removeExternalModifier.kt")
|
||||||
|
public void testRemoveExternalModifier() throws Exception {
|
||||||
|
runTest("idea/testData/quickfix/modifiers/removeExternalModifier.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("removeIncompatibleModifier.kt")
|
@TestMetadata("removeIncompatibleModifier.kt")
|
||||||
public void testRemoveIncompatibleModifier() throws Exception {
|
public void testRemoveIncompatibleModifier() throws Exception {
|
||||||
runTest("idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt");
|
runTest("idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt");
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// "Remove 'external' modifier" "true"
|
||||||
|
|
||||||
|
class B {
|
||||||
|
<caret>external val foo: Int = 23
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// "Remove 'external' modifier" "true"
|
||||||
|
|
||||||
|
class B {
|
||||||
|
val foo: Int = 23
|
||||||
|
}
|
||||||
@@ -9432,6 +9432,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
runTest("idea/testData/quickfix/modifiers/removeConst.kt");
|
runTest("idea/testData/quickfix/modifiers/removeConst.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("removeExternalModifier.kt")
|
||||||
|
public void testRemoveExternalModifier() throws Exception {
|
||||||
|
runTest("idea/testData/quickfix/modifiers/removeExternalModifier.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("removeIncompatibleModifier.kt")
|
@TestMetadata("removeIncompatibleModifier.kt")
|
||||||
public void testRemoveIncompatibleModifier() throws Exception {
|
public void testRemoveIncompatibleModifier() throws Exception {
|
||||||
runTest("idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt");
|
runTest("idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user