Enable basic spell check for Kotlin
#KT-4272 Fixed
This commit is contained in:
@@ -219,6 +219,8 @@
|
||||
id="KotlinFunction"
|
||||
order="first"/>
|
||||
|
||||
<spellchecker.support implementationClass="org.jetbrains.jet.plugin.KotlinSpellcheckingStrategy" language="jet"/>
|
||||
|
||||
<liveTemplateContext implementation="org.jetbrains.jet.plugin.liveTemplates.JetTemplateContextType$Generic"/>
|
||||
<liveTemplateContext implementation="org.jetbrains.jet.plugin.liveTemplates.JetTemplateContextType$Namespace"/>
|
||||
<liveTemplateContext implementation="org.jetbrains.jet.plugin.liveTemplates.JetTemplateContextType$Statement"/>
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin
|
||||
|
||||
import com.intellij.spellchecker.tokenizer.SuppressibleSpellcheckingStrategy
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.spellchecker.tokenizer.Tokenizer
|
||||
import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy
|
||||
import com.intellij.codeInspection.SuppressQuickFix
|
||||
import com.intellij.spellchecker.tokenizer.PsiIdentifierOwnerTokenizer
|
||||
import com.intellij.psi.PsiNameIdentifierOwner
|
||||
import com.intellij.psi.PsiComment
|
||||
|
||||
class KotlinSpellcheckingStrategy: SuppressibleSpellcheckingStrategy() {
|
||||
private val nameIdentifierTokenizer = PsiIdentifierOwnerTokenizer()
|
||||
|
||||
[suppress("UNCHECKED_CAST")]
|
||||
private val emptyTokenizer = SpellcheckingStrategy.EMPTY_TOKENIZER as Tokenizer<out PsiElement?>
|
||||
|
||||
override fun getTokenizer(element: PsiElement?): Tokenizer<out PsiElement?> {
|
||||
[suppress("UNCHECKED_CAST")]
|
||||
return when {
|
||||
element is PsiNameIdentifierOwner || element is PsiComment ->
|
||||
super.getTokenizer(element) as Tokenizer<out PsiElement?>
|
||||
|
||||
else ->
|
||||
emptyTokenizer
|
||||
}
|
||||
}
|
||||
|
||||
public override fun isSuppressedFor(element : PsiElement, name : String) : Boolean = false
|
||||
public override fun getSuppressActions(element : PsiElement, name : String) : Array<SuppressQuickFix> = SuppressQuickFix.EMPTY_ARRAY
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ fun returnFunctionLiteral(<info>a</info>: Any?): Function0<Int> =
|
||||
if (<info>a</info> is Int) { (): Int -> <info descr="Automatically cast to jet.Int"><info>a</info></info> }
|
||||
else { () -> 1 }
|
||||
|
||||
fun mergeAutocasts(a: Any?) {
|
||||
fun merge<TYPO descr="Typo: In word 'Autocasts'">Autocasts</TYPO>(a: Any?) {
|
||||
if (a is String || a is Int) {
|
||||
a.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: compareTo">compareTo</error>("")
|
||||
<info descr="Automatically cast to jet.Any">a</info>.toString()
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package kara.internal
|
||||
|
||||
/* Test <TYPO descr="Typo: In word 'somthing'">somthing</TYPO> */
|
||||
class <TYPO descr="Typo: In word 'Moree'">Moree</TYPO>Fun {
|
||||
fun <TYPO descr="Typo: In word 'wrte'">wrte</TYPO>() {
|
||||
val <TYPO descr="Typo: In word 'childen'">childen</TYPO> = 12
|
||||
val <warning descr="[UNUSED_VARIABLE] Variable 'come' is never used">come</warning> = childen
|
||||
wrte()
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.jet.checkers;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.spellchecker.inspections.SpellCheckingInspection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||
import org.jetbrains.jet.plugin.highlighter.JetPsiChecker;
|
||||
@@ -29,6 +30,7 @@ public abstract class AbstractJetPsiCheckerTest extends LightDaemonAnalyzerTestC
|
||||
|
||||
public void doTestWithInfos(@NotNull String filePath) throws Exception {
|
||||
try {
|
||||
enableInspectionTool(new SpellCheckingInspection());
|
||||
JetPsiChecker.setNamesHighlightingEnabled(false);
|
||||
doTest(filePath, true, true);
|
||||
}
|
||||
|
||||
@@ -442,6 +442,11 @@ public class JetPsiCheckerTestGenerated extends AbstractJetPsiCheckerTest {
|
||||
doTestWithInfos("idea/testData/checker/infos/PropertiesWithBackingFields.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Typos.kt")
|
||||
public void testTypos() throws Exception {
|
||||
doTestWithInfos("idea/testData/checker/infos/Typos.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("WrapIntoRef.kt")
|
||||
public void testWrapIntoRef() throws Exception {
|
||||
doTestWithInfos("idea/testData/checker/infos/WrapIntoRef.kt");
|
||||
|
||||
Reference in New Issue
Block a user