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 233529 - Fix uses occasionally puts namespace statement after use statements (wrong and undesirable)
Summary: Fix uses occasionally puts namespace statement after use statements (wrong an...
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: All All
: P4 normal (vote)
Assignee: Ondrej Brejla
Depends on:
Reported: 2013-07-27 09:03 UTC by icaine
Modified: 2013-10-15 14:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description icaine 2013-07-27 09:03:04 UTC
Fix uses occasionally puts namespace statement after use statements (wrong and undesirable) but unfortunately i cant reproduce it now.. When i run into it again i will try to update this issue..


use NS1\NS2\SomeClass;
use NS2\NS2\SomeClass2;

namespace NS1;

//uses should be here

Comment 1 Ondrej Brejla 2013-07-28 07:36:22 UTC
I can't reproduce it either.
Comment 2 icaine 2013-09-01 09:05:09 UTC
Hello, it occurred again on dev version Build 201308270001 with the option "remove unused uses" set on. It seems to me that the problem occurs when the option is set on because when it was set off i havent met the problem.

Anyway i am not able to reproduce it because when i reverted the code to the state before and used it again this time i didnt happen.
Comment 3 Ondrej Brejla 2013-09-04 08:42:05 UTC
Sorry, but I'm not able to reproduce that... P4 util we have a reproducible test case. Without that I'm not able to do anything.
Comment 4 icaine 2013-09-04 09:51:56 UTC
I understand.. Just wanted to point out that the bug exists in the latest versions too.
Comment 5 icaine 2013-10-15 14:15:37 UTC
step 1:
step 2:
step 3:
step 4:

Product Version = NetBeans IDE Dev (Build 201310110001)
Operating System = Windows 8 version 6.2 running on x86
Java; VM; Vendor = 1.7.0_25
Runtime = Java HotSpot(TM) Client VM 23.25-b01
Comment 6 Ondrej Brejla 2013-10-15 14:24:47 UTC
Yep, I know where is the problem. The problem is in a place, where is the caret, when Fix Uses is invoked. In this case, it's outside of any the and of a file. In the whitespace. And because PHP parser doesn't handle whitespaces (lexer ignores it), then the "place of invocation" is considered to be a default ns...('s invoked "nowhere"...from parser point of view the invoking place doesn't exist.)

And unfortunately it can't be simply fixed. There is a workaround for that, never invoke that action at the end of a file. Put the caret somewhere inside it.

Reproducible case:


namespace Aaa;

class Foo {}



namespace Bbb;

class Bar extends Foo {}


...and invoke Fix Uses on a ^ caret place.