@@ -48,6 +48,10 @@ type StringExtractor interface {
48
48
ExtractString (extractor * ExpressionExtractor , expression * StringExpression ) ExpressionExtraction
49
49
}
50
50
51
+ type StringTemplateExtractor interface {
52
+ ExtractStringTemplate (extractor * ExpressionExtractor , expression * StringTemplateExpression ) ExpressionExtraction
53
+ }
54
+
51
55
type ArrayExtractor interface {
52
56
ExtractArray (extractor * ExpressionExtractor , expression * ArrayExpression ) ExpressionExtraction
53
57
}
@@ -117,31 +121,32 @@ type AttachExtractor interface {
117
121
}
118
122
119
123
type ExpressionExtractor struct {
120
- IndexExtractor IndexExtractor
121
- ForceExtractor ForceExtractor
122
- BoolExtractor BoolExtractor
123
- NilExtractor NilExtractor
124
- IntExtractor IntExtractor
125
- FixedPointExtractor FixedPointExtractor
126
- StringExtractor StringExtractor
127
- ArrayExtractor ArrayExtractor
128
- DictionaryExtractor DictionaryExtractor
129
- IdentifierExtractor IdentifierExtractor
130
- AttachExtractor AttachExtractor
131
- MemoryGauge common.MemoryGauge
132
- VoidExtractor VoidExtractor
133
- UnaryExtractor UnaryExtractor
134
- ConditionalExtractor ConditionalExtractor
135
- InvocationExtractor InvocationExtractor
136
- BinaryExtractor BinaryExtractor
137
- FunctionExtractor FunctionExtractor
138
- CastingExtractor CastingExtractor
139
- CreateExtractor CreateExtractor
140
- DestroyExtractor DestroyExtractor
141
- ReferenceExtractor ReferenceExtractor
142
- MemberExtractor MemberExtractor
143
- PathExtractor PathExtractor
144
- nextIdentifier int
124
+ IndexExtractor IndexExtractor
125
+ ForceExtractor ForceExtractor
126
+ BoolExtractor BoolExtractor
127
+ NilExtractor NilExtractor
128
+ IntExtractor IntExtractor
129
+ FixedPointExtractor FixedPointExtractor
130
+ StringExtractor StringExtractor
131
+ StringTemplateExtractor StringTemplateExtractor
132
+ ArrayExtractor ArrayExtractor
133
+ DictionaryExtractor DictionaryExtractor
134
+ IdentifierExtractor IdentifierExtractor
135
+ AttachExtractor AttachExtractor
136
+ MemoryGauge common.MemoryGauge
137
+ VoidExtractor VoidExtractor
138
+ UnaryExtractor UnaryExtractor
139
+ ConditionalExtractor ConditionalExtractor
140
+ InvocationExtractor InvocationExtractor
141
+ BinaryExtractor BinaryExtractor
142
+ FunctionExtractor FunctionExtractor
143
+ CastingExtractor CastingExtractor
144
+ CreateExtractor CreateExtractor
145
+ DestroyExtractor DestroyExtractor
146
+ ReferenceExtractor ReferenceExtractor
147
+ MemberExtractor MemberExtractor
148
+ PathExtractor PathExtractor
149
+ nextIdentifier int
145
150
}
146
151
147
152
var _ ExpressionVisitor [ExpressionExtraction ] = & ExpressionExtractor {}
@@ -271,6 +276,35 @@ func (extractor *ExpressionExtractor) ExtractString(expression *StringExpression
271
276
return rewriteExpressionAsIs (expression )
272
277
}
273
278
279
+ func (extractor * ExpressionExtractor ) VisitStringTemplateExpression (expression * StringTemplateExpression ) ExpressionExtraction {
280
+
281
+ // delegate to child extractor, if any,
282
+ // or call default implementation
283
+
284
+ if extractor .StringTemplateExtractor != nil {
285
+ return extractor .StringTemplateExtractor .ExtractStringTemplate (extractor , expression )
286
+ }
287
+ return extractor .ExtractStringTemplate (expression )
288
+ }
289
+
290
+ func (extractor * ExpressionExtractor ) ExtractStringTemplate (expression * StringTemplateExpression ) ExpressionExtraction {
291
+
292
+ // copy the expression
293
+ newExpression := * expression
294
+
295
+ // rewrite all value expressions
296
+
297
+ rewrittenExpressions , extractedExpressions :=
298
+ extractor .VisitExpressions (expression .Expressions )
299
+
300
+ newExpression .Expressions = rewrittenExpressions
301
+
302
+ return ExpressionExtraction {
303
+ RewrittenExpression : & newExpression ,
304
+ ExtractedExpressions : extractedExpressions ,
305
+ }
306
+ }
307
+
274
308
func (extractor * ExpressionExtractor ) VisitArrayExpression (expression * ArrayExpression ) ExpressionExtraction {
275
309
276
310
// delegate to child extractor, if any,
0 commit comments