Re: Looking for contributors as part of Apache incubation

"Wong, Christopher" <[email protected]> Wed, 1 Jul 2015 20:25:34 +0000
Newsgroups gmane.comp.web.freemarker.devel
Message-ID <539656908CC6F74DA205B033A4EA5EF872533FBA@PC1WEPSIEXDAG04.corp.epsilon.com>
I agree that introspection is a tricky business. So far, I have adopted your recommendation to use the package local TemplateObject.getParameterCount/getParameterValue accessors, but that works as long as Freemarker is kind enough to expose the AST.

These are the major things I'm doing with freemarker-introspection:
- identify custom directives (UnifiedCalls) and their params
- identify variables used
- replace specific elements with something else (takes advantage of begin/end line/column properties)

Your parser plugin proposal might work for me, if it supplies enough information. I could build my own AST as Freemarker does its thing. Of course, that pretty much means I'd have to rewrite freemarker-introspection. This will hopefully be a longer-term thing so I have time to do this. But there could be some uses of freemarker-introspection that I could reimplement using the ParserPlugin mechanism instead.

Chris

-----Original Message-----
From: Daniel Dekany [mailto:[email protected]]
Sent: Saturday, June 06, 2015 8:26 PM
To: Wong, Christopher
Cc: Daniel Dekany
Subject: Re: [Freemarker-devel] Looking for contributors as part of Apache incubation

I'm still not sure what will be done about this (I mean whole topic of detailed introspection). Right now, what I'm think of is that at some point (even 2.3.24) I will add something like ParserPlugin, which is something the user could specify on the Configuration level (maybe per template name pattern). That means that a parser plugin can participate in the parsing, because it was there before the template parsing was started. This already eliminates some compatibility risks (like what if Template-s won't contain an AST anymore, but generated byte code for example - this can work even then). The plugin could attach arbitrary attributes to the template (see custom attributes) to store plugin output (if any), or even change the template.

So how does is make backward compatibility easier (apart from what was already said above)? For now the user couldn't define custom plugins... FM itself (or some additional optional artifacts) would, define some plugins that cover the most frequent needs, and the user only has the power to chose among these plugins. Two frequent things that we could solve with a plugin are:

- Collecting the names of maybe-data-model variables used (to find out the
  requires data-model variables for a template)

- Collecting the includes/imports (to analyze which template depends on
  which)

So this hopefully somewhat alleviates the need for more detailed template introspection (such as walking the AST), while we haven't exposed much from the internals (and hence from the things that we may want to change later).

What exactly was template introspection used for in your use case?

BTW, a plugin that I will make is the interruptible template plugin. A template to which that plugin was associated will support
Thread.interrupt() on the running template. This functionality (template interruptability) is already present in 2.3.22, but is only accessibly through internal API-s, and is used on freemarker-online to automatically abort long running templates.

--
Thanks,
 Daniel Dekany


Tuesday, June 2, 2015, 5:12:52 PM, Wong, Christopher wrote:

> Concerning the "public template introspection API", I'd like to
> provide an update on my freemarker-introspection project:
>
> https://github.com/cwong15/freemarker-introspection
>
> I've updated the code to support the latest Freemarker (2.3.22). To
> inspect the parsed Freemarker AST, it now uses package-local access
> instead of reflection for more robust Freemarker compatibility. I'm
> open to recommendations on how to progress towards making this part
> of the Freemarker project somehow.
>
> Chris
>
> -----Original Message-----
> From: Daniel Dekany [mailto:[email protected]]
> Sent: Saturday, May 30, 2015 6:21 AM
> To: [email protected]
> Subject: [Freemarker-devel] Looking for contributors as part of Apache incubation
>
> We are (or mostly, I'm) trying to move FreeMarker over to the
> Apache Software Foundation. So far the reaction is mostly positive
> on Apache's side, but, the major concern is the low number of active
> contributors. If everything goes well, there will be a voting about
> letting FreeMarker in into the Apache *Incubator*, where it will
> have to build up some kind of community or else it will fail. OTOH
> the main reason I want FM to be an Apache project is exactly to
> improve chances of finding contributors, especially long term ones like myself.
> Obviously, one man (me) is not very safe for the users (like what
> if something happens with me, or I just move on).
>
> So, I just wonder if I can expect anyone to join the incubation
> when and if it will be started. There's lot of interesting but
> difficult tasks to do. Like better automatic escaping, a new parser
> that's more IDE friendly and faster and has better error messages,
> proper support of Map-s with non-string keys, better null handling,
> advanced white-space removal, better caching, better i18n,
> supporting custom "dialects" (i.e., changing the set of built-ins
> and built-in directives), public template introspection API, better
> debugging, Android support, and many more. It was just a glimpse.
> There's a lot of space for advancement.
>
> --
> Best regards,
>  Daniel Dekany


________________________________

This e-mail and files transmitted with it are confidential, and are intended solely for the use of the individual or entity to whom this e-mail is addressed. If you are not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you are not one of the named recipient(s) or otherwise have reason to believe that you received this message in error, please immediately notify sender by e-mail, and destroy the original message. Thank You.

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/