Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ProcessAxis()

Query MS.Internal.Xml.XPath.QueryBuilder.ProcessAxis ( Axis root,
Flags flags,
out Props props )
inlineprivate

Definition at line 46 of file QueryBuilder.cs.

47 {
48 Query query = null;
49 if (root.Prefix.Length > 0)
50 {
51 _needContext = true;
52 }
53 _firstInput = null;
55 if (root.Input != null)
56 {
57 Flags flags2 = Flags.None;
58 if ((flags & Flags.PosFilter) == 0)
59 {
60 if (root.Input is Axis axis && root.TypeOfAxis == Axis.AxisType.Child && axis.TypeOfAxis == Axis.AxisType.DescendantOrSelf && axis.NodeType == XPathNodeType.All)
61 {
63 if (axis.Input != null)
64 {
65 qyParent = ProcessNode(axis.Input, Flags.SmartDesc, out props);
66 }
67 else
68 {
69 qyParent = new ContextQuery();
70 props = Props.None;
71 }
72 query = new DescendantQuery(qyParent, root.Name, root.Prefix, root.NodeType, matchSelf: false, axis.AbbrAxis);
73 if ((props & Props.NonFlat) != 0)
74 {
75 query = new DocumentOrderQuery(query);
76 }
77 props |= Props.NonFlat;
78 return query;
79 }
80 if (root.TypeOfAxis == Axis.AxisType.Descendant || root.TypeOfAxis == Axis.AxisType.DescendantOrSelf)
81 {
82 flags2 |= Flags.SmartDesc;
83 }
84 }
85 query2 = ProcessNode(root.Input, flags2, out props);
86 }
87 else
88 {
89 query2 = new ContextQuery();
90 props = Props.None;
91 }
92 switch (root.TypeOfAxis)
93 {
94 case Axis.AxisType.Ancestor:
95 query = new XPathAncestorQuery(query2, root.Name, root.Prefix, root.NodeType, matchSelf: false);
96 props |= Props.NonFlat;
97 break;
98 case Axis.AxisType.AncestorOrSelf:
99 query = new XPathAncestorQuery(query2, root.Name, root.Prefix, root.NodeType, matchSelf: true);
100 props |= Props.NonFlat;
101 break;
102 case Axis.AxisType.Child:
103 query = (((props & Props.NonFlat) == 0) ? new ChildrenQuery(query2, root.Name, root.Prefix, root.NodeType) : new CacheChildrenQuery(query2, root.Name, root.Prefix, root.NodeType));
104 break;
105 case Axis.AxisType.Parent:
106 query = new ParentQuery(query2, root.Name, root.Prefix, root.NodeType);
107 break;
108 case Axis.AxisType.Descendant:
109 if ((flags & Flags.SmartDesc) != 0)
110 {
111 query = new DescendantOverDescendantQuery(query2, matchSelf: false, root.Name, root.Prefix, root.NodeType, abbrAxis: false);
112 }
113 else
114 {
115 query = new DescendantQuery(query2, root.Name, root.Prefix, root.NodeType, matchSelf: false, abbrAxis: false);
116 if ((props & Props.NonFlat) != 0)
117 {
118 query = new DocumentOrderQuery(query);
119 }
120 }
121 props |= Props.NonFlat;
122 break;
123 case Axis.AxisType.DescendantOrSelf:
124 if ((flags & Flags.SmartDesc) != 0)
125 {
126 query = new DescendantOverDescendantQuery(query2, matchSelf: true, root.Name, root.Prefix, root.NodeType, root.AbbrAxis);
127 }
128 else
129 {
130 query = new DescendantQuery(query2, root.Name, root.Prefix, root.NodeType, matchSelf: true, root.AbbrAxis);
131 if ((props & Props.NonFlat) != 0)
132 {
133 query = new DocumentOrderQuery(query);
134 }
135 }
136 props |= Props.NonFlat;
137 break;
138 case Axis.AxisType.Preceding:
139 query = new PrecedingQuery(query2, root.Name, root.Prefix, root.NodeType);
140 props |= Props.NonFlat;
141 break;
142 case Axis.AxisType.Following:
143 query = new FollowingQuery(query2, root.Name, root.Prefix, root.NodeType);
144 props |= Props.NonFlat;
145 break;
146 case Axis.AxisType.FollowingSibling:
147 query = new FollSiblingQuery(query2, root.Name, root.Prefix, root.NodeType);
148 if ((props & Props.NonFlat) != 0)
149 {
150 query = new DocumentOrderQuery(query);
151 }
152 break;
153 case Axis.AxisType.PrecedingSibling:
154 query = new PreSiblingQuery(query2, root.Name, root.Prefix, root.NodeType);
155 break;
156 case Axis.AxisType.Attribute:
157 query = new AttributeQuery(query2, root.Name, root.Prefix, root.NodeType);
158 break;
159 case Axis.AxisType.Self:
160 query = new XPathSelfQuery(query2, root.Name, root.Prefix, root.NodeType);
161 break;
162 case Axis.AxisType.Namespace:
163 query = (((root.NodeType != XPathNodeType.All && root.NodeType != XPathNodeType.Element && root.NodeType != XPathNodeType.Attribute) || root.Prefix.Length != 0) ? ((Query)new EmptyQuery()) : ((Query)new NamespaceQuery(query2, root.Name, root.Prefix, root.NodeType)));
164 break;
165 default:
167 }
168 return query;
169 }
Query ProcessNode(AstNode root, Flags flags, out Props props)
static string Xp_NotSupported
Definition SR.cs:1246
Definition SR.cs:7
static XPathException Create(string res)

References MS.Internal.Xml.XPath.QueryBuilder._firstInput, MS.Internal.Xml.XPath.QueryBuilder._needContext, MS.Internal.Xml.XPath.QueryBuilder._query, MS.Internal.Xml.XPath.Axis.AbbrAxis, System.Xml.XPath.XPathException.Create(), MS.Internal.Xml.XPath.Axis.Input, MS.Internal.Xml.XPath.Axis.Name, MS.Internal.Xml.XPath.Axis.NodeType, MS.Internal.Xml.XPath.Axis.Prefix, MS.Internal.Xml.XPath.QueryBuilder.ProcessNode(), System.Query, MS.Internal.Xml.XPath.Axis.TypeOfAxis, and System.SR.Xp_NotSupported.

Referenced by MS.Internal.Xml.XPath.QueryBuilder.ProcessNode().