From f286db7650465b42fb6cca337843a12bff03135a Mon Sep 17 00:00:00 2001 From: ecmel Date: Tue, 19 Sep 2023 12:49:22 +0300 Subject: [PATCH] fixed private access --- server/src/qLangServer.ts | 22 ++++++++++++---------- test/suite/qLangServer.test.ts | 24 +++++++++++++----------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/server/src/qLangServer.ts b/server/src/qLangServer.ts index cd509aae..9febc02e 100644 --- a/server/src/qLangServer.ts +++ b/server/src/qLangServer.ts @@ -178,7 +178,7 @@ export default class QLangServer { } } - public onCompletion(params: TextDocumentPositionParams): CompletionItem[] { + private onCompletion(params: TextDocumentPositionParams): CompletionItem[] { const keyword = this.getKeyword(params); if (!keyword) { return []; @@ -186,13 +186,13 @@ export default class QLangServer { return this.analyzer.getCompletionItems(keyword); } - public async onCompletionResolve( + private async onCompletionResolve( item: CompletionItem ): Promise { return item; } - public async onHover( + private async onHover( params: TextDocumentPositionParams ): Promise { const keyword = this.getEntireKeyword(params); @@ -203,14 +203,14 @@ export default class QLangServer { } // TODO: Document highlight - public onDocumentHighlight( + private onDocumentHighlight( params: TextDocumentPositionParams ): DocumentHighlight[] | null { const position = params.position; return []; } - public onDefinition(params: TextDocumentPositionParams): Location[] { + private onDefinition(params: TextDocumentPositionParams): Location[] { const document = this.documents.get(params.textDocument.uri); if (!document) { return []; @@ -246,7 +246,7 @@ export default class QLangServer { }); } - public onDocumentSymbol(params: DocumentSymbolParams): SymbolInformation[] { + private onDocumentSymbol(params: DocumentSymbolParams): SymbolInformation[] { const document = this.documents.get(params.textDocument.uri); if (document) { return this.analyzer.getSymbols(document); @@ -313,7 +313,7 @@ export default class QLangServer { .map((el) => ({ to: el, fromRanges: [el.range] })); } - public onReferences(params: ReferenceParams): Location[] | null { + private onReferences(params: ReferenceParams): Location[] | null { const document = this.documents.get(params.textDocument.uri); if (!document) { return []; @@ -330,7 +330,7 @@ export default class QLangServer { return this.analyzer.getReferences(word, document); } - public onRenameRequest({ + private onRenameRequest({ textDocument, position, newName, @@ -385,7 +385,7 @@ export default class QLangServer { return result; } - public onSemanticsTokens({ + private onSemanticsTokens({ textDocument, }: SemanticTokensParams): SemanticTokens { // Get the semantic tokens for the given document. @@ -394,7 +394,9 @@ export default class QLangServer { return tokens ?? { data: [] }; } - public async validateTextDocument(textDocument: TextDocument): Promise { + private async validateTextDocument( + textDocument: TextDocument + ): Promise { const settings = await this.getDocumentSettings(textDocument.uri); const text = textDocument.getText(); const pattern = /\b[A-Z]{2,}\b/g; diff --git a/test/suite/qLangServer.test.ts b/test/suite/qLangServer.test.ts index faa4dbe3..5477d5a6 100644 --- a/test/suite/qLangServer.test.ts +++ b/test/suite/qLangServer.test.ts @@ -114,7 +114,7 @@ describe("qLangServer tests", () => { it("onCompletion should return empty array for no keyword", () => { const getKeywordStub = sinon.stub(server, "getKeyword"); getKeywordStub.value(() => undefined); - const result = server.onCompletion({ + const result = server["onCompletion"]({ textDocument: { uri: undefined }, position: undefined, }); @@ -123,14 +123,14 @@ describe("qLangServer tests", () => { it("onCompletionResolve should return a value", async () => { const item = { label: "test" }; - const result = await server.onCompletionResolve(item); + const result = await server["onCompletionResolve"](item); assert.strictEqual(result, item); }); it("onHover should return null for no keyword", async () => { const getKeywordStub = sinon.stub(server, "getEntireKeyword"); getKeywordStub.value(() => undefined); - const result = await server.onHover({ + const result = await server["onHover"]({ textDocument: { uri: undefined }, position: undefined, }); @@ -138,7 +138,7 @@ describe("qLangServer tests", () => { }); it("onDocumentHighlight should return empty array for no document", () => { - const result = server.onDocumentHighlight({ + const result = server["onDocumentHighlight"]({ textDocument: { uri: undefined }, position: undefined, }); @@ -148,7 +148,7 @@ describe("qLangServer tests", () => { it("onDefinition should return empty array for no document", () => { const getStub = sinon.stub(server.documents, "get"); getStub.value(() => undefined); - const result = server.onDefinition({ + const result = server["onDefinition"]({ textDocument: { uri: undefined }, position: undefined, }); @@ -158,7 +158,7 @@ describe("qLangServer tests", () => { it("onDocumentSymbol should return empty array for no document", () => { const getStub = sinon.stub(server.documents, "get"); getStub.value(() => undefined); - const result = server.onDocumentSymbol({ + const result = server["onDocumentSymbol"]({ textDocument: { uri: undefined }, position: undefined, }); @@ -168,7 +168,9 @@ describe("qLangServer tests", () => { it("onPrepareCallHierarchy should return empty array for no document", () => { const getStub = sinon.stub(server.documents, "get"); getStub.value(() => undefined); - const result = server.onPrepareCallHierarchy({ + const result = server["onPrepareCallHierarchy"](< + TextDocumentPositionParams + >{ textDocument: { uri: undefined }, position: undefined, }); @@ -194,7 +196,7 @@ describe("qLangServer tests", () => { it("onReferences should return empty array for no document", () => { const getStub = sinon.stub(server.documents, "get"); getStub.value(() => undefined); - const result = server.onReferences({ + const result = server["onReferences"]({ textDocument: { uri: undefined }, }); assert.strictEqual(result.length, 0); @@ -207,7 +209,7 @@ describe("qLangServer tests", () => { const newName = "CHANGEDVAR"; const getStub = sinon.stub(server.documents, "get"); getStub.value(() => doc); - const result = server.onRenameRequest({ + const result = server["onRenameRequest"]({ textDocument, position, newName, @@ -221,7 +223,7 @@ describe("qLangServer tests", () => { const textDocument = TextDocumentIdentifier.create("/test/test.q"); const getStub = sinon.stub(server.documents, "get"); getStub.value(() => doc); - const result = server.onSemanticsTokens({ + const result = server["onSemanticsTokens"]({ textDocument, }); assert.strictEqual(result.data.length, 0); @@ -237,7 +239,7 @@ describe("qLangServer tests", () => { async (params: PublishDiagnosticsParams) => (result = params) ); const doc = TextDocument.create("/test/test.q", "q", 1, "SOMEVAR:1"); - await server.validateTextDocument(doc); + await server["validateTextDocument"](doc); assert.strictEqual(result.diagnostics.length, 1); }); });