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

Fixes #671 - Move some platform-ui undo utility classes into a core location #672

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

robstryker
Copy link

No description provided.

@robstryker
Copy link
Author

See #671 for description

@mickaelistria
Copy link
Contributor

Couldn't those be in an internal but exported with x-friends package?

@robstryker
Copy link
Author

Couldn't those be in an internal but exported with x-friends package?

In theory, yes, but, I personally draw the line between what I consider to be major repositories. I can understand if platform core wanted a bundle to be xfriends with something in platform ui, but once you cross the road into JDT-land, it seems that it should be publicly available API.

Basically, once a major consumer is attempting to use it, there's no point to keeping it as xfriends. It should be supported as public.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 12, 2023

Test Results

       40 files   -     2         40 suites   - 2   51m 31s ⏱️ - 11m 13s
  3 775 tests ±    0    3 770 ✔️  -     2    3 💤 ±0  1 +1  1 🔥 +1 
11 181 runs   - 147  11 152 ✔️  - 149  27 💤 ±0  1 +1  1 🔥 +1 

For more details on these failures and errors, see this check.

Results for commit 75fb0ca. ± Comparison against base commit 0613f93.

♻️ This comment has been updated with latest results.

@mickaelistria
Copy link
Contributor

I'm a bit worried about the names of all that. For example having a "ProjectDescription" API when there is already IProjectDescription as a main object is likely to bring confusion. I'm also not sure about the "descriptors" package which doesn't make it clear what these classes are intended to.
Can you please also show draft PRs for Platform UI and JDT to see how this change would impact consumers?

import org.eclipse.core.runtime.CoreException;

/**
* IFileContentDescription is a description of a file's content.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not using directly IFile or IFileInfo for that?

@mickaelistria
Copy link
Contributor

OK, I start to understand it better that those classes are meant to get a local snapshot of a resource to store in the undo/redo stack and process later. If there are no other consumers than undo/redo, then we can probably just show undo in the package name, and instead of "Descriptions" name them "Snapshots".
Couldn't we also move in here that bits that take care of undo/restoring (ie applying the "snapshot" to the workspace) ?

@robstryker
Copy link
Author

I'm a +1 on changing package name to include an undo. I trhink that would add a lot of clarity.

I'm generally against renaming the classes to 'Snapshots' unless there's a wider consensus that's the correct thing to do. Changing package name is one thing but changing the class name, well, I'm not sure. I'll do it if demanded, but...

For JDT, the patch to migrate from use of the ui.ide.undo classes to the new core ones would be as simple as changing imports (assuming we don't change the class name, just the package). This is because our primary entry point to creating these objects is by calling ResourceDescription.fromResource(rootResource);.

For eclipse ui, I'd need to investigate more deeply to see how extensively these classes are used. I can see that org.eclipse.ui.ide.undo, is an exported package that is public API. Migration would probably involve having existing classes extend those in core.

Copy link
Contributor

@mickaelistria mickaelistria left a comment

Choose a reason for hiding this comment

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

That looks good overall, just a minor comment inline that we need to address before moving forward.

* Base implementation of ResourceSnapshot that describes the common attributes
* of a resource to be created.
*
* This class is not intended to be instantiated or used by clients.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should maybe remove this line?

Copy link
Author

Choose a reason for hiding this comment

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

This line should not be removed. The approved way of accessing these classes is by calling ResourceSnapshot.fromResource(r);

Copy link
Contributor

Choose a reason for hiding this comment

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

So couldn't the constructors be only package-visible? And the documentation mention that the right approach to get an instance if ResourceSnapshot.fromResource() ?

@mickaelistria
Copy link
Contributor

The test failure is also visible on master and doesn't relate to the change (ie actually tests the content of help for last I-Build, not the one that would be generated by this PR).
While I still think we should aim at moving the extension point to make it easier for consumers to use it, I think it's not too bad to have its description in the "legacy" bundle at the moment. So, unless we find a quick and easy solution to the problem (which are yet unclear to me), it would be OK to merge it.

However, I still miss the exact symptom of the problem we're trying to fix. @robstryker do you have a link to some failure somewhere? If it's the current test that we see failing here that we're trying to fix, then the solution can be simply to list the "new" bundle in https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/blob/725cacd808359189e38bda85b416ed80d03bda22/eclipse.platform.common/bundles/org.eclipse.platform.doc.isv/buildDoc.xml#L54

@robstryker
Copy link
Author

I'll be refactoring this patch to ensure that org.eclipse.ui.ide can properly consume these in an api-compatible fashion. Please hold off.

@mickaelistria mickaelistria marked this pull request as draft September 15, 2023 16:21
@mickaelistria
Copy link
Contributor

Please hold off.

OK, I'm converting to draft in the meantime.

@robstryker
Copy link
Author

The test failure is also visible on master and doesn't relate to the change (ie actually tests the content of help for last I-Build, not the one that would be generated by this PR). While I still think we should aim at moving the extension point to make it easier for consumers to use it, I think it's not too bad to have its description in the "legacy" bundle at the moment. So, unless we find a quick and easy solution to the problem (which are yet unclear to me), it would be OK to merge it.

However, I still miss the exact symptom of the problem we're trying to fix. @robstryker do you have a link to some failure somewhere? If it's the current test that we see failing here that we're trying to fix, then the solution can be simply to list the "new" bundle in https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/blob/725cacd808359189e38bda85b416ed80d03bda22/eclipse.platform.common/bundles/org.eclipse.platform.doc.isv/buildDoc.xml#L54

I think this comment was meant to be posted to a different issue. This issue here is not prompted by any test failures.

@robstryker
Copy link
Author

I have significantly refactored the proposed patch, to add an internal package as the current ui.ide had done. This was an oversight on my part since only 1 of the classes should have been public.

In order to maintain API compatibility with prior consumers of the ui.ide code, I have chosen to make use of interfaces instead of only abstract classes. This allows the existing UI code to simply wrap the core implementation and implement the same interface. This will maintain compatability with all of the existing classes and the expected return values. More of that can be discussed on an issue in the UI repository when appropriate.

@robstryker robstryker marked this pull request as ready for review September 18, 2023 17:18
…es into a core location

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

Update copyright headers and since tags

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

Rename API to use snapshot instead of description for clarity

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

Missing since tag

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

Reorganize newly moved classes and clean up

Signed-off-by: Rob Stryker <stryker@redhat.com>
* IContainerSnapshot is a lightweight description that describes a container to
* be created.
*
* This class is not intended to be instantiated by clients.
Copy link
Contributor

Choose a reason for hiding this comment

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

This line can be removed as interfaces cannot be instantiated.
However, 1 important thing to settle when introducing this interface API is whether we want to allow other implementations? If we want to restrict the implementations to the ones that are shipped here, we should add a @noimplements tag to make PDE warn in case someone wants to implement it.
It's safer to start with as many restrictions as possible and to remove them later than the other way round, as it gives more freedom for further changes.

* IMarkerSnapshot is a lightweight snapshot of a marker for the purposes of
* undoing.
*
* This class is not intended to be instantiated by clients.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

* IResourceSnapshot is a lightweight snapshot that describes the common
* attributes of a resource to be created.
*
* This class is not intended to be extended by clients.
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

Signed-off-by: Rob Stryker <stryker@redhat.com>
@mickaelistria mickaelistria merged commit df661fe into eclipse-platform:master Sep 19, 2023
12 of 14 checks passed
* the progress monitor to be used when creating the resource
* @throws CoreException if creation failed
*/
public void createExistentResourceFromHandle(IResource resource,
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that my comment is late, but create method usually returns an instance of something (like the method above). Do you think something like "materialize" or "actualize" could be better here @robstryker @mickaelistria ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree it looks like this particular thing can be improved. I'm also curious about why is this method useful when we already have createResource. @robstryker in which case would one want to call it instead of createResource? What about a new restoreResource that would join both?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also thinking that we could maybe add generics <T extends IResource> here and there to polish things a bit and facilitate consumption.

Copy link
Contributor

Choose a reason for hiding this comment

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

generics are proposed in #705

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