Skip to content

Commit

Permalink
fixed private access
Browse files Browse the repository at this point in the history
  • Loading branch information
ecmel committed Sep 19, 2023
1 parent 08fa3f8 commit f286db7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
22 changes: 12 additions & 10 deletions server/src/qLangServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,21 @@ export default class QLangServer {
}
}

public onCompletion(params: TextDocumentPositionParams): CompletionItem[] {
private onCompletion(params: TextDocumentPositionParams): CompletionItem[] {
const keyword = this.getKeyword(params);
if (!keyword) {
return [];
}
return this.analyzer.getCompletionItems(keyword);
}

public async onCompletionResolve(
private async onCompletionResolve(
item: CompletionItem
): Promise<CompletionItem> {
return item;
}

public async onHover(
private async onHover(
params: TextDocumentPositionParams
): Promise<Hover | null> {
const keyword = this.getEntireKeyword(params);
Expand All @@ -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 [];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 [];
Expand All @@ -330,7 +330,7 @@ export default class QLangServer {
return this.analyzer.getReferences(word, document);
}

public onRenameRequest({
private onRenameRequest({
textDocument,
position,
newName,
Expand Down Expand Up @@ -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.
Expand All @@ -394,7 +394,9 @@ export default class QLangServer {
return tokens ?? { data: [] };
}

public async validateTextDocument(textDocument: TextDocument): Promise<void> {
private async validateTextDocument(
textDocument: TextDocument
): Promise<void> {
const settings = await this.getDocumentSettings(textDocument.uri);
const text = textDocument.getText();
const pattern = /\b[A-Z]{2,}\b/g;
Expand Down
24 changes: 13 additions & 11 deletions test/suite/qLangServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe("qLangServer tests", () => {
it("onCompletion should return empty array for no keyword", () => {
const getKeywordStub = sinon.stub(server, <any>"getKeyword");
getKeywordStub.value(() => undefined);
const result = server.onCompletion(<TextDocumentPositionParams>{
const result = server["onCompletion"](<TextDocumentPositionParams>{
textDocument: { uri: undefined },
position: undefined,
});
Expand All @@ -123,22 +123,22 @@ describe("qLangServer tests", () => {

it("onCompletionResolve should return a value", async () => {
const item = <CompletionItem>{ 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, <any>"getEntireKeyword");
getKeywordStub.value(() => undefined);
const result = await server.onHover(<TextDocumentPositionParams>{
const result = await server["onHover"](<TextDocumentPositionParams>{
textDocument: { uri: undefined },
position: undefined,
});
assert.strictEqual(result, null);
});

it("onDocumentHighlight should return empty array for no document", () => {
const result = server.onDocumentHighlight(<TextDocumentPositionParams>{
const result = server["onDocumentHighlight"](<TextDocumentPositionParams>{
textDocument: { uri: undefined },
position: undefined,
});
Expand All @@ -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(<TextDocumentPositionParams>{
const result = server["onDefinition"](<TextDocumentPositionParams>{
textDocument: { uri: undefined },
position: undefined,
});
Expand All @@ -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(<TextDocumentPositionParams>{
const result = server["onDocumentSymbol"](<TextDocumentPositionParams>{
textDocument: { uri: undefined },
position: undefined,
});
Expand All @@ -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(<TextDocumentPositionParams>{
const result = server["onPrepareCallHierarchy"](<
TextDocumentPositionParams
>{
textDocument: { uri: undefined },
position: undefined,
});
Expand All @@ -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(<ReferenceParams>{
const result = server["onReferences"](<ReferenceParams>{
textDocument: { uri: undefined },
});
assert.strictEqual(result.length, 0);
Expand All @@ -207,7 +209,7 @@ describe("qLangServer tests", () => {
const newName = "CHANGEDVAR";
const getStub = sinon.stub(server.documents, "get");
getStub.value(() => doc);
const result = server.onRenameRequest(<RenameParams>{
const result = server["onRenameRequest"](<RenameParams>{
textDocument,
position,
newName,
Expand All @@ -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(<SemanticTokensParams>{
const result = server["onSemanticsTokens"](<SemanticTokensParams>{
textDocument,
});
assert.strictEqual(result.data.length, 0);
Expand All @@ -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);
});
});

0 comments on commit f286db7

Please sign in to comment.