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

#472 Refactor action defintion to interfaces #171

Merged
merged 4 commits into from
Mar 30, 2022
Merged

Conversation

tortmayr
Copy link
Contributor

@tortmayr tortmayr commented Mar 28, 2022

Sprotty moved away from class based approach for action definition and solely relies on interfaces now.
To be able to update to the latest sprotty version GLSP needs to to do the same. Otherwise action definitions might clash
and there will be an inconsistent mix of class and interface definitions.
This PR refactors the action definitions in the base protocol & the glsp client to interfaces. Action definitions that are reused from sprotty are marked
with extends sprotty.XYZAction. In addition, to the pure interface definition for each action/operation type a namespace is provided that offers utility functions for type checking and creating new instances.

  • Refactor all action definitions to interfaces+namespaces
  • Refactor all action constructions calls to use the new Action.create() approach instead of the old new Action() approach
  • Add tests for the action utility function (is, create etc.) of all protocol actions.
  • Replace all old typeguard functions like isComputedBoundsAction with their new namespace counterpart (SetBoundsAction.is)
  • Add isOperation:true boolean property to the operation interface. This serves as discriminator to make actions & operations distinguishable on a
    type level.
  • Update to latest sprotty version
  • Update to latest glsp-config package to make use of the new no-deprecated eslint rules.
  • Add package specific eslint warnings for restricted/discourages imports.

Also:

  • Disable hover-popup listener when the Edge creation tool is active
  • Update changelog

Contributed on behalf of STMicroelectronics

@tortmayr tortmayr requested a review from planger March 28, 2022 11:49
@tortmayr tortmayr force-pushed the sprotty-update-v2 branch 2 times, most recently from 7d05103 to 2e6ac2d Compare March 28, 2022 12:15
Sprotty moved away from class based approach for action definiton and solely  relies on interfaces now.
To be able to update to the latest sprotty version GLSP needs to to do the same. Otherwise action definitions might clash
and there will be an inconsistent mix of class and interface definitions.
This PR refactors the action definitions in the base protocol & the glsp client to interfaces. Action definitions that are reused from sprotty are marked
with `extends sprotty.XYZAction`. In addition, to the pure interface definition for each action/operation type a namespace is provided that offers utility functions for type checking and creating new instances.

- Refactor all action definitions to interfaces+namespaces
- Refactor all action constructions calls to use the new `Action.create() `approach instead of the old `new Action()` approach
- Add tests for the action utility function (is, create etc.) of all protocol actions.
- Replace all old typeguard functions like `isComputedBoundsAction` with their new namespace counterpart (SetBoundsAction.is)
- Add `isOperation`:true boolean property to the operation interface. This serves as discriminator to make actions & operations distinguishable on a
type level.
- Update to latest sprotty version
- Update to latest glsp-config package to  make use of the new no-deprecated eslint rules.
- Add package specific eslint warnings for restricted/discourages imports. 

Also: 
- Disable hover-popup listener when the Ede creation tool is active
- Update changelog

Contributed on behalf of STMicroelectronics
tortmayr added a commit to eclipse-glsp/glsp-theia-integration that referenced this pull request Mar 28, 2022
#472
- Consume the new glsp-client and sprotty version and update the code base to comply to the new action definitions
- Update linking script
- Update to latest glsp-config package to  make use of the new no-deprecated eslint rules.
- Add package specific eslint warnings for restricted/discourages imports. 

 #559
- Consume new @eclipse-glsp/config version and update to typescript 4.5.5.
- Adapt code to conform to new "strict" mode and "noImplicitOverride"
- Cleanup dev dependencies and move common dependencies into package root

Part of eclipse-glsp/glsp/issues/472
Part of eclipse-glsp/glsp/issues/559

Requires eclipse-glsp/glsp-client#171

Contributed on behalf of STMicroelectronics
- Fix clipboard definitions
- Add Menu & Palette item types to protocol
tortmayr added a commit to eclipse-glsp/glsp-server-node that referenced this pull request Mar 28, 2022
#472
- Consume the new glsp-protocol version and update the code base to comply to the new action definitions

 #559
