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 258713 - [PHP7] Warnings for code foldings are shown when an anonymous class is used
Summary: [PHP7] Warnings for code foldings are shown when an anonymous class is used
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.2
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-08 00:05 UTC by junichi11
Modified: 2016-08-08 20:06 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 junichi11 2016-04-08 00:05:31 UTC
Steps:
1. Write the following code
2. Type something
3. Look at the IDE log

Reproducible code:
<?php

class C {

    public function foo() {
        return new class () {
            public function bar() {
                
            }
        };
    }
}         


IDE log:
Existing fold: [class] E1 <74,151>, desc='{...}', hash=0x3aa82593, [74, 151] {74, 151}; FoldManager: org.netbeans.modules.csl.editor.fold.GsfFoldManager@600a4010
     New fold: [class] E1 <74,151>, desc='{...}', hash=0x798b9fa3, [74, 151] {74, 151}; FoldManager: org.netbeans.modules.csl.editor.fold.GsfFoldManager@600a4010
Adding a fold that is identical with another previously added fold from the same FoldManager is not allowed.
Existing fold: [function] E1 <110,141>, desc='{...}', hash=0x74ef0d73, [110, 141] {110, 141}; FoldManager: org.netbeans.modules.csl.editor.fold.GsfFoldManager@600a4010
     New fold: [function] E1 <110,141>, desc='{...}', hash=0x66453684, [110, 141] {110, 141}; FoldManager: org.netbeans.modules.csl.editor.fold.GsfFoldManager@600a4010

Thanks.
Comment 1 Tomas Mysik 2016-04-08 06:51:22 UTC
Thanks for the report.
Comment 2 Tomas Mysik 2016-08-08 11:16:16 UTC
So, the warnings are now fixed but not really sure if properly. The fix just ignores duplicated scopes which is likely incorrect. However, I am not able to find out how the proper fix should be - in lazy scan, we need to scan method bodies for anonymous classes so they appear in the Navigator window. However, method bodies are later fully scanned again (in non-lazy mode) so these anonymous classes appear in scopes (in model) twice.

Thanks.

http://hg.netbeans.org/web-main/rev/f4e3eceb4eed
Comment 3 Quality Engineering 2016-08-08 20:06:41 UTC
Integrated into 'main-silver', will be available in build *201608081727* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/f4e3eceb4eed
User: Tomas Mysik <tmysik@netbeans.org>
Log: #258713 - [PHP7] Warnings for code foldings are shown when an anonymous class is used

Not sure if it is the proper fix but anonymous classes need to be scanned even
in lazy mode because of navigator. Therefore they can appear twice in scopes.