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.
It seems some of the code templates do show up in completion (eg, whileit) but anything user-defined is ignored. The code template works by pressing tab but it's not shown in the code completion popup like abbreviations used to. The problem seems to be this line from CodeTemplateCompletionProvider: if (ct.getContexts() != null && ct.getContexts().size() > 0 && accept(ct, filters)) and the problem is that user-defined code templates have no contexts. The other problem is the even if I could define a context (which is not documented btw, but for Java seems to be Tree.Kind) there is no "global" context. How do I define an abbreviation that's visible all the time in the completion popup?
Originally, custom code templates were not intended to appear in code completion. However, we can make it an enhancement for the next release.
*** Bug 221275 has been marked as a duplicate of this bug. ***
*** Bug 226162 has been marked as a duplicate of this bug. ***
@Dusan: Any news here? Will this be fixed in 7.4? Proposed behavior: When there are contexts configured, then show them in CC only for the specific contexts. (current behavior) When there are no contexts configured, then show them in CC for every context. (new additional behavior)
Customizer to specify contexts for user-defined code templates is already implemented. To prevent UI cluttering of the code completion list, only those templates that have their respective contexts specify are displayed. See issue #160771 for more details. *** This bug has been marked as a duplicate of bug 160771 ***
(In reply to comment #5) > Customizer to specify contexts for user-defined code templates is already > implemented. To prevent UI cluttering of the code completion list, only those > templates that have their respective contexts specify are displayed. See issue > #160771 for more details. > > *** This bug has been marked as a duplicate of bug 160771 *** @Dusan: I understand your intention and respect it. But I have a doubt that the standard end user will have the knowledge to select the correct context. Does the user really has to know the internal language structure (token a.s.o) to make his simple code snippet appear in code completion? Do not hide IMHO useful features. How about a compromise? Add an option to "Options|Editor|Code Completion" and let the user decide if he wants to see those templates in CC. Name the option like "Show Custom Code Templates In Code Completion"/"Show Code Templates Without Context In Code Completion". I would also provide a patch if you want me to. What do you think? Thanks for your time and have a nice weekend.
(In reply to comment #6) I understand your point, however I don't think the "Show Code Templates Without Context In Code Completion" option would be a good solution. We have to somehow mark templates to be displayed in code completion selectively on per template basis. You really don't want all code templates to be displayed in code completion at once in all possible places. We have already tried. That was in fact the main reason for introducing contexts.