| 196 | |
| 197 | // Clone the AST |
| 198 | export class CloneVisitor implements Visitor { |
| 199 | visitText(text: Text, context?: any): Text { |
| 200 | return new Text(text.value, text.sourceSpan); |
| 201 | } |
| 202 | |
| 203 | visitContainer(container: Container, context?: any): Container { |
| 204 | const children = container.children.map((n) => n.visit(this, context)); |
| 205 | return new Container(children, container.sourceSpan); |
| 206 | } |
| 207 | |
| 208 | visitIcu(icu: Icu, context?: any): Icu { |
| 209 | const cases: {[k: string]: Node} = {}; |
| 210 | Object.keys(icu.cases).forEach((key) => (cases[key] = icu.cases[key].visit(this, context))); |
| 211 | const msg = new Icu(icu.expression, icu.type, cases, icu.sourceSpan, icu.expressionPlaceholder); |
| 212 | return msg; |
| 213 | } |
| 214 | |
| 215 | visitTagPlaceholder(ph: TagPlaceholder, context?: any): TagPlaceholder { |
| 216 | const children = ph.children.map((n) => n.visit(this, context)); |
| 217 | return new TagPlaceholder( |
| 218 | ph.tag, |
| 219 | ph.attrs, |
| 220 | ph.startName, |
| 221 | ph.closeName, |
| 222 | children, |
| 223 | ph.isVoid, |
| 224 | ph.sourceSpan, |
| 225 | ph.startSourceSpan, |
| 226 | ph.endSourceSpan, |
| 227 | ); |
| 228 | } |
| 229 | |
| 230 | visitPlaceholder(ph: Placeholder, context?: any): Placeholder { |
| 231 | return new Placeholder(ph.value, ph.name, ph.sourceSpan); |
| 232 | } |
| 233 | |
| 234 | visitIcuPlaceholder(ph: IcuPlaceholder, context?: any): IcuPlaceholder { |
| 235 | return new IcuPlaceholder(ph.value, ph.name, ph.sourceSpan); |
| 236 | } |
| 237 | |
| 238 | visitBlockPlaceholder(ph: BlockPlaceholder, context?: any): BlockPlaceholder { |
| 239 | const children = ph.children.map((n) => n.visit(this, context)); |
| 240 | return new BlockPlaceholder( |
| 241 | ph.name, |
| 242 | ph.parameters, |
| 243 | ph.startName, |
| 244 | ph.closeName, |
| 245 | children, |
| 246 | ph.sourceSpan, |
| 247 | ph.startSourceSpan, |
| 248 | ph.endSourceSpan, |
| 249 | ); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | // Visit all the nodes recursively |
| 254 | export class RecurseVisitor implements Visitor { |
nothing calls this directly
no outgoing calls
no test coverage detected