NB code templates at /Tools/Options/Editor/Code Templates gives use predefined templates and the option for creating
Now reproduce as follows:
1. Open /Tools/Options/Editor/Code Templates
2. Set Language to PHP
3. Click New
4. Type "mytemplate" as abbreviation
5. Click OK
6. Type "This is my template text" in the Expanded Text tab
7. Click OK at the bottom of the window
8. Back in the editor delete the typed "for" from the method body
9. Type "mytemplate" and invoke the code completion "Ctrl+Space"
What we get is "No suggestions". Sigh :-(
What I expected was the same behavior as for the built-in templates. For me it also does not make much sens to have a
hugh stack of custom code templates and have to remember each and every abbreviation to be able to expand it with TAB
or whatever. Because please reproduce as follows:
1. Delete the typed "mytemplate" from the method body
2. Retype "mytemplate" and press "TAB"
What we get is "This is my template text". This shows us that the IDE is perfectly aware of the custom code templates
but for some reason the code completion is not.
(this was resolved in https://netbeans.org/bugzilla/show_bug.cgi?id=160771#c14 for java) But not for PHP)
Please, I would really appreacite if this is done for PHP as well. Since We as developers use a lot code completion.
Thanks a lot
More a bug if the API already exists and it is used in Java - Ondro, please evaulate, thanks.
Thanks for reporting.
Created attachment 157320 [details]
I've created a patch.
Created attachment 157321 [details]
A custom code template will be shown in the CC popup if you check the "php-code" in the Contexts tab.
Tomas, Because "php-code" is used as contexts in the default templates file, I just used it.
Will try to get to your patches ASAP, sorry I am quite busy now :/. Likely till the end of the next week.
Thanks for understanding.
(In reply to Tomas Mysik from comment #5)
> Will try to get to your patches ASAP, sorry I am quite busy now :/. Likely
> till the end of the next week.
Anytime is OK for me :)
*** Bug 256553 has been marked as a duplicate of this bug. ***
Please take note that as I wrote here
the problem is not only about PHP, it involves also the other web related languages, such as HTML, JS, etc.
(In reply to riksoft from comment #8)
> Please take note that as I wrote here
> the problem is not only about PHP, it involves also the other web related
> languages, such as HTML, JS, etc.
Probably, you should report it to each language support. Thanks.
OK, I've changed the scope from product PHP to Editor and Component="Complations & Templates".
(In reply to riksoft from comment #10)
> OK, I've changed the scope from product PHP to Editor and
> Component="Complations & Templates".
Because this feature already exists in the editor area, each language support has to implement it.
Patch applied, thanks a lot for it, Junichi! The only change I made was to set proper library version to be used.
Integrated into 'main-silver', will be available in build *201511210002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Tomas Mysik <firstname.lastname@example.org>
Log: #246664 - Custom Code Templates and Code Completion for PHP
Patch contributed by email@example.com.
I blogged about it: https://benkiew.wordpress.com/2016/01/07/quicktip-how-to-display-your-own-php-code-templates-in-the-code-completion-of-netbeans-ide/
*** Bug 257229 has been marked as a duplicate of this bug. ***