File tree Expand file tree Collapse file tree 5 files changed +84
-1
lines changed
java/io/protostuff/jetbrains/plugin/spellchecker
java/io/protostuff/jetbrains/plugin/spellchecker Expand file tree Collapse file tree 5 files changed +84
-1
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ dependencies {
3333 exclude group : ' org.slf4j'
3434 }
3535 compile ' com.google.guava:guava:21.0'
36- compile (' io.protostuff:protostuff-parser:2.2.25 ' ) {
36+ compile (' io.protostuff:protostuff-parser:2.2.26 ' ) {
3737 exclude group : ' org.slf4j'
3838 }
3939 compile (' io.sentry:sentry:1.7.5' ) {
Original file line number Diff line number Diff line change 1+ package io .protostuff .jetbrains .plugin .spellchecker ;
2+
3+ import com .intellij .lang .ASTNode ;
4+ import com .intellij .psi .PsiElement ;
5+ import com .intellij .spellchecker .inspections .PlainTextSplitter ;
6+ import com .intellij .spellchecker .tokenizer .SpellcheckingStrategy ;
7+ import com .intellij .spellchecker .tokenizer .TokenConsumer ;
8+ import com .intellij .spellchecker .tokenizer .Tokenizer ;
9+ import io .protostuff .compiler .parser .ProtoLexer ;
10+ import io .protostuff .jetbrains .plugin .ProtoParserDefinition ;
11+ import org .antlr .jetbrains .adapter .lexer .TokenIElementType ;
12+ import org .jetbrains .annotations .NotNull ;
13+
14+ /**
15+ * Spellchecker support.
16+ *
17+ * @author Kostiantyn Shchepanovskyi
18+ */
19+ public class ProtoSpellcheckingStrategy extends SpellcheckingStrategy {
20+
21+ private static final TokenIElementType STRING_VALUE_TOKEN = ProtoParserDefinition .token (ProtoLexer .STRING_VALUE );
22+ private static final Tokenizer <PsiElement > STRING_VALUE_TOKENIZER = new Tokenizer <PsiElement >() {
23+ @ Override
24+ public void tokenize (@ NotNull PsiElement element , TokenConsumer consumer ) {
25+ consumer .consumeToken (element , PlainTextSplitter .getInstance ());
26+ }
27+ };
28+
29+ @ NotNull
30+ @ Override
31+ public Tokenizer getTokenizer (PsiElement element ) {
32+ ASTNode node = element .getNode ();
33+ if (node != null && node .getElementType () == STRING_VALUE_TOKEN ) {
34+ return STRING_VALUE_TOKENIZER ;
35+ }
36+ return super .getTokenizer (element );
37+ }
38+ }
Original file line number Diff line number Diff line change 213213 <stubIndex implementation =" io.protostuff.jetbrains.plugin.psi.indices.DataTypeFullNameIndex" />
214214 <stubIndex implementation =" io.protostuff.jetbrains.plugin.psi.indices.DataTypeNameIndex" />
215215
216+ <spellchecker .support
217+ language =" PROTO"
218+ implementationClass =" io.protostuff.jetbrains.plugin.spellchecker.ProtoSpellcheckingStrategy" />
216219 </extensions >
217220
218221 <actions >
Original file line number Diff line number Diff line change 1+ package io .protostuff .jetbrains .plugin .spellchecker ;
2+
3+ import com .google .common .collect .ImmutableList ;
4+ import com .intellij .spellchecker .inspections .SpellCheckingInspection ;
5+ import io .protostuff .jetbrains .plugin .AbstractProtobufLibraryDependentTestCase ;
6+
7+ /**
8+ * Test for spell checker.
9+ *
10+ * @author Kostiantyn Shchepanovskyi
11+ */
12+ public class SpellcheckerTest extends AbstractProtobufLibraryDependentTestCase {
13+
14+ @ Override
15+ protected String getTestDataPath () {
16+ return "src/test/resources/" ;
17+ }
18+
19+
20+ public void testSpellchecking () {
21+ myFixture .configureByFile ("spellchecker/SpellcheckerTest.proto" );
22+ myFixture .enableInspections (ImmutableList .of (SpellCheckingInspection .class ));
23+ myFixture .checkHighlighting ();
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ syntax = "proto3" ;
2+
3+ import "google/<TYPO descr="Typo: In word 'protobuf'">protobuf</TYPO>/descriptor.proto";
4+
5+ // <TYPO descr="Typo: In word 'badcomment'">badcomment</TYPO>
6+
7+ message <TYPO descr="Typo: In word 'Badmessagename'">Badmessagename</TYPO> {
8+ int32 <TYPO descr="Typo: In word 'badfieldname'">badfieldname</TYPO> = 1 [(note) = "<TYPO descr="Typo: In word 'badstringliteral'">badstringliteral</TYPO>"];
9+ }
10+
11+ enum <TYPO descr="Typo: In word 'Badenumname'">Badenumname</TYPO> {
12+ <TYPO descr="Typo: In word 'BADENUMCONSTANTNAME'">BADENUMCONSTANTNAME</TYPO> = 0;
13+ }
14+
15+ extend google.protobuf.FieldOptions {
16+ string note = 50003 ;
17+ }
You can’t perform that action at this time.
0 commit comments