Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies {
compile 'org.antlr:antlr4-runtime:4.5.1'
compile 'org.antlr:antlr4-jetbrains-adapter:1.0.0'
antlr 'org.antlr:antlr4:4.5'
compile 'io.protostuff:protostuff-parser:2.0.0-alpha10'
compile 'io.protostuff:protostuff-parser:2.0.0-alpha12'
}

apply plugin: 'idea'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class ProtoParserDefinition implements ParserDefinition {
public static final IElementType R_TYPE_REFERENCE;
public static final IElementType R_NAME;
public static final IElementType R_FIELD_MODIFIER;
public static final IElementType R_TO;
private static final IFileElementType FILE;
private static final TokenSet COMMENTS;
private static final TokenSet WHITESPACE;
Expand Down Expand Up @@ -71,11 +70,13 @@ public class ProtoParserDefinition implements ParserDefinition {
ProtoLexer.ONEOF,
ProtoLexer.EXTEND,
ProtoLexer.EXTENSIONS,
ProtoLexer.RESERVED,
ProtoLexer.TO,
ProtoLexer.MAX,
ProtoLexer.ENUM,
ProtoLexer.SERVICE,
ProtoLexer.RPC,
ProtoLexer.STREAM,
ProtoLexer.RETURNS,
ProtoLexer.MAP,
ProtoLexer.BOOLEAN_VALUE,
Expand All @@ -101,7 +102,6 @@ public class ProtoParserDefinition implements ParserDefinition {
R_TYPE_REFERENCE = ruleTypes.get(ProtoParser.RULE_typeReference);
R_NAME = ruleTypes.get(ProtoParser.RULE_name);
R_FIELD_MODIFIER = ruleTypes.get(ProtoParser.RULE_fieldModifier);
R_TO = ruleTypes.get(ProtoParser.RULE_to);
}

@NotNull
Expand Down Expand Up @@ -198,6 +198,12 @@ public PsiElement createElement(ASTNode node) {
return new MapKeyNode(node);
case ProtoParser.RULE_optionValue:
return new OptionValueNode(node);
case ProtoParser.RULE_range:
return new RangeNode(node);
case ProtoParser.RULE_reserved:
return new ReservedFieldsNode(node);
case ProtoParser.RULE_rpcType:
return new RpcMethodTypeNode(node);
default:
return new ANTLRPsiNode(node);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
package io.protostuff.jetbrains.plugin.psi;

import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import io.protostuff.jetbrains.plugin.ProtoParserDefinition;
import org.antlr.jetbrains.adapter.psi.ANTLRPsiNode;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
* @author Kostiantyn Shchepanovskyi
*/
Expand All @@ -19,16 +13,4 @@ public ExtensionsNode(@NotNull ASTNode node) {
super(node);
}

@Override
public Collection<PsiElement> keywords() {
ASTNode node = getNode();
ASTNode toPart = node.findChildByType(ProtoParserDefinition.R_TO);
if (toPart != null) {
List<PsiElement> result = new ArrayList<>();
result.addAll(Util.findKeywords(toPart));
result.addAll(Util.findKeywords(node));
return result;
}
return Util.findKeywords(node);
}
}
16 changes: 16 additions & 0 deletions src/main/java/io/protostuff/jetbrains/plugin/psi/RangeNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.protostuff.jetbrains.plugin.psi;

import com.intellij.lang.ASTNode;
import org.antlr.jetbrains.adapter.psi.ANTLRPsiNode;
import org.jetbrains.annotations.NotNull;

/**
* @author Kostiantyn Shchepanovskyi
*/
public class RangeNode extends ANTLRPsiNode implements KeywordsContainer {

public RangeNode(@NotNull ASTNode node) {
super(node);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.protostuff.jetbrains.plugin.psi;

import com.intellij.lang.ASTNode;
import org.antlr.jetbrains.adapter.psi.ANTLRPsiNode;
import org.jetbrains.annotations.NotNull;

/**
* @author Kostiantyn Shchepanovskyi
*/
public class ReservedFieldsNode extends ANTLRPsiNode implements KeywordsContainer {

public ReservedFieldsNode(@NotNull ASTNode node) {
super(node);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.protostuff.jetbrains.plugin.psi;

import com.intellij.lang.ASTNode;
import org.antlr.jetbrains.adapter.psi.ANTLRPsiNode;
import org.jetbrains.annotations.NotNull;

/**
* @author Kostiantyn Shchepanovskyi
*/
public class RpcMethodTypeNode extends ANTLRPsiNode implements KeywordsContainer {

public RpcMethodTypeNode(@NotNull ASTNode node) {
super(node);
}

}