-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathUsing.qll
More file actions
77 lines (67 loc) · 2.14 KB
/
Using.qll
File metadata and controls
77 lines (67 loc) · 2.14 KB
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
/**
* Provides all `using` directive classes.
*
* All `using` directives have the common base class `UsingDirective`.
*/
import Element
private import TypeRef
/**
* A `using` directive. Either a namespace `using` directive
* (`UsingNamespaceDirective`) or a type `using` directive
* (`UsingStaticDirective`).
*/
class UsingDirective extends Element, @using_directive {
/**
* Gets the namespace in which this `using` directive appears, if any.
*
* Example:
*
* ```csharp
* using System;
*
* namespace N {
* using System.Web;
* using static System.Console;
* }
* ```
*
* The first `using` directive on line 1 does not appear in a namespace,
* the second and third `using` directives on lines 4 and 5 appear in the
* namespace `N`.
*/
NamespaceDeclaration getParentNamespaceDeclaration() {
parent_namespace_declaration(this, result)
}
override Location getALocation() { using_directive_location(this, result) }
/** Holds if this directive is `global`. */
predicate isGlobal() { using_global(this) }
}
/**
* A namespace `using` directive, for example `using System`.
*/
class UsingNamespaceDirective extends UsingDirective, @using_namespace_directive {
/**
* Gets the target of this namespace `using` directive, for example `System`
* in `using System`.
*/
Namespace getImportedNamespace() { using_namespace_directives(this, result) }
override string toString() { result = "using ...;" }
override string getAPrimaryQlClass() { result = "UsingNamespaceDirective" }
}
/**
* A type `using` directive, for example `using static System.Console`.
*/
class UsingStaticDirective extends UsingDirective, @using_static_directive {
/**
* Gets the target of this type `using` directive, for example
* `System.Console` in `using static System.Console`.
*/
ValueOrRefType getTarget() {
using_static_directives(this, result)
or
not using_static_directives(this, any(Type t)) and
using_static_directives(this, getTypeRef(result))
}
override string toString() { result = "using static ...;" }
override string getAPrimaryQlClass() { result = "UsingStaticDirective" }
}