@Override
@RuleDependencies({
@RuleDependency(recognizer=GoParser.class, rule=GoParser.RULE_methodDecl, version=0),
@RuleDependency(recognizer=GoParser.class, rule=GoParser.RULE_methodName, version=0),
@RuleDependency(recognizer=GoParser.class, rule=GoParser.RULE_receiver, version=0),
@RuleDependency(recognizer=GoParser.class, rule=GoParser.RULE_baseTypeName, version=0),
})
public void enterMethodDecl(MethodDeclContext ctx) {
Interval sourceInterval = ParseTrees.getSourceInterval(ctx);
String name = ctx.methodName() != null && ctx.methodName().IDENTIFIER() != null ? ctx.methodName().IDENTIFIER().getSymbol().getText() : "?";
String signature = HtmlSignatureVisitor.COLORED.visit(ctx);
GoNode.DeclarationDescription description = new GoNode.DeclarationDescription(name, DeclarationKind.METHOD);
description.setOffset(snapshot, getCurrentParent().getFileObject(), sourceInterval.a);
description.setHtmlHeader(signature);
getCurrentParent().getChildren().add(description);
ReceiverContext receiverContext = ctx.receiver();
BaseTypeNameContext baseTypeNameContext = receiverContext != null ? receiverContext.baseTypeName() : null;
if (baseTypeNameContext != null && baseTypeNameContext.IDENTIFIER() != null) {
String receiverTypeName = baseTypeNameContext.IDENTIFIER().getText();
_methodDescriptions.add(Tuple.create(receiverTypeName, getCurrentParent(), description));
}
descriptionStack.push(description);
}
GoDeclarationsScanner.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:goworks
作者:
评论列表
文章目录