Is it possible to add custom nodes to parse tree after the fact?

I am working on a feature that requires parsing of user code, and then performing some limited semantic analyses on the parsed code. For example, we want to check whether particular function applications use correct number and type of arguments. Say, a specific function can take only one argument of type list. We need to check that and highlight any incorrect arguments. They can be either arguments that are missing or ones that should not be present, or ones of wrong types. I think it would be convenient to modify the parse tree to include information about these errors. For example, create error nodes for the arguments that are missing so that I could render them later as placeholders or whatever. The question is whether it is possible to add custom nodes to a parse tree? Any other advice about how to best handle this? So far the only solution that I see is to create my own tree from the parse tree and work with that instead. It is just that I want to avoid traversing the original parse tree just to create my own structure…

No, that’s not something Lezer is built for. The general solution to keeping metadata about parts of a document in CodeMirror is range sets, but I’m not sure that will fit your problem here.