// inlineAllCalls inlines all calls to the original function declaration // described by callee, returning the resulting modified file content. // // inlining everything is currently an expensive operation: it involves re-type // checking every package that contains a potential call, as reported by // References. In cases where there are multiple calls per file, inlineAllCalls // must type check repeatedly for each additional call. // // The provided post processing function is applied to the resulting source // after each transformation. This is necessary because we are using this // function to inline synthetic wrappers for the purpose of signature // rewriting. The delegated function has a fake name that doesn't exist in the // snapshot, and so we can't re-type check until we replace this fake name. // // TODO(rfindley): this only works because removing a parameter is a very // narrow operation. A better solution would be to allow for ad-hoc snapshots // that expose the full machinery of real snapshots: minimal invalidation, // batched type checking, etc. Then we could actually rewrite the declaring // package in this snapshot (and so 'post' would not be necessary), and could // robustly re-type check for the purpose of iterative inlining, even if the // inlined code pulls in new imports that weren't present in export data. // // The code below notes where are assumptions are made that only hold true in // the case of parameter removal (annotated with 'Assumption:') func inlineAllCalls(ctx context.Context, logf func(string, ...any), snapshot *cache.Snapshot, pkg *cache.Package, pgf *parsego.File, origDecl *ast.FuncDecl, callee *inline.Callee, post func([]byte) []byte) (map[protocol.DocumentURI][]byte, error) { … }