Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326870

Summary: Autocomplete gets confused for classes with names ending in '$' (e.g. AClass$)
Product: [Eclipse Project] JDT Reporter: Daniel Ratiu <ratiud>
Component: CoreAssignee: JDT Core Triaged <jdt-core-triaged>
Status: CLOSED WONTFIX QA Contact: Ayushman Jain <amj87.iitr>
Severity: normal    
Priority: P3 CC: amj87.iitr, andy.m.sheldon, donnchadh, eclipse, lieven.lemiengre, sinchronized.arun
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/101392
Whiteboard: stalebug
Attachments:
Description Flags
Patch to leave '$' at end of class name in resolved signature during completion
none
Test patch to leave '$' at end of class name in resolved signature during completion none

Description Daniel Ratiu CLA 2010-10-03 15:11:16 EDT
Build Identifier: M20100909-0800

The autocomplete functionality gets confused in the case of classes with names ending with '$' (e.g. 'AClass$' ). Such classes, with names ending in '$', are frequent when interacting with code written in the Scala programing language. Below is an example of this issue.

---

package pack1;

class AClass$ {
  public static int M;
}

--
package another_pack;

class Foo {
   void a () {
      AClass$.|     //cursor
   }
}
----
When selecting at the cursor the autocompletion for 'M', a bad import and autocompletion is generated:

---
package another_pack;

import test.a.AClass.;                     //PROBLEM

class Foo {
	void a() {
	  .M                 //PROBLEM
	}
}
---


Reproducible: Always

Steps to Reproduce:
1. Create class 'AClass$', in package 'pack1'
2. Add a static attribute 'M' to this class.
3. Create class 'Foo' in package 'another_pack'
4. Create a method 'a()' in class Foo
5. Inside this method try to access the member 'M' of class 'AClass$' by using the autocomplete feature.
This gives, as presented above, erroneous results.
Comment 1 Ayushman Jain CLA 2010-10-04 01:52:46 EDT
(In reply to comment #0)

Reproduced with I20100928-0800. Note that for this to happen, the class AClass$ should be declared public. Also, this doesnt happen when an import statement for AClass$ has already been added.

In the content assist proposal list, I can see that the resolved type for M is showing as "AClass." So might be a problem in resolution here. Will investigate.
Comment 2 Arun Ramakrishnan CLA 2012-05-23 13:31:42 EDT
Looks like there quite a few votes on this one. This is marked for 3.7. But, Wondering if there is a chance this can make it into 4.2 juno simultaneous release.
Comment 3 Ayushman Jain CLA 2012-05-24 00:04:07 EDT
(In reply to comment #2)
> Looks like there quite a few votes on this one. This is marked for 3.7. But,
> Wondering if there is a chance this can make it into 4.2 juno simultaneous
> release.

This was found in 3.7, the target is still not set. This will not make it into 4.2 as we are into RC where only stop ship issues are fixed.
Comment 4 Andy Sheldon CLA 2012-09-15 22:52:05 EDT
Created attachment 221124 [details]
Patch to leave '$' at end of class name in resolved signature during completion

Will also attach patch with a few test cases.
Comment 5 Andy Sheldon CLA 2012-09-15 23:22:58 EDT
Created attachment 221125 [details]
Test patch to leave '$' at end of class name in resolved signature during completion

New test class and input, separate from full CompletionTests.java for ease of review.
Comment 6 Eclipse Genie CLA 2017-07-17 15:24:41 EDT
New Gerrit change created: https://git.eclipse.org/r/101392
Comment 7 Eclipse Genie CLA 2020-04-30 00:39:04 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.