Generate code in onAfterTyping

A bit of background: I am trying to generate code in the Context.onAfterTyping call (because of the rich amount of information available at that point) with an approach similar to the one described here: Google Groups

What this basically comes down to is that in code I use an extern class with a :native meta tag. In the Context.onAfterTyping call I can then use Context.defineType to define a different type with the same :native meta tag. On runtime the generated type is used.

I am using VSCode in combination with the completion server and I am running into the issue that it appears that the cache determines that because the code file has changed it does not need to run the macro and as a result the Context.defineType is not called. It appears that because of this the type is not generated and therefore also not outputted.

Another thing is that because this approach replies on the :native being the same you cannot easily use DCE. I was therefore wondering whether there is another approach to achieving this?