GoDeclarationsScanner.java 文件源码

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

项目:goworks 作者:
@Override
@RuleDependencies({
    @RuleDependency(recognizer=GoParser.class, rule=GoParser.RULE_shortVarDecl, version=1),
    @RuleDependency(recognizer=GoParser.class, rule=GoParser.RULE_identifierList, version=0),
})
public void enterShortVarDecl(ShortVarDeclContext ctx) {
    // no locals in navigator
    if (blockLevel > 0) {
        return;
    }

    IdentifierListContext idListContext = ctx.identifierList();
    List<? extends TerminalNode> identifiers = idListContext.IDENTIFIER();
    for (TerminalNode identifier : identifiers) {
        Interval sourceInterval = new Interval(identifier.getSymbol().getStartIndex(), ParseTrees.getStopSymbol(ctx).getStopIndex());
        String name = identifier.getSymbol().getText();
        String signature = name;

        GoNode.DeclarationDescription description = new GoNode.DeclarationDescription(name, DeclarationKind.VARIABLE);
        description.setOffset(snapshot, getCurrentParent().getFileObject(), sourceInterval.a);
        description.setHtmlHeader(String.format("%s", Description.htmlEscape(signature)));
        getCurrentParent().getChildren().add(description);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号