diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/nonAsciiCharacters/Groovy.groovy b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/nonAsciiCharacters/Groovy.groovy new file mode 100644 index 000000000000..42c434cce987 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/nonAsciiCharacters/Groovy.groovy @@ -0,0 +1,9 @@ +class X { + int Ж = 0; + class InnerП {} + // commentжп 234 + String s = "12л3орыва0"; + void жжж() { + жжж(); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/NonAsciiCharactersTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/NonAsciiCharactersTest.java index 734dede6e0be..adf5235ce10a 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/NonAsciiCharactersTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/NonAsciiCharactersTest.java @@ -38,12 +38,15 @@ public class NonAsciiCharactersTest extends DaemonAnalyzerTestCase { return new LocalInspectionTool[]{inspection}; } - private void doTest() throws Exception { - doTest(BASE_PATH + "/" + getTestName(false)+".java", true, false); + private void doTest(String extension) throws Exception { + doTest(BASE_PATH + "/" + getTestName(false) + extension, true, false); UIUtil.dispatchAllInvocationEvents(); } public void testSimple() throws Exception { - doTest(); + doTest(".java"); + } + public void testGroovy() throws Exception { + doTest(".groovy"); } } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/NonAsciiCharactersInspection.java b/platform/lang-impl/src/com/intellij/codeInspection/NonAsciiCharactersInspection.java index bf4c5c87dfcb..97211906de75 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/NonAsciiCharactersInspection.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/NonAsciiCharactersInspection.java @@ -80,13 +80,18 @@ public class NonAsciiCharactersInspection extends LocalInspectionTool { public void visitElement(PsiElement element) { if (CHECK_FOR_NOT_ASCII_IDENTIFIER_NAME || CHECK_FOR_DIFFERENT_LANGUAGES_IN_IDENTIFIER_NAME) { PsiElement parent = element.getParent(); - if (parent instanceof PsiNameIdentifierOwner && ((PsiNameIdentifierOwner)parent).getNameIdentifier() == element) { + PsiElement identifier; + if (parent instanceof PsiNameIdentifierOwner && + (identifier = ((PsiNameIdentifierOwner)parent).getNameIdentifier()) != null) { + // Groovy has this twisted PSI where method.geNameIdentifier() is some random light element String text = element.getText(); - if (CHECK_FOR_NOT_ASCII_IDENTIFIER_NAME) { - checkAscii(element, text, holder, "an identifier"); - } - if (CHECK_FOR_DIFFERENT_LANGUAGES_IN_IDENTIFIER_NAME) { - checkSameLanguage(element, text, holder); + if (identifier == element || text.equals(identifier.getText())) { + if (CHECK_FOR_NOT_ASCII_IDENTIFIER_NAME) { + checkAscii(element, text, holder, "an identifier"); + } + if (CHECK_FOR_DIFFERENT_LANGUAGES_IN_IDENTIFIER_NAME) { + checkSameLanguage(element, text, holder); + } } } }