[java spellchecker] don't spellcheck overridden method names

GitOrigin-RevId: 5e30ecfa06fe2e1a172e1906c715e2494484cd0f
This commit is contained in:
Peter Gromov
2022-11-24 11:08:05 +01:00
committed by intellij-monorepo-bot
parent e77457cae4
commit 626dc6aa40
2 changed files with 7 additions and 17 deletions

View File

@@ -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<PsiMethod> {
@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);
}
}

View File

@@ -4,6 +4,10 @@ class Super {
WithTyppoInName myWithTyppoInName = new WithTyppoInName();
}
class Sub extends Super {
void asdftypo() {}
}
class With<TYPO descr="Typo: In word 'Typpo'">Typpo</TYPO>InName {}
class InheritorOfWithTyppoInName extends WithTyppoInName {}