Giter Site home page Giter Site logo

Comments (4)

rgrunber avatar rgrunber commented on August 22, 2024

Seems slightly similar to what @snjeza reported in #2014 (comment) . It's worth checking if the calls to completion return all the overloads, and if so, we should be able to figure out why signature help isn't displaying all of them.

from eclipse.jdt.ls.

rgrunber avatar rgrunber commented on August 22, 2024

The problem is here :

while (declaringType != null) {
String unqualifiedName = declaringType.getErasure().getName().replace(";", "");
typeNames.add(unqualifiedName);
declaringType = declaringType.getSuperclass();
}
this.declaringTypeNames = typeNames;

We get the declaring type based on the specific method that is selected (eg. for test.speed(), even though test is a Car, speed() is declared in Vehicle. From there we only discover the super classes of Vehicle, which are MovingObject, and java.lang.Object. Once we get to :

public void accept(CompletionProposal proposal) {
if (!isIgnored(proposal.getKind())) {
if (proposal.getKind() == CompletionProposal.METHOD_REF && !Objects.equals(proposal.getName() == null ? null : new String(proposal.getName()), methodName)) {
return;
}
if (this.declaringTypeNames != null) {
char[] declarationSignature = proposal.getDeclarationSignature();
if (declarationSignature != null) {
String proposalTypeSimpleName = SignatureHelpUtils.getSimpleTypeName(String.valueOf(declarationSignature));
for (String typeName : this.declaringTypeNames) {
String declaringTypeSimpleName = Signature.getSimpleName(typeName);
if (Objects.equals(proposalTypeSimpleName, declaringTypeSimpleName)) {
proposals.putIfAbsent(String.valueOf(proposal.getSignature()), proposal);
return;
}
}
return;
}
}
proposals.putIfAbsent(String.valueOf(proposal.getSignature()), proposal);
}
}

we do get speed(int), speed(int, int) from the completion engine, but we dismiss them because Car is not in declaringTypeNames.

I think we need to revisit this logic because it is definitely broken. The name comparison is there because completion invocation within the parameter "area" was always a bit buggy and we had to dismiss some odd values, but computing subtypes (in addition to supertypes) could get expensive. Do we need to compute the types at all or can we just go by the rule of "accept any method whose name matches".

from eclipse.jdt.ls.

rgrunber avatar rgrunber commented on August 22, 2024

As a note the following is now an issue for signature help :

Test.java

package test1;

public class Test {

    public String[] getQuestions(boolean onlyMultipleChoice) {
        return null;
    }

    public String[] getQuestions() {
        return null;
    }
}

Exam.java

package test1;

public class Exam extends Test {

    public String[] getQuestions(int number) {
        return null;
    }
}

Main.java

package test1;

public class Main {
    public void doStuff() {
        Test ex = new Test();
        ((Exam) ex).getQuestions(|)
    }

    public String[] getQuestions(int number, String section, boolean multiple) {
        return null;
    }
}

image

It's an improvement over the issue of missing overloads.

from eclipse.jdt.ls.

jdneo avatar jdneo commented on August 22, 2024

As a note the following is now an issue for signature help

Ah, that might be the reason why declaring type is preserved. Let's file an issue first.

from eclipse.jdt.ls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.