Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 212176 - User defined abbreviation/code template is not shown in completion
User defined abbreviation/code template is not shown in completion
Status: RESOLVED DUPLICATE of bug 160771
Product: editor
Classification: Unclassified
Component: Completion & Templates
7.1.1
PC All
: P3 with 1 vote (vote)
: 7.4
Assigned To: Dusan Balek
issues@editor
:
: 221275 226162 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-08 08:45 UTC by emi
Modified: 2013-06-21 17:52 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description emi 2012-05-08 08:45:41 UTC
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?
Comment 1 Dusan Balek 2012-11-27 13:16:03 UTC
Originally, custom code templates were not intended to appear in code
completion. However, we can make it an enhancement for the next release.
Comment 2 Dusan Balek 2012-11-27 13:16:56 UTC
*** Bug 221275 has been marked as a duplicate of this bug. ***
Comment 3 Jiri Prox 2013-02-15 10:09:30 UTC
*** Bug 226162 has been marked as a duplicate of this bug. ***
Comment 4 markiewb 2013-06-20 12:57:37 UTC
@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)
Comment 5 Dusan Balek 2013-06-20 16:09:46 UTC
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 ***
Comment 6 markiewb 2013-06-21 14:32:44 UTC
(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.
Comment 7 Dusan Balek 2013-06-21 17:52:48 UTC
(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.


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