From 626dc6aa40bee9c77eadc15c16bc4b24f489f302 Mon Sep 17 00:00:00 2001 From: Peter Gromov Date: Thu, 24 Nov 2022 11:08:05 +0100 Subject: [PATCH] [java spellchecker] don't spellcheck overridden method names GitOrigin-RevId: 5e30ecfa06fe2e1a172e1906c715e2494484cd0f --- .../spellchecker/MethodNameTokenizerJava.java | 20 +++---------------- .../spellchecker/DoNotCheckDerivedNames.java | 4 ++++ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/java/java-impl/src/com/intellij/spellchecker/MethodNameTokenizerJava.java b/java/java-impl/src/com/intellij/spellchecker/MethodNameTokenizerJava.java index 00cb3e916d26..53d15d66862f 100644 --- a/java/java-impl/src/com/intellij/spellchecker/MethodNameTokenizerJava.java +++ b/java/java-impl/src/com/intellij/spellchecker/MethodNameTokenizerJava.java @@ -15,8 +15,6 @@ */ package com.intellij.spellchecker; -import com.intellij.openapi.roots.ProjectRootManager; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiMethod; import com.intellij.spellchecker.tokenizer.TokenConsumer; import org.jetbrains.annotations.NotNull; @@ -28,21 +26,9 @@ public class MethodNameTokenizerJava extends NamedElementTokenizer { @Override public void tokenize(@NotNull PsiMethod element, TokenConsumer consumer) { - if (element.isConstructor()) return; - final PsiMethod[] methods = (element).findDeepestSuperMethods(); - boolean isInSource = true; - for (PsiMethod psiMethod : methods) { - isInSource &= isMethodDeclarationInSource(psiMethod); - } - if (isInSource) { - super.tokenize(element, consumer); - } + if (element.isConstructor() || element.findDeepestSuperMethods().length > 0) return; + + super.tokenize(element, consumer); } - private static boolean isMethodDeclarationInSource(@NotNull PsiMethod psiMethod) { - if (psiMethod.getContainingFile() == null) return false; - final VirtualFile virtualFile = psiMethod.getContainingFile().getVirtualFile(); - if (virtualFile == null) return false; - return ProjectRootManager.getInstance(psiMethod.getProject()).getFileIndex().isInSource(virtualFile); - } } diff --git a/plugins/java-i18n/testData/inspections/spellchecker/DoNotCheckDerivedNames.java b/plugins/java-i18n/testData/inspections/spellchecker/DoNotCheckDerivedNames.java index 603522f5104c..33ad3d162fef 100644 --- a/plugins/java-i18n/testData/inspections/spellchecker/DoNotCheckDerivedNames.java +++ b/plugins/java-i18n/testData/inspections/spellchecker/DoNotCheckDerivedNames.java @@ -4,6 +4,10 @@ class Super { WithTyppoInName myWithTyppoInName = new WithTyppoInName(); } +class Sub extends Super { + void asdftypo() {} +} + class WithTyppoInName {} class InheritorOfWithTyppoInName extends WithTyppoInName {} \ No newline at end of file