public Ust VisitClassDeclaration(JavaParser.ClassDeclarationContext context) { var typeTypeToken = new TypeTypeLiteral(TypeType.Class, context.GetChild <ITerminalNode>(0).Symbol.GetTextSpan()); var id = (IdToken)Visit(context.IDENTIFIER()); EntityDeclaration[] typeMembers = context.classBody().classBodyDeclaration() .Select(dec => Visit(dec) as EntityDeclaration) .Where(dec => dec != null).ToArray(); var baseTypes = new List <TypeToken>(); if (context.typeType() != null) { baseTypes.Add((TypeToken)Visit(context.typeType())); } if (context.typeList() != null) { baseTypes.AddRange(context.typeList().typeType().Select(t => (TypeToken)Visit(t))); } var result = new TypeDeclaration(typeTypeToken, id, baseTypes, typeMembers, context.GetTextSpan()); return(result); }