eclipse-jdt / eclipse-jdt/eclipse.jdt.core

[content assist] Improve chain template proposals

Open
#961 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 10h
Merged PRs (30d)
49

Description

This request was originally entered in the old bug tracking system: https://bugs.eclipse.org/bugs/show_bug.cgi?id=570577

TLDR; Eclipse should show "Chain Template Proposals" in the standard template proposals and improve the ranking of proposals.

Eclipse introduced "Chain Template Proposals" a few releases ago. And it works really well.

That is the reason why I'm wondering why Eclipse kind of hides this cool feature. Here is an example:
```
public class ChainTemplateProposal {

public static void main(String[] args) {
Person p;
Country c = p.; // <===
}

interface Person {
String getName();
Address getAddress();
int getAge();
}

interface Address {
String getStreetAddress();
String getZipCode();
Country getCountry();
}

interface Country {
}
}
```
When I type the "p." in the code above I get the following proposals:
```
equals(Object obj)
getAddress()
getAge()
...
```
Then I type CTRL-SPACE 3 (!) times and I get
```
getAddress().getCountry()
```
If I change the defaults and check "Chain Template Proposals" in the preferences (Content Assist -> Advanced) then I get
```
equals(Object obj)
getAddress()
getAge()
... (9 other proposals including 2 notify() and 3 wait() methods with "void" return value)
getAddress().getCountry()
```
I would like

1. Per default integrate Chain Template Proposals in the default content assist list

2. Sort the whole list by the appropriate return value.

Another example:

Consider e.g.
```
String x = p.
```
This then shows me the following proposal:
```
getName()
toString()
... (> 10 not-very-useful proposals)
getAddress().getStreetAddress()
getAddress().getZipCode()
getClass().getCanonicalName()
```

The proposals should first show the local methods which return the correct type. Then they should show the chain template proposals for the user-defined classes (this means: JDK methods like getClass() should come later).

[[reply](https://bugs.eclipse.org/bugs/show_bug.cgi?id=570577#add_comment)] [[−]](https://bugs.eclipse.org/bugs/show_bug.cgi?id=570577#) [Comment 1](https://bugs.eclipse.org/bugs/show_bug.cgi?id=570577#c1)

Contributor guide

Open the contributing guide

Research direction

The issue names no repository files, tests, or implementation entry points. Start by locating the content-assist handling for Chain Template Proposals and the Advanced preference, then compare its proposal ordering with standard content assist. Done means chain proposals are enabled by default and the combined list prioritizes compatible local and user-defined return types as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.