Skip to content

Commit

Permalink
Fix some typings
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master committed Nov 27, 2023
1 parent ed03cbf commit 803d5c5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/languageservice/services/yamlSelectionRanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import { yamlDocumentsCache } from '../parser/yaml-documents';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { ASTNode } from 'vscode-json-languageservice';

export function getSelectionRanges(document: TextDocument, positions: Position[]): SelectionRange[] | undefined {
if (!document) {
return;
}
export function getSelectionRanges(document: TextDocument, positions: Position[]): SelectionRange[] {
const doc = yamlDocumentsCache.getYamlDocument(document);
return positions.map((position) => {
const ranges = getRanges(position);
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/yamlLanguageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export interface LanguageService {
deleteSchemaContent: (schemaDeletions: SchemaDeletions) => void;
deleteSchemasWhole: (schemaDeletions: SchemaDeletionsAll) => void;
getFoldingRanges: (document: TextDocument, context: FoldingRangesContext) => FoldingRange[] | null;
getSelectionRanges: (document: TextDocument, positions: Position[]) => SelectionRange[] | undefined;
getSelectionRanges: (document: TextDocument, positions: Position[]) => SelectionRange[];
getCodeAction: (document: TextDocument, params: CodeActionParams) => CodeAction[] | undefined;
getCodeLens: (document: TextDocument) => PromiseLike<CodeLens[] | undefined> | CodeLens[] | undefined;
resolveCodeLens: (param: CodeLens) => PromiseLike<CodeLens> | CodeLens;
Expand Down
10 changes: 6 additions & 4 deletions test/yamlSelectionRanges.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ function isRangesEqual(range1: Range, range2: Range): boolean {
);
}

function expectSelections(selectionRange: SelectionRange, ranges: Range[]): void {
function expectSelections(selectionRange: SelectionRange | undefined, ranges: Range[]): void {
for (const range of ranges) {
expect(selectionRange.range).eql(range);
expect(selectionRange?.range).eql(range);

// Deduplicate ranges
while (selectionRange.parent && isRangesEqual(selectionRange.range, selectionRange.parent.range)) {
while (selectionRange?.parent && isRangesEqual(selectionRange.range, selectionRange.parent.range)) {
selectionRange = selectionRange.parent;
}
selectionRange = selectionRange.parent;

selectionRange = selectionRange?.parent;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"outDir": "./out/server",
"sourceMap": true,
"target": "es2020",
"allowSyntheticDefaultImports": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": [ "src", "test" ],
Expand Down

0 comments on commit 803d5c5

Please sign in to comment.