Skip to content

Commit

Permalink
chore: remove onDidChangeTextDocument CA trigger
Browse files Browse the repository at this point in the history
Signed-off-by: Ilona Shishov <[email protected]>
  • Loading branch information
IlonaShishov committed Feb 12, 2024
1 parent 966eb6c commit d7be642
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
27 changes: 8 additions & 19 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import { globalConfig } from './config';
import { AnalysisLSPServer } from './fileHandler';
import { getDiagnosticsCodeActions, clearCodeActionsMap } from './codeActionHandler';

/**
* Declares timeout identifier to track delays for server.handleFileEvent execution
*/
let checkDelay: NodeJS.Timeout;

/**
* Create a connection for the server, using Node's IPC as a transport.
*/
Expand Down Expand Up @@ -65,36 +60,30 @@ connection.onInitialized(() => {
const server = new AnalysisLSPServer(connection);

/**
* On open document event handler
* On open document trigger event handler
*/
connection.onDidOpenTextDocument((params) => {
server.handleFileEvent(params.textDocument.uri, params.textDocument.text);
});

/**
* On save document event handler
* On changes applied, apply to server file data
*/
connection.onDidSaveTextDocument((params) => {
clearTimeout(checkDelay);
server.handleFileEvent(params.textDocument.uri, server.files.fileData[params.textDocument.uri]);
connection.onDidChangeTextDocument((params) => {
server.files.fileData[params.textDocument.uri] = params.contentChanges[0].text;
});

/**
* On changes applied to document event handler
* On save document trigger event handler
*/
connection.onDidChangeTextDocument((params) => {
server.files.fileData[params.textDocument.uri] = params.contentChanges[0].text;
clearTimeout(checkDelay);
checkDelay = setTimeout(() => {
server.handleFileEvent(params.textDocument.uri, server.files.fileData[params.textDocument.uri]);
}, 3000);
connection.onDidSaveTextDocument((params) => {
server.handleFileEvent(params.textDocument.uri, server.files.fileData[params.textDocument.uri]);
});

/**
* On close document event handler
* On close document clear URI from codeActions Map
*/
connection.onDidCloseTextDocument((params) => {
clearTimeout(checkDelay);
clearCodeActionsMap(params.textDocument.uri);
});

Expand Down
2 changes: 1 addition & 1 deletion test/providers/pom.xml.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe('Java Maven pom.xml parser tests', () => {
]);
});

it('test duplicate dependencies where none specify a version', async () => {
it('tests duplicate dependencies where none specify a version', async () => {
const pom = `
<project>
<dependencies>
Expand Down

0 comments on commit d7be642

Please sign in to comment.