Skip to content

Commit

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

import com.intellij.plugins.thrift.lang.psi.ThriftEnumField;
import com.intellij.psi.PsiElement;
import com.intellij.psi.impl.source.tree.TreeElement;
import com.intellij.spellchecker.NamedElementTokenizer;
import com.intellij.spellchecker.tokenizer.SpellcheckingStrategy;
import com.intellij.spellchecker.tokenizer.Tokenizer;
import org.jetbrains.annotations.NotNull;

public final class ThriftSpellcheckingStrategy extends SpellcheckingStrategy {
private final NamedElementTokenizer myNamedElementTokenizer = new NamedElementTokenizer();

@Override
public @NotNull Tokenizer getTokenizer(PsiElement element) {
if (element.getParent() instanceof ThriftEnumField && element instanceof TreeElement && ((TreeElement) element).getElementType().toString().equals("Identifier")) {
return myNamedElementTokenizer;
}
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
15 changes: 15 additions & 0 deletions thrift/src/test/resources/spell/useages1.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
struct Userr { // 1
1: required string nmae // 2
}

enum Mothed // 3
{
GET = 1,
POST = 2,
UNKOW = 3, // 4
}

service TypoSrevice // 5
{
string Naem(1: string tyypo), // commemt 6, 7, 8
}

0 comments on commit 1932788

Please sign in to comment.