Code Completion for Namespaces - part I

Posted by Radek Matous on Aug 10 2009, 08:51:28 AM CEST

This is brief overview how to use code completion for namespaced elements in NetBeans 6.8.
Namespaced elements are resolved according  name resolution rules.

See examples for namespace name definitions that are important for resolution rules:

// Fully qualified name
$c = new \my\name\ExampleClass();

// Qualified name
$c = new name\ExampleClass();

// Unqualified name
$c = new ExampleClass();

Now we have 3 ways how to create new instance of class ExampleClass. Let's look how to harness code completion to generate all of them.

Fully qualified name

Simply begin with a namespace separator after new keyword (e.g. new \Exam), choose from the list of proposals and press enter. 

fully qualified name proposals

As a result:

fully qualified name result

Unqualified name

 The same as for fully qualified name - just omit namespace separator at the beginning (e.g. new Exam).

qualified name proposal

As a result:

qulified name result

Qualified name

Begin with a sub-namespace name (whereas code completion can be used here also ) followed with namespace separator after new keyword (e.g. new name\Exam), choose from the list of proposals and press enter. 

qualified name proposal

As a result:

qualified name result

As mentioned above, for sub-namespace name can be used code completion too.

namespace name proposal

For e.g. new name\test\Exam can be used code completion 3 times: name, test, Exam.

Category: Features | Permalink | Comments [5]

Trackback URL: http://blogs.sun.com/netbeansphp/entry/using_namespaces_in_netbeans_6
Comments:

DO we have any other version of NetBeans. this NetBeans 6.8 is getting trouble often.

Regards,
stutalk.com

Posted by blostutalk on August 10, 2009 at 12:46 PM CEST #

to blostutalk:

NetBeans 6.8 is in development phase, relase is planned for Fall 2009, but using it and reporting bug is very helpful for us and help us make the IDE better.

Latest stable version is 6.7.1:
http://www.netbeans.org/downloads/index.html

Posted by radek on August 10, 2009 at 12:58 PM CEST #

to blostutalk:

BTW: could you report the mentioned problems, thanks

Posted by 192.9.112.196 on August 10, 2009 at 01:02 PM CEST #

Diky! Nice work

Posted by Vitex on August 10, 2009 at 05:04 PM CEST #

It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader. Thanks again.

Posted by links of london on October 31, 2009 at 03:27 AM CET #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed