public void Visit(PickStatement statement) { VerifyCssSelector(statement.Selector, new Semantic.LineInfo(statement.Line.Line, statement.Line.CharacterPosition)); _codeStack.Peek() .ParentStatements.Add(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression("result"), "AddColumn", new CodePrimitiveExpression(statement.Selector))); var expression = new CodeMethodInvokeExpression( new CodeTypeReferenceExpression("node"), "Pick", new CodePrimitiveExpression(statement.Selector) ); var takeDomArg = VisitChild(statement.TakeStatement); var takeExpression = takeDomArg.CodeExpression as CodeMethodInvokeExpression; takeExpression.Method.TargetObject = expression; if (statement.Match != null && statement.Match.Replace != null) { takeExpression = new CodeMethodInvokeExpression(takeExpression, "MatchReplace", new CodePrimitiveExpression(statement.Match.Value), new CodePrimitiveExpression(statement.Match.Replace.Value)); } else if (statement.Match != null) { takeExpression = new CodeMethodInvokeExpression(takeExpression, "Match", new CodePrimitiveExpression(statement.Match.Value)); } _codeStack.Peek().Tag = true; _codeStack.Peek().CodeExpression = takeExpression; _codeStack.Peek().Scope = new ScopeData<Type> { Type = typeof(string), CodeDomReference = new CodeTypeReference(typeof(string)) }; }
public void Visit(PickStatement statement, CommonTree tree) { Parent(tree).Children.Add(statement); SetLine(statement, tree); VisitChildren(tree); }