Skip to content

Commit

Permalink
feat: integrate spellchecker
Browse files Browse the repository at this point in the history
  • Loading branch information
tmkx committed Oct 1, 2024
1 parent aa8a99b commit edd80b3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.intellij.plugins.thrift;

import com.intellij.plugins.thrift.lang.psi.ThriftEnumField;
import com.intellij.psi.PsiElement;
import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy;
import com.intellij.spellchecker.tokenizer.Tokenizer;
import org.jetbrains.annotations.NotNull;

public final class ThriftSpellcheckingStrategy extends SpellcheckingStrategy {
@Override
public @NotNull Tokenizer getTokenizer(PsiElement element) {
PsiElement parent = element.getParent();
if (parent instanceof ThriftEnumField && ((ThriftEnumField) parent).getIdentifier() == element) {
return SpellcheckingStrategy.TEXT_TOKENIZER;
}
return super.getTokenizer(element);
}
}
2 changes: 2 additions & 0 deletions thrift/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
<frameworkSupport implementation="com.intellij.plugins.thrift.config.facet.ThriftFacetSupportProvider"/>
<facetType implementation="com.intellij.plugins.thrift.config.facet.ThriftFacetType"/>
<compileServer.plugin classpath="thrift-jps.jar" />

<spellchecker.support language="thrift" implementationClass="com.intellij.plugins.thrift.ThriftSpellcheckingStrategy"/>
</extensions>

<actions>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.intellij.plugins.thrift.inspections;

import com.intellij.spellchecker.inspections.SpellCheckingInspection;
import org.junit.jupiter.api.Test;

public class SpellcheckingTest extends ThriftInspectionTestBase {
public SpellcheckingTest() {
super("spell", SpellCheckingInspection.class);
}

@Test
public void testUsages1() {
doTest();
}
}
20 changes: 20 additions & 0 deletions thrift/src/test/resources/spell/usages1.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
struct <TYPO>Userr</TYPO> {
1: required string <TYPO>nmae</TYPO>
}

enum <TYPO>Mothed</TYPO>
{
GET = 1,
POST = 2,
<TYPO>UNKOW</TYPO> = 3,
}

exception <TYPO>Xceptoin</TYPO> {
1: i32 <TYPO>erroor</TYPO>Code,
2: string message
}

service Typo<TYPO>Srevice</TYPO> // 7
{
string <TYPO>Naem</TYPO>(1: string <TYPO>tyypo</TYPO>), // <TYPO>commemt</TYPO>
}

0 comments on commit edd80b3

Please sign in to comment.