chore: more work on the lsp

This commit is contained in:
Andre Henriques 2024-02-29 15:39:13 +00:00
parent 7b1e9e063e
commit d2d5a279ad
5 changed files with 511 additions and 434 deletions

View File

@ -15,6 +15,6 @@ const res = parseLsp(file);
fs.writeFileSync('./res', res.text);
//const diag = await diagnosticsRequests(res);
const diag = await getDiagnostics(file);
//const diag = await getDiagnostics(file);
//add_personal(['AutoML']);

View File

@ -6,7 +6,7 @@ export async function add_personal(words: string[]): Promise<void> {
method: 'POST',
headers: {
'Accept': 'application/json',
'authorization': process.env.AUTHORIZATION ?? '',
'authorization': process.env.AUTHORIZATION_MY_LTEX ?? '',
'content-type': 'application/json',
},
body: JSON.stringify({

14
lsp.ts
View File

@ -187,11 +187,19 @@ async function handleJSON(req: RPCRequest) {
const character = req.params.range.start.character;
const line = req.params.range.start.line;
if (!req.params.context?.diagnostics[0]) {
sendRPCMessage(req, [{
title: "No diagnostics found in this file"
}]);
return;
}
let item: GetDiagnosticsReturn | undefined = undefined;
console.log(JSON.stringify(req.params));
console.log(JSON.stringify(req.params) + "\n\n\n");
console.log(JSON.stringify(req.params.context.diagnostics[0]) + "\n\n\n");
if (!req.params.context?.diagnostics || !req.params.context?.diagnostics[0] || typeof req.params.context?.diagnostics[0].data != 'number') {
if (typeof req.params.context?.diagnostics[0].data != 'number') {
for (const _item of saved) {
if (_item.range.end.line >= line && _item.range.start.line <= line) {
if (_item.range.end.character >= character && _item.range.start.character <= line) {
@ -236,7 +244,7 @@ async function handleJSON(req: RPCRequest) {
changes: {
[reqO.params.textDocument.uri]: [
{
range: item!.range,
range: reqO.params.context.diagnostics[0].range,
newText: value
}
]

View File

@ -2,12 +2,24 @@ import { error, handleData, log } from "./lsp";
console.log = log;
process.stdin.resume();
log('Started the server logging');
try {
log('Listening for Input')
process.stdin.resume();
} catch (e: any) {
log('failed to listen to the stdin');
log(e.toString());
throw e;
}
process.stdin.on('data', function(data) {
try {
handleData(data);
} catch (e) {
error("TRY GOT ERROR:" + e)
}
log('Got the data function');
try {
handleData(data);
} catch (e) {
log("got here")
error("TRY GOT ERROR:" + e)
}
})

899
parser.ts

File diff suppressed because it is too large Load Diff