@@ -32,6 +32,10 @@ class AstNode extends TAstNode {
3232 node = toQL ( this ) and
3333 result = node .getLocation ( )
3434 )
35+ or
36+ result = toGenerateYaml ( this ) .getLocation ( )
37+ or
38+ result = toDbscheme ( this ) .getLocation ( )
3539 }
3640
3741 predicate hasLocationInfo (
@@ -111,7 +115,7 @@ class TopLevel extends TTopLevel, AstNode {
111115 ModuleMember getAMember ( ) { result = this .getMember ( _) }
112116
113117 /** 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 ( _) }
115119
116120 /** Gets a top-level import in this module. */
117121 Import getAnImport ( ) { result = this .getAMember ( ) }
@@ -349,7 +353,7 @@ class Predicate extends TPredicate, AstNode, PredicateOrBuiltin, Declaration {
349353 * A relation in the database.
350354 */
351355class Relation extends TDBRelation , AstNode , Declaration {
352- QL :: DbTable table ;
356+ Dbscheme :: Table table ;
353357
354358 Relation ( ) { this = TDBRelation ( table ) }
355359
@@ -358,9 +362,9 @@ class Relation extends TDBRelation, AstNode, Declaration {
358362 */
359363 override string getName ( ) { result = table .getTableName ( ) .getChild ( ) .getValue ( ) }
360364
361- private QL :: DbColumn getColumn ( int i ) {
365+ private Dbscheme :: Column getColumn ( int i ) {
362366 result =
363- rank [ i + 1 ] ( QL :: DbColumn column , int child |
367+ rank [ i + 1 ] ( Dbscheme :: Column column , int child |
364368 table .getChild ( child ) = column
365369 |
366370 column order by child
@@ -373,7 +377,7 @@ class Relation extends TDBRelation, AstNode, Declaration {
373377 /** Gets the `i`th parameter type */
374378 string getParameterType ( int i ) {
375379 // 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 ( )
377381 }
378382
379383 /**
@@ -1171,13 +1175,27 @@ class Import extends TImport, ModuleMember, TypeRef {
11711175 string importedAs ( ) { result = imp .getChild ( 1 ) .( QL:: ModuleName ) .getChild ( ) .getValue ( ) }
11721176
11731177 /**
1174- * Gets the `i`th selected name from the imported module.
1178+ * Gets the qualified name of the module selected in the import statement .
11751179 * E.g. for
11761180 * `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.
11781192 */
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 ( )
11811199 }
11821200
11831201 /**
@@ -1187,27 +1205,25 @@ class Import extends TImport, ModuleMember, TypeRef {
11871205 * It is true that `getQualifiedName(0) = "foo"` and `getQualifiedName(1) = "bar"`.
11881206 */
11891207 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 ( )
11911209 }
11921210
11931211 /**
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!
11951215 */
11961216 string getImportString ( ) {
1197- exists ( string selec |
1198- not exists ( this .getSelectionName ( _) ) and selec = ""
1217+ exists ( string qual |
1218+ not exists ( this .getQualifiedName ( _) ) and qual = ""
11991219 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 ) + "."
12021221 |
1203- result =
1204- strictconcat ( int i , string q | q = this .getQualifiedName ( i ) | q , "." order by i ) + selec
1222+ result = qual + this .getSelectionName ( )
12051223 )
12061224 }
12071225
1208- override Type getResolvedType ( ) {
1209- exists ( FileOrModule mod | resolve ( this , mod ) | result = mod .toType ( ) )
1210- }
1226+ override Type getResolvedType ( ) { result = this .getModuleExpr ( ) .getResolvedType ( ) }
12111227}
12121228
12131229/** A formula, such as `x = 6 and y < 5`. */
@@ -2282,6 +2298,19 @@ class ModuleExpr extends TModuleExpr, TypeRef {
22822298 SignatureExpr getArgument ( int i ) {
22832299 result .toQL ( ) = me .getAFieldOrChild ( ) .( QL:: ModuleInstantiation ) .getChild ( i )
22842300 }
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+ }
22852314}
22862315
22872316/** A signature expression, either a `PredicateExpr` or a `TypeExpr`. */
@@ -2426,11 +2455,13 @@ module YAML {
24262455 class YAMLNode extends TYamlNode , AstNode {
24272456 /** Holds if the predicate is a root node (has no parent) */
24282457 predicate isRoot ( ) { not exists ( this .getParent ( ) ) }
2458+
2459+ override AstNode getParent ( ) { toGenerateYaml ( result ) = toGenerateYaml ( this ) .getParent ( ) }
24292460 }
24302461
24312462 /** A YAML comment. */
24322463 class YamlComment extends TYamlCommemt , YAMLNode {
2433- QL :: YamlComment yamlcomment ;
2464+ Yaml :: Comment yamlcomment ;
24342465
24352466 YamlComment ( ) { this = TYamlCommemt ( yamlcomment ) }
24362467
@@ -2442,23 +2473,23 @@ module YAML {
24422473
24432474 /** A YAML entry. */
24442475 class YamlEntry extends TYamlEntry , YAMLNode {
2445- QL :: YamlEntry yamle ;
2476+ Yaml :: Entry yamle ;
24462477
24472478 YamlEntry ( ) { this = TYamlEntry ( yamle ) }
24482479
24492480 /** Gets the key of this YAML entry. */
24502481 YamlKey getKey ( ) {
2451- exists ( QL :: YamlKeyvaluepair pair |
2482+ exists ( Yaml :: Keyvaluepair pair |
24522483 pair .getParent ( ) = yamle and
24532484 result = TYamlKey ( pair .getKey ( ) )
24542485 )
24552486 }
24562487
2457- YamlListItem getListItem ( ) { toQL ( result ) .getParent ( ) = yamle }
2488+ YamlListItem getListItem ( ) { toGenerateYaml ( result ) .getParent ( ) = yamle }
24582489
24592490 /** Gets the value of this YAML entry. */
2460- YAMLValue getValue ( ) {
2461- exists ( QL :: YamlKeyvaluepair pair |
2491+ YamlValue getValue ( ) {
2492+ exists ( Yaml :: Keyvaluepair pair |
24622493 pair .getParent ( ) = yamle and
24632494 result = TYamlValue ( pair .getValue ( ) )
24642495 )
@@ -2472,15 +2503,15 @@ module YAML {
24722503
24732504 /** A YAML key. */
24742505 class YamlKey extends TYamlKey , YAMLNode {
2475- QL :: YamlKey yamlkey ;
2506+ Yaml :: Key yamlkey ;
24762507
24772508 YamlKey ( ) { this = TYamlKey ( yamlkey ) }
24782509
24792510 /**
24802511 * Gets the value of this YAML key.
24812512 */
2482- YAMLValue getValue ( ) {
2483- exists ( QL :: YamlKeyvaluepair pair |
2513+ YamlValue getValue ( ) {
2514+ exists ( Yaml :: Keyvaluepair pair |
24842515 pair .getKey ( ) = yamlkey and result = TYamlValue ( pair .getValue ( ) )
24852516 )
24862517 }
@@ -2489,7 +2520,7 @@ module YAML {
24892520
24902521 /** Gets the value of this YAML value. */
24912522 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 ( )
24932524 or
24942525 exists ( YamlKey child |
24952526 child = TYamlKey ( yamlkey .getChild ( 1 ) ) and
@@ -2511,14 +2542,14 @@ module YAML {
25112542
25122543 /** A YAML list item. */
25132544 class YamlListItem extends TYamlListitem , YAMLNode {
2514- QL :: YamlListitem yamllistitem ;
2545+ Yaml :: Listitem yamllistitem ;
25152546
25162547 YamlListItem ( ) { this = TYamlListitem ( yamllistitem ) }
25172548
25182549 /**
25192550 * Gets the value of this YAML list item.
25202551 */
2521- YAMLValue getValue ( ) { result = TYamlValue ( yamllistitem .getChild ( ) ) }
2552+ YamlValue getValue ( ) { result = TYamlValue ( yamllistitem .getChild ( ) ) }
25222553
25232554 override string getAPrimaryQlClass ( ) { result = "YamlListItem" }
25242555 }
@@ -2527,12 +2558,12 @@ module YAML {
25272558 deprecated class YAMLListItem = YamlListItem ;
25282559
25292560 /** A YAML value. */
2530- class YAMLValue extends TYamlValue , YAMLNode {
2531- QL :: YamlValue yamlvalue ;
2561+ class YamlValue extends TYamlValue , YAMLNode {
2562+ Yaml :: Value yamlvalue ;
25322563
2533- YAMLValue ( ) { this = TYamlValue ( yamlvalue ) }
2564+ YamlValue ( ) { this = TYamlValue ( yamlvalue ) }
25342565
2535- override string getAPrimaryQlClass ( ) { result = "YAMLValue " }
2566+ override string getAPrimaryQlClass ( ) { result = "YamlValue " }
25362567
25372568 /** Gets the value of this YAML value. */
25382569 string getValue ( ) { result = yamlvalue .getValue ( ) }
0 commit comments