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 270385 - Hint-Fix not properly formatted
Summary: Hint-Fix not properly formatted
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: Dev
Hardware: All All
: P3 normal (vote)
Assignee: junichi11
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-13 08:44 UTC by marcusson
Modified: 2017-04-18 13:42 UTC (History)
1 user (show)

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 marcusson 2017-04-13 08:44:57 UTC
I'm using dev-build 201704120200.

The following issue was introduced after code changes submitted to fix issue 206532.

This changeset http://hg.netbeans.org/main-silver/rev/55a9fd535b01 introduced a hint when a Non-Abstract PHP function was found that didn't have a body.

Part of the changeset is the method AddBodyFix.implement() that is called when the user chooses to automatically apply a fix for the hint.

When certain formatting & indentation settings are selected, the auto-formatting feature doesn't seem to behave as intended.

To replicate this behavior, go to menu "Tools / Options / Editor / Formatting". Set "PHP / Braces / Method declaration" to "New Line".

Here are some test cases.

Source code BEFORE applying the hint-fix:

<?php

class Test1 {

private function test();

}

class Test2 {

    private function test();
}

class Test3 {

                private function test();
}

class Test4 {

    private function test()
;

}

?>

Results AFTER applying the hint-fix:

<?php

class Test1 {

private function test()
    {
        
    }

}

class Test2 {

    private function test()    {
        
    }

}

class Test3 {

                private function test()                {
        
    }

}

class Test4
{

    private function test()
    {
        
    }

}

?>

EXPECTED:

<?php

class Test1 {

private function test()
    {
        
    }

}

class Test2 {

    private function test()
    {
        
    }

}

class Test3 {

                private function test()
    {
        
    }

}

class Test4
{

    private function test()
    {
        
    }

}

?>

Obviously applying the hint behaves differently depending on how many spaces are found before the head of the function and introduces the exact same number of spaces as the function head is indented.

It appears to be unclear what exactly causes this behavior.
Comment 1 junichi11 2017-04-13 11:34:54 UTC
Thanks for reporting!

I'll look at it later.
Comment 2 junichi11 2017-04-14 00:53:13 UTC
I think that the same result is expected.

i.e. 
EXPECTED:

<?php

class Test1 {

    private function test()
    {
        
    }

}

class Test2 {

    private function test()
    {
        
    }

}

class Test3 {

    private function test()
    {
        
    }

}

class Test4
{

    private function test()
    {
        
    }

}
Comment 3 marcusson 2017-04-14 08:20:37 UTC
You are absolutely right! Ideally, yes, all should be the same.

However, that depends on what you apply the formatting to: do you apply it to the head of the function as well (thus changing the formatting of preexisting code), or only to the body that was inserted by applying the hint-fix.

There is good arguments for both options. I personally would have it your way, but that's just my personal preference ;)
Comment 4 junichi11 2017-04-14 11:53:33 UTC
Fixed.

http://hg.netbeans.org/web-main/rev/6613b6ada27e

Thanks.
Comment 5 Quality Engineering 2017-04-15 02:50:08 UTC
Integrated into 'main-silver', will be available in build *201704150002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/6613b6ada27e
User: Junichi Yamamoto <junichi11@netbeans.org>
Log: #270385 - Hint-Fix not properly formatted
Comment 6 Tomas Mysik 2017-04-18 08:52:58 UTC
Thanks a lot, Junichi!
Comment 7 marcusson 2017-04-18 09:53:00 UTC
I just tried the fix with the current Nightly Build 201704180002. Works perfectly well.

Thanks! Great job.
Comment 8 junichi11 2017-04-18 13:42:08 UTC
You are welcome :)