Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 123004 - Generalize the Templates mechanism for code snippets also
Generalize the Templates mechanism for code snippets also
Product: platform
Classification: Unclassified
Component: Templates
All All
: P3 (vote)
: 7.4
Assigned To: Martin Entlicher
Depends on:
  Show dependency treegraph
Reported: 2007-11-28 18:56 UTC by _ sandipchitale
Modified: 2013-09-02 12:48 UTC (History)
2 users (show)

See Also:


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:

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 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
Comment 2 Martin Entlicher 2013-09-02 12:48:55 UTC
This is already possible.
See Java -> Code Snippets.

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo