Using FreeMarker extension points


I'm writing a plugin which needs to contribute implicit variables to FreeMarker templates. I've found the 'FtlGlobalVariableProvider' class which can be extended and registered under the 'freemarker.globalVariableProvider' extension point.

But I'm not sure how to create the FtlXXX variables. I've tried this:

    public List<? extends FtlVariable> getGlobalVariables( FtlFile ftlFile )
        FtlImplicitVariable languages = new FtlImplicitVariable( null, "languages", ftlFile );
        languages.addSubVariable( "en" );
        return Arrays.asList( languages );

This code throws an NPE because I'm passing 'null' as the PsiComment parameter to FtlImplicitVariable - how do I create a PsiComment?

Please sign in to leave a comment.