Re: Continue Eclipse Freemarker DLTK?

Angelo zerr <[email protected]> Mon, 29 Jul 2013 15:57:38 +0200
Newsgroups gmane.comp.web.freemarker.devel
Message-ID <CAKLdLg-BqiZP3HZQ_k_QiP3juVz2jTU1_=H2y3jYh+ygXVYeNA@mail.gmail.com>
Hi Daniel,

Actaully, those two things are independent of each other. Regardless
> if when I accept that patch, we should do this in its own branch. It's
> just the usual thing with longer features that may not reach stable
> state until the next release (2.3.21).
>
> [snip]
>

OK, so I think branch should be named with *-debug or* -tools becaus it's
not linked to dltk.
I would like that Freemarker improves :

 * debugger (add any debugger service, add stepping features, fix bug with
debug unsert ftl (Breakpoint should stores too filename (the full path of
the template)).
 * syntax errors (add start/end offset info of the token) parser should be
tolerant to displays several errors and build an AST even if they are
errors.


> > If you are OK with my patch, we could discuss how to inject with
> > properties like system property as you have explained.
>
> I guess static DebuggerService.getInstance(), when first called,
> should check the "freemarker.debug.debuggerService" system property,
> which had to be something like "new
> com.example.SomeDebuggerService(true) { password = 'qweqwe', port =
> 1234 }" (where the { ... } section sets JavaBeans properties). (This
> also means that we don't need extra properties like
> "freemarker.debug.password".)
>
> You may wonder what will interpret that fancy property value syntax. I
> will have to implement a such mini-language for the FreeMarker
> settings API in 2.3.21 anyway, so when it's done, we could just re-use
> that. (Until that, just so it's not a blocker, it could be just be
> interpreted as class name, and it's expected that the class has a
> no-arg consturctor.)
>

IMHO, I'm not a big fan to set a system property valeu which contains some
java code  "new
com.example.SomeDebuggerServic.."

I think we should have a DebuggerServiceRegistry which is enable to returns
an instance of DebuggerService
according configuration.

I havei mplemented this idea in my private commit
https://github.com/angelozerr/freemarker/commit/fb604a707e7d88e98f19bd0f40cbccce03080e19

by using SPI like I have suggested you.

You can see test at
https://github.com/angelozerr/freemarker/blob/fb604a707e7d88e98f19bd0f40cbccce03080e19/src/test/java/freemarker/debug/DebuggerServiceRegistryTest.java

The basic idea is to register debugger service provider with SPI and get
the well debugger provider according the system properties by calling
DebuggerServiceRegistry#getService() .
The Configuration#getDebuggerService() checks fi there are debugger service
setted (usefull for IDE) and if it's null,  use
DebuggerServiceRegistry#getService() .

If you like it, I will clean my code and create a pull request.

Regards Angelo


> > With Java5 we can use SPI services to register debugger service,
>
> I'm not sure how/why the SPI feature is useful in this case. You
> probably don't want to enumerate available implementations. But you
> will want to pass parameters to the implementation (like port number),
> and the SPI API doesn't help in that, if I'm not mistaken. So you do
> that with system properties, I guess, but if you have to set
> properteis anyway (which often also assumes that you know ahead which
> implementation will be chosen), then why not just use
> "freemarker.debug.debuggerService", where you explictly specify the
> class name too.
>
> > it could be a good idea (doesn't work with java 1.4, but is it a
> > problem?)
>
> That's not a problem. Maybe we will have to pull some reflection
> tricks (as with all other optional features), but that's all.


