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 262205 - [PHP7] Incorrect formatting for CC in mixed group use
Summary: [PHP7] Incorrect formatting for CC in mixed group use
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 8.2
Hardware: All All
: P3 normal (vote)
Assignee: junichi11
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-24 11:26 UTC by junichi11
Modified: 2016-08-27 02:18 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
proposal patch (2.73 MB, patch)
2016-08-26 06:03 UTC, junichi11
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description junichi11 2016-05-24 11:26:31 UTC
When "const" and "function" keywords are added using CC, formatting is incorrect.

Reproducible code:

1.
----------------------------------
use A\{
    MyClass,cons^ // CC here
};

expected:
use A\{
    MyClass,const or MyClass, const
};

actual:
use A\{
    MyClass,  const // 2 spaces
};

2. 
----------------------------------
use A\{
    MyClass,
    cons^ // CC here
};

expected:
use A\{
    MyClass,
    const
};

actual:
use A\{
    MyClass,
     const
};

3. 
----------------------------------
use A\{
    MyClass,funct^ // CC here
};

expected: 
use A\{
    MyClass,function or MyClass, function
};

actual:
use A\{
    MyClass,
    function
};

Thanks.
Comment 1 junichi11 2016-05-24 11:28:31 UTC
I'm not sure whether I can fix this. But I'll try to fix it.

Thanks.
Comment 2 Tomas Mysik 2016-05-24 11:36:17 UTC
Thanks a lot, Junichi!
Comment 3 junichi11 2016-08-26 06:03:54 UTC
Created attachment 161776 [details]
proposal patch

It's hard to fix because there is a syntax error.

But I have just one idea:

1. Allow an empty group use (CUP)
2. Sanitizing (GSFPHPParser)
3. Add an UnhandledErrorRule for the empty group use
4. Fix the FormatVisitor and TokenFormatter

Tomas, What do you think?

If OK, I'll add tests. Then, I'll push them on next Wednesday(8/31).

Thanks.
Comment 4 Tomas Mysik 2016-08-26 06:38:02 UTC
Sounds good to me, feel free to do it. But please ensure that no tests are broken, we are a few days before code freeze :)

Thanks!

(In reply to junichi11 from comment #3)
> If OK, I'll add tests. Then, I'll push them on next Wednesday(8/31).

If you can add tests today (in 8 hours or so), feel free to push it today. If not, please wait till Wednesday (and verify that the file licenses are OK).

Thanks a lot!
Comment 5 junichi11 2016-08-26 10:40:50 UTC
(In reply to Tomas Mysik from comment #4)
> Sounds good to me, feel free to do it. 

Thanks!

> But please ensure that no tests are
> broken, we are a few days before code freeze :)
> If you can add tests today (in 8 hours or so), feel free to push it today.
> If not, please wait till Wednesday (and verify that the file licenses are
> OK).

I'll try adding them now. I'll push after all editor's tests are passed in my local environment.

Thanks!
Comment 6 Tomas Mysik 2016-08-26 10:45:41 UTC
Perfect, thank you!
Comment 7 junichi11 2016-08-26 12:51:48 UTC
Fixed. 

http://hg.netbeans.org/web-main/rev/b8f8f5943cc2

Thanks.
Comment 8 Tomas Mysik 2016-08-26 12:56:33 UTC
Thanks a lot, Junichi!
Comment 9 Quality Engineering 2016-08-27 02:18:37 UTC
Integrated into 'main-silver', will be available in build *201608270002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/b8f8f5943cc2
User: Junichi Yamamoto <junichi11@netbeans.org>
Log: #262205 - [PHP7] Incorrect formatting for CC in mixed group use