GrammarIndentTask.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:goworks 作者:
@Override
@RuleDependencies({
    @RuleDependency(recognizer=GrammarParser.class, rule=GrammarParser.RULE_modeSpec, version=3, dependents=Dependents.PARENTS),
    @RuleDependency(recognizer=GrammarParser.class, rule=GrammarParser.RULE_ruleSpec, version=3, dependents=Dependents.PARENTS),
})
public Tuple2<? extends ParseTree, Integer> visitModeSpec(ModeSpecContext ctx) {
    // use the preceeding rule (if any), otherwise relative to mode
    for (int i = priorSiblings.size() - 2; i >= 0; i--) {
        ParseTree sibling = priorSiblings.get(i);
        if (!(sibling instanceof RuleNode)) {
            continue;
        }

        RuleContext context = ((RuleNode)sibling).getRuleContext();
        if (context.getRuleIndex() == GrammarParser.RULE_ruleSpec) {
            return Tuple.create(context, 0);
        }
    }

    return Tuple.create(ctx, getCodeStyle().getIndentSize());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号