@@ -55,19 +55,25 @@ private Content getContent(SummaryComponent component) {
55
55
56
56
module SupportMethod {
57
57
GenMethod genMethodForContent ( SummaryComponentStack c ) {
58
- result = min ( GenMethod g | g . appliesTo ( any ( VoidType v ) , getContent ( c . head ( ) ) ) )
58
+ result = genMethodFor ( any ( VoidType v ) , c )
59
59
}
60
60
61
61
GenMethod genMethodFor ( Type t , SummaryComponentStack c ) {
62
- result = min ( GenMethod g | g .appliesTo ( t , getContent ( c .head ( ) ) ) )
62
+ result =
63
+ min ( GenMethod g |
64
+ g = min ( GenMethod g1 | g1 .appliesTo ( t , getContent ( c .head ( ) ) ) | g1 order by g1 .getPriority ( ) )
65
+ )
63
66
}
64
67
65
68
GetMethod getMethodForContent ( SummaryComponentStack c ) {
66
- result = min ( GetMethod g | g . appliesTo ( any ( VoidType v ) , getContent ( c . head ( ) ) ) )
69
+ result = getMethodFor ( any ( VoidType v ) , c )
67
70
}
68
71
69
72
GetMethod getMethodFor ( Type t , SummaryComponentStack c ) {
70
- result = min ( GetMethod g | g .appliesTo ( t , getContent ( c .head ( ) ) ) )
73
+ result =
74
+ min ( GetMethod g |
75
+ g = min ( GetMethod g1 | g1 .appliesTo ( t , getContent ( c .head ( ) ) ) | g1 order by g1 .getPriority ( ) )
76
+ )
71
77
}
72
78
}
73
79
@@ -82,6 +88,10 @@ abstract class SupportMethod extends string {
82
88
bindingset [ this , arg]
83
89
abstract string getCall ( string arg ) ;
84
90
91
+ /** Gets the priority of this support method. Lower priorities are preferred when multiple support methods apply. */
92
+ bindingset [ this ]
93
+ int getPriority ( ) { result = 50 }
94
+
85
95
/**
86
96
* Gets the CSV row describing this support method if it is needed to set up the output for this test.
87
97
*
@@ -123,11 +133,12 @@ abstract class GetMethod extends SupportMethod { }
123
133
private class DefaultGetMethod extends GetMethod {
124
134
Content c ;
125
135
126
- // prefix with zzz so the default getter is always last
127
- DefaultGetMethod ( ) { this = "zzzDefaultGet" + contentToken ( c ) }
136
+ DefaultGetMethod ( ) { this = "DefaultGet" + contentToken ( c ) }
128
137
129
138
string getName ( ) { result = "get" + contentToken ( c ) }
130
139
140
+ override int getPriority ( ) { result = 999 }
141
+
131
142
override predicate appliesTo ( Type t , Content c1 ) {
132
143
c = c1 and
133
144
// suppress unused variable warning
@@ -248,11 +259,12 @@ abstract class GenMethod extends SupportMethod { }
248
259
private class DefaultGenMethod extends GenMethod {
249
260
Content c ;
250
261
251
- // prefix with zzz so the default generator is always last
252
- DefaultGenMethod ( ) { this = "zzzDefaultGen" + contentToken ( c ) }
262
+ DefaultGenMethod ( ) { this = "DefaultGen" + contentToken ( c ) }
253
263
254
264
string getName ( ) { result = "newWith" + contentToken ( c ) }
255
265
266
+ override int getPriority ( ) { result = 999 }
267
+
256
268
override predicate appliesTo ( Type t , Content c1 ) {
257
269
c = c1 and
258
270
// suppress unused variable warning
0 commit comments