mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix non-ascii chars inspection in Groovy with its twisted PSI where method.getNameIdentifier()==some random light element
GitOrigin-RevId: cda967acd545b533dcfcfbeeeaef128a8f091950
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1a56f441ca
commit
76b937f25d
+9
@@ -0,0 +1,9 @@
|
||||
class X {
|
||||
int <warning descr="Non-ASCII characters in an identifier">Ж</warning> = 0;
|
||||
class <warning descr="Identifier contains symbols from different languages: [LATIN, CYRILLIC]"><warning descr="Non-ASCII characters in an identifier">InnerП</warning></warning> {}
|
||||
// comment<warning descr="Non-ASCII characters in a comment">жп</warning> 234
|
||||
String s = "12<warning descr="Non-ASCII characters in a string literal">л</warning>3<warning descr="Non-ASCII characters in a string literal">орыва</warning>0";
|
||||
void <warning descr="Non-ASCII characters in an identifier">жжж</warning>() {
|
||||
жжж();
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
+11
-6
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user