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 196113 - Auto-insert use statement when a class (in namespace) is first used
Summary: Auto-insert use statement when a class (in namespace) is first used
Status: RESOLVED WORKSFORME
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.0
Hardware: All All
: P3 normal with 6 votes (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks: 193356
  Show dependency tree
 
Reported: 2011-02-28 16:21 UTC by OndrejBrejla
Modified: 2012-03-01 12:35 UTC (History)
0 users

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 OndrejBrejla 2011-02-28 16:21:32 UTC
That would be nice to have a same functionality for "use namespace" statement as is in Java module. What I mean is that when I want to instantiate new object, I write a class name and its namespace is auto-completed before that class name, so there is something like this:

$foo = new \Bar\Foo();

But I would like to have just:

namespace Whatever;

use Bar\Foo;

$foo = new Foo();
Comment 1 OndrejBrejla 2011-02-28 17:57:04 UTC
Don't forget to implement some fixation when class name conflict appears...in the case when there are two classes, with a same name but in different namespaces.
Comment 2 OndrejBrejla 2011-02-28 22:09:49 UTC
Maybe that behaviour could be realized by a bulb hint? Something like switching between fully qualified class name and simple name with use statement above.
Comment 3 honzamarek 2011-02-28 22:28:53 UTC
I would prefer bulb hint implementation. In Visual Studio it works fine. Situation with more classes with same name in different namespaces wolud be solved easily.

http://bartdesmet.info/images_wlw/CallingtheTaskSchedulerinWindowsVistaand_20ED/image_thumb_4.png
Comment 4 Ondrej Brejla 2011-09-09 13:08:27 UTC
It seems that it works for me in NB 7.0.1. If I'm in some namespace, and use some class (which is not from this namespace or is not "used"), and I put a carret on the line with instantiation of that class, "bulb" hint occurs in the gutter and I can generate "use" clasues.
Comment 5 Stawi 2012-03-01 12:30:53 UTC
(In reply to comment #4)
> It seems that it works for me in NB 7.0.1. If I'm in some namespace, and use
> some class (which is not from this namespace or is not "used"), and I put a
> carret on the line with instantiation of that class, "bulb" hint occurs in the
> gutter and I can generate "use" clasues.

"bulb" hint doesnt show when you're using aliases.
Comment 6 Ondrej Brejla 2012-03-01 12:35:46 UTC
This hint will be removed (or absolutely rewritten). And replaced by more powerful solution.