- Consume new @eclipse-glsp/config version and update to typescript 4.5.5.
- Adapt code to conform to new "strict" mode and "noImplicitOverride"
- Cleanup dev dependencies and move common dependencies into package root

Part of eclipse-glsp/glsp/issues/472
Part of eclipse-glsp/glsp/issues/559

Requires eclipse-glsp/glsp-client#171

Contributed on behalf of STMicroelectronics
tortmayr added a commit to eclipse-glsp/glsp-server-node that referenced this pull request Mar 28, 2022
#472
- Consume the new glsp-protocol version and update the code base to comply to the new action definitions

 #559
- Consume new @eclipse-glsp/config version and update to typescript 4.5.5.
- Adapt code to conform to new "strict" mode and "noImplicitOverride"
- Cleanup dev dependencies and move common dependencies into package root

#492
Update workflow builders to provide the same improved styled components as the Java GLSP server


Part of eclipse-glsp/glsp/issues/472
Part of eclipse-glsp/glsp/issues/559
Part of eclipse-glsp/glsp/issues/492

Requires eclipse-glsp/glsp-client#171

Contributed on behalf of STMicroelectronics
Copy link
Member

@planger planger left a comment

Choose a reason for hiding this comment

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

Excellent work! Thank you very much for this comprehensive change!
Great that you also added lots of typedoc and unit tests! 💯

I made a couple of edit suggestions and comments about the typedocs. While most of them are great, there are several which imho don't really add information. I tend to prefer omitting those, because they add noise without helping.

