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 200359 - PHP code templates inside classes do not work outside of function scope
Summary: PHP code templates inside classes do not work outside of function scope
Status: RESOLVED DUPLICATE of bug 206413
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.0
Hardware: Macintosh (x86) Mac OS X
: P2 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-25 14:24 UTC by gsnerf
Modified: 2012-02-12 02:50 UTC (History)
2 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 gsnerf 2011-07-25 14:24:31 UTC
Hi,

I noticed that in the mac version one cannot use php code templates inside classes but outside functions. The template with the abrev 'fcom' for example which usually would generate the editor-fold code does not work that way. When used inside a function or outside the class boundary the templates work fine.

The workaround is obvious but very annoying: use the abrev inside a method or outside the class and copy/paste the whole thing to the correct places (like around methods etc.)

I'm sorry if this should have gone directly to the php component instead of the editor.
Comment 1 gsnerf 2011-08-10 12:29:30 UTC
I just noticed, manually created templates work just fine even if used in the described way!
Comment 2 Petr Pisl 2011-09-02 08:35:34 UTC
Looking into the code, in the class context there is only accepted fnc template. I'm going to rewrite it.
Comment 3 Petr Pisl 2011-09-02 09:09:37 UTC
Fixed in web main
Comment 4 Quality Engineering 2011-09-03 14:26:53 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/4cad4e5a1f2e
User: Petr Pisl <ppisl@netbeans.org>
Log: #200359 - PHP code templates inside classes do not work outside of function scope
Comment 5 Vladimir Riha 2011-09-23 09:53:22 UTC
verified
Comment 6 slevin 2012-02-01 15:42:04 UTC
It seems like now manually created code templates doesn't work outside function but inside class scope.  They do work in 7.0.1

Actually, I dont see any need for this code:
===========================================================
if (context == CompletionContext.CLASS_CONTEXT_KEYWORDS) {
    String abbrev = template.getAbbreviation();
    return "fnc".equals(abbrev) || "fcom".equals(abbrev);
}
===========================================================
Because, if I understand it correctly, for context described above (inside class, but outside function) it declines code template if it is not a 'fnc' or 'fcom'. And it doesn't allow using custom code templates.


--
Product Version: NetBeans IDE 7.1 (Build 201112071828)
Java: 1.7.0_02; Java HotSpot(TM) Client VM 22.0-b10
System: Windows 7 version 6.1 running on x86; Cp1251; en_US (nb)
User directory: C:\Users\U\.netbeans\7.1
Cache directory: C:\Users\U\.netbeans\7.1\var\cache
Comment 7 BullfrogBlues 2012-02-12 02:28:02 UTC
I have the same issue, there are two thing to notice about the behaviour: how the template works outside methods/functions i.e. it does nothing and how it works inside method/functions i.e. invalid-php/wrong-formatting. See below for specific examples.

Templates like the one are invaluable, and should probably be part of the base set templates.

==================================================

Create the PHP Code Template
--------------------------
Abbreviation: pm or anything
Expand Template on: Shift+Space or anything
Expanded Text:

${public} function ${methodName}($$${param})
{
    ${selection}${cursor}
}

Outside method = Nothing
------------------------

class MyClass {

    pm|

}

Where the cursor is at "|" hit shift+space/tab/enter = nothing

Inside method = Wrong formatting / invalid
------------------------------------------

class MyClass {

    public function myMethod() {

        pm|

    }

}

Where the cursor is at "|" hit shift+space results in:

class MyClass {

    public function myMethod() {

        public|
        function methodName($param)
        {
            
        }

    }

}
Comment 8 BullfrogBlues 2012-02-12 02:50:17 UTC
Looks like this one has been fixed "... Integrated into 'releases', will be available in build *201202072200* or newer ..."

*** This bug has been marked as a duplicate of bug 206413 ***