DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Static Public Member Functions | List of all members
Deveel.Data.Sql.Parser.SqlNodeExtensions Class Reference

Extension methods to ISqlNode for diagnostics and other purposes. More...

Static Public Member Functions

static TNode FindNode< TNode > (this ISqlNode node)
 
static ISqlNode FindNode (this ISqlNode node, Type nodeType)
 
static TNode FindNodeOf< TNode > (this ISqlNode node, string nodeName)
 
static ISqlNode FindByName (this ISqlNode node, string nodeName)
 
static bool HasOptionalNode (this ISqlNode node, string nodeName)
 
static IEnumerable< TNode > FindNodes< TNode > (this ISqlNode node)
 
static IEnumerable FindNodes (this ISqlNode node, Type nodeType)
 
static int StartColumn (this ISqlNode node)
 
static int EndColumn (this ISqlNode node)
 
static int StartLine (this ISqlNode node)
 
static int EndLine (this ISqlNode node)
 

Detailed Description

Extension methods to ISqlNode for diagnostics and other purposes.

Definition at line 27 of file SqlNodeExtensions.cs.

Member Function Documentation

static int Deveel.Data.Sql.Parser.SqlNodeExtensions.EndColumn ( this ISqlNode  node)
inlinestatic

Definition at line 105 of file SqlNodeExtensions.cs.

105  {
106  if (node == null || node.Tokens == null)
107  return 0;
108 
109  var token = node.Tokens.LastOrDefault();
110  return token == null ? 0 : token.Column;
111  }
static int Deveel.Data.Sql.Parser.SqlNodeExtensions.EndLine ( this ISqlNode  node)
inlinestatic

Definition at line 121 of file SqlNodeExtensions.cs.

121  {
122  if (node == null || node.Tokens == null)
123  return 0;
124 
125  var token = node.Tokens.LastOrDefault();
126  return token == null ? 0 : token.Line;
127  }
static ISqlNode Deveel.Data.Sql.Parser.SqlNodeExtensions.FindByName ( this ISqlNode  node,
string  nodeName 
)
inlinestatic

Definition at line 57 of file SqlNodeExtensions.cs.

57  {
58  foreach (var childNode in node.ChildNodes) {
59  if (childNode.NodeName.Equals(nodeName))
60  return childNode;
61 
62  var foundNode = childNode.FindByName(nodeName);
63  if (foundNode != null)
64  return foundNode;
65  }
66 
67  return null;
68  }
static ISqlNode Deveel.Data.Sql.Parser.SqlNodeExtensions.FindNode ( this ISqlNode  node,
Type  nodeType 
)
inlinestatic

Definition at line 36 of file SqlNodeExtensions.cs.

36  {
37  foreach (var childNode in node.ChildNodes) {
38  if (nodeType.IsInstanceOfType(childNode))
39  return childNode;
40 
41  var foundNode = childNode.FindNode(nodeType);
42  if (foundNode != null)
43  return foundNode;
44  }
45 
46  return null;
47  }
static TNode Deveel.Data.Sql.Parser.SqlNodeExtensions.FindNode< TNode > ( this ISqlNode  node)
inlinestatic
Type Constraints
TNode :class 
TNode :ISqlNode 

Definition at line 28 of file SqlNodeExtensions.cs.

28  : class, ISqlNode {
29  var foundNode = node.FindNode(typeof(TNode));
30  if (foundNode == null)
31  return null;
32 
33  return (TNode)foundNode;
34  }
static TNode Deveel.Data.Sql.Parser.SqlNodeExtensions.FindNodeOf< TNode > ( this ISqlNode  node,
string  nodeName 
)
inlinestatic
Type Constraints
TNode :class 
TNode :ISqlNode 

Definition at line 49 of file SqlNodeExtensions.cs.

49  : class, ISqlNode {
50  var parent = node.FindByName(nodeName);
51  if (parent == null)
52  return null;
53 
54  return parent.FindNode<TNode>();
55  }
static IEnumerable Deveel.Data.Sql.Parser.SqlNodeExtensions.FindNodes ( this ISqlNode  node,
Type  nodeType 
)
inlinestatic

Definition at line 83 of file SqlNodeExtensions.cs.

83  {
84  var nodes = new List<ISqlNode>();
85 
86  foreach (var childNode in node.ChildNodes) {
87  if (nodeType.IsInstanceOfType(childNode)) {
88  nodes.Add(childNode);
89  }
90 
91  nodes.AddRange(childNode.FindNodes(nodeType).Cast<ISqlNode>());
92  }
93 
94  return nodes.ToArray();
95  }
static IEnumerable<TNode> Deveel.Data.Sql.Parser.SqlNodeExtensions.FindNodes< TNode > ( this ISqlNode  node)
inlinestatic
Type Constraints
TNode :class 
TNode :ISqlNode 

Definition at line 78 of file SqlNodeExtensions.cs.

78  : class, ISqlNode {
79  var foundNodes = node.FindNodes(typeof(TNode));
80  return foundNodes.Cast<TNode>();
81  }
static bool Deveel.Data.Sql.Parser.SqlNodeExtensions.HasOptionalNode ( this ISqlNode  node,
string  nodeName 
)
inlinestatic

Definition at line 70 of file SqlNodeExtensions.cs.

70  {
71  var foundNode = node.FindByName(nodeName);
72  if (foundNode == null)
73  return false;
74 
75  return foundNode.ChildNodes.Any();
76  }
static int Deveel.Data.Sql.Parser.SqlNodeExtensions.StartColumn ( this ISqlNode  node)
inlinestatic

Definition at line 97 of file SqlNodeExtensions.cs.

97  {
98  if (node == null || node.Tokens == null)
99  return 0;
100 
101  var token = node.Tokens.FirstOrDefault();
102  return token == null ? 0 : token.Column;
103  }
static int Deveel.Data.Sql.Parser.SqlNodeExtensions.StartLine ( this ISqlNode  node)
inlinestatic

Definition at line 113 of file SqlNodeExtensions.cs.

113  {
114  if (node == null || node.Tokens == null)
115  return 0;
116 
117  var token = node.Tokens.FirstOrDefault();
118  return token == null ? 0 : token.Line;
119  }

The documentation for this class was generated from the following file: