I don't know if the current Demetra API allows for this, but it would be nice if:
-When I do "Extract Variable" on ctx.get('foo"), the refactoring would get type information from the context, and suggest variable types, and create a valid cast.
Similar functionality is present when using "itco" and other live templates - IDEA infers the type and adds the right cast. (using 1.4 lang level)