Bug 550928 - nested anonymous class code completion not respecting nesting when prompting for methods
Summary: nested anonymous class code completion not respecting nesting when prompting ...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: PHP Core CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-10 06:29 EDT by Richard Harding CLA
Modified: 2020-05-14 10:17 EDT (History)
1 user (show)

See Also:


Attachments
illustration of methods being exposed incorrectly (45.63 KB, image/png)
2019-09-10 06:33 EDT, Richard Harding CLA
no flags Details
Duplicates ? (18.63 KB, image/png)
2019-12-31 05:01 EST, Richard Harding CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Harding CLA 2019-09-10 06:29:22 EDT
When nesting more than one layer of anonymous class, PDT is incorrectly exposing methods of nested classes to code completion. (these should only be exposed at the level to which they apply.

I will attach a screenshot.
Comment 1 Richard Harding CLA 2019-09-10 06:33:40 EDT
Created attachment 279827 [details]
illustration of methods being exposed incorrectly

it appears that PDT is aware that the depth of the methods is different but ignores it in proposing possibilities (I'm inferring this by looking at the light grey information to the right of the displayed properties)

To hopefully assist, here follows the exact code shown in the screenshot...

<?php

class main {
  
  static function level1($val) : object {
    return new class($val) {
      private $value;
      
      function __construct(string $value) {
        $this->value = $value;
      }
      
      function level2() : object {
        return new class($this->value) {
          private $value2;
          
          function __construct(?string $value2) {
             $this->value2 = $value2;
          }
            
          function uppercase() {
            print strtoupper($this->value2);
          }
            
          function lowercase() {
            print strtolower($this->value2);
          }
            
        };
      }
      
    };
  }
}

$a = main::level1("frED");
$a->level2()->lowercase();
$a->
Comment 2 Richard Harding CLA 2019-10-15 15:24:03 EDT
Issue persists in PDT 7.0.0.201910011154
Comment 3 Eclipse Genie CLA 2019-12-30 16:27:07 EST
New Gerrit change created: https://git.eclipse.org/r/155113
Comment 5 Dawid Pakula CLA 2019-12-30 16:43:35 EST
Fixed in 7.1. 

Thank You for report with example!
Comment 6 Richard Harding CLA 2019-12-31 05:01:34 EST
Created attachment 281360 [details]
Duplicates ?

My pleasure! 

I have just upgraded to 7.1 and I notice 2 things:

1. OK: code completion is now showing the correct methods.
2. ISSUE: the methods are showing twice

This screenshot should hopefully illustrate the above.
Comment 7 Richard Harding CLA 2019-12-31 05:02:24 EST
Please see previous comment and screenshot explaining reason for re-opening
Comment 8 Dawid Pakula CLA 2019-12-31 05:03:58 EST
Could you clean your project first? Menu -> Project -> Clean and select your project.

I cannot reproduce on mac. Maybe this is a problem on Windows hmmm
Comment 9 Richard Harding CLA 2019-12-31 05:20:59 EST
oops - my bad :) 

I had the file existing already in the project and created a new 

...which meant that it was showing the methods from both files.

I have deleted the new "duplicate" file and tested in the original - and all good!

thanks very much for sorting - apologies for causing time waste.