예제 #1
0
 public override void EnterConstructorDeclaration(JavaParser.ConstructorDeclarationContext context)
 {
     ParseMethodFromContext(
         context.formalParameters(),
         null,
         context.qualifiedNameList(),
         context.IDENTIFIER().GetText(),
         context.GetFullText());
 }
예제 #2
0
        public UstNode VisitConstructorDeclaration(JavaParser.ConstructorDeclarationContext context)
        {
            var id = (IdToken)Visit(context.IDENTIFIER());
            IEnumerable <ParameterDeclaration> parameters;

            JavaParser.FormalParameterListContext formalParameterList = context.formalParameters().formalParameterList();
            if (formalParameterList == null)
            {
                parameters = Enumerable.Empty <ParameterDeclaration>();
            }
            else
            {
                parameters = formalParameterList.formalParameter()
                             .Select(param => (ParameterDeclaration)Visit(param))
                             .Where(p => p != null).ToArray();
            }

            var body = (BlockStatement)Visit(context.constructorBody);

            var constructorDelaration = new ConstructorDeclaration(id, parameters, body, context.GetTextSpan(), FileNode);

            return(constructorDelaration);
        }