public override void EnterClassVarList([NotNull] XSharpParser.ClassVarListContext context) { // if (context.DataType != null && currentClass != null) { var fieldType = BuildDataType(context.DataType); // foreach (var varContext in context._Var) { var field = new XCodeMemberField(); field.Name = varContext.Id.GetText(); field.Type = fieldType; field.Attributes = this.classVarModifiers; if (varContext.Initializer != null) { if (varContext.Initializer is XSharpParser.PrimaryExpressionContext) { XSharpParser.PrimaryContext ctx = ((XSharpParser.PrimaryExpressionContext)varContext.Initializer).Expr; if (ctx is XSharpParser.LiteralExpressionContext) { XSharpParser.LiteralExpressionContext lit = (XSharpParser.LiteralExpressionContext)ctx; field.InitExpression = BuildLiteralValue(lit.Literal); } } else { field.InitExpression = BuildSnippetExpression(varContext.Initializer.GetText()); } } FillCodeDomDesignerData(field, varContext.Start.Line, varContext.Start.Column); // FieldList[currentClass].Add(field); } // } }
public override void EnterImpliedvar([NotNull] XSharpParser.ImpliedvarContext context) { try { if (context.Expression is XSharpParser.PrimaryExpressionContext) { XSharpParser.PrimaryExpressionContext primaryEx = (XSharpParser.PrimaryExpressionContext)context.Expression; XSharpParser.PrimaryContext primary = primaryEx.Expr; if (primary is XSharpParser.LiteralExpressionContext) { // LOCAL IMPLIED xxx:= "azertyuiop" XSharpParser.LiteralExpressionContext lit = (XSharpParser.LiteralExpressionContext)primary; XVariable local; String localType = buildLiteralValue(lit.Literal); String localName; localName = context.Id.GetText(); // local = new XVariable(this._currentMethod, localName, Kind.Local, Modifiers.Public, new TextRange(context), new TextInterval(context), localType); local.File = this._file; local.IsArray = false; // if (this._currentMethod != null) { this._currentMethod.Locals.Add(local); } } else if (primary is XSharpParser.NameExpressionContext) { // LOCAL IMPLIED xx:= otherLocalVar XVariable local; XSharpParser.NameExpressionContext expr = (XSharpParser.NameExpressionContext)primary; string name = expr.Name.Id.GetText(); // String localName; localName = context.Id.GetText(); String localType = buildValueName(name); if (localType == XVariable.VarType) { XVariable xVar = findLocal(name); // local = new XVariable(this._currentMethod, localName, Kind.Local, Modifiers.Public, new TextRange(context), xVar.Interval, XVariable.VarType); } else { // local = new XVariable(this._currentMethod, localName, Kind.Local, Modifiers.Public, new TextRange(context), new TextInterval(context), localType); } local.File = this._file; local.IsArray = false; // if (this._currentMethod != null) { this._currentMethod.Locals.Add(local); } } else if (primary is XSharpParser.CtorCallContext) { // LOCAL IMPLIED xxxx:= List<STRING>{ } XVariable local; XSharpParser.CtorCallContext expr = (XSharpParser.CtorCallContext)primary; XCodeTypeReference typeRef = buildDataType(expr.Type); // String localType = typeRef.TypeName; String localName; localName = context.Id.GetText(); // local = new XVariable(this._currentMethod, localName, Kind.Local, Modifiers.Public, new TextRange(context), new TextInterval(context), localType); local.File = this._file; local.IsArray = false; // if (this._currentMethod != null) { this._currentMethod.Locals.Add(local); } } } else if (context.Expression is XSharpParser.MethodCallContext) { // LOCAL IMPLIED xxxxx:= Obj:MethodCall() XSharpParser.MethodCallContext callCtxEx = (XSharpParser.MethodCallContext)context.Expression; XSharpParser.ExpressionContext exprCtx = callCtxEx.Expr; String mtdCall = exprCtx.GetText(); XVariable local; String localName; localName = context.Id.GetText(); // local = new XVariable(this._currentMethod, localName, Kind.Local, Modifiers.Public, new TextRange(context), new TextInterval(exprCtx), XVariable.VarType); local.File = this._file; local.IsArray = false; // if (this._currentMethod != null) { this._currentMethod.Locals.Add(local); } } } catch (Exception ex) { Support.Debug("EnterImpliedvar : Error Walking {0}, at {1}/{2} : " + ex.Message, this.File.Name, context.Start.Line, context.Start.Column); } }