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.
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.
I just noticed, manually created templates work just fine even if used in the described way!
Looking into the code, in the class context there is only accepted fnc template. I'm going to rewrite it.
Fixed in web main
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
verified
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
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) { } } }
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 ***