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 206413 - Code template will not expand outside class method
Summary: Code template will not expand outside class method
Status: VERIFIED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.1
Hardware: All All
: P3 normal with 2 votes (vote)
Assignee: Ondrej Brejla
URL:
Keywords: REGRESSION
: 200359 205750 205968 207279 208180 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-12-15 00:24 UTC by ptrwrsm
Modified: 2012-03-06 18:53 UTC (History)
9 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ptrwrsm 2011-12-15 00:24:44 UTC
Product Version: NetBeans IDE 7.1 RC2 (Build 201111302200)
Java: 1.6.0_29; Java HotSpot(TM) 64-Bit Server VM 20.4-b02-402
System: Mac OS X version 10.6.8 running on x86_64; MacRoman; en_US (nb)


When you try to insert/execute a code template inside the class declaration, it will not expand the template. If you, however, execute the template inside the method, it does work.

With a template name "mapper:save" (and expand template on [TAB]), the following WILL NOT work:

class A {
  mapper:save[TAB]
}


And the following WILL work:

class A {
  public function b() {
    mapper:save[TAB]
  }
}
Comment 1 Ondrej Brejla 2012-01-25 14:14:00 UTC
*** Bug 205968 has been marked as a duplicate of this bug. ***
Comment 2 Ondrej Brejla 2012-01-25 14:14:04 UTC
*** Bug 205750 has been marked as a duplicate of this bug. ***
Comment 3 Ondrej Brejla 2012-01-25 14:14:06 UTC
*** Bug 207279 has been marked as a duplicate of this bug. ***
Comment 4 Ondrej Brejla 2012-01-25 14:54:40 UTC
Fixed in web-main: http://hg.netbeans.org/web-main/rev/0ff1b19b4ae7
Comment 5 Quality Engineering 2012-01-26 16:10:39 UTC
Integrated into 'main-golden', will be available in build *201201260600* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/0ff1b19b4ae7
User: Ondrej Brejla <obrejla@netbeans.org>
Log: #206413 - Code template will not expand outside class method
Comment 6 activ 2012-01-29 22:32:30 UTC
i still have that issue on nb nigtly 201201260600.

i saw you marked few bugs as duplicate. i dont think it was, becouse it depends somehow on nb background state (i dont know details). what i mean: in exacly same context, sometimes Code template works, and sometimes not. exacly same context mean same file, cursor placement etc.

what i noticed also: i have CT expand on space press. when i type "sthsthsth" and hit space, there is no laq. but when i type some of code template for example "vd"  (should expand to var dump) i feel some kind of laqy. but then nothing happens.
Comment 7 Monomachus 2012-01-30 15:44:50 UTC
Product Version: NetBeans IDE Dev (Build 201201260600)
Java: 1.6.0_30; Java HotSpot(TM) Client VM 20.5-b03
System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)

Encountering the same problem. 
Can be tested with my set of code templates for Symfony2.
https://github.com/Monomachus/Symfony2CodeTemplates/downloads

You can just try to type in a PHP class
action - code template should generate something like this:
public function ${name}Action(${cursor}
Comment 8 Ondrej Brejla 2012-02-06 10:25:39 UTC
Vlado, please, can you verify this patch candidate? Just create your custom code template and try to expand it in some class definition. Thanks!
Comment 9 Vladimir Riha 2012-02-06 11:53:07 UTC
The bug (partially) still exists. 

To reproduce create new empty project (PHP 5.3/5.4) and in index.php declare new class and type "my_fa" and hit TAB. Code template should be inserted but it's not. If you repeat the same in function, it works.

I've noticed that If I create custom template, then it works just fine inside the class declaration. I even copied the content of "Expanded text" of the "my_fa" to custom new template and it also works.



Product Version: NetBeans IDE Dev (Build 201202060400)
Java: 1.7.0_03; Java HotSpot(TM) Client VM 22.1-b02
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Comment 10 Ondrej Brejla 2012-02-06 12:35:49 UTC
But I think, that it's the right behavior. Because "my_fa" is a template for a while cycle...and it can't be used in class declaration (only "fnc" and "fcom" can be used there). But all custom templates are allowed everywhere, because there is no possibility to set the right context in the UI.
Comment 11 Vladimir Riha 2012-02-06 12:47:21 UTC
OK, v.
Comment 12 Monomachus 2012-02-06 13:52:14 UTC
Can I test it somehow?
Comment 13 Ondrej Brejla 2012-02-06 13:55:33 UTC
It's in dev builds.
Comment 14 Monomachus 2012-02-06 15:11:31 UTC
Works for me too.
Comment 15 Monomachus 2012-02-07 13:36:20 UTC
It is reproducible in .twig files. 
I added a custom code template

block

{% block ${name} %}
    ${cursor}
{% endblock %}

And now when I try to type block and press Tab key, 
nothing is happening.
Comment 16 Ondrej Brejla 2012-02-07 13:38:16 UTC
It's issue of twig templates...it's another file type.
Comment 17 Quality Engineering 2012-02-08 02:33:02 UTC
Integrated into 'releases', will be available in build *201202072200* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/36822f922938
User: Ondrej Brejla <obrejla@netbeans.org>
Log: #206413 - Code template will not expand outside class method
(transplanted from 0ff1b19b4ae78ed35457281e59736c977b7de658)
Comment 18 Ondrej Brejla 2012-02-09 09:24:18 UTC
*** Bug 208180 has been marked as a duplicate of this bug. ***
Comment 19 BullfrogBlues 2012-02-12 02:50:17 UTC
*** Bug 200359 has been marked as a duplicate of this bug. ***
Comment 20 Vladimir Riha 2012-02-13 12:13:58 UTC
verified 7.1.1

Product Version: NetBeans IDE 7.1.1 (Build 201202122200)
Comment 21 hinson0 2012-03-01 02:24:49 UTC
all is ok!~thank you!~i love you.version 7.1.1 is very very good!~i love it
Comment 22 BullfrogBlues 2012-03-06 18:53:49 UTC
Nice fix guys. Verified 7.1.1