@@ -32,6 +32,10 @@ class AstNode extends TAstNode {
32
32
node = toQL ( this ) and
33
33
result = node .getLocation ( )
34
34
)
35
+ or
36
+ result = toGenerateYaml ( this ) .getLocation ( )
37
+ or
38
+ result = toDbscheme ( this ) .getLocation ( )
35
39
}
36
40
37
41
predicate hasLocationInfo (
@@ -111,7 +115,7 @@ class TopLevel extends TTopLevel, AstNode {
111
115
ModuleMember getAMember ( ) { result = this .getMember ( _) }
112
116
113
117
/** Gets the `i`'th member of this top-level module. */
114
- ModuleMember getMember ( int i ) { toQL ( result ) = file .getChild ( i ) .( QL :: ModuleMember ) . getChild ( _) }
118
+ ModuleMember getMember ( int i ) { toQL ( result ) = file .getChild ( i ) .getChild ( _) }
115
119
116
120
/** Gets a top-level import in this module. */
117
121
Import getAnImport ( ) { result = this .getAMember ( ) }
@@ -349,7 +353,7 @@ class Predicate extends TPredicate, AstNode, PredicateOrBuiltin, Declaration {
349
353
* A relation in the database.
350
354
*/
351
355
class Relation extends TDBRelation , AstNode , Declaration {
352
- QL :: DbTable table ;
356
+ Dbscheme :: Table table ;
353
357
354
358
Relation ( ) { this = TDBRelation ( table ) }
355
359
@@ -358,9 +362,9 @@ class Relation extends TDBRelation, AstNode, Declaration {
358
362
*/
359
363
override string getName ( ) { result = table .getTableName ( ) .getChild ( ) .getValue ( ) }
360
364
361
- private QL :: DbColumn getColumn ( int i ) {
365
+ private Dbscheme :: Column getColumn ( int i ) {
362
366
result =
363
- rank [ i + 1 ] ( QL :: DbColumn column , int child |
367
+ rank [ i + 1 ] ( Dbscheme :: Column column , int child |
364
368
table .getChild ( child ) = column
365
369
|
366
370
column order by child
@@ -373,7 +377,7 @@ class Relation extends TDBRelation, AstNode, Declaration {
373
377
/** Gets the `i`th parameter type */
374
378
string getParameterType ( int i ) {
375
379
// TODO: This is just using the name of the type, not the actual type. Checkout Type.qll
376
- result = this .getColumn ( i ) .getColType ( ) .getChild ( ) .( QL :: Token ) .getValue ( )
380
+ result = this .getColumn ( i ) .getColType ( ) .getChild ( ) .( Dbscheme :: Token ) .getValue ( )
377
381
}
378
382
379
383
/**
@@ -1171,13 +1175,27 @@ class Import extends TImport, ModuleMember, TypeRef {
1171
1175
string importedAs ( ) { result = imp .getChild ( 1 ) .( QL:: ModuleName ) .getChild ( ) .getValue ( ) }
1172
1176
1173
1177
/**
1174
- * Gets the `i`th selected name from the imported module.
1178
+ * Gets the qualified name of the module selected in the import statement .
1175
1179
* E.g. for
1176
1180
* `import foo.bar::Baz::Qux`
1177
- * It is true that `getSelectionName(0) = "Baz"` and `getSelectionName(1) = "Qux"`.
1181
+ * It is true that `getSelectionName() = "Baz::Qux"`.
1182
+ *
1183
+ * Does NOT include type arguments!
1184
+ */
1185
+ string getSelectionName ( ) { result = this .getModuleExpr ( ) .getQualifiedName ( ) }
1186
+
1187
+ /**
1188
+ * Gets the module expression selected in the import statement.
1189
+ * E.g. for
1190
+ * `import foo.Bar::Baz::Qux`
1191
+ * The module expression is the `Bar::Baz::Qux` part.
1178
1192
*/
1179
- string getSelectionName ( int i ) {
1180
- result = imp .getChild ( 0 ) .( QL:: ImportModuleExpr ) .getName ( i ) .getValue ( )
1193
+ ModuleExpr getModuleExpr ( ) { toQL ( result ) = imp .getChild ( 0 ) .( QL:: ImportModuleExpr ) .getChild ( ) }
1194
+
1195
+ override AstNode getAChild ( string pred ) {
1196
+ result = super .getAChild ( pred )
1197
+ or
1198
+ pred = directMember ( "getModuleExpr" ) and result = this .getModuleExpr ( )
1181
1199
}
1182
1200
1183
1201
/**
@@ -1187,27 +1205,25 @@ class Import extends TImport, ModuleMember, TypeRef {
1187
1205
* It is true that `getQualifiedName(0) = "foo"` and `getQualifiedName(1) = "bar"`.
1188
1206
*/
1189
1207
string getQualifiedName ( int i ) {
1190
- result = imp .getChild ( 0 ) .( QL:: ImportModuleExpr ) .getChild ( ) . getName ( i ) .getValue ( )
1208
+ result = imp .getChild ( 0 ) .( QL:: ImportModuleExpr ) .getQualName ( i ) .getValue ( )
1191
1209
}
1192
1210
1193
1211
/**
1194
- * Gets the full string specifying the module being imported.
1212
+ * Gets a full string specifying the module being imported.
1213
+ *
1214
+ * Does NOT include type arguments!
1195
1215
*/
1196
1216
string getImportString ( ) {
1197
- exists ( string selec |
1198
- not exists ( this .getSelectionName ( _) ) and selec = ""
1217
+ exists ( string qual |
1218
+ not exists ( this .getQualifiedName ( _) ) and qual = ""
1199
1219
or
1200
- selec =
1201
- "::" + strictconcat ( int i , string q | q = this .getSelectionName ( i ) | q , "::" order by i )
1220
+ qual = strictconcat ( int i , string q | q = this .getQualifiedName ( i ) | q , "." order by i ) + "."
1202
1221
|
1203
- result =
1204
- strictconcat ( int i , string q | q = this .getQualifiedName ( i ) | q , "." order by i ) + selec
1222
+ result = qual + this .getSelectionName ( )
1205
1223
)
1206
1224
}
1207
1225
1208
- override Type getResolvedType ( ) {
1209
- exists ( FileOrModule mod | resolve ( this , mod ) | result = mod .toType ( ) )
1210
- }
1226
+ override Type getResolvedType ( ) { result = this .getModuleExpr ( ) .getResolvedType ( ) }
1211
1227
}
1212
1228
1213
1229
/** A formula, such as `x = 6 and y < 5`. */
@@ -2282,6 +2298,19 @@ class ModuleExpr extends TModuleExpr, TypeRef {
2282
2298
SignatureExpr getArgument ( int i ) {
2283
2299
result .toQL ( ) = me .getAFieldOrChild ( ) .( QL:: ModuleInstantiation ) .getChild ( i )
2284
2300
}
2301
+
2302
+ /**
2303
+ * Gets the qualified name for this module expression, which does not include the type arguments.
2304
+ */
2305
+ string getQualifiedName ( ) {
2306
+ exists ( string qual |
2307
+ not exists ( this .getQualifier ( ) ) and qual = ""
2308
+ or
2309
+ qual = this .getQualifier ( ) .getQualifiedName ( ) + "::"
2310
+ |
2311
+ result = qual + this .getName ( )
2312
+ )
2313
+ }
2285
2314
}
2286
2315
2287
2316
/** A signature expression, either a `PredicateExpr` or a `TypeExpr`. */
@@ -2426,11 +2455,13 @@ module YAML {
2426
2455
class YAMLNode extends TYamlNode , AstNode {
2427
2456
/** Holds if the predicate is a root node (has no parent) */
2428
2457
predicate isRoot ( ) { not exists ( this .getParent ( ) ) }
2458
+
2459
+ override AstNode getParent ( ) { toGenerateYaml ( result ) = toGenerateYaml ( this ) .getParent ( ) }
2429
2460
}
2430
2461
2431
2462
/** A YAML comment. */
2432
2463
class YamlComment extends TYamlCommemt , YAMLNode {
2433
- QL :: YamlComment yamlcomment ;
2464
+ Yaml :: Comment yamlcomment ;
2434
2465
2435
2466
YamlComment ( ) { this = TYamlCommemt ( yamlcomment ) }
2436
2467
@@ -2442,23 +2473,23 @@ module YAML {
2442
2473
2443
2474
/** A YAML entry. */
2444
2475
class YamlEntry extends TYamlEntry , YAMLNode {
2445
- QL :: YamlEntry yamle ;
2476
+ Yaml :: Entry yamle ;
2446
2477
2447
2478
YamlEntry ( ) { this = TYamlEntry ( yamle ) }
2448
2479
2449
2480
/** Gets the key of this YAML entry. */
2450
2481
YamlKey getKey ( ) {
2451
- exists ( QL :: YamlKeyvaluepair pair |
2482
+ exists ( Yaml :: Keyvaluepair pair |
2452
2483
pair .getParent ( ) = yamle and
2453
2484
result = TYamlKey ( pair .getKey ( ) )
2454
2485
)
2455
2486
}
2456
2487
2457
- YamlListItem getListItem ( ) { toQL ( result ) .getParent ( ) = yamle }
2488
+ YamlListItem getListItem ( ) { toGenerateYaml ( result ) .getParent ( ) = yamle }
2458
2489
2459
2490
/** Gets the value of this YAML entry. */
2460
- YAMLValue getValue ( ) {
2461
- exists ( QL :: YamlKeyvaluepair pair |
2491
+ YamlValue getValue ( ) {
2492
+ exists ( Yaml :: Keyvaluepair pair |
2462
2493
pair .getParent ( ) = yamle and
2463
2494
result = TYamlValue ( pair .getValue ( ) )
2464
2495
)
@@ -2472,15 +2503,15 @@ module YAML {
2472
2503
2473
2504
/** A YAML key. */
2474
2505
class YamlKey extends TYamlKey , YAMLNode {
2475
- QL :: YamlKey yamlkey ;
2506
+ Yaml :: Key yamlkey ;
2476
2507
2477
2508
YamlKey ( ) { this = TYamlKey ( yamlkey ) }
2478
2509
2479
2510
/**
2480
2511
* Gets the value of this YAML key.
2481
2512
*/
2482
- YAMLValue getValue ( ) {
2483
- exists ( QL :: YamlKeyvaluepair pair |
2513
+ YamlValue getValue ( ) {
2514
+ exists ( Yaml :: Keyvaluepair pair |
2484
2515
pair .getKey ( ) = yamlkey and result = TYamlValue ( pair .getValue ( ) )
2485
2516
)
2486
2517
}
@@ -2489,7 +2520,7 @@ module YAML {
2489
2520
2490
2521
/** Gets the value of this YAML value. */
2491
2522
string getNamePart ( int i ) {
2492
- i = 0 and result = yamlkey .getChild ( 0 ) .( QL :: SimpleId ) .getValue ( )
2523
+ i = 0 and result = yamlkey .getChild ( 0 ) .( Yaml :: SimpleId ) .getValue ( )
2493
2524
or
2494
2525
exists ( YamlKey child |
2495
2526
child = TYamlKey ( yamlkey .getChild ( 1 ) ) and
@@ -2511,14 +2542,14 @@ module YAML {
2511
2542
2512
2543
/** A YAML list item. */
2513
2544
class YamlListItem extends TYamlListitem , YAMLNode {
2514
- QL :: YamlListitem yamllistitem ;
2545
+ Yaml :: Listitem yamllistitem ;
2515
2546
2516
2547
YamlListItem ( ) { this = TYamlListitem ( yamllistitem ) }
2517
2548
2518
2549
/**
2519
2550
* Gets the value of this YAML list item.
2520
2551
*/
2521
- YAMLValue getValue ( ) { result = TYamlValue ( yamllistitem .getChild ( ) ) }
2552
+ YamlValue getValue ( ) { result = TYamlValue ( yamllistitem .getChild ( ) ) }
2522
2553
2523
2554
override string getAPrimaryQlClass ( ) { result = "YamlListItem" }
2524
2555
}
@@ -2527,12 +2558,12 @@ module YAML {
2527
2558
deprecated class YAMLListItem = YamlListItem ;
2528
2559
2529
2560
/** A YAML value. */
2530
- class YAMLValue extends TYamlValue , YAMLNode {
2531
- QL :: YamlValue yamlvalue ;
2561
+ class YamlValue extends TYamlValue , YAMLNode {
2562
+ Yaml :: Value yamlvalue ;
2532
2563
2533
- YAMLValue ( ) { this = TYamlValue ( yamlvalue ) }
2564
+ YamlValue ( ) { this = TYamlValue ( yamlvalue ) }
2534
2565
2535
- override string getAPrimaryQlClass ( ) { result = "YAMLValue " }
2566
+ override string getAPrimaryQlClass ( ) { result = "YamlValue " }
2536
2567
2537
2568
/** Gets the value of this YAML value. */
2538
2569
string getValue ( ) { result = yamlvalue .getValue ( ) }
0 commit comments