Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use a better heuristic for guessing type/field references in no classpath mode #5170

Merged
merged 3 commits into from
Apr 13, 2023

Conversation

I-Al-Istannen
Copy link
Collaborator

In no classpath mode, JDT only gives us a ProblemBinding with a QualifiedNameReference. We then have to figure out whether this is a type, field, inner class, package or anything else ourselves. Previously, every child of an invocation was treated as a type. This patch changes it to favor fields and only falls back to a type access, if it appeared somewhere in an import.

This is still far from perfect, but it at least produces better guesses.

Closes #5151

…classpath mode

In no classpath mode, JDT only gives us a ProblemBinding with a
QualifiedNameReference. We then have to figure out whether this is a
type, field, inner class, package or anything else ourselves.
Previously, every child of an invocation was treated as a type. This
patch changes it to favor fields and only falls back to a type access,
if it appeared somewhere in an import.

This is still far from perfect, but it at least produces better guesses.

Closes INRIA#5151
@I-Al-Istannen I-Al-Istannen self-assigned this Apr 10, 2023
@I-Al-Istannen I-Al-Istannen changed the title fix: Use a better heuristic for guessing type/field references in no classpath mode review: fix: Use a better heuristic for guessing type/field references in no classpath mode Apr 10, 2023
@@ -63,7 +63,7 @@ public static void initializeContext() {
/* 22 */ "...\n" +
/* 23 */ "}\n";

ctx = new ZippedCodeBaseTestContext(smpl, "src/test/resources/C4JShouldVibrate.zip", false);
ctx = new ZippedCodeBaseTestContext(smpl, "src/test/resources/C4JShouldVibrate.zip", true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it makes the test pass.

The test expects types to be imported but did not set the auto-import flag.

@MartinWitt
Copy link
Collaborator

Could fix the reording of the imports before we merge?

@MartinWitt MartinWitt changed the title review: fix: Use a better heuristic for guessing type/field references in no classpath mode fix: Use a better heuristic for guessing type/field references in no classpath mode Apr 13, 2023
@MartinWitt MartinWitt merged commit fe049a5 into INRIA:master Apr 13, 2023
@MartinWitt
Copy link
Collaborator

Thanks @I-Al-Istannen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Confusion between simple access to class fields (or enum) and fully qualified name
2 participants