I tested with eclipse-glsp/glsp-theia-integration#110 and observed a few regressions:

  • Task editing doesn't work: after selecting type or duration, the input disappears
  • Validation throws an error (Missing handler for action { kind: 'applyMarkers',...)
  • Resize and move restrictors for overlaps don't work... I'm not sure though if this is a regression or didn't work in the first place
  • Open push command (in Theia) doesn't select the correct element (could be unrelated too)

Is there a particular reason why we really copy and not import and re-export all Sprotty actions? I think there was a reason, but I can't remember right now. Now reviewing the code it feels like a lot of maintenance overhead with the risk of getting out of sync?

Again, excellent work on this huge change! Thanks for your persistence!

packages/client/src/features/command-palette/di.config.ts Outdated Show resolved Hide resolved
packages/protocol/src/action-protocol/clipboard.ts Outdated Show resolved Hide resolved
packages/protocol/src/action-protocol/element-creation.ts Outdated Show resolved Hide resolved
packages/protocol/src/action-protocol/node-modification.ts Outdated Show resolved Hide resolved
packages/protocol/src/action-protocol/node-modification.ts Outdated Show resolved Hide resolved
packages/protocol/src/action-protocol/node-modification.ts Outdated Show resolved Hide resolved
packages/protocol/src/action-protocol/tool-palette.ts Outdated Show resolved Hide resolved
packages/protocol/src/action-protocol/tool-palette.ts Outdated Show resolved Hide resolved
@tortmayr
Copy link
Contributor Author

tortmayr commented Mar 28, 2022

Thank you for your fast review. I'm going to address the feedback right away.

Task editing doesn't work: after selecting type or duration, the input disappears

This problem seems to be already present on the current master

Resize and move restrictors for overlaps don't work... I'm not sure though if this is a regression or didn't work in the first place

This is related to eclipse-glsp/glsp/issues/394. Currently the movement restrictor is not enabled for the workflow example.

Is there a particular reason why we really copy and not import and re-export all Sprotty actions? I think there was a reason, but I can't remember right now. Now reviewing the code it feels like a lot of maintenance overhead with the risk of getting out of sync?

I assume you are referring to the actions in the protocol package?

  • With a simple reexport we lose the possibility to apply GLSP-specific JS-DOC to the action definitions
  • The sprotty protocol actions use a slightly different approach regarding their namespace functions. They only offer the constant KIND and a create function. And (for whatever reason) opted to keep the guard functions as separate isSomeAction() functions. In GLSP we prefer guard functions as part of the namespace (is()). So we would have to do some kind of module augmentation anyways. In addtion, the isSomeAction guard functions of sprotty are only available for some actions.
  • With re declaring we have the possibility to extend the sprotty provided interfaces. This is something we for instance do in the ServerStatusAction where we add an additional timeout property.
  • The parameterize of sprottiy's create() functions is not consistent and quite confusing at times. With the namespace re declare we have the possibility to apply our own consistent pattern.
  • With re declaring the protocol actions we have a consistent entry place for API documentation. Otherwise the doc would
    be scattered across sprotty-protocol and @eclipse-glsp/protocol. With the current approach we have all protocol action documented in one place which also makes it relatively easy to sync doc changes with the https://github.com/eclipse-glsp/glsp/blob/master/PROTOCOL.md file.

Since we extend from the sprotty interfaces I don't see any risks of getting out of sync. This ensure that we are always compliant to the sprotty definition. I would even argue that is is a better approach in terms of API stability. With a simple reexport we would pick up breaking changes much later (if at all).

@planger
Copy link
Member

planger commented Mar 28, 2022

Ah, right, now I see. Thanks!

- Remove comments that add no additional value
- Merge TYPES & GLSP_TYPES service identifier definitions and reexport them in @eclipse-glsp/client. The "old" GLSP_TYPES namespace has been deprecated but is still available to ease the migration pain for (early) adopters.
- Adapt base-protocol.spec test case names. After reviewer aprroval the same naming pattern will be applied to all other test cases.
- Fix command definition for `ApplyMarkersCommand`
- Fix incorrect `LabeledAction.is` method
- Fix duplicate and autogenerated names in example1.wf
@tortmayr
Copy link
Contributor Author

tortmayr commented Mar 29, 2022

I have pushed an update that should address all the raised issues.
There are a lot of comments regading JS-DOC so I hope that I didn't miss any. I had a quick check and all comments regarding doc seem to be outdated now (meaning the source code at the location has changed -> I hopefully addressed the comment 😉 )

Task editing doesn't work: after selecting type or duration, the input disappears

Should be fixed now. Was related to a incorrect implementation of LabeledAction.is. With fixed I mean its in the current state
as the master. Apparently something is broken here. At least for me selecting a suggestion has no effect on the actual model. We should look into that in a follow-up.

Validation throws an error (Missing handler for action { kind: 'applyMarkers',...)

Fixed. Was related to an incorrect KIND property of the ApplyMarkers command.

Resize and move restrictors for overlaps don't work... I'm not sure though if this is a regression or didn't work in the first place

As mentioned before, movement restrictors for the Workflow example are currently disabled.

Open push command (in Theia) doesn't select the correct element (could be unrelated too)

Fixed. It seems like we introduced duplicate names when changing the Workflow example styling. I updated all example1.wf files.

Copy link
Member

@planger planger left a comment

Choose a reason for hiding this comment

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

Excellent, thanks a lot!
I did a few inline suggestions that you should be able to directly apply, mostly to typedoc.
So the only thing left is imho to adjust the text in the other tests. But I already approve for you to spare another review cycle.

Thanks again for your persistence with this large and important change! Now we are consistent and up to date with Sprotty again, and it is simpler for adopters when it comes to importing classes and registering DI implementations! 💯

packages/client/src/features/hints/type-hints.ts Outdated Show resolved Hide resolved
packages/client/src/features/layout/layout-commands.ts Outdated Show resolved Hide resolved
packages/client/src/features/layout/layout-commands.ts Outdated Show resolved Hide resolved
packages/client/src/features/layout/layout-commands.ts Outdated Show resolved Hide resolved
packages/protocol/src/action-protocol/element-selection.ts Outdated Show resolved Hide resolved
packages/protocol/src/action-protocol/model-layout.ts Outdated Show resolved Hide resolved
packages/protocol/src/action-protocol/types.ts Outdated Show resolved Hide resolved
packages/protocol/src/action-protocol/viewport.ts Outdated Show resolved Hide resolved
@tortmayr
Copy link
Contributor Author

@planger Thank you for the detailled review. I have updated the JS-DOC according to your suggestions and applied the new naming scheme to all test cases. So now we should be ready to merge

@tortmayr tortmayr merged commit 88e4725 into master Mar 30, 2022
@tortmayr tortmayr deleted the sprotty-update-v2 branch March 30, 2022 09:45
tortmayr added a commit to eclipse-glsp/glsp-server-node that referenced this pull request Mar 30, 2022
#472
- Consume the new glsp-protocol version and update the code base to comply to the new action definitions

 #559
- Consume new @eclipse-glsp/config version and update to typescript 4.5.5.
- Adapt code to conform to new "strict" mode and "noImplicitOverride"
- Cleanup dev dependencies and move common dependencies into package root

#492
Update workflow builders to provide the same improved styled components as the Java GLSP server


Part of eclipse-glsp/glsp/issues/472
Part of eclipse-glsp/glsp/issues/559
Part of eclipse-glsp/glsp/issues/492

Requires eclipse-glsp/glsp-client#171

Contributed on behalf of STMicroelectronics
tortmayr added a commit to eclipse-glsp/glsp-theia-integration that referenced this pull request Mar 30, 2022
Consume new client version & update TS

#472
- Consume the new glsp-client and sprotty version and update the code base to comply to the new action definitions
- Update linking script
- Update to latest glsp-config package to  make use of the new no-deprecated eslint rules.
- Add package specific eslint warnings for restricted/discourages imports. 

 #559
- Consume new @eclipse-glsp/config version and update to typescript 4.5.5.
- Adapt code to conform to new "strict" mode and "noImplicitOverride"
- Cleanup dev dependencies and move common dependencies into package root

Part of eclipse-glsp/glsp/issues/472
Part of eclipse-glsp/glsp/issues/559

Requires eclipse-glsp/glsp-client#171

Contributed on behalf of STMicroelectronics
tortmayr added a commit to eclipse-glsp/glsp-server-node that referenced this pull request Mar 30, 2022
#472
- Consume the new glsp-protocol version and update the code base to comply to the new action definitions

 #559
- Consume new @eclipse-glsp/config version and update to typescript 4.5.5.
- Adapt code to conform to new "strict" mode and "noImplicitOverride"
- Cleanup dev dependencies and move common dependencies into package root

#492
Update workflow builders to provide the same improved styled components as the Java GLSP server


Part of eclipse-glsp/glsp/issues/472
Part of eclipse-glsp/glsp/issues/559
Part of eclipse-glsp/glsp/issues/492

Requires eclipse-glsp/glsp-client#171

Contributed on behalf of STMicroelectronics
tortmayr added a commit to eclipse-glsp/glsp-server-node that referenced this pull request Mar 30, 2022
#472
- Consume the new glsp-protocol version and update the code base to comply to the new action definitions

 #559
- Consume new @eclipse-glsp/config version and update to typescript 4.5.5.
- Adapt code to conform to new "strict" mode and "noImplicitOverride"
- Cleanup dev dependencies and move common dependencies into package root

#492
Update workflow builders to provide the same improved styled components as the Java GLSP server


Part of eclipse-glsp/glsp/issues/472
Part of eclipse-glsp/glsp/issues/559
Part of eclipse-glsp/glsp/issues/492

Requires eclipse-glsp/glsp-client#171

Contributed on behalf of STMicroelectronics
tortmayr added a commit to eclipse-glsp/glsp-server-node that referenced this pull request Mar 30, 2022
#472
- Consume the new glsp-protocol version and update the code base to comply to the new action definitions

 #559
- Consume new @eclipse-glsp/config version and update to typescript 4.5.5.
- Adapt code to conform to new "strict" mode and "noImplicitOverride"
- Cleanup dev dependencies and move common dependencies into package root

#492
Update workflow builders to provide the same improved styled components as the Java GLSP server


Part of eclipse-glsp/glsp/issues/472
Part of eclipse-glsp/glsp/issues/559
Part of eclipse-glsp/glsp/issues/492

Requires eclipse-glsp/glsp-client#171

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

Successfully merging this pull request may close these issues.

2 participants