Skip to content

Commit

Permalink
Prefer vscode-languageserver-types imports (redhat-developer#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing authored May 18, 2022
1 parent 812985f commit f4365bd
Show file tree
Hide file tree
Showing 42 changed files with 83 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/languageserver/commandExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ExecuteCommandParams } from 'vscode-languageserver';
import { ExecuteCommandParams } from 'vscode-languageserver-protocol';

export interface CommandHandler {
(...args: unknown[]): void;
Expand Down
21 changes: 14 additions & 7 deletions src/languageserver/handlers/languageHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,30 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { FoldingRange } from 'vscode-json-languageservice';
import { Connection } from 'vscode-languageserver';
import {
CodeAction,
CodeActionParams,
CompletionList,
DidChangeWatchedFilesParams,
DocumentFormattingParams,
DocumentLink,
DocumentLinkParams,
DocumentOnTypeFormattingParams,
DocumentSymbolParams,
FoldingRangeParams,
Connection,
TextDocumentPositionParams,
CodeLensParams,
DefinitionParams,
} from 'vscode-languageserver';
import { CodeLens, DefinitionLink, DocumentSymbol, Hover, SymbolInformation, TextEdit } from 'vscode-languageserver-types';
} from 'vscode-languageserver-protocol';
import {
CodeAction,
CodeLens,
CompletionList,
DefinitionLink,
DocumentLink,
DocumentSymbol,
Hover,
SymbolInformation,
TextEdit,
} from 'vscode-languageserver-types';
import { isKubernetesAssociatedDocument } from '../../languageservice/parser/isKubernetes';
import { LanguageService } from '../../languageservice/yamlLanguageService';
import { SettingsState } from '../../yamlSettings';
Expand Down Expand Up @@ -214,7 +221,7 @@ export class LanguageHandlers {
if (!textDocument) {
return;
}
return this.languageService.getCodeLens(textDocument, params);
return this.languageService.getCodeLens(textDocument);
}

codeLensResolveHandler(param: CodeLens): Thenable<CodeLens> | CodeLens {
Expand Down
2 changes: 1 addition & 1 deletion src/languageserver/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Connection } from 'vscode-languageserver/lib/common/server';
import { Connection } from 'vscode-languageserver';

