Skip to content

Commit 3892a87

Browse files
remcohaszinggorkem
authored andcommitted
Fix some small type issues
Some parameters are optional, but were marked as required. Language service methods were marked as bound methods, but they don’t have to be called as such. The `Thenable` type from `json-rpc` was used. These were replaced with the builtin TypeScript type `PromiseLike`.
1 parent 3a74bdc commit 3892a87

5 files changed

Lines changed: 27 additions & 27 deletions

File tree

src/languageserver/handlers/languageHandlers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,15 @@ export class LanguageHandlers {
229229
return this.languageService.getCodeAction(textDocument, params);
230230
}
231231

232-
codeLensHandler(params: CodeLensParams): Thenable<CodeLens[] | undefined> | CodeLens[] | undefined {
232+
codeLensHandler(params: CodeLensParams): PromiseLike<CodeLens[] | undefined> | CodeLens[] | undefined {
233233
const textDocument = this.yamlSettings.documents.get(params.textDocument.uri);
234234
if (!textDocument) {
235235
return;
236236
}
237237
return this.languageService.getCodeLens(textDocument);
238238
}
239239

240-
codeLensResolveHandler(param: CodeLens): Thenable<CodeLens> | CodeLens {
240+
codeLensResolveHandler(param: CodeLens): PromiseLike<CodeLens> | CodeLens {
241241
return this.languageService.resolveCodeLens(param);
242242
}
243243

src/languageservice/services/yamlCodeLens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class YamlCodeLens {
4444

4545
return result;
4646
}
47-
resolveCodeLens(param: CodeLens): Thenable<CodeLens> | CodeLens {
47+
resolveCodeLens(param: CodeLens): PromiseLike<CodeLens> | CodeLens {
4848
return param;
4949
}
5050
}

src/languageservice/services/yamlFormatter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class YAMLFormatter {
2121
}
2222
}
2323

24-
public format(document: TextDocument, options: FormattingOptions & CustomFormatterOptions): TextEdit[] {
24+
public format(document: TextDocument, options: Partial<FormattingOptions> & CustomFormatterOptions = {}): TextEdit[] {
2525
if (!this.formatterEnabled) {
2626
return [];
2727
}

src/languageservice/yamlLanguageService.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -157,28 +157,28 @@ export interface CustomFormatterOptions {
157157
}
158158

159159
export interface LanguageService {
160-
configure(settings: LanguageSettings): void;
161-
registerCustomSchemaProvider(schemaProvider: CustomSchemaProvider): void;
162-
doComplete(document: TextDocument, position: Position, isKubernetes: boolean): Promise<CompletionList>;
163-
doValidation(document: TextDocument, isKubernetes: boolean): Promise<Diagnostic[]>;
164-
doHover(document: TextDocument, position: Position): Promise<Hover | null>;
165-
findDocumentSymbols(document: TextDocument, context: DocumentSymbolsContext): SymbolInformation[];
166-
findDocumentSymbols2(document: TextDocument, context: DocumentSymbolsContext): DocumentSymbol[];
167-
findLinks(document: TextDocument): Promise<DocumentLink[]>;
168-
resetSchema(uri: string): boolean;
169-
doFormat(document: TextDocument, options: CustomFormatterOptions): TextEdit[];
170-
doDefinition(document: TextDocument, params: DefinitionParams): DefinitionLink[] | undefined;
171-
doDocumentOnTypeFormatting(document: TextDocument, params: DocumentOnTypeFormattingParams): TextEdit[] | undefined;
172-
addSchema(schemaID: string, schema: JSONSchema): void;
173-
deleteSchema(schemaID: string): void;
174-
modifySchemaContent(schemaAdditions: SchemaAdditions): void;
175-
deleteSchemaContent(schemaDeletions: SchemaDeletions): void;
176-
deleteSchemasWhole(schemaDeletions: SchemaDeletionsAll): void;
177-
getFoldingRanges(document: TextDocument, context: FoldingRangesContext): FoldingRange[] | null;
178-
getSelectionRanges(document: TextDocument, positions: Position[]): SelectionRange[] | undefined;
179-
getCodeAction(document: TextDocument, params: CodeActionParams): CodeAction[] | undefined;
180-
getCodeLens(document: TextDocument): Thenable<CodeLens[] | undefined> | CodeLens[] | undefined;
181-
resolveCodeLens(param: CodeLens): Thenable<CodeLens> | CodeLens;
160+
configure: (settings: LanguageSettings) => void;
161+
registerCustomSchemaProvider: (schemaProvider: CustomSchemaProvider) => void;
162+
doComplete: (document: TextDocument, position: Position, isKubernetes: boolean) => Promise<CompletionList>;
163+
doValidation: (document: TextDocument, isKubernetes: boolean) => Promise<Diagnostic[]>;
164+
doHover: (document: TextDocument, position: Position) => Promise<Hover | null>;
165+
findDocumentSymbols: (document: TextDocument, context?: DocumentSymbolsContext) => SymbolInformation[];
166+
findDocumentSymbols2: (document: TextDocument, context?: DocumentSymbolsContext) => DocumentSymbol[];
167+
findLinks: (document: TextDocument) => Promise<DocumentLink[]>;
168+
resetSchema: (uri: string) => boolean;
169+
doFormat: (document: TextDocument, options?: CustomFormatterOptions) => TextEdit[];
170+
doDefinition: (document: TextDocument, params: DefinitionParams) => DefinitionLink[] | undefined;
171+
doDocumentOnTypeFormatting: (document: TextDocument, params: DocumentOnTypeFormattingParams) => TextEdit[] | undefined;
172+
addSchema: (schemaID: string, schema: JSONSchema) => void;
173+
deleteSchema: (schemaID: string) => void;
174+
modifySchemaContent: (schemaAdditions: SchemaAdditions) => void;
175+
deleteSchemaContent: (schemaDeletions: SchemaDeletions) => void;
176+
deleteSchemasWhole: (schemaDeletions: SchemaDeletionsAll) => void;
177+
getFoldingRanges: (document: TextDocument, context: FoldingRangesContext) => FoldingRange[] | null;
178+
getSelectionRanges: (document: TextDocument, positions: Position[]) => SelectionRange[] | undefined;
179+
getCodeAction: (document: TextDocument, params: CodeActionParams) => CodeAction[] | undefined;
180+
getCodeLens: (document: TextDocument) => PromiseLike<CodeLens[] | undefined> | CodeLens[] | undefined;
181+
resolveCodeLens: (param: CodeLens) => PromiseLike<CodeLens> | CodeLens;
182182
}
183183

184184
export function getLanguageService(params: {

src/yamlSettings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface JSONSchemaSettings {
6060
export class SettingsState {
6161
yamlConfigurationSettings: JSONSchemaSettings[] = undefined;
6262
schemaAssociations: ISchemaAssociations | SchemaConfiguration[] | undefined = undefined;
63-
formatterRegistration: Thenable<Disposable> = null;
63+
formatterRegistration: PromiseLike<Disposable> = null;
6464
specificValidatorPaths = [];
6565
schemaConfigurationSettings = [];
6666
yamlShouldValidate = true;

0 commit comments

Comments
 (0)