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

Fixing Java field access #1862

Merged
merged 6 commits into from
Jan 9, 2025
Merged

Fixing Java field access #1862

merged 6 commits into from
Jan 9, 2025

Conversation

oxisto
Copy link
Member

@oxisto oxisto commented Nov 21, 2024

This PR consists of a major overhaul of Java reference and member expression parsing. It removes a LOT of old weird legacy code that was full of weird things.

It also introduces a new Java-specific pass, that takes care of deciding when a member access is actually static or not. This might be something that we could decide to adapt for other/all languages (maybe also tied to the discussion in #1863).

@oxisto
Copy link
Member Author

oxisto commented Nov 21, 2024

Blocked by #1586

@oxisto oxisto added the blocked Blocked by an external factor label Nov 21, 2024
Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 86.53846% with 7 lines in your changes missing coverage. Please review.

Project coverage is 77.12%. Comparing base (0fea809) to head (dcf7e97).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...in/de/fraunhofer/aisec/cpg/passes/JavaExtraPass.kt 70.58% 0 Missing and 5 partials ⚠️
...raunhofer/aisec/cpg/frontends/java/JavaLanguage.kt 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
...n/de/fraunhofer/aisec/cpg/passes/SymbolResolver.kt 87.85% <ø> (+1.34%) ⬆️
...s/kotlin/de/fraunhofer/aisec/cpg/test/TestUtils.kt 71.27% <ø> (ø)
...ofer/aisec/cpg/frontends/java/ExpressionHandler.kt 77.90% <100.00%> (+4.79%) ⬆️
...aisec/cpg/frontends/java/JavaCallResolverHelper.kt 44.44% <ø> (ø)
...r/aisec/cpg/frontends/java/JavaLanguageFrontend.kt 70.46% <100.00%> (-4.22%) ⬇️
...raunhofer/aisec/cpg/frontends/java/JavaLanguage.kt 84.09% <60.00%> (-3.09%) ⬇️
...in/de/fraunhofer/aisec/cpg/passes/JavaExtraPass.kt 70.58% <70.58%> (ø)

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@oxisto oxisto removed the blocked Blocked by an external factor label Nov 28, 2024
@oxisto oxisto marked this pull request as ready for review November 28, 2024 14:05
@oxisto oxisto added the java Related to Java language parsing label Nov 28, 2024
Copy link
Contributor

@KuechA KuechA left a comment

Choose a reason for hiding this comment

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

I fail to understand most of the changes since the old code is hard to understand and the new code requires in-depth knowledge and understanding of the java parser and frontend which I do not have. However, I have some nits which should already be resolved and may support subsequent more detailed reviews.

@oxisto
Copy link
Member Author

oxisto commented Dec 18, 2024

I fail to understand most of the changes since the old code is hard to understand and the new code requires in-depth knowledge and understanding of the java parser and frontend which I do not have. However, I have some nits which should already be resolved and may support subsequent more detailed reviews.

Agreed. I will extract the remaining changes that are not Java-specific to extra PRs (#1908 and #1909)

oxisto added 4 commits January 8, 2025 16:58
…t of candidates

This adds a new function `Language.bestViableReferenceCandidate` which takes the old implementation as a default behaviour.
@oxisto oxisto requested a review from KuechA January 8, 2025 16:28
@oxisto
Copy link
Member Author

oxisto commented Jan 8, 2025

I fail to understand most of the changes since the old code is hard to understand and the new code requires in-depth knowledge and understanding of the java parser and frontend which I do not have. However, I have some nits which should already be resolved and may support subsequent more detailed reviews.

Please re-check, I addressed the issues.

@oxisto oxisto enabled auto-merge (squash) January 9, 2025 15:28
@oxisto oxisto merged commit fbd7c79 into main Jan 9, 2025
2 checks passed
@oxisto oxisto deleted the java-fix-static branch January 9, 2025 15:31
oxisto added a commit that referenced this pull request Jan 9, 2025
* Provide a function for languages to influence reference resolution out of candidates

This adds a new function `Language.bestViableReferenceCandidate` which takes the old implementation as a default behaviour.

* Fixing Java field access

* Better solution for reference candidate

* Addressed code review

* Simplified
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java Related to Java language parsing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants