mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 16:15:41 +01:00
Merge a25e4fa288 into ec78a33c7b
This commit is contained in:
commit
d7b5659a50
1 changed files with 34 additions and 0 deletions
34
Schema item
Normal file
34
Schema item
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue