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 184604 - Patch for: Code completion for templates
Summary: Patch for: Code completion for templates
Alias: None
Product: editor
Classification: Unclassified
Component: Completion & Templates (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 normal with 4 votes (vote)
Assignee: Dusan Balek
: 108180 129278 194734 (view as bug list)
Depends on:
Reported: 2010-04-21 12:15 UTC by Filip Zamboj
Modified: 2013-05-05 02:30 UTC (History)
6 users (show)

See Also:
Exception Reporter:

Proposed patch (5.41 KB, patch)
2013-01-30 23:01 UTC, markiewb
Details | Diff
Patch in action (73.57 KB, image/png)
2013-01-30 23:04 UTC, markiewb

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Zamboj 2010-04-21 12:15:14 UTC
code completion for templates shouldn't use expanded text only but should use abbreviation as well.

example of template: 
abbreviation: myclass
expanded text: myclass { __construct() {} } 
code completion will now offer myclass from template when you type mycla(ctr+space)

as stated in BUG 183547 you "run into troubles" once you change expanded text on something else then myclass. 
abbreviation: myclass
expanded text: 
 * @author PHP Super Trooper Coder 
myclass { __construct() {} } 
you have no chance to get this in code completion
Comment 1 Vitezslav Stejskal 2010-05-18 10:21:27 UTC
Makes sense to me. Perhaps CC could offer any template containing the text typed in the editor and not just those that start with the text. A reasonable ordering of these suggestions would be neccessary of course. Or maybe these inexact templates might not be offered in the smart CC. Just random thoughts...
Comment 2 markiewb 2013-01-30 23:01:26 UTC
Created attachment 130859 [details]
Proposed patch

I like to propose a patch for this issue.

* completion now works with the abbreviation (as prefix) - as requested
* completion based on parameterized text has been removed (made no sense for me - see point 2.)
* no contexts are supported anymore (made no sense for me too)

@NetBeans-Devs: Please review, discuss and commit... Thank you
Comment 3 markiewb 2013-01-30 23:04:30 UTC
Created attachment 130860 [details]
Patch in action
Comment 4 markiewb 2013-01-31 08:27:17 UTC
*** Bug 194734 has been marked as a duplicate of this bug. ***
Comment 5 Dusan Balek 2013-01-31 13:54:51 UTC
Comments to the proposed patch:
- I'm not sure that using the template abbreviation as the code completion prefix is always better than the expanded text prefix (e.g. typing 'Sy(ctrl+space)' inside method body, code template 'System.out.println()' with abbreviation 'sout' would not be proposed)
- as for contexts - makes sense for me not to propose e.g. "protected void method()" outside of a class or inside of another method body.

Anyway, I think that the NB integration of code templates and code completion deserves a deeper redesign (currently planned for the next release hopefully).
Comment 6 markiewb 2013-03-03 23:19:19 UTC
*** Bug 108180 has been marked as a duplicate of this bug. ***
Comment 7 markiewb 2013-03-03 23:20:19 UTC
*** Bug 129278 has been marked as a duplicate of this bug. ***
Comment 8 markiewb 2013-03-03 23:20:53 UTC
*** Bug 167108 has been marked as a duplicate of this bug. ***
Comment 9 Dusan Balek 2013-05-03 06:39:19 UTC
Fixed in jet-main. Abbreviations should be used together with parameterized text prefix.
Comment 10 Quality Engineering 2013-05-05 02:30:19 UTC
Integrated into 'main-golden', will be available in build *201305042300* on (upload may still be in progress)
User: Dusan Balek <>
Log: Issue #184604: Code completion for templates should use abbreviations as well - fixed.