redhat-developer / redhat-developer/vscode-yaml
Allow requestSchema to return Promise
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 829
- Forks
- 260
- Avg merge
- 5h 43m
- Merged PRs (30d)
- 1
Description
Is your enhancement related to a problem? Please describe.
We integrate vscode-yaml to provide language support for our yaml project configuration files. Nature of the config is such that you can't decide just by looking at the name of the file what "type" of configuration file it is. To find if given file is even part of our project configuration and if so what role it plays (thus what schema to apply) we need to invoke some async code, which we can't do because requestSchema requires immediate string result.
Describe the solution you would like
We'd like the ExtensionAPI.registerContributor to be extended like this
registerContributor(
schema: string,
requestSchema: (resource: string) => Promise<string> | string, // << Allows `Promise<string>` here
requestSchemaContent: (uri: string) => Promise<string> | string,
label?: string
): boolean;
this change should be backwards compatible as simple string result is still allowed.
Looking at the history I see requestSchemaContent also started as allowing only string return but in time was extended to also allow Promise<string> - was there some reason to keep requestSchema synchronous only or was there simply no usecase for also extending it so it was left as is?
Describe alternatives you have considered
It is possible to work around this limitation by eagerly caching results for requestSchema so when this callback is invoked we can return the cached value (if already available) but we'd like to fall back to this solution as last resort as it will introduce significant complexity for our implementation and consume extra time+memory for the user (we have to eagerly prefetch everything to have it ready for when requestSchema gets called)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the ExtensionAPI.registerContributor entry point and compare requestSchema with the existing requestSchemaContent callback, which already supports synchronous and Promise results. Trace how the requestSchema return value is consumed. Done means Promise is accepted while existing string callbacks remain supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, devtools
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100