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

An extension point allowing third parties to override source to dom tree implementations #2560

Merged

Conversation

robstryker
Copy link
Contributor

@robstryker robstryker commented Jun 12, 2024

What it does

This extension point would allow third party products to override the conversion between java source files and the JDT dom tree with a custom implementation. In order to prevent rogue extenders from simply breaking people's installations, a system property selecting the preferred ICompilationUnitResolver must be set, as well.

As consumers of JDT become more diverse and also have been operating in environments not previously expected, being able to properly define the borders and interactions between and among the various parts of JDT becomes important. As resources to maintain various parts of the codebase become scarce, allowing the community to experiment with potentially more efficient solutions also becomes important.

Ensuring that the community can contribute to a common codebase for the vast majority of the shared work is critical to providing that community the cohesion, common goals, and shared visions that maintains a project. And allowing different elements of the community the freedom, via extension points or otherwise, to investigate alternatives to parts of the current codebase will serve to keep the project growing long term.

How to test

Other than exposing an extension point, this change does not significantly change any behavior. To test, one could attempt to make a plugin using this extension point and verifying that the various interface methods are called in a runtime workbench. I am not familiar with how the jdt.core project prefers to automatically test extension points, especially ones that require a sysprop to also be set.

Author checklist

@robstryker robstryker force-pushed the jdt_core_pr_curesolution_extpt branch 2 times, most recently from 67b41dd to a4d4296 Compare June 13, 2024 15:25
@robstryker
Copy link
Contributor Author

@testforstephen Would you mind giving a review on this PR?

Thanks.

@testforstephen
Copy link
Contributor

Would you mind giving a review on this PR?

sure, I'll take a look next week.

@rgrunber
Copy link
Contributor

@testforstephen , also something to consider. I noticed your compiler extension PR extends via system property containing the FQN + Class.forName(..) on it. Rob's current approach is to use the extension point framework. It seems like it would be better for all extensions to standardize on a single approach.

Copy link
Contributor

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

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

Overall, the extension point looks clean to me. Could you add some unit tests for it?

@testforstephen
Copy link
Contributor

@testforstephen , also something to consider. I noticed your compiler extension PR extends via system property containing the FQN + Class.forName(..) on it. Rob's current approach is to use the extension point framework. It seems like it would be better for all extensions to standardize on a single approach.

I'd keep the compiler extension PR as it is for now. If we encounter any limitations with this approach, we can consider changing it to an extension point later.

@robstryker
Copy link
Contributor Author

Working on test cases. Will update PR asap.

@robstryker robstryker force-pushed the jdt_core_pr_curesolution_extpt branch from 0b8c177 to cc3ded4 Compare June 18, 2024 15:17
mickaelistria

This comment was marked as off-topic.

jukzi
jukzi previously requested changes Jun 26, 2024
Copy link
Contributor

@jukzi jukzi left a comment

Choose a reason for hiding this comment

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

Please make sure that only copies or immutable data structures are passed to third party to prevent that changes by third party can make errors in jdt. IProgressMonitor is an exceptional case.
int is OK,
String is OK,
Arrays are mutable -> copy or better use a immutable List.
Map -> make a immutable copy
FileASTRequestor is mutable -> i don't have solution for that at hand

@mickaelistria
Copy link
Contributor

The FileASTRequestor is intentionally mutable. It's even expected that one of its field gets modified as part of the process. It kind of captures some of the state. I believe we won't be able to change that.
For other structure, I think we should go to copies over immutable. The issue with immutable is that the immutability doesn't surface in the API, so one can try to change them and get a crash at runtime, which is a worse behavior than changing something which doesn't have an effect outside of the change scope.

@robstryker
Copy link
Contributor Author

robstryker commented Jun 26, 2024

Please make sure that only copies or immutable data structures are passed to third party to prevent that changes by third party can make errors in jdt. IProgressMonitor is an exceptional case. int is OK, String is OK, Arrays are mutable -> copy or better use a immutable List. Map -> make a immutable copy FileASTRequestor is mutable -> i don't have solution for that at hand

I've updated arrays and maps to be cloned or immutable before sending them to the unitResolver.

@robstryker robstryker force-pushed the jdt_core_pr_curesolution_extpt branch from 059b135 to d452370 Compare June 26, 2024 20:03
@mickaelistria
Copy link
Contributor

Is anything else needed before this can be merged?

Copy link
Contributor

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

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

It has some formatting issues, others look good to me.

@jukzi jukzi dismissed their stale review July 1, 2024 06:27

would be good if others review as well

Rob Stryker and others added 7 commits July 2, 2024 09:07
…mentations

Signed-off-by: Rob Stryker <stryker@redhat.com>

exsd cleanup

Signed-off-by: Rob Stryker <stryker@redhat.com>

Cleanup

Signed-off-by: Rob Stryker <stryker@redhat.com>

Javadoc for added interface

Signed-off-by: Rob Stryker <stryker@redhat.com>

More docs

Remove printStackTrace()

Signed-off-by: Rob Stryker <stryker@redhat.com>

Handle quality checks

Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>

Import errors

Signed-off-by: Rob Stryker <stryker@redhat.com>

Clean up API Tools warnings

Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
Signed-off-by: Rob Stryker <stryker@redhat.com>
according to review comments
@mickaelistria mickaelistria force-pushed the jdt_core_pr_curesolution_extpt branch from d452370 to 060655a Compare July 2, 2024 07:17
@mickaelistria
Copy link
Contributor

Unless I missed one, all former review comments are now covered.

@jukzi jukzi requested a review from iloveeclipse July 2, 2024 07:26
Copy link
Contributor

@testforstephen testforstephen left a comment

Choose a reason for hiding this comment

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

LGTM

* cache the config element and minimize access to extension registry
* Removed @SInCE
* Add doc
* Fix and register test case in a suite
@mickaelistria
Copy link
Contributor

@iloveeclipse I appended a commit that should cover all your comments.

@mickaelistria
Copy link
Contributor

@iloveeclipse I think all your review comments were addressed, can you please have another look?

Copy link
Member

@iloveeclipse iloveeclipse left a comment

Choose a reason for hiding this comment

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

All concerns cleared.

@akurtakov
Copy link
Contributor

Are we waiting for someone else to review?

Copy link
Contributor

@akurtakov akurtakov left a comment

Choose a reason for hiding this comment

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

Unless there is some concern I plan to merge this one on Monday.

@akurtakov
Copy link
Contributor

3 committers approved the patch - merging.

@akurtakov akurtakov merged commit 07c9984 into eclipse-jdt:master Jul 8, 2024
9 checks passed
@mickaelistria
Copy link
Contributor

Thanks to everyone involved!

robstryker added a commit to robstryker/eclipse.jdt.core that referenced this pull request Jul 18, 2024
…ree implementations (eclipse-jdt#2560)

This extension point would allow third party products to override the conversion between java source files and the JDT dom tree with a custom implementation. In order to prevent rogue extenders from simply breaking people's installations, a system property selecting the preferred ICompilationUnitResolver must be set, as well.

Signed-off-by: Rob Stryker <stryker@redhat.com>
Co-authored-by: Rob Stryker <stryker@redhat.com>
Co-authored-by: Mickael Istria <mistria@redhat.com>
gayanper pushed a commit to gayanper/eclipse.jdt.core that referenced this pull request Sep 7, 2024
…ree implementations (eclipse-jdt#2560)

This extension point would allow third party products to override the conversion between java source files and the JDT dom tree with a custom implementation. In order to prevent rogue extenders from simply breaking people's installations, a system property selecting the preferred ICompilationUnitResolver must be set, as well.

Signed-off-by: Rob Stryker <stryker@redhat.com>
Co-authored-by: Rob Stryker <stryker@redhat.com>
Co-authored-by: Mickael Istria <mistria@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants