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

Summary: Patch for: Code completion for templates
Product: editor Reporter: Filip Zamboj <fzamboj>
Component: Completion & TemplatesAssignee: Dusan Balek <dbalek>
Status: RESOLVED FIXED    
Severity: normal CC: 11mb, culli, joshis, jrojcek, markiewb, mcinp
Priority: P3 Keywords: PATCH_AVAILABLE
Version: 6.x   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: Proposed patch
Patch in action

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: 
1. 
abbreviation: myclass
expanded text: myclass { __construct() {} } 
code completion will now offer myclass from template when you type mycla(ctr+space)

2. 
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 http://netbeans.org/bugzilla/show_bug.cgi?id=184604#c0 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.

http://hg.netbeans.org/jet-main/rev/9cde477eea86
Comment 10 Quality Engineering 2013-05-05 02:30:19 UTC
Integrated into 'main-golden', will be available in build *201305042300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/9cde477eea86
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #184604: Code completion for templates should use abbreviations as well - fixed.