private static string ColumnName(SqlNode[] segment, int start, int i) { if (i >= (start + 2) && segment[start + 1].TextEquals("=") && segment[start] is SqlLiteral) { var lastNode = segment[start] as SqlLiteral; if (lastNode != null && lastNode.Type == SqlType.Identifier) return lastNode.Text; } else { var lastNode = LastNonCommentNode(segment.Skip(start).Take(i - start)).LastNonCommentNode() as SqlLiteral; if (lastNode != null && lastNode.TextEquals("*")) { var idx = Array.IndexOf(segment, lastNode, start); if (idx > start && segment[idx - 1] is SqlName) { return (segment[idx - 1] as SqlName).FullName + "." + lastNode.Text; } else { return lastNode.Text; } } else if (lastNode != null && lastNode.Type == SqlType.Identifier) { return lastNode.Text; } } return null; }
int ISqlGroupNode.IndexOf(SqlNode node) { var ofType = node as T; if (ofType == null) { return(-1); } return(_nodes.IndexOf(ofType)); }
public static bool TextEquals(this SqlNode node, string value) { var literal = node as SqlLiteral; if (literal != null && string.Equals(literal.Text, value, StringComparison.OrdinalIgnoreCase)) { return(true); } return(false); }
public override bool Equals(SqlNode obj) { var literal = obj as SqlLiteral; if (literal == null) { return(false); } return(base.Equals(obj) && this.Text == literal.Text); }
private static SqlNode LastNonCommentNode(this SqlNode node) { if (node == null) { return(node); } var last = node; var group = node as ISqlGroupNode; while (group != null) { last = group.Items.Where(i => i.Type != SqlType.Comment).Last(); group = last as ISqlGroupNode; } if (last.Type == SqlType.Comment) { return(null); } return(last); }
public override bool Equals(SqlNode obj) { var literal = obj as SqlLiteral; if (literal == null) return false; return base.Equals(obj) && this.Text == literal.Text; }
public virtual bool Equals(SqlNode obj) { return this.StartOffset == obj.StartOffset; }