[java-i18n] IDEA-247707 @NonNls inspection doesn't propagate to receiver expressions in Kotlin

GitOrigin-RevId: 77b96c095d076825edb0cab3f5629de52b1611b8
This commit is contained in:
Tagir Valeev
2020-08-11 18:34:37 +07:00
committed by intellij-monorepo-bot
parent 6378aab247
commit c9b12e1abe
3 changed files with 24 additions and 2 deletions

View File

@@ -18,6 +18,19 @@ class KtI18NInspectionTest : LightJavaCodeInsightFixtureTestCase() {
""".trimIndent())
myFixture.testHighlighting()
}
fun testPropagateToReceiver() {
myFixture.enableInspections(com.intellij.codeInspection.i18n.I18nInspection())
myFixture.configureByText("Foo.kt", """
public fun String.trimIndent(): String = this
fun foo(@org.jetbrains.annotations.NonNls <warning descr="[UNUSED_PARAMETER] Parameter 'message' is never used">message</warning>: String) { }
fun bar() {
foo("foo bar")
foo("foo bar".trimIndent())
}
""".trimIndent())
myFixture.testHighlighting()
}
fun testPropertyAssignment() {
val inspection = com.intellij.codeInspection.i18n.I18nInspection()

View File

@@ -352,8 +352,13 @@ public abstract class NlsInfo {
UExpression parent = expression;
while (true) {
UExpression next = ObjectUtils.tryCast(parent.getUastParent(), UExpression.class);
if (next == null || next instanceof ULambdaExpression || next instanceof UReturnExpression) return parent;
if (next instanceof USwitchClauseExpression || next instanceof UNamedExpression) return parent;
if (next == null ||
next instanceof ULambdaExpression ||
next instanceof UReturnExpression ||
next instanceof USwitchClauseExpression ||
next instanceof UNamedExpression) {
return parent;
}
if (next instanceof UPolyadicExpression && ((UPolyadicExpression)next).getOperator() != UastBinaryOperator.PLUS) return parent;
if (next instanceof UCallExpression) {
if (!UastExpressionUtils.isArrayInitializer(next) && !UastExpressionUtils.isNewArrayWithInitializer(next)) {

View File

@@ -43,5 +43,9 @@ class StringMethods {
if (this.getFoo().toLowerCase().equals("bar")) {}
}
void test() {
test("foo".trim());
}
@NonNls native String getFoo();
}