[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [platform-text-dev] template formatting
|
John-Mason,
great you're already using the template stuff - when you update, you'll
notice that I have changed quite a lot of the code again for M8, so you
will likely see compile errors.
The most prominent new feature is that templates, context types, and
variable resolvers can be contributed via XML now (see the templates
extension point in org.eclipse.ui.editors). I will add a very basic XML
editor example based on the PDE "plug-in with an editor" example project
to the example java editor project today.
About the formatting: This is something the template context is
responsible for, since there may be many different context types in a
document (context types map to partitions in many ways) that have
different formatters. A template context contains all the information
needed to evaluate a template at a specific location in a document.
For an example, the JavaContext does that already: it formats (well, it
tries to...) a code template when it evaluates it. So, when you add your
Ant context type, you might add a specific AntContext which will extend
the default TemplateContext with formatting capabilities.
-tom
Shackelford, John-Mason wrote:
Tom,
We've used the newly pushed down template code to add rudamentry template
support to the ant editor via code assist and an extension point. We used
the following classes in our solution: ContextType, DocumentTemplateContext,
Template, TemplateContext, TemplateProposal.
I now need to format the templates to correct the indendentation, etc.
Since formatting a template upon insertion will be required by most users of
the the template framework I seems to me we ought to add support for this in
the template API. It appears that the work of actually inserting the
template is done with TemplateProposal.apply(ITextViewer,char,int,int). What
do you think about adding a method to the TemplateProposal object such as
setTemplateFormatter(TemplateFormatter) which would allow the apply method
to format the template as part of the insertion. The apply method might
check to see if a formatter has been set and then call
TemplateFormatter.format(ITextViewer (or IDocument), int offset,
TemplateBuffer) or something to that effect. This is a fairly simple and
unobtrusive implementation that would likely be handy for most users of the
framework.
What do you think?