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

Refactor and cleanup GLSPContribution API #146

Merged
merged 2 commits into from
Mar 15, 2023
Merged

Conversation

tortmayr
Copy link
Contributor

@tortmayr tortmayr commented Mar 8, 2023

  • Refactor GLSPCLientProvider and reuse it in BaseGLSPTheiaConnector
  • Make GLSPContributions disposable
  • Cleanup redundant session concept in GLSPBackendContribution
  • Cleanup & refactorGLSPClientContribution API.
  • Cleanup & refactorGLSPSocketServerContribution API
  • Remove remains from @theia/languages
  • Simplify client initialization by using Theia's Deferred concept.

Fixes eclipse-glsp/glsp#848

@tortmayr tortmayr requested a review from martin-fleck-at March 8, 2023 08:10
@tortmayr tortmayr force-pushed the tortmayr/issues/848 branch from 0564786 to ad1346f Compare March 8, 2023 10:45
@tortmayr tortmayr requested a review from planger March 10, 2023 09:08
tortmayr added a commit that referenced this pull request Mar 11, 2023
Drop dependency to sprotty-theia , move dependent code in-repo and adapt existing code base.
Code that is adapted from the orginal sprotty-theia repository is proplery marked in the copyright notice and with an inline comment

Depends on: #146
Fixes eclipse-glsp/glsp#847
tortmayr added a commit that referenced this pull request Mar 11, 2023
Drop dependency to sprotty-theia , move dependent code in-repo and adapt existing code base.
Code that is adapted from the orginal sprotty-theia repository is proplery marked in the copyright notice and with an inline comment

Depends on: #146
Fixes eclipse-glsp/glsp#847
Copy link
Contributor

@martin-fleck-at martin-fleck-at left a comment

Choose a reason for hiding this comment

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

Changes look good to me and seem to work well. I have a few questions regarding code which I'd like to clarify first.

if (data) {
const message = data.toString();
protected override processLogInfo(line: string): void {
if (line) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can line be undefined? If so, the method signature should actually show this. If not then I do not see any advantage of checking for empty string here if we check for startsWith anyway.

const message = data.toString();
protected override processLogInfo(line: string): void {
if (line) {
const message = line.toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary if line really can be only of type string and not of type Buffer as available before.

if (data) {
console.error(`${this.id}: ${data}`);
protected processLogError(line: string): void {
if (line) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we do this to filter empty lines or because line can be undefined?

* @returns the corresponding `GLSPClient` or `undefined` if no client is configured for the given type
*/
async getGLSPClient(contributionId: string): Promise<GLSPClient | undefined> {
return this.getGLSPClientContribution(contributionId)?.glspClient ?? undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return this.getGLSPClientContribution(contributionId)?.glspClient ?? undefined;
return this.getGLSPClientContribution(contributionId)?.glspClient;

@@ -83,84 +109,58 @@ export abstract class BaseGLSPClientContribution implements GLSPClientContributi
});
}

waitForActivation(app: FrontendApplication): Promise<any> {
const activationPromises: Promise<any>[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

I really like that we no longer have a default activation condition! We just need to make sure we properly document it as it definitely may break some assumptions.


activate(): Disposable {
if (this.toDeactivate.disposed) {
activate(app: FrontendApplication): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should activate maybe return a promise? Seems like we should have one at hand and it might be useful for some cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

=> MaybePromise

}

deactivate(_app: FrontendApplication): void {
this.toDeactivate.dispose();
this.toDispose.dispose();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should that call dispose or the other way around?

})
]);
}
},
{ reconnecting: false }
{ reconnecting: true }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we properly handle reconnection or does that work out of the box? Or does it not matter at all?

- Refactor `GLSPCLientProvider` and reuse it in `BaseGLSPTheiaConnector`
- Make GLSPContributions disposable
- Cleanup redundant session concept in `GLSPBackendContribution`
- Cleanup & refactor`GLSPClientContribution` API.
- Cleanup & refactor`GLSPSocketServerContribution` API
- Remove remains from @theia/languages
- Simplify client initialization by using Theia's Deferred concept.

Fixes eclipse-glsp/glsp#848
@tortmayr tortmayr force-pushed the tortmayr/issues/848 branch from ad1346f to 18351b7 Compare March 15, 2023 11:29
@tortmayr
Copy link
Contributor Author

Thanks for the fast review, I have added a commit that should address the open issues

Copy link
Contributor

@martin-fleck-at martin-fleck-at left a comment

Choose a reason for hiding this comment

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

LGTM!

@tortmayr tortmayr merged commit b258494 into master Mar 15, 2023
@tortmayr tortmayr deleted the tortmayr/issues/848 branch March 15, 2023 13:12
tortmayr added a commit that referenced this pull request Mar 15, 2023
Drop dependency to sprotty-theia , move dependent code in-repo and adapt existing code base.
Code that is adapted from the orginal sprotty-theia repository is proplery marked in the copyright notice and with an inline comment

Depends on: #146
Fixes eclipse-glsp/glsp#847
tortmayr added a commit that referenced this pull request Mar 16, 2023
Drop dependency to sprotty-theia , move dependent code in-repo and adapt existing code base.
Code that is adapted from the orginal sprotty-theia repository is proplery marked in the copyright notice and with an inline comment

Depends on: #146
Fixes eclipse-glsp/glsp#847
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.

Refactor and cleanup GLSPContribution API
2 participants