(
editor: monaco.editor.IStandaloneCodeEditor,
documentUri: string,
connection: ProtocolConnection
)
| 139 | } |
| 140 | |
| 141 | function setupDocumentHandlingAndDiagnostics( |
| 142 | editor: monaco.editor.IStandaloneCodeEditor, |
| 143 | documentUri: string, |
| 144 | connection: ProtocolConnection |
| 145 | ) { |
| 146 | async function updateDiagnostics() { |
| 147 | const params: DocumentDiagnosticParams = { |
| 148 | textDocument: { |
| 149 | uri: documentUri |
| 150 | } |
| 151 | }; |
| 152 | const result = await connection.sendRequest(DocumentDiagnosticRequest.type, params); |
| 153 | if (result.kind === 'unchanged') { |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | monaco.editor.setModelMarkers(editor.getModel()!, 'lsp', result.items.map(lspToMonacoMarker)); |
| 158 | } |
| 159 | updateDiagnostics(); |
| 160 | |
| 161 | editor.onDidChangeModelContent(async e => { |
| 162 | await connection.sendNotification(DidChangeTextDocumentNotification.type, { |
| 163 | textDocument: { |
| 164 | uri: documentUri, |
| 165 | version: e.versionId |
| 166 | }, |
| 167 | contentChanges: e.changes.map(monacoToLspContentChange) |
| 168 | }); |
| 169 | |
| 170 | await updateDiagnostics(); |
| 171 | }); |
| 172 | } |
| 173 | |
| 174 | function setupHover( |
| 175 | documentUri: string, |
no test coverage detected