|
5 | 5 |
|
6 | 6 | import codeql.Locations as L
|
7 | 7 |
|
| 8 | +/** Holds if the database is an overlay. */ |
| 9 | +overlay[local] |
| 10 | +private predicate isOverlay() { databaseMetadata("isOverlay", "true") } |
| 11 | + |
8 | 12 | module QL {
|
9 | 13 | /** The base class for all AST nodes */
|
10 | 14 | class AstNode extends @ql_ast_node {
|
@@ -48,6 +52,30 @@ module QL {
|
48 | 52 | final override string getAPrimaryQlClass() { result = "ReservedWord" }
|
49 | 53 | }
|
50 | 54 |
|
| 55 | + /** Gets the file containing the given `node`. */ |
| 56 | + overlay[local] |
| 57 | + private @file getNodeFile(@ql_ast_node node) { |
| 58 | + exists(@location_default loc | ql_ast_node_location(node, loc) | |
| 59 | + locations_default(loc, result, _, _, _, _) |
| 60 | + ) |
| 61 | + } |
| 62 | + |
| 63 | + /** Holds if `file` was extracted as part of the overlay database. */ |
| 64 | + overlay[local] |
| 65 | + private predicate discardFile(@file file) { isOverlay() and file = getNodeFile(_) } |
| 66 | + |
| 67 | + /** Holds if `node` is in the `file` and is part of the overlay base database. */ |
| 68 | + overlay[local] |
| 69 | + private predicate discardableAstNode(@file file, @ql_ast_node node) { |
| 70 | + not isOverlay() and file = getNodeFile(node) |
| 71 | + } |
| 72 | + |
| 73 | + /** Holds if `node` should be discarded, because it is part of the overlay base and is in a file that was also extracted as part of the overlay database. */ |
| 74 | + overlay[discard_entity] |
| 75 | + private predicate discardAstNode(@ql_ast_node node) { |
| 76 | + exists(@file file | discardableAstNode(file, node) and discardFile(file)) |
| 77 | + } |
| 78 | + |
51 | 79 | /** A class representing `add_expr` nodes. */
|
52 | 80 | class AddExpr extends @ql_add_expr, AstNode {
|
53 | 81 | /** Gets the name of the primary QL class for this element. */
|
@@ -1318,6 +1346,30 @@ module Dbscheme {
|
1318 | 1346 | final override string getAPrimaryQlClass() { result = "ReservedWord" }
|
1319 | 1347 | }
|
1320 | 1348 |
|
| 1349 | + /** Gets the file containing the given `node`. */ |
| 1350 | + overlay[local] |
| 1351 | + private @file getNodeFile(@dbscheme_ast_node node) { |
| 1352 | + exists(@location_default loc | dbscheme_ast_node_location(node, loc) | |
| 1353 | + locations_default(loc, result, _, _, _, _) |
| 1354 | + ) |
| 1355 | + } |
| 1356 | + |
| 1357 | + /** Holds if `file` was extracted as part of the overlay database. */ |
| 1358 | + overlay[local] |
| 1359 | + private predicate discardFile(@file file) { isOverlay() and file = getNodeFile(_) } |
| 1360 | + |
| 1361 | + /** Holds if `node` is in the `file` and is part of the overlay base database. */ |
| 1362 | + overlay[local] |
| 1363 | + private predicate discardableAstNode(@file file, @dbscheme_ast_node node) { |
| 1364 | + not isOverlay() and file = getNodeFile(node) |
| 1365 | + } |
| 1366 | + |
| 1367 | + /** Holds if `node` should be discarded, because it is part of the overlay base and is in a file that was also extracted as part of the overlay database. */ |
| 1368 | + overlay[discard_entity] |
| 1369 | + private predicate discardAstNode(@dbscheme_ast_node node) { |
| 1370 | + exists(@file file | discardableAstNode(file, node) and discardFile(file)) |
| 1371 | + } |
| 1372 | + |
1321 | 1373 | /** A class representing `annotName` tokens. */
|
1322 | 1374 | class AnnotName extends @dbscheme_token_annot_name, Token {
|
1323 | 1375 | /** Gets the name of the primary QL class for this element. */
|
@@ -1654,6 +1706,30 @@ module Blame {
|
1654 | 1706 | final override string getAPrimaryQlClass() { result = "ReservedWord" }
|
1655 | 1707 | }
|
1656 | 1708 |
|
| 1709 | + /** Gets the file containing the given `node`. */ |
| 1710 | + overlay[local] |
| 1711 | + private @file getNodeFile(@blame_ast_node node) { |
| 1712 | + exists(@location_default loc | blame_ast_node_location(node, loc) | |
| 1713 | + locations_default(loc, result, _, _, _, _) |
| 1714 | + ) |
| 1715 | + } |
| 1716 | + |
| 1717 | + /** Holds if `file` was extracted as part of the overlay database. */ |
| 1718 | + overlay[local] |
| 1719 | + private predicate discardFile(@file file) { isOverlay() and file = getNodeFile(_) } |
| 1720 | + |
| 1721 | + /** Holds if `node` is in the `file` and is part of the overlay base database. */ |
| 1722 | + overlay[local] |
| 1723 | + private predicate discardableAstNode(@file file, @blame_ast_node node) { |
| 1724 | + not isOverlay() and file = getNodeFile(node) |
| 1725 | + } |
| 1726 | + |
| 1727 | + /** Holds if `node` should be discarded, because it is part of the overlay base and is in a file that was also extracted as part of the overlay database. */ |
| 1728 | + overlay[discard_entity] |
| 1729 | + private predicate discardAstNode(@blame_ast_node node) { |
| 1730 | + exists(@file file | discardableAstNode(file, node) and discardFile(file)) |
| 1731 | + } |
| 1732 | + |
1657 | 1733 | /** A class representing `blame_entry` nodes. */
|
1658 | 1734 | class BlameEntry extends @blame_blame_entry, AstNode {
|
1659 | 1735 | /** Gets the name of the primary QL class for this element. */
|
@@ -1767,6 +1843,30 @@ module JSON {
|
1767 | 1843 | final override string getAPrimaryQlClass() { result = "ReservedWord" }
|
1768 | 1844 | }
|
1769 | 1845 |
|
| 1846 | + /** Gets the file containing the given `node`. */ |
| 1847 | + overlay[local] |
| 1848 | + private @file getNodeFile(@json_ast_node node) { |
| 1849 | + exists(@location_default loc | json_ast_node_location(node, loc) | |
| 1850 | + locations_default(loc, result, _, _, _, _) |
| 1851 | + ) |
| 1852 | + } |
| 1853 | + |
| 1854 | + /** Holds if `file` was extracted as part of the overlay database. */ |
| 1855 | + overlay[local] |
| 1856 | + private predicate discardFile(@file file) { isOverlay() and file = getNodeFile(_) } |
| 1857 | + |
| 1858 | + /** Holds if `node` is in the `file` and is part of the overlay base database. */ |
| 1859 | + overlay[local] |
| 1860 | + private predicate discardableAstNode(@file file, @json_ast_node node) { |
| 1861 | + not isOverlay() and file = getNodeFile(node) |
| 1862 | + } |
| 1863 | + |
| 1864 | + /** Holds if `node` should be discarded, because it is part of the overlay base and is in a file that was also extracted as part of the overlay database. */ |
| 1865 | + overlay[discard_entity] |
| 1866 | + private predicate discardAstNode(@json_ast_node node) { |
| 1867 | + exists(@file file | discardableAstNode(file, node) and discardFile(file)) |
| 1868 | + } |
| 1869 | + |
1770 | 1870 | class UnderscoreValue extends @json_underscore_value, AstNode { }
|
1771 | 1871 |
|
1772 | 1872 | /** A class representing `array` nodes. */
|
|
0 commit comments