> > Regards Angelo
> >
> > --
> > Thanks,
> >  Daniel Dekany
> >
> >
> >>> Regards Angelo
> >>>
> >>>
> >>> --
> >>> Thanks,
> >>>  Daniel Dekany
> >>>
> >>>> Last night I have switched to FM 2.3 (the Ouline doesn't work
> >>>> because I have commented code about DLTK ASTNode). See
> >>>>
> https://github.com/angelozerr/Freemarker-Eclipse-DLTK/commit/915952c3eec28a4531a54edacc7e33cb88993f18
> >>>>
> >>>> I have removed FM 3.0 bundle (org.freemarker.freemarker) and
> >>>> replaced with FM 2.3. As 2.3 is an OSGi bundle, I use it directly as
> >>>> OSGi bundle (you can see in action that OSGi with FM seems working).
> >>>>
> >>>> You must build the freemarker.jar and set in the
> >>>> TargetPlatform/plugins
> >>>>
> https://github.com/angelozerr/Freemarker-Eclipse-DLTK/tree/master/TargetPlatform/plugins
> >>>> if you wish to use the version from Git master.
> >>>>
> >>>> Now I would like to work on the debugger. I will create a new topic
> about the debugger.
> >>>>
> >>>> Regards Angelo
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> 2013/7/26 Daniel Dekany <[email protected]>
> >>>> Friday, July 26, 2013, 12:28:19 AM, Angelo zerr wrote:
> >>>>
> >>>>>> What do you mean by "manage with 2.3"?
> >>>>>
> >>>>> I mean that DLTK Freemarker will use FM 2.3 and not 3.0
> >>>>
> >>>> Sure.
> >>>>
> >>>>>> You want to modify FM, or it's plugin development only?
> >>>>>
> >>>>> My first step is just modify or comments code of DLTK Freemarker.
> >>>>>
> >>>>> After I would like contribute with my code
> >>>>>
> https://github.com/angelozerr/Freemarker-Eclipse-DLTK/tree/master/freemarker.provisionnal/src/freemarker/provisionnal
> >>>>> to FM to improve debugger and contribute to FM tools.
> >>>>>
> >>>>>> I'm OK with both, except that you will have
> >>>>>> to send a signed Contributor License Agreement for modifying FM
> >>>>>> itself.
> >>>>>
> >>>>>> In last past I had send a CLA to Atila (to commit in the svn FM),
> is not enough?
> >>>>
> >>>> That's enough. Sorry for the confusion, it's just that I don't have a
> >>>> copy of that here for some reason... never mind.
> >>>>
> >>>>> Regards Angelo
> >>>>>
> >>>>> --
> >>>>> Thanks,
> >>>>>  Daniel Dekany
> >>>>>
> >>>>>
> >>>>>> Regards Angelo
> >>>>>>
> >>>>>>
> >>>>>> 2013/7/25 Daniel Dekany <[email protected]>
> >>>>>> Thursday, July 25, 2013, 4:40:28 PM, Angelo zerr wrote:
> >>>>>>
> >>>>>>> Hi Daniel,
> >>>>>>>
> >>>>>>> OK I understand why you don't want expose the AST API. Thank's for
> your information.
> >>>>>>>
> >>>>>>> The DLTK ASTNode is used for several features like folding,
> >>>>>>> refactoring, search, codeassist.
> >>>>>>>
> >>>>>>> You can read info about ASTNode at
> >>>>>>> http://wiki.eclipse.org/DLTK_Core_Architecture
> >>>>>>> It's difficult for me to tell you now which info are required  to
> >>>>>>> build a DLTK ASTNode.
> >>>>>>
> >>>>>> Then, to start somewhere... I think, org.freemarker:tooling will
> give
> >>>>>> you an abstract FTLVisitor class, which however will only have two
> >>>>>> kind of visit-s for now: visit(ElementInfo) and
> visit(ExpressionInfo).
> >>>>>> (That's so that the plugin or other tools won't assume that they
> know
> >>>>>> all the directives and expression types.) (Note that the 3.0 API
> >>>>>> didn't visit expressions at all, only elements.) And then I start
> >>>>>> adding properties to these XxxInfo-s as the need arises. Like,
> >>>>>> isFoldable(), isOutlineNode and getOutlineNodeLabel for starters.
> The
> >>>>>> initial "accept" method of the tools API could have a Query object
> (a
> >>>>>> JavaBean again) as parameter, in which you can specify what are you
> >>>>>> interested in (like, folding and/or outline nodes and/or variables
> >>>>>> used, etc). So as you move ahead, we will see if it's appropriate at
> >>>>>> all. And of course I'm open for suggestions.
> >>>>>>
> >>>>>>> I will try to switch to 2.3 and I will see what we need.
> >>>>>>>
> >>>>>>> My work about AST was very simply (I have just managed #assign in
> >>>>>>> the AST to display the variable name of assign in the Outline
> View).
> >>>>>>> But perhaps for Freemarker, the Outline View should display more
> >>>>>>> info like JBoss IDE
> >>>>>>
> >>>>>> JBoss IDE's outline is useless IMAO. It shows far too much. After
> all,
> >>>>>> the goal of an outline view is to show you a summary that's good for
> >>>>>> navigation (among others). Although I'm not entirely sure how the
> >>>>>> outlook should look. It has to show #macro and #function, and that's
> >>>>>> already useful, but what else?
> >>>>>>
> >>>>>>> and your idea about freemaker-tool.jar is perhaps a good idea.
> >>>>>>
> >>>>>> (I wonder what's the proper term is. "tooling" or "tools"? Like
> >>>>>> "FreeMarker Tooling API" or "FreeMarker Tools API"... or even
> >>>>>> "tool-helpers"...)
> >>>>>>
> >>>>>>> I have not experimented a lot the capability of the DLTK ASTNode
> >>>>>>> but at the end of the
> http://wiki.eclipse.org/DLTK_Core_Architecture
> >>>>>>> it says "Use of the DLTK AST is not mandatory, but some DLTK
> >>>>>>> features like folding may rely on it and it can greatly simplify
> implementation."
> >>>>>>>
> >>>>>>> For the completion (interpolation) I don't use the ASTNode but I
> >>>>>>> think I should to use it (so I need a more complex AST).
> >>>>>>
> >>>>>> For that you need the variable names used, in a hierarchy. Like, on
> >>>>>> the top-level you have "user" and "department", but after "user."
> the
> >>>>>> possibilities are different, like "user.name" etc. If DLTK can
> extract
> >>>>>> such info from the AST, we might as well add that in ExpressionInfo.
> >>>>>> Also there's the case where some of the data-model variables has a
> >>>>>> known class (that's not a FreeMarker feature).
> >>>>>>
> >>>>>>> So I must switch to 2.3, my first idea is to try to remove the use
> >>>>>>> of DLTK ASTNode an dmanage other features like syntax errors and
> debug.
> >>>>>>>
> >>>>>>> Regards Angelo
> >>>>>>
> >>>>>> --
> >>>>>> Thanks,
> >>>>>>  Daniel Dekany
> >>>>>>
> >>>>>>
> >>>>>>
> ------------------------------------------------------------------------------
> >>>>>> See everything from the browser to the database with AppDynamics
> >>>>>> Get end-to-end visibility with application monitoring from
> AppDynamics
> >>>>>> Isolate bottlenecks and diagnose root cause in seconds.
> >>>>>> Start your free trial of AppDynamics Pro today!
> >>>>>>
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> >>>>>> _______________________________________________
> >>>>>> FreeMarker-devel mailing list
> >>>>>> [email protected]
> >>>>>> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
> >>>>>>
> >>>>>
> >>>>>
> >>>>
> >>>> --
> >>>> Thanks,
> >>>>  Daniel Dekany
> >
> >
> >
> ------------------------------------------------------------------------------
> > See everything from the browser to the database with AppDynamics
> > Get end-to-end visibility with application monitoring from AppDynamics
> > Isolate bottlenecks and diagnose root cause in seconds.
> > Start your free trial of AppDynamics Pro today!
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> > _______________________________________________
> > FreeMarker-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/freemarker-devel
> >
>
> --
> Thanks,
>  Daniel Dekany
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> FreeMarker-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk

_______________________________________________
FreeMarker-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel