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

Add adapter for IProject > (bnd) Project #918

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

laeubi
Copy link
Contributor

@laeubi laeubi commented Nov 13, 2023

If one wants to write generic UI components then there is often the question to answer to what (bnd) project an Eclipse IProject belongs (if any).

This adds an Adapter that can adapt from IProject > (bnd) Project if the IProject is a PDE Bnd backed project.

See also

Copy link

github-actions bot commented Nov 13, 2023

Test Results

   264 files   -        6     264 suites   - 6   41m 22s ⏱️ - 14m 16s
3 328 tests +       1  3 297 ✔️ ±       0  30 💤 ±  0  1 +1 
7 557 runs   - 2 721  7 490 ✔️  - 2 698  66 💤  - 24  1 +1 

For more details on these failures, see this check.

Results for commit e3359e4. ± Comparison against base commit 62e8a76.

♻️ This comment has been updated with latest results.

try {
return adapterType.cast(BndProjectManager.getBndProject(project).orElse(null));
} catch (Exception e) {
// can't adapt then...

Choose a reason for hiding this comment

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

Should this be logged at least?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can add a logging but this mostly means there is some error already visible for the user in the workspace so an additional logging (possibly multiple times) seem not so useful.

The general contract of adapting is to try adapt and getting null if it is not possible, but there is no way to let the caller know why it didn't work out.

Choose a reason for hiding this comment

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

Alright. Maybe I'm just confused by BndProjectManager.getBndProject(project) returning an optional yet declaring an undocumented Exception to be possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Exception is sadly a burden from the BND project that uses throws Exception all the time :-
In this case it actually should never happen but if it does something is wrong and caller can just give up as we can't decide whats going wrong.

If one wants to write generic UI components then there is often the
question to answer to what (bnd) project an Eclipse IProject belongs (if
any).

This adds an Adapter that can adapt from IProject > (bnd) Project if the
IProject is a PDE Bnd backed project.

See also
- https://bnd.discourse.group/t/announcement-bnd-and-pde-cooperation/372
@laeubi laeubi force-pushed the add_project_adapter branch from efc55f8 to e3359e4 Compare November 29, 2023 05:41
@laeubi laeubi merged commit d249c58 into eclipse-pde:master Nov 29, 2023
14 of 16 checks passed
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.

3 participants