@@ -23,13 +23,27 @@ abstract class Use extends Locatable {
23
23
abstract string getUseType ( ) ;
24
24
}
25
25
26
- private newtype TDef =
27
- TVariable ( Variable v ) or
28
- TFormatArgsArgName ( Name name ) { name = any ( FormatArgsArg a ) .getName ( ) } or
29
- TFormatArgsArgIndex ( Expr e ) { e = any ( FormatArgsArg a ) .getExpr ( ) }
26
+ cached
27
+ private module Cached {
28
+ cached
29
+ newtype TDef =
30
+ TVariable ( Variable v ) or
31
+ TFormatArgsArgName ( Name name ) { name = any ( FormatArgsArg a ) .getName ( ) } or
32
+ TFormatArgsArgIndex ( Expr e ) { e = any ( FormatArgsArg a ) .getExpr ( ) }
33
+
34
+ /**
35
+ * Gets an element, of kind `kind`, that element `use` uses, if any.
36
+ */
37
+ cached
38
+ Definition definitionOf ( Use use , string kind ) {
39
+ result = use .getDefinition ( ) and kind = use .getUseType ( )
40
+ }
41
+ }
42
+
43
+ predicate definitionOf = Cached:: definitionOf / 2 ;
30
44
31
45
/** A definition */
32
- class Definition extends TDef {
46
+ class Definition extends Cached :: TDef {
33
47
/** Gets the location of this variable. */
34
48
Location getLocation ( ) {
35
49
result = this .asVariable ( ) .getLocation ( ) or
@@ -38,13 +52,13 @@ class Definition extends TDef {
38
52
}
39
53
40
54
/** Gets this definition as a `Variable` */
41
- Variable asVariable ( ) { this = TVariable ( result ) }
55
+ Variable asVariable ( ) { this = Cached :: TVariable ( result ) }
42
56
43
57
/** Gets this definition as a `Name` */
44
- Name asName ( ) { this = TFormatArgsArgName ( result ) }
58
+ Name asName ( ) { this = Cached :: TFormatArgsArgName ( result ) }
45
59
46
60
/** Gets this definition as an `Expr` */
47
- Expr asExpr ( ) { this = TFormatArgsArgIndex ( result ) }
61
+ Expr asExpr ( ) { this = Cached :: TFormatArgsArgIndex ( result ) }
48
62
49
63
/** Gets the string representation of this element. */
50
64
string toString ( ) {
@@ -107,11 +121,3 @@ private class PositionalFormatArgumentUse extends Use instanceof PositionalForma
107
121
108
122
override string getUseType ( ) { result = "format argument" }
109
123
}
110
-
111
- /**
112
- * Gets an element, of kind `kind`, that element `use` uses, if any.
113
- */
114
- cached
115
- Definition definitionOf ( Use use , string kind ) {
116
- result = use .getDefinition ( ) and kind = use .getUseType ( )
117
- }
0 commit comments