提交 dd20dd98 编写于 作者: M Mark Punzalan 提交者: Ilya Kirillov

Report WRONG_MODIFIER_TARGET on the modifier instead of the declaration

in ExternalFunChecker.

This allows RemoveModifierFix to provide a quickfix to remove it.
上级 c680ee85
......@@ -23,8 +23,8 @@ import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtDeclarationWithBody
import org.jetbrains.kotlin.psi.KtPropertyAccessor
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.DeclarationCheckerContext
import org.jetbrains.kotlin.resolve.inline.InlineUtil
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
......@@ -39,7 +39,9 @@ class ExternalFunChecker : DeclarationChecker {
is ClassDescriptor -> "class"
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
}
......
<!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 {
<!WRONG_MODIFIER_TARGET!>external class A<!>
<!WRONG_MODIFIER_TARGET!>external<!> class A
<!WRONG_MODIFIER_TARGET!>external val foo: Int = 23<!>
}
\ No newline at end of file
<!WRONG_MODIFIER_TARGET!>external<!> val foo: Int = 23
}
......@@ -650,6 +650,11 @@ public class HighLevelQuickFixTestGenerated extends AbstractHighLevelQuickFixTes
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")
public void testRemoveIncompatibleModifier() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt");
......
// "Remove 'external' modifier" "true"
class B {
<caret>external val foo: Int = 23
}
\ No newline at end of file
// "Remove 'external' modifier" "true"
class B {
val foo: Int = 23
}
\ No newline at end of file
......@@ -9432,6 +9432,11 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
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")
public void testRemoveIncompatibleModifier() throws Exception {
runTest("idea/testData/quickfix/modifiers/removeIncompatibleModifier.kt");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册