-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathNodeName.qll
More file actions
32 lines (31 loc) · 934 Bytes
/
NodeName.qll
File metadata and controls
32 lines (31 loc) · 934 Bytes
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
import ql
/**
* Gets the name for a `node` that defines something in a QL program.
* E.g. a predicate, class, or module definition.
*/
string getName(AstNode node, string kind) {
result = node.(Class).getName() and kind = "class"
or
// not including CharPreds or db relations. The remaining are: classlessPredicate, classPredicate, newTypeBranch.
result = node.(ClasslessPredicate).getName() and
kind = "predicate"
or
result = node.(ClassPredicate).getName() and
kind = "predicate"
or
result = node.(NewTypeBranch).getName() and
kind = "newtype"
or
result = node.(NewType).getName() and
kind = "newtype"
or
result = node.(VarDef).getName() and
kind = "variable" and
not node = any(FieldDecl f).getVarDecl()
or
result = node.(FieldDecl).getName() and kind = "field"
or
result = node.(Module).getName() and kind = "module"
or
result = node.(Import).importedAs() and kind = "module"
}