mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
spellchecker: skip checking for string literals marked with NonNls (IDEA-50373), add early created tests with vararg spellcheking
This commit is contained in:
@@ -15,13 +15,18 @@
|
||||
*/
|
||||
package com.intellij.spellchecker;
|
||||
|
||||
import com.intellij.codeInsight.AnnotationUtil;
|
||||
import com.intellij.psi.PsiLiteralExpression;
|
||||
import com.intellij.psi.PsiModifierListOwner;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.spellchecker.inspections.SplitterFactory;
|
||||
import com.intellij.spellchecker.tokenizer.Token;
|
||||
import com.intellij.spellchecker.tokenizer.Tokenizer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
*
|
||||
@@ -32,6 +37,11 @@ public class LiteralExpressionTokenizer extends Tokenizer<PsiLiteralExpression>
|
||||
@Override
|
||||
@Nullable
|
||||
public Token[] tokenize(@NotNull PsiLiteralExpression element) {
|
||||
return new Token[]{new Token<PsiLiteralExpression>(element, SplitterFactory.getInstance().getStringLiteralSplitter())};
|
||||
final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(element, PsiModifierListOwner.class);
|
||||
boolean isNls = false;
|
||||
if (listOwner != null) {
|
||||
isNls = AnnotationUtil.isAnnotated(listOwner, Collections.singleton(AnnotationUtil.NON_NLS));
|
||||
}
|
||||
return !isNls ? new Token[]{new Token<PsiLiteralExpression>(element, SplitterFactory.getInstance().getStringLiteralSplitter())} : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
public class VarArgTest {
|
||||
|
||||
public void a(Test first, Test... rest){
|
||||
}
|
||||
|
||||
public void b(<TYPO descr="Typo: In word 'Testt'">Testt</TYPO> first, <TYPO descr="Typo: In word 'Testt'">Testt</TYPO>... rest){
|
||||
}
|
||||
|
||||
public class Test {
|
||||
}
|
||||
|
||||
public class <TYPO descr="Typo: In word 'Testt'">Testt</TYPO> {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,4 +36,10 @@ public class JavaSpellcheckingTest extends SpellcheckerInspectionTestCase {
|
||||
public void testTypoInJava() throws Throwable {
|
||||
doTest("GenericTestt.java", SpellCheckerInspectionToolProvider.getInspectionTools());
|
||||
}
|
||||
|
||||
public void testVarArg() throws Throwable {
|
||||
doTest("VarArgTest.java", SpellCheckerInspectionToolProvider.getInspectionTools());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user