-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXPathBuilder.cpp
420 lines (318 loc) · 25.9 KB
/
XPathBuilder.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
// SPDX-License-Identifier: GPL-3.0-only
/**
* @file XPathBuilder.cpp
*
* @copyright Copyright (C) 2021-2024 srcML, LLC. (www.srcML.org)
*
* This file is part of the Stereocode application.
*/
#include "XPathBuilder.hpp"
extern bool STRUCT;
extern bool INTERFACE;
extern bool UNION;
extern bool ENUM;
void XPathBuilder::generateXpath() {
//// C++ ////
// Unions can't inherit, but can be declared anonymous (union without a name)
// Anonymous can only be declared inside a class or struct and can't have methods,
// and their data members can be accessed directly without a dot or arrow by the parent class or struct
// Therefore, data members that are defined inside anonymous unions are considered
// and the anonymous union itself is not considered
// Classes can be declared without a name, but you need an instance to use their data members
// Therefore, these are treated as normal classes
std::string language = "C++";
std::string xpath = "//src:*[(self::src:class";
if (STRUCT) xpath += " or self::src:struct";
if (UNION) xpath += " or self::src:union[src:name]";
xpath += ") and not(ancestor::src:class or ancestor::src:struct or ancestor::src:union)]";
xpathTable[language]["class"] = xpath;
xpath = "/src:unit/src:*[self::src:class or self::src:struct or self::src:union]/src:name";
xpathTable[language]["class_name"] = xpath;
xpath = "/src:unit/src:*[self::src:class or self::src:struct or self::src:union]/text()[1]";
xpathTable[language]["class_type"] = xpath;
xpath = "/src:unit/src:*[self::src:class or self::src:struct]/src:super_list/src:super";
xpathTable[language]["parent_name"] = xpath;
xpath = "//src:decl_stmt[not(ancestor::src:function) and count(ancestor::src:class | ancestor::src:struct | ancestor::src:union[src:name]) = 1]";
xpath += "/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpathTable[language]["attribute_name"] = xpath;
xpath = "//src:decl_stmt[not(ancestor::src:function) and count(ancestor::src:class | ancestor::src:struct | ancestor::src:union[src:name]) = 1]";
xpath += "/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpathTable[language]["attribute_type"] = xpath;
xpath = "//src:decl_stmt[not(ancestor::src:function) and count(ancestor::src:class | ancestor::src:struct | ancestor::src:union[src:name]) = 1";
xpath += " and (ancestor::src:class and (ancestor::src:public or ancestor::src:protected))";
xpath += " or (ancestor::src:struct and not(ancestor::src:private))]/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpathTable[language]["non_private_attribute_name"] = xpath;
xpath = "//src:decl_stmt[not(ancestor::src:function) and count(ancestor::src:class | ancestor::src:struct | ancestor::src:union[src:name]) = 1";
xpath += " and (ancestor::src:class and (ancestor::src:public or ancestor::src:protected))";
xpath += " or (ancestor::src:struct and not(ancestor::src:private))]/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpathTable[language]["non_private_attribute_type"] = xpath;
xpath = "//*[(self::src:function or self::src:constructor or self::src:destructor)";
xpath += " and not(src:type/src:specifier='static') and count(ancestor::src:class | ancestor::src:struct | ancestor::src:union) = 1";
// This is needed to make sure that methods defined in a class where the class
// is inside a free function are stereotyped correctly (C++ case)
// and not treated as a nested function
xpath += " and not(ancestor::src:function[not(descendant::src:class | descendant::src:struct | descendant::src:union)])]";
xpathTable[language]["method"] = xpath;
xpath = "//*[self::src:function and (not(ancestor::src:class or ancestor::src:struct or ancestor::src:union) or src:type/src:specifier='static')]";
xpathTable[language]["free_function"] = xpath;
xpath = "/src:unit/src:function/src:name";
xpathTable[language]["method_name"] = xpath;
xpath = "/src:unit/*[self::src:constructor or self::src:destructor]/src:name";
xpathTable[language]["constructor_destructor_name"] = xpath;
xpath = "/src:unit/*[self::src:constructor or self::src:destructor]";
xpathTable[language]["constructor_or_destructor"] = xpath;
xpath = "/src:unit/*[self::src:constructor or self::src:destructor]/src:parameter_list";
xpathTable[language]["constructor_destructor_parameter_list"] = xpath;
xpath = "/src:unit/src:function/src:parameter_list";
xpathTable[language]["method_parameter_list"] = xpath;
// This skips the generics parameters in Java return types
xpath = "/src:unit/src:function/src:type//text()[not(ancestor::src:parameter_list)]";
xpathTable[language]["method_return_type"] = xpath;
xpath = "//src:decl_stmt/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpath += " | //src:control/src:init/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpathTable[language]["local_variable_name"] = xpath;
xpath = "//src:decl_stmt/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpath += " | //src:control/src:init/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpathTable[language]["local_variable_type"] = xpath;
xpath = "/src:unit/src:function/src:parameter_list/src:parameter/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpathTable[language]["parameter_name"] = xpath;
xpath = "/src:unit/src:function/src:parameter_list/src:parameter/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpathTable[language]["parameter_type"] = xpath;
xpath = "//src:return/src:expr";
xpathTable[language]["return_expression"] = xpath;
// Constructor calls are a type of function calls
xpath = "//src:call[not(src:name/src:operator='->') and not(src:name/src:operator='.') and not(preceding-sibling::*[1][self::src:operator='new'])]/src:name[following-sibling::*[1][self::src:argument_list]]";
xpathTable[language]["function_call_name"] = xpath;
xpath = "//src:call[(src:name/src:operator='->' or src:name/src:operator='.') and not(preceding-sibling::*[1][self::src:operator='new'])]/src:name[following-sibling::*[1][self::src:argument_list]]";
xpathTable[language]["method_call_name"] = xpath;
xpath = "//src:call[preceding-sibling::*[1][self::src:operator='new']]/src:name[following-sibling::*[1][self::src:argument_list]]";
xpathTable[language]["constructor_call_name"] = xpath;
xpath = "//src:call[not(src:name/src:operator='->') and not(src:name/src:operator='.') and not(preceding-sibling::*[1][self::src:operator='new'])]/src:argument_list[preceding-sibling::*[1][self::src:name]]";
xpathTable[language]["function_call_arglist"] = xpath;
xpath = "//src:call[(src:name/src:operator='->' or src:name/src:operator='.') and not(preceding-sibling::*[1][self::src:operator='new'])]/src:argument_list[preceding-sibling::*[1][self::src:name]]";
xpathTable[language]["method_call_arglist"] = xpath;
xpath = "//src:call[preceding-sibling::*[1][self::src:operator='new']]/src:argument_list[preceding-sibling::*[1][self::src:name]]";
xpathTable[language]["constructor_call_arglist"] = xpath;
xpath = "//src:decl_stmt/src:decl[./src:init/src:expr/src:operator[.='new']]/src:name";
xpath += " | //src:expr_stmt[count(ancestor::src:function) = 1]/src:expr[./src:operator[.='new']]/src:name";
xpathTable[language]["new_operator_assign"] = xpath;
xpath = "/src:unit/src:function/src:specifier[.='const']";
xpathTable[language]["const"] = xpath;
xpath = "//src:block_content[1][*[not(self::src:comment)][1]]";
xpathTable[language]["empty"] = xpath;
xpath = "//src:expr/src:name";
xpathTable[language]["expression_name"] = xpath;
xpath = "//src:expr/src:name[";
xpath += "following-sibling::*[1][self::src:operator='=' or self::src:operator='+='";
xpath += " or self::src:operator='-=' or self::src:operator='*=' or self::src:operator='/='";
xpath += " or self::src:operator='%=' or self::src:operator='>>=' or self::src:operator='<<='";
xpath += " or self::src:operator='&=' or self::src:operator='^=' or self::src:operator='|='";
xpath += " or self::src:operator='\\?\\?=' or self::src:operator='>>>=' or self::src:operator='++'";
xpath += " or self::src:operator='--'] or preceding-sibling::*[1][self::src:operator='++' or self::src:operator='--']]";
xpathTable[language]["expression_assignment"] = xpath;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// C# ////
// C# allows static classes to be declared, and these must contain only static members
// They are ignored and their methods are collected as free functions
// Nested classes, struct, or interfaces are ignored
language = "C#";
xpath = "//src:*[(self::src:class";
if (STRUCT) xpath += " or self::src:struct";
if (INTERFACE) xpath += " or self::src:interface";
xpath += ") and not(src:specifier='static') and not(ancestor::src:class or ancestor::src:struct or ancestor::src:interface)]";
xpathTable[language]["class"] = xpath;
xpath = "/src:unit/src:*[self::src:class or self::src:struct or self::src:interface]/src:name";
xpathTable[language]["class_name"] = xpath;
xpath = "/src:unit/src:*[self::src:class or self::src:struct or self::src:interface]/text()[1]";
xpathTable[language]["class_type"] = xpath;
xpath = "/src:unit/src:*[self::src:class or self::src:struct or self::src:interface]/src:super_list/src:super/src:name";
xpathTable[language]["parent_name"] = xpath;
// Auto-properties can be used to declare data members implicitly
// And normal properties get or set data members (not always)
// Therefore, properties will be treated as data members as they can be used and called as normal data members
// where property name = data member name and where property type = data member type
xpath = "//src:decl_stmt[not(ancestor::src:function) and count(ancestor::src:class | ancestor::src:struct | ancestor::src:interface) = 1]";
xpath += "/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpath += " | //src:property[count(ancestor::src:class | ancestor::src:struct | ancestor::src:interface) = 1]/src:name";
xpathTable[language]["attribute_name"] = xpath;
xpath = "//src:decl_stmt[not(ancestor::src:function) and count(ancestor::src:class | ancestor::src:struct | ancestor::src:interface) = 1]";
xpath += "/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpath += " | //src:property[count(ancestor::src:class | ancestor::src:struct | ancestor::src:interface) = 1]/src:type";
xpathTable[language]["attribute_type"] = xpath;
// Also ignores attributes with no specifier
// If struct or interface, include the attributes with no specifier
xpath = "//src:decl_stmt[not(ancestor::src:function) and count(ancestor::src:class | ancestor::src:struct | ancestor::src:interface) = 1]";
xpath += "/src:decl[(ancestor::src:class and src:type/src:specifier[not(.='private')])";
xpath += " or ((ancestor::src:struct or ancestor::src:interface) and src:type/src:specifier[not(.='private')] or not(src:type/src:specifier))]";
xpath += "/src:name[preceding-sibling::*[1][self::src:type]]";
xpath += " | //src:property[count(ancestor::src:class | ancestor::src:struct | ancestor::src:interface) = 1";
xpath += " and (ancestor::src:class and src:type/src:specifier[not(.='private')])";
xpath += " or ((ancestor::src:struct or ancestor::src:interface) and src:type/src:specifier[not(.='private')] or not(src:type/src:specifier))]/src:name";
xpathTable[language]["non_private_attribute_name"] = xpath;
xpath += "/src:decl[(ancestor::src:class and src:type/src:specifier[not(.='private')])";
xpath += " or ((ancestor::src:struct or ancestor::src:interface) and src:type/src:specifier[not(.='private')] or not(src:type/src:specifier))]";
xpath += "/src:type[following-sibling::*[1][self::src:name]]";
xpath += " | //src:property[count(ancestor::src:class | ancestor::src:struct | ancestor::src:interface) = 1";
xpath += " and (ancestor::src:class and src:type/src:specifier[not(.='private')])";
xpath += " or ((ancestor::src:struct or ancestor::src:interface) and src:type/src:specifier[not(.='private')] or not(src:type/src:specifier))]/src:type";
xpathTable[language]["non_private_attribute_type"] = xpath;
// Nested local functions within methods in C# are ignored
xpath = "//*[(self::src:function or self::src:constructor or self::src:destructor)";
xpath += " and count(ancestor::src:class | ancestor::src:struct | ancestor::src:interface) = 1";
xpath += " and not(src:type/src:specifier='static') and not(ancestor::src:function) and not(ancestor::src:property)]";
xpathTable[language]["method"] = xpath;
// C# properties can't be nested in methods or in other properties, so no need to check
xpath = "//src:property[count(ancestor::src:class | ancestor::src:struct | ancestor::src:interface) = 1 and not(src:type/src:specifier='static')]";
xpathTable[language]["property"] = xpath;
xpath = "//src:property/src:type";
xpathTable[language]["property_type"] = xpath;
xpath = "//src:function[not(ancestor::src:function)]";
xpathTable[language]["property_method"] = xpath;
xpath = "//*[(self::src:function or self::src:constructor) and src:type/src:specifier='static']";
xpathTable[language]["free_function"] = xpath;
xpath = "/src:unit/src:function/src:name";
xpathTable[language]["method_name"] = xpath;
xpath = "/src:unit/*[self::src:constructor or self::src:destructor]/src:name";
xpathTable[language]["constructor_destructor_name"] = xpath;
xpath = "/src:unit/*[self::src:constructor or self::src:destructor]";
xpathTable[language]["constructor_or_destructor"] = xpath;
xpath = "/src:unit/*[self::src:constructor or self::src:destructor]/src:parameter_list";
xpathTable[language]["constructor_destructor_parameter_list"] = xpath;
xpath = "/src:unit/src:function/src:parameter_list";
xpathTable[language]["method_parameter_list"] = xpath;
xpath = "/src:unit/src:function/src:type//text()[not(ancestor::src:parameter_list)]";
xpathTable[language]["method_return_type"] = xpath;
xpath = "//src:decl_stmt[count(ancestor::src:function) = 1]/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpath += " | //src:control/src:init/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpathTable[language]["local_variable_name"] = xpath;
xpath = "//src:decl_stmt[count(ancestor::src:function) = 1]/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpath += " | //src:control/src:init/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpathTable[language]["local_variable_type"] = xpath;
xpath = "/src:unit/src:function/src:parameter_list/src:parameter/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpathTable[language]["parameter_name"] = xpath;
xpath = "/src:unit/src:function/src:parameter_list/src:parameter/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpathTable[language]["parameter_type"] = xpath;
xpath = "//src:return[count(ancestor::src:function) = 1]/src:expr";
xpathTable[language]["return_expression"] = xpath;
xpath = "//src:call[count(ancestor::src:function) = 1 and not(src:name/src:operator='->') and not(src:name/src:operator='.') and not(preceding-sibling::*[1][self::src:operator='new'])]/src:name[following-sibling::*[1][self::src:argument_list]]";
xpathTable[language]["function_call_name"] = xpath;
xpath = "//src:call[count(ancestor::src:function) = 1 and (src:name/src:operator='->' or src:name/src:operator='.') and not(preceding-sibling::*[1][self::src:operator='new'])]/src:name[following-sibling::*[1][self::src:argument_list]]";
xpathTable[language]["method_call_name"] = xpath;
xpath = "//src:call[count(ancestor::src:function) = 1 and preceding-sibling::*[1][self::src:operator='new']]/src:name[following-sibling::*[1][self::src:argument_list]]";
xpathTable[language]["constructor_call_name"] = xpath;
xpath = "//src:call[count(ancestor::src:function) = 1 and not(src:name/src:operator='->') and not(src:name/src:operator='.') and not(preceding-sibling::*[1][self::src:operator='new'])]/src:argument_list[preceding-sibling::*[1][self::src:name]]";
xpathTable[language]["function_call_arglist"] = xpath;
xpath = "//src:call[count(ancestor::src:function) = 1 and (src:name/src:operator='->' or src:name/src:operator='.') and not(preceding-sibling::*[1][self::src:operator='new'])]/src:argument_list[preceding-sibling::*[1][self::src:name]]";
xpathTable[language]["method_call_arglist"] = xpath;
xpath = "//src:call[count(ancestor::src:function) = 1 and preceding-sibling::*[1][self::src:operator='new']]/src:argument_list[preceding-sibling::*[1][self::src:name]]";
xpathTable[language]["constructor_call_arglist"] = xpath;
xpath = "//src:decl_stmt[count(ancestor::src:function) = 1]/src:decl[./src:init/src:expr/src:operator[.='new']]/src:name";
xpath += " | //src:expr_stmt[count(ancestor::src:function) = 1]/src:expr[./src:operator[.='new']]/src:name";
xpathTable[language]["new_operator_assign"] = xpath;
xpath = "//src:block_content[1][*[not(self::src:comment)][1]]";
xpathTable[language]["empty"] = xpath;
xpath = "//src:expr[count(ancestor::src:function) = 1]/src:name";
xpathTable[language]["expression_name"] = xpath;
xpath = "//src:expr[count(ancestor::src:function) = 1]/src:name[";
xpath += "following-sibling::*[1][self::src:operator='=' or self::src:operator='+='";
xpath += " or self::src:operator='-=' or self::src:operator='*=' or self::src:operator='/='";
xpath += " or self::src:operator='%=' or self::src:operator='>>=' or self::src:operator='<<='";
xpath += " or self::src:operator='&=' or self::src:operator='^=' or self::src:operator='|='";
xpath += " or self::src:operator='\\?\\?=' or self::src:operator='>>>=' or self::src:operator='++'";
xpath += " or self::src:operator='--'] or preceding-sibling::*[1][self::src:operator='++' or self::src:operator='--']]";
xpathTable[language]["expression_assignment"] = xpath;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Java ////
// enums in Java can contain methods and fields
// enums They are implicitly static
// Java allows static classes, but these can only be nested within other classes, interfaces, or enums
// Static classes in java can contain non-static fields or methods
// They are ignored (since they are nested) and their methods (only if static) are collected as free functions
language = "Java";
xpath = "//src:*[((self::src:class and not(child::src:super[1]))"; // Ignores anonymous classes (classes without names and are nested as instances)
if (INTERFACE) xpath += " or self::src:interface";
if (ENUM) xpath += " or self::src:enum";
xpath += ") and not(ancestor::src:class or ancestor::src:interface or ancestor::src:enum)]";
xpathTable[language]["class"] = xpath;
xpath = "/src:unit/src:*[self::src:class or self::src:interface or self::src:enum]/src:name";
xpathTable[language]["class_name"] = xpath;
xpath = "/src:unit/src:*[self::src:class or self::src:interface or self::src:enum]/text()[1]";
xpathTable[language]["class_type"] = xpath;
xpath = "/src:unit/src:*[self::src:class or self::src:interface or self::src:enum]/src:super_list/*[self::src:extends or self::src:implements]/src:super/src:name";
xpathTable[language]["parent_name"] = xpath;
xpath = "//src:decl_stmt[not(ancestor::src:function) and count(ancestor::src:class | ancestor::src:interface | ancestor::src:enum) = 1]";
xpath += "/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpathTable[language]["attribute_name"] = xpath;
xpath = "//src:decl_stmt[not(ancestor::src:function) and count(ancestor::src:class | ancestor::src:interface | ancestor::src:enum) = 1]";
xpath += "/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpathTable[language]["attribute_type"] = xpath;
xpath = "//src:decl_stmt[not(ancestor::src:function) and count(ancestor::src:class | ancestor::src:interface | ancestor::src:enum) = 1]";
xpath += "/src:decl[(ancestor::src:class and src:type/src:specifier[not(.='private')])";
xpath += " or (ancestor::src:interface and src:type/src:specifier[not(.='private')] or not(src:type/src:specifier))]";
xpath += "/src:name[preceding-sibling::*[1][self::src:type]]";
xpathTable[language]["non_private_attribute_name"] = xpath;
xpath = "//src:decl_stmt[not(ancestor::src:function) and count(ancestor::src:class | ancestor::src:interface | ancestor::src:enum) = 1]";
xpath += "/src:decl[(ancestor::src:class and src:type/src:specifier[not(.='private')])";
xpath += " or (ancestor::src:interface and src:type/src:specifier[not(.='private')] or not(src:type/src:specifier))]";
xpath += "/src:type[following-sibling::*[1][self::src:name]]";
xpathTable[language]["non_private_attribute_type"] = xpath;
xpath = "//*[(self::src:function or self::src:constructor)";
xpath += " and not(src:type/src:specifier='static') and count(ancestor::src:class | ancestor::src:interface | ancestor::src:enum) = 1]";
xpathTable[language]["method"] = xpath;
xpath = "//*[self::src:function and src:type/src:specifier='static']";
xpathTable[language]["free_function"] = xpath;
xpath = "/src:unit/src:function/src:name";
xpathTable[language]["method_name"] = xpath;
xpath = "/src:unit/*[self::src:constructor]/src:name";
xpathTable[language]["constructor_destructor_name"] = xpath;
xpath = "/src:unit/*[self::src:constructor]";
xpathTable[language]["constructor_or_destructor"] = xpath;
xpath = "/src:unit/*[self::src:constructor]/src:parameter_list";
xpathTable[language]["constructor_destructor_parameter_list"] = xpath;
xpath = "/src:unit/src:function/src:parameter_list";
xpathTable[language]["method_parameter_list"] = xpath;
xpath = "/src:unit/src:function/src:type//text()[not(ancestor::src:parameter_list)]";
xpathTable[language]["method_return_type"] = xpath;
xpath = "//src:decl_stmt/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpath += " | //src:control/src:init/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpathTable[language]["local_variable_name"] = xpath;
xpath = "//src:decl_stmt/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpath += " | //src:control/src:init/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpathTable[language]["local_variable_type"] = xpath;
xpath = "/src:unit/src:function/src:parameter_list/src:parameter/src:decl/src:name[preceding-sibling::*[1][self::src:type]]";
xpathTable[language]["parameter_name"] = xpath;
xpath = "/src:unit/src:function/src:parameter_list/src:parameter/src:decl/src:type[following-sibling::*[1][self::src:name]]";
xpathTable[language]["parameter_type"] = xpath;
xpath = "//src:return/src:expr";
xpathTable[language]["return_expression"] = xpath;
xpath = "//src:call[not(src:name/src:operator='.') and not(preceding-sibling::*[1][self::src:operator='new'])]/src:name[following-sibling::*[1][self::src:argument_list]]";
xpathTable[language]["function_call_name"] = xpath;
xpath = "//src:call[src:name/src:operator='.' and not(preceding-sibling::*[1][self::src:operator='new'])]/src:name[following-sibling::*[1][self::src:argument_list]]";
xpathTable[language]["method_call_name"] = xpath;
xpath = "//src:call[preceding-sibling::*[1][self::src:operator='new']]/src:name[following-sibling::*[1][self::src:argument_list]]";
xpathTable[language]["constructor_call_name"] = xpath;
xpath = "//src:call[not(src:name/src:operator='.') and not(preceding-sibling::*[1][self::src:operator='new'])]/src:argument_list[preceding-sibling::*[1][self::src:name]]";
xpathTable[language]["function_call_arglist"] = xpath;
xpath = "//src:call[src:name/src:operator='.' and not(preceding-sibling::*[1][self::src:operator='new'])]/src:argument_list[preceding-sibling::*[1][self::src:name]]";
xpathTable[language]["method_call_arglist"] = xpath;
xpath = "//src:call[preceding-sibling::*[1][self::src:operator='new']]/src:argument_list[preceding-sibling::*[1][self::src:name]]";
xpathTable[language]["constructor_call_arglist"] = xpath;
xpath = "//src:decl_stmt/src:decl[./src:init/src:expr/src:operator[.='new']]/src:name";
xpath += " | //src:expr_stmt/src:expr[./src:operator[.='new']]/src:name";
xpathTable[language]["new_operator_assign"] = xpath;
xpath = "//src:block_content[1][*[not(self::src:comment)][1]]";
xpathTable[language]["empty"] = xpath;
xpath = "//src:expr/src:name";
xpathTable[language]["expression_name"] = xpath;
xpath = "//src:expr/src:name[";
xpath += "following-sibling::*[1][self::src:operator='=' or self::src:operator='+='";
xpath += " or self::src:operator='-=' or self::src:operator='*=' or self::src:operator='/='";
xpath += " or self::src:operator='%=' or self::src:operator='>>=' or self::src:operator='<<='";
xpath += " or self::src:operator='&=' or self::src:operator='^=' or self::src:operator='|='";
xpath += " or self::src:operator='\\?\\?=' or self::src:operator='>>>=' or self::src:operator='++'";
xpath += " or self::src:operator='--'] or preceding-sibling::*[1][self::src:operator='++' or self::src:operator='--']]";
xpathTable[language]["expression_assignment"] = xpath;
}
const std::string& XPathBuilder::getXpath(const std::string& language, const std::string& xpathName) {
return xpathTable[language][xpathName];
}