/**
* Due to LSP limitation this object must be JSON serializable
Expand Down
3 changes: 1 addition & 2 deletions src/languageservice/parser/jsonParser07.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import {
import { ErrorCode } from 'vscode-json-languageservice';
import * as nls from 'vscode-nls';
import { URI } from 'vscode-uri';
import { DiagnosticSeverity, Range } from 'vscode-languageserver-types';
import { Diagnostic, DiagnosticSeverity, Range } from 'vscode-languageserver-types';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { Diagnostic } from 'vscode-languageserver';
import { isArrayEqual } from '../utils/arrUtils';
import { Node, Pair } from 'yaml';
import { safeCreateUnicodeRegExp } from '../utils/strings';
Expand Down
5 changes: 2 additions & 3 deletions src/languageservice/services/yamlCodeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@

import { TextDocument } from 'vscode-languageserver-textdocument';
import {
ClientCapabilities,
CodeAction,
CodeActionKind,
CodeActionParams,
Command,
Diagnostic,
Position,
Range,
TextEdit,
WorkspaceEdit,
} from 'vscode-languageserver';
} from 'vscode-languageserver-types';
import { ClientCapabilities, CodeActionParams } from 'vscode-languageserver-protocol';
import { YamlCommands } from '../../commands';
import * as path from 'path';
import { TextBuffer } from '../utils/textBuffer';
Expand Down
4 changes: 1 addition & 3 deletions src/languageservice/services/yamlCodeLens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ import { YAMLSchemaService } from './yamlSchemaService';
import { URI } from 'vscode-uri';
import * as path from 'path';
import { JSONSchema } from '../jsonSchema';
import { CodeLensParams } from 'vscode-languageserver-protocol';
import { Telemetry } from '../../languageserver/telemetry';
import { getSchemaUrls } from '../utils/schemaUrls';
import { convertErrorToTelemetryMsg } from '../utils/objects';

export class YamlCodeLens {
constructor(private schemaService: YAMLSchemaService, private readonly telemetry: Telemetry) {}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
async getCodeLens(document: TextDocument, params: CodeLensParams): Promise<CodeLens[]> {
async getCodeLens(document: TextDocument): Promise<CodeLens[]> {
const result = [];
try {
const yamlDocument = yamlDocumentsCache.getYamlDocument(document);
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/services/yamlCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Connection } from 'vscode-languageserver/node';
import { Connection } from 'vscode-languageserver';
import { YamlCommands } from '../../commands';
import { CommandExecutor } from '../../languageserver/commandExecutor';
import { URI } from 'vscode-uri';
Expand Down
4 changes: 2 additions & 2 deletions src/languageservice/services/yamlCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/

import { TextDocument } from 'vscode-languageserver-textdocument';
import { ClientCapabilities } from 'vscode-languageserver';
import {
ClientCapabilities,
CompletionItem as CompletionItemBase,
CompletionItemKind,
CompletionList,
Expand All @@ -16,7 +16,7 @@ import {
Position,
Range,
TextEdit,
} from 'vscode-languageserver/node';
} from 'vscode-languageserver-types';
import { Node, isPair, isScalar, isMap, YAMLMap, isSeq, YAMLSeq, isNode, Pair } from 'yaml';
import { Telemetry } from '../../languageserver/telemetry';
import { SingleYAMLDocument, YamlDocuments } from '../parser/yaml-documents';
Expand Down
4 changes: 2 additions & 2 deletions src/languageservice/services/yamlDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { DefinitionParams, LocationLink, Range } from 'vscode-languageserver-protocol';
import { DefinitionParams } from 'vscode-languageserver-protocol';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { DefinitionLink } from 'vscode-languageserver-types';
import { DefinitionLink, LocationLink, Range } from 'vscode-languageserver-types';
import { isAlias } from 'yaml';
import { Telemetry } from '../../languageserver/telemetry';
import { yamlDocumentsCache } from '../parser/yaml-documents';
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/services/yamlFolding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { FoldingRange, Range } from 'vscode-languageserver';
import { FoldingRange, Range } from 'vscode-languageserver-types';
import { FoldingRangesContext } from '../yamlTypes';
import { ASTNode } from '../jsonASTTypes';
import { yamlDocumentsCache } from '../parser/yaml-documents';
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/services/yamlLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { findLinks as JSONFindLinks } from 'vscode-json-languageservice/lib/umd/services/jsonLinks';
import { DocumentLink } from 'vscode-languageserver';
import { DocumentLink } from 'vscode-languageserver-types';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { Telemetry } from '../../languageserver/telemetry';
import { yamlDocumentsCache } from '../parser/yaml-documents';
Expand Down
3 changes: 2 additions & 1 deletion src/languageservice/services/yamlOnTypeFormatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { DocumentOnTypeFormattingParams, Position, Range, TextEdit } from 'vscode-languageserver';
import { DocumentOnTypeFormattingParams } from 'vscode-languageserver';
import { Position, Range, TextEdit } from 'vscode-languageserver-types';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { TextBuffer } from '../utils/textBuffer';

Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/services/yamlValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';

import { Diagnostic, Position } from 'vscode-languageserver';
import { Diagnostic, Position } from 'vscode-languageserver-types';
import { LanguageSettings } from '../yamlLanguageService';
import { YAMLDocument, YamlVersion } from '../parser/yamlParser07';
import { SingleYAMLDocument } from '../parser/yamlParser07';
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/utils/paths.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WorkspaceFolder, WorkspaceFoldersChangeEvent } from 'vscode-languageserver';
import { WorkspaceFolder, WorkspaceFoldersChangeEvent } from 'vscode-languageserver-protocol';
import { join, normalize, sep } from 'path';
import { URI } from 'vscode-uri';

Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/utils/ranges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Range } from 'vscode-languageserver';
import { Range } from 'vscode-languageserver-types';

/**
* Check if rangeA and rangeB is intersect
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/utils/schemaUrls.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WorkspaceFolder } from 'vscode-languageserver';
import { WorkspaceFolder } from 'vscode-languageserver-protocol';
import { URI } from 'vscode-uri';
import { Telemetry } from '../../languageserver/telemetry';
import { JSONSchema, JSONSchemaRef } from '../jsonSchema';
Expand Down
2 changes: 1 addition & 1 deletion src/languageservice/utils/textBuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { TextDocument } from 'vscode-json-languageservice';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { Position, Range } from 'vscode-languageserver-types';

interface FullTextDocument {
Expand Down
13 changes: 6 additions & 7 deletions src/languageservice/yamlLanguageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import {
} from './services/yamlSchemaService';
import {
Position,
CodeAction,
CompletionList,
Diagnostic,
Hover,
SymbolInformation,
DocumentSymbol,
FoldingRange,
TextEdit,
DocumentLink,
CodeLens,
Expand All @@ -31,15 +33,12 @@ import { YAMLFormatter } from './services/yamlFormatter';
import { DocumentSymbolsContext } from 'vscode-json-languageservice';
import { YamlLinks } from './services/yamlLinks';
import {
FoldingRange,
ClientCapabilities,
CodeActionParams,
CodeAction,
Connection,
DocumentOnTypeFormattingParams,
CodeLensParams,
DefinitionParams,
} from 'vscode-languageserver/node';
} from 'vscode-languageserver';
import { TextDocument } from 'vscode-languageserver-textdocument';
import { getFoldingRanges } from './services/yamlFolding';
import { FoldingRangesContext, SchemaVersions } from './yamlTypes';
Expand Down Expand Up @@ -165,7 +164,7 @@ export interface LanguageService {
deleteSchemasWhole(schemaDeletions: SchemaDeletionsAll): void;
getFoldingRanges(document: TextDocument, context: FoldingRangesContext): FoldingRange[] | null;
getCodeAction(document: TextDocument, params: CodeActionParams): CodeAction[] | undefined;
getCodeLens(document: TextDocument, params: CodeLensParams): Thenable<CodeLens[] | undefined> | CodeLens[] | undefined;
getCodeLens(document: TextDocument): Thenable<CodeLens[] | undefined> | CodeLens[] | undefined;
resolveCodeLens(param: CodeLens): Thenable<CodeLens> | CodeLens;
}

Expand Down Expand Up @@ -250,8 +249,8 @@ export function getLanguageService(
getCodeAction: (document, params) => {
return yamlCodeActions.getCodeAction(document, params);
},
getCodeLens: (document, params) => {
return yamlCodeLens.getCodeLens(document, params);
getCodeLens: (document) => {
return yamlCodeLens.getCodeLens(document);
},
resolveCodeLens: (param) => yamlCodeLens.resolveCodeLens(param),
};
Expand Down
2 changes: 1 addition & 1 deletion src/yamlSettings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TextDocuments, Disposable, ClientCapabilities, WorkspaceFolder } from 'vscode-languageserver/node';
import { TextDocuments, Disposable, ClientCapabilities, WorkspaceFolder } from 'vscode-languageserver';
import { CustomFormatterOptions, SchemaConfiguration } from './languageservice/yamlLanguageService';
import { ISchemaAssociations } from './requestTypes';
import { URI } from 'vscode-uri';
Expand Down
2 changes: 1 addition & 1 deletion test/autoCompletion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import assert = require('assert');
import path = require('path');
import { createExpectedCompletion } from './utils/verifyError';
import { ServiceSetup } from './utils/serviceSetup';
import { CompletionList, InsertTextFormat, MarkupContent, MarkupKind, Position } from 'vscode-languageserver';
import { CompletionList, InsertTextFormat, MarkupContent, MarkupKind, Position } from 'vscode-languageserver-types';
import { expect } from 'chai';
import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings';
import { LanguageService } from '../src';
Expand Down
2 changes: 1 addition & 1 deletion test/autoCompletionFix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { CompletionList, Position, Range } from 'vscode-languageserver/node';
import { CompletionList, Position, Range } from 'vscode-languageserver-types';
import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers';
import { LanguageService } from '../src/languageservice/yamlLanguageService';
import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings';
Expand Down
2 changes: 1 addition & 1 deletion test/customTags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { setupLanguageService, setupTextDocument } from './utils/testHelper';
import { ServiceSetup } from './utils/serviceSetup';
import { createExpectedError } from './utils/verifyError';
import * as assert from 'assert';
import { Diagnostic } from 'vscode-languageserver';
import { Diagnostic } from 'vscode-languageserver-types';
import { LanguageService } from '../src/languageservice/yamlLanguageService';
import { ValidationHandler } from '../src/languageserver/handlers/validationHandlers';

Expand Down
2 changes: 1 addition & 1 deletion test/defaultSnippets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import path = require('path');
import { ServiceSetup } from './utils/serviceSetup';
import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers';
import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings';
import { CompletionList, TextEdit } from 'vscode-languageserver';
import { CompletionList, TextEdit } from 'vscode-languageserver-types';
import { expect } from 'chai';

describe('Default Snippet Tests', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/documentSymbols.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { DocumentSymbol, SymbolKind } from 'vscode-languageserver-types';
import assert = require('assert');
import { ServiceSetup } from './utils/serviceSetup';
import { SymbolInformation } from 'vscode-languageserver';
import { SymbolInformation } from 'vscode-languageserver-types';
import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings';
import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers';

Expand Down
2 changes: 1 addition & 1 deletion test/findLinks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { setupLanguageService, setupTextDocument } from './utils/testHelper';
import assert = require('assert');
import { ServiceSetup } from './utils/serviceSetup';
import { DocumentLink } from 'vscode-languageserver';
import { DocumentLink } from 'vscode-languageserver-types';
import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings';
import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers';

Expand Down
2 changes: 1 addition & 1 deletion test/formatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { setupLanguageService, setupTextDocument } from './utils/testHelper';
import { ServiceSetup } from './utils/serviceSetup';
import * as assert from 'assert';
import { TextEdit } from 'vscode-languageserver';
import { TextEdit } from 'vscode-languageserver-types';
import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings';
import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers';

Expand Down
2 changes: 1 addition & 1 deletion test/hover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ServiceSetup } from './utils/serviceSetup';
import { SCHEMA_ID, setupLanguageService, setupSchemaIDTextDocument } from './utils/testHelper';
import { LanguageService } from '../src';
import * as assert from 'assert';
import { Hover, MarkupContent, Position } from 'vscode-languageserver';
import { Hover, MarkupContent, Position } from 'vscode-languageserver-types';
import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers';
import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings';
import { expect } from 'chai';
Expand Down
2 changes: 1 addition & 1 deletion test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { setupLanguageService, setupTextDocument } from './utils/testHelper';
import * as assert from 'assert';
import { Diagnostic, CompletionList, Hover, MarkupContent } from 'vscode-languageserver';
import { Diagnostic, CompletionList, Hover, MarkupContent } from 'vscode-languageserver-types';
import { ServiceSetup } from './utils/serviceSetup';
import { LanguageHandlers } from '../src/languageserver/handlers/languageHandlers';
import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings';
Expand Down
3 changes: 1 addition & 2 deletions test/jsonParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { getNodeValue, JSONDocument } from './../src/languageservice/parser/json
import * as JsonSchema from './../src/languageservice/jsonSchema';
import { ASTNode, ObjectASTNode } from './../src/languageservice/jsonASTTypes';
import { ErrorCode, getLanguageService } from 'vscode-json-languageservice';
import { TextDocument, Range } from 'vscode-languageserver-types';
import { Diagnostic } from 'vscode-languageserver';
import { Diagnostic, TextDocument, Range } from 'vscode-languageserver-types';

describe('JSON Parser', () => {
function isValid(json: string): void {
Expand Down
2 changes: 1 addition & 1 deletion test/multipleDocuments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as path from 'path';
import { setupLanguageService, setupTextDocument, toFsPath } from './utils/testHelper';
import * as assert from 'assert';
import { ServiceSetup } from './utils/serviceSetup';
import { Diagnostic, Hover, MarkupContent } from 'vscode-languageserver';
import { Diagnostic, Hover, MarkupContent } from 'vscode-languageserver-types';
import { SettingsState, TextDocumentTestManager } from '../src/yamlSettings';
import { LanguageService } from '../src/languageservice/yamlLanguageService';
import { ValidationHandler } from '../src/languageserver/handlers/validationHandlers';
Expand Down
2 changes: 1 addition & 1 deletion test/paths.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as assert from 'assert';
import { WorkspaceFolder } from 'vscode-languageserver';
import { WorkspaceFolder } from 'vscode-languageserver-protocol';
import { join } from 'path';

import { relativeToAbsolutePath, isRelativePath, workspaceFoldersChanged } from '../src/languageservice/utils/paths';
Expand Down
2 changes: 1 addition & 1 deletion test/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { expect } from 'chai';
import { ServiceSetup } from './utils/serviceSetup';
import { setupLanguageService, setupTextDocument, TEST_URI } from './utils/testHelper';
import { LanguageService, SchemaPriority } from '../src';
import { MarkupContent, Position } from 'vscode-languageserver';
import { MarkupContent, Position } from 'vscode-languageserver-types';
import { LineCounter } from 'yaml';
import { getSchemaFromModeline } from '../src/languageservice/services/modelineUtil';

Expand Down
Loading

0 comments on commit f4365bd

Please sign in to comment.