Do not spell check overridden declaration names (KT-15000)
#KT-15000 Fixed
This commit is contained in:
@@ -512,7 +512,7 @@
|
|||||||
language="kotlin"
|
language="kotlin"
|
||||||
implementationClass="org.jetbrains.kotlin.idea.refactoring.rename.KotlinResolveSnapshotProvider"/>
|
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$Generic"/>
|
||||||
<liveTemplateContext implementation="org.jetbrains.kotlin.idea.liveTemplates.KotlinTemplateContextType$TopLevel"/>
|
<liveTemplateContext implementation="org.jetbrains.kotlin.idea.liveTemplates.KotlinTemplateContextType$TopLevel"/>
|
||||||
|
|||||||
+21
-14
@@ -14,33 +14,40 @@
|
|||||||
* limitations under the License.
|
* 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.PsiComment
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiNameIdentifierOwner
|
import com.intellij.psi.PsiNameIdentifierOwner
|
||||||
import com.intellij.spellchecker.inspections.PlainTextSplitter
|
import com.intellij.spellchecker.inspections.PlainTextSplitter
|
||||||
import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy
|
import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy
|
||||||
import com.intellij.spellchecker.tokenizer.SuppressibleSpellcheckingStrategy
|
|
||||||
import com.intellij.spellchecker.tokenizer.Tokenizer
|
import com.intellij.spellchecker.tokenizer.Tokenizer
|
||||||
import com.intellij.spellchecker.tokenizer.TokenizerBase
|
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 plainTextTokenizer = TokenizerBase<KtLiteralStringTemplateEntry>(PlainTextSplitter.getInstance())
|
||||||
private val emptyTokenizer = SpellcheckingStrategy.EMPTY_TOKENIZER
|
private val emptyTokenizer = SpellcheckingStrategy.EMPTY_TOKENIZER
|
||||||
|
|
||||||
override fun getTokenizer(element: PsiElement?): Tokenizer<out PsiElement?> {
|
override fun getTokenizer(element: PsiElement?): Tokenizer<out PsiElement?> {
|
||||||
@Suppress("UNCHECKED_CAST")
|
return when (element) {
|
||||||
return when {
|
is PsiComment -> super.getTokenizer(element)
|
||||||
element is PsiNameIdentifierOwner || element is PsiComment ->
|
is KtParameter -> {
|
||||||
super.getTokenizer(element)
|
val function = (element.parent as? KtParameterList)?.parent as? KtNamedFunction
|
||||||
|
when {
|
||||||
element is KtLiteralStringTemplateEntry -> plainTextTokenizer
|
function?.hasModifier(KtTokens.OVERRIDE_KEYWORD) == true -> emptyTokenizer
|
||||||
|
else -> super.getTokenizer(element)
|
||||||
else ->
|
}
|
||||||
emptyTokenizer
|
}
|
||||||
|
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);
|
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")
|
@TestMetadata("WrapIntoRef.kt")
|
||||||
public void testWrapIntoRef() throws Exception {
|
public void testWrapIntoRef() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/infos/WrapIntoRef.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/infos/WrapIntoRef.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user