eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

Open Declaration: Overloaded constructors having same class name in arguments are buggy

Open
#1,165 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
59
Forks
127
Avg merge
23h 30m
Merged PRs (30d)
35

Description

I saw this while working with [eclipse/gef-classic.](https://github.com/eclipse/gef-classic/).

The class `org.eclipse.draw2d.geometry.Rectangle` has two constructors of note, written as follows (comment added to the first one for clarity):

```java
public Rectangle(/*org.eclipse.draw2d.geometry.*/Rectangle rect) {
```

and
```java
public Rectangle(org.eclipse.swt.graphics.Rectangle rect) {
```

So far I have seen this lead to 3 buggy scenarios:
1. In code that calls the 2nd constructor (the SWT Rectangle), if you **Open Declaration** it will open the first one (draw2d Rectangle).

https://github.com/eclipse-jdt/eclipse.jdt.ui/assets/136501322/ef096da2-dd4d-45c8-9750-5539ed99af42

2. The **Outline View** in the Rectangle class does not let you navigate to the SWT Rectangle constructor (note that it doesn't highlight it, if it wasn't visible already it wouldn't be scrolled to).

https://github.com/eclipse-jdt/eclipse.jdt.ui/assets/136501322/29a2bf4d-e0ee-4137-9aff-7a6cc464e0e0

3. **Quick Outline** in the Rectangle class does not let you navigate to the SWT rectangle constructor (probably same bug as above)

Basically in all cases where you would want to see the SWT Rectangle constructor, you are always given the other one instead.

---

Eclipse.org Java Development Tools UI 3.31.0.v20231115-2128 org.eclipse.jdt.ui

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with org.eclipse.draw2d.geometry.Rectangle and its two overloaded constructors, then check Open Declaration, Outline View, and Quick Outline for the SWT Rectangle overload. Done means each navigation path selects or opens the SWT Rectangle constructor rather than the draw2d Rectangle constructor.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.