public override object VisitTypeType(TypeTypeContext context) { var obj = ""; obj = ((string)Visit(context.GetChild(0))); return(obj); }
protected virtual bool VisitariableDeclaratorId(VariableDeclaratorIdContext ctx) { var idenifier = ctx.Identifier(); if (ctx.GetText().EndsWith("[]") && idenifier != null) { var idenifierText = idenifier.GetText(); var fieldDeclaration = ctx.Ancestors().OfType <FieldDeclarationContext>().FirstOrDefault(); var localVariableDeclaration = ctx.Ancestors().OfType <LocalVariableDeclarationContext>().FirstOrDefault(); TypeTypeContext typeType = null; if (fieldDeclaration != null) { typeType = fieldDeclaration.typeType(); } else if (localVariableDeclaration != null) { typeType = localVariableDeclaration.typeType(); } if (typeType != null) { _rewriter.InsertAfter(typeType.Stop, "[]"); _rewriter.Replace(ctx.Start, ctx.Stop, idenifierText); } } return(true); }
protected virtual bool VisitTypeType(TypeTypeContext ctx) { var primitiveType = ctx.primitiveType(); if (primitiveType != null) { if (primitiveType.GetText() == "boolean") { _rewriter.Replace(primitiveType.Start, primitiveType.Stop, "bool"); } } return(true); }
public static TypeContainer GetTypeContainer(TypeTypeContext inTypeContext) { var tmpTypeContainer = new TypeContainer(); if (inTypeContext == null) { return(TypeContainer.Void); } if (inTypeContext.primitiveType() != null) { tmpTypeContainer.Name = inTypeContext.primitiveType().GetText(); } else if (inTypeContext.annotation() != null) { throw new NotImplementedException($"Unknown TypeContext: " + inTypeContext.GetText()); } else if (inTypeContext.classOrInterfaceType() != null) { var tmpClassType = inTypeContext.classOrInterfaceType(); tmpTypeContainer.Name = tmpClassType.IDENTIFIER(0).GetText(); if (tmpClassType.IDENTIFIER().Length > 1) { throw new NotImplementedException($"Unknown TypeContext: to many identifier"); } foreach (var tmpArg in tmpClassType.typeArguments()) { foreach (var tmpTypeArg in tmpArg.typeArgument()) { var tmpGenericType = GetTypeContainer(tmpTypeArg.typeType()); if (tmpTypeArg.EXTENDS() != null) { tmpGenericType.Extends.Add(GetTypeContainer(tmpTypeArg.typeType())); } if (tmpTypeArg.SUPER() != null) { throw new NotImplementedException($"TypeArgument SUPER handling"); } tmpTypeContainer.GenericTypes.Add(tmpGenericType); } } if (inTypeContext.children.Last().GetText() == "]") { tmpTypeContainer.IsArray = true; } } return(tmpTypeContainer); }