This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 123004 - Generalize the Templates mechanism for code snippets also
Summary: Generalize the Templates mechanism for code snippets also
Status: RESOLVED WORKSFORME
Alias: None
Product: platform
Classification: Unclassified
Component: Templates (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-28 18:56 UTC by _ sandipchitale
Modified: 2013-09-02 12:48 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ sandipchitale 2007-11-28 18:56:45 UTC
Currently the Templates/ folder in the SFS stores the files that are used to instantiate complete files. However there
is an emergent use case for creating templates for snippets of code. For example see the Add Property module's use of
the template:

http://www.netbeans.org/source/browse/contrib/AddProperty/src/org/netbeans/modules/java/addproperty/AddProperty.freemarker

which uses the now available powerful mechanism of scripting based template instantiation to create the snippets of java
code while generating the property. I want to allow the user to edit this template using the Template manager
mechanism...for that I set the attribute template to true...so that it appears in the template manager. However that
makes the template appear in the New file wizard. Therefore an additional mechanism needs to be supported to store the
templates with say an attribute partial=true or something like that which are excluded from the New File wizard.

Using the new mime-path based lexer functionality could be used to do syntax colouring of template files e.g. java with
embedded freemarker and so on.

Lastly every time NetBeans does any code generation e.g. Alt+Insert in Java editor (Generate Getter, Setter, Getter and
Setter and so on...) it should be based on templates. That way the user will be able to customize the generated code.
The abbreviations could also be stored in a similar fashion and use the same mechanism. Of course the templates could
clearly indicate the required parameters in a scripting language comment block (possibly in a read only editor fold).
The read only editor folds/sections could be used in templates to disallow modification of required parts of the template.
Comment 1 rmichalsky 2009-06-16 12:55:56 UTC
Reassigning
Comment 2 Martin Entlicher 2013-09-02 12:48:55 UTC
This is already possible.
See Java -> Code Snippets.