Skip to content

[AstAnalyser] Add initialize and finalize callback to manipulate SourceFile #268

Closed
@fraxken

Description

@fraxken

Current AstAnalyser as flaw when we want to manipulate the SourceFile class before or after walking the AST, here is an example where we add new custom tracing;

import { AstAnalyser } from "@nodesecure/js-x-ray";

const scanner = new AstAnalyser();

scanner.analyse("const foo = 'bar';", {
 initialize(sourceFile) {
   sourceFile.tracer.trace("...");
 },
 finalize(sourceFile) {
   // do something
 }
});

Those callbacks should be triggered before and after walking the AST

image

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions