-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Expose JSON worker #3956
base: main
Are you sure you want to change the base?
Expose JSON worker #3956
Conversation
@microsoft-github-policy-service agree |
Worth noting, this mirrors exactly what the typescript/javascript worker do and how they expose their worker. |
ced3760
to
c1dd3e1
Compare
And as an example of what this allows monaco.languages.registerCodeLensProvider('json', {
provideCodeLenses: async function (model, token) {
const getWorker = await monaco.languages.json.getWorker();
const worker = await getWorker(model.uri.toString());
const schema = await worker.getMatchingSchemas(model.uri.toString());
return {
lenses: schema
.filter((item) => item.schema.format === 'ipv4')
.map((schemaItem) => {
const start = model.getPositionAt(schemaItem.node.parent.offset);
const end = model.getPositionAt(
schemaItem.node.parent.offset + schemaItem.node.parent.length
);
return {
range: {
startLineNumber: start.lineNumber,
startColumn: start.column,
endLineNumber: end.lineNumber,
endColumn: end.column,
},
id: 'First Line',
command: {
id: commandId,
title: 'Select VM',
},
};
}),
dispose: () => {},
};
},
resolveCodeLens: function (model, codeLens, token) {
return codeLens;
},
}); |
Sorry to hear that. What problems did you run into? |
Any news on this pull request? This is exactly what I am looking for. |
@@ -4,7 +4,8 @@ | |||
*--------------------------------------------------------------------------------------------*/ | |||
|
|||
import * as mode from './jsonMode'; | |||
import { Emitter, IEvent, languages } from '../../fillers/monaco-editor-core'; | |||
import { Emitter, IEvent, languages, Uri } from '../../fillers/monaco-editor-core'; | |||
import type { JSONWorker } from './jsonWorker'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want that all exported types are in monaco.contribution.ts. So also a interface describing the JSONWorker
should be defined here.
Can you add a IJSONWorker. I suggest it is limited to the function you want to expose.
Fix #727
Exposes the JSON worker and the parseDocument function from the JSON Worker.
This is useful when editors want to use the JSON Worker's ability to parse the document, as using a separate parser can result in inconsistencies and does double the work.
(I had a lot of trouble getting this repository to build properly. Best I can tell the instructions in CONTRIBUTING should be significantly updated, and certain things just don't seem to work (the standard playground linked execution seems to never work with the JSON worker)).