Do not spell check overridden declaration names (KT-15000)
#KT-15000 Fixed
This commit is contained in:
@@ -512,7 +512,7 @@
|
||||
language="kotlin"
|
||||
implementationClass="org.jetbrains.kotlin.idea.refactoring.rename.KotlinResolveSnapshotProvider"/>
|
||||
|
||||
<spellchecker.support implementationClass="org.jetbrains.kotlin.idea.KotlinSpellcheckingStrategy" language="kotlin"/>
|
||||
<spellchecker.support implementationClass="org.jetbrains.kotlin.idea.codeInsight.spellchecker.KotlinSpellcheckingStrategy" language="kotlin"/>
|
||||
|
||||
<liveTemplateContext implementation="org.jetbrains.kotlin.idea.liveTemplates.KotlinTemplateContextType$Generic"/>
|
||||
<liveTemplateContext implementation="org.jetbrains.kotlin.idea.liveTemplates.KotlinTemplateContextType$TopLevel"/>
|
||||
|
||||
+21
-14
@@ -14,33 +14,40 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea
|
||||
package org.jetbrains.kotlin.idea.codeInsight.spellchecker
|
||||
|
||||
import com.intellij.codeInspection.SuppressQuickFix
|
||||
import com.intellij.psi.PsiComment
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiNameIdentifierOwner
|
||||
import com.intellij.spellchecker.inspections.PlainTextSplitter
|
||||
import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy
|
||||
import com.intellij.spellchecker.tokenizer.SuppressibleSpellcheckingStrategy
|
||||
import com.intellij.spellchecker.tokenizer.Tokenizer
|
||||
import com.intellij.spellchecker.tokenizer.TokenizerBase
|
||||
import org.jetbrains.kotlin.psi.KtLiteralStringTemplateEntry
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
|
||||
class KotlinSpellcheckingStrategy: SpellcheckingStrategy() {
|
||||
class KotlinSpellcheckingStrategy : SpellcheckingStrategy() {
|
||||
private val plainTextTokenizer = TokenizerBase<KtLiteralStringTemplateEntry>(PlainTextSplitter.getInstance())
|
||||
private val emptyTokenizer = SpellcheckingStrategy.EMPTY_TOKENIZER
|
||||
|
||||
override fun getTokenizer(element: PsiElement?): Tokenizer<out PsiElement?> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return when {
|
||||
element is PsiNameIdentifierOwner || element is PsiComment ->
|
||||
super.getTokenizer(element)
|
||||
|
||||
element is KtLiteralStringTemplateEntry -> plainTextTokenizer
|
||||
|
||||
else ->
|
||||
emptyTokenizer
|
||||
return when (element) {
|
||||
is PsiComment -> super.getTokenizer(element)
|
||||
is KtParameter -> {
|
||||
val function = (element.parent as? KtParameterList)?.parent as? KtNamedFunction
|
||||
when {
|
||||
function?.hasModifier(KtTokens.OVERRIDE_KEYWORD) == true -> emptyTokenizer
|
||||
else -> super.getTokenizer(element)
|
||||
}
|
||||
}
|
||||
is PsiNameIdentifierOwner -> {
|
||||
when {
|
||||
element is KtModifierListOwner && element.hasModifier(KtTokens.OVERRIDE_KEYWORD) -> emptyTokenizer
|
||||
else -> super.getTokenizer(element)
|
||||
}
|
||||
}
|
||||
is KtLiteralStringTemplateEntry -> plainTextTokenizer
|
||||
else -> emptyTokenizer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<info descr="null">abstract</info> class Base {
|
||||
<info descr="null">abstract</info> fun foo(<TYPO descr="Typo: In word 'oher'">oher</TYPO>: Int)
|
||||
|
||||
<info descr="null">abstract</info> val <TYPO descr="Typo: In word 'smal'">smal</TYPO>Val: Int
|
||||
<info descr="null">abstract</info> fun <TYPO descr="Typo: In word 'smal'">smal</TYPO>Fun()
|
||||
}
|
||||
|
||||
class Other : Base() {
|
||||
<info descr="null">override</info> fun foo(oher: Int) {
|
||||
}
|
||||
|
||||
<info descr="null">override</info> val smalVal: Int <info descr="null">get</info>() = 1
|
||||
<info descr="null">override</info> fun smalFun() {}
|
||||
}
|
||||
|
||||
@@ -960,6 +960,12 @@ public class PsiCheckerTestGenerated extends AbstractPsiCheckerTest {
|
||||
doTestWithInfos(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TyposInOverrideParams.kt")
|
||||
public void testTyposInOverrideParams() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/infos/TyposInOverrideParams.kt");
|
||||
doTestWithInfos(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("WrapIntoRef.kt")
|
||||
public void testWrapIntoRef() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/infos/WrapIntoRef.kt");
|
||||
|
||||
Reference in New Issue
Block a user