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 capability information to the metamodel #1591

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MariaSolOs
Copy link
Contributor

@MariaSolOs MariaSolOs commented Nov 30, 2024

@@ -25,6 +25,7 @@ export namespace ConfigurationRequest {
export const type = new ProtocolRequestType<ConfigurationParams, LSPAny[], never, void, void>(method);
export type HandlerSignature = RequestHandler<ConfigurationParams, LSPAny[], void>;
export type MiddlewareSignature = (params: ConfigurationParams, token: CancellationToken, next: HandlerSignature) => HandlerResult<LSPAny[], void>;
export const capabilities: { client: 'workspace.configuration'; server: 'workspace' } = { client: 'workspace.configuration', server: 'workspace' };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dbaeumer The spec doesn't mention a server capability for the workspace/configuration request so I'm unsure about this. Since this is requested by the server it seems like there's no server capability needed here?

@@ -59,6 +59,7 @@ export namespace CallHierarchyPrepareRequest {
export const messageDirection: MessageDirection = MessageDirection.clientToServer;
export const type = new ProtocolRequestType<CallHierarchyPrepareParams, CallHierarchyItem[] | null, never, void, CallHierarchyRegistrationOptions>(method);
export type HandlerSignature = RequestHandler<CallHierarchyPrepareParams, CallHierarchyItem[] | null, void>;
export const capabilities: { client: 'textDocument.callHierarchy'; server: 'callHierarchyProvider' } = { client: 'textDocument.callHierarchy', server: 'callHierarchyProvider' };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dbaeumer Do you think we should add capability information for requests like callHierarchy/incomingCalls that don't define their own capabilities and instead depend on whether the server supports other methods (in this case textDocument/prepareCallHierarchy)?

@MariaSolOs MariaSolOs force-pushed the capabilities branch 4 times, most recently from 24151f6 to 9dce9a9 Compare December 1, 2024 21:47
@MariaSolOs MariaSolOs marked this pull request as ready for review December 1, 2024 21:48
@MariaSolOs
Copy link
Contributor Author

@microsoft-github-policy-service agree

@dbaeumer
Copy link
Member

dbaeumer commented Dec 9, 2024

@MariaSolOs just a heads up. We have house keeping month in Dezember. New features have to wait until next year.

@MariaSolOs
Copy link
Contributor Author

@MariaSolOs just a heads up. We have house keeping month in Dezember. New features have to wait until next year.

Thanks for the heads-up. Although this isn't user facing so I wouldn't consider it a new feature per se, I understand. I'll wait until January then!

@MariaSolOs
Copy link
Contributor Author

@dbaeumer happy new year!

Are you available to take a look at this PR? :)

@dbaeumer
Copy link
Member

Yes. Will look into it this week.

@dbaeumer
Copy link
Member

dbaeumer commented Jan 24, 2025

The change looks good to me. The only thing I am wondering is that we have a lot of repetition and if we want to change something we need to use find / replace. Alternatively we could investigate something like this:

Current

export const capabilities: { client: 'textDocument.selectionRange'; server: 'selectionRangeProvider' } = { client: 'textDocument.selectionRange', server: 'selectionRangeProvider' }

New

type CM<C extends string, S extends string> = { client: C; server: S };
namespace CM {
   export function create<C extends string, S extends string>(client: C, server: S): CM<C, S> {
       return { client, server };
   }
}

export const capabilities: CM<'textDocument.selectionRange', 'selectionRangeProvider'> = CM.create('textDocument.selectionRange', 'selectionRangeProvider');

Then if we every want to change something we can either do that inside the type definition / or function or at least can use find all references to see where it is used.

What do you think?

@MariaSolOs
Copy link
Contributor Author

The change looks good to me. The only thing I am wondering is that we have a lot of repetition and if we want to change something we need to use find / replace. Alternatively we could investigate something like this:

Current

export const capabilities: { client: 'textDocument.selectionRange'; server: 'selectionRangeProvider' } = { client: 'textDocument.selectionRange', server: 'selectionRangeProvider' }

New

type CM<C extends string, S extends string> = { client: C; server: S };
namespace CM {
   export function create<C extends string, S extends string>(client: C, server: S): CM<C, S> {
       return { client, server };
   }
}

export const capabilities: CM<'textDocument.selectionRange', 'selectionRangeProvider'> = CM.create('textDocument.selectionRange', 'selectionRangeProvider');

Then if we every want to change something we can either do that inside the type definition / or function or at least can use find all references to see where it is used.

What do you think?

That sounds like a good idea. I'll update the PR.

@MariaSolOs
Copy link
Contributor Author

Hmm @dbaeumer how do you want this solution to handle the cases were only a single capability has been documented? Take the workspace/configuration request as an example: There's only the client capability (workspace.configuration)

@dbaeumer
Copy link
Member

We could define the type parameters as C extends string | undefined and then use undefined to indicate there is no server or client capability. But I have not tested it if it works :-)

@MariaSolOs
Copy link
Contributor Author

We could define the type parameters as C extends string | undefined and then use undefined to indicate there is no server or client capability. But I have not tested it if it works :-)

Yeah the thing is that if we do that I think we would lose the literal typing. But I'll play with it.

@MariaSolOs
Copy link
Contributor Author

@dbaeumer I just tried your suggested approach of using CM.create to generate these capability objects, but then this complicates the generator script because the initializer node here is now a call expression (and I don't even think we could invoke it to get the output object literal).

@dbaeumer
Copy link
Member

You don't need to invoke the call expression. You need to look at the arguments of the call expression and then take the arguments and use them in the meta model.

@MariaSolOs
Copy link
Contributor Author

You don't need to invoke the call expression. You need to look at the arguments of the call expression and then take the arguments and use them in the meta model.

Thank you for the hint. I've updated the code to follow your suggested approach :)

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.

Include capability property path information in the metamodel
2 participants