Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,295 changes: 0 additions & 2,295 deletions package-lock.json

This file was deleted.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
},
"dependencies": {
"js-yaml": "^3.13.1",
"jsonc-parser": "^2.1.0",
"jsonc-parser": "^2.2.1",
"request-light": "^0.2.4",
"vscode-json-languageservice": "^3.3.0",
"vscode-json-languageservice": "^3.5.2",
"vscode-languageserver": "^5.2.1",
"vscode-languageserver-types": "^3.14.0",
"vscode-nls": "^4.1.1",
"vscode-uri": "^2.0.3",
"vscode-languageserver-types": "^3.15.1",
"vscode-nls": "^4.1.2",
"vscode-uri": "^2.1.1",
"yaml-ast-parser-custom-tags": "0.0.43"
},
"optionalDependencies": {
Expand All @@ -52,9 +52,9 @@
"nyc": "^14.1.1",
"source-map-support": "^0.5.12",
"ts-node": "^5.0.1",
"tslint": "^5.18.0",
"typescript": "^3.5.3",
"typescript-tslint-plugin": "^0.5.4"
"tslint": "^6.1.1",
"typescript": "^3.8.3",
"typescript-tslint-plugin": "^0.5.5"
},
"scripts": {
"compile": "installServerIntoExtension ./out ./package.json ./tsconfig.json && tsc -p .",
Expand Down
14 changes: 11 additions & 3 deletions src/languageservice/services/yamlSchemaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { SchemaRequestService, WorkspaceContextService, PromiseConstructor, Then
import { UnresolvedSchema, ResolvedSchema, JSONSchemaService,
SchemaDependencies, ISchemaContributions } from 'vscode-json-languageservice/lib/umd/services/jsonSchemaService';

import { URI } from 'vscode-uri';

import * as nls from 'vscode-nls';
import { convertSimple2RegExpPattern } from '../utils/strings';
const localize = nls.loadMessageBundle();
Expand Down Expand Up @@ -71,7 +73,7 @@ export class YAMLSchemaService extends JSONSchemaService {
[x: string]: any;

private customSchemaProvider: CustomSchemaProvider | undefined;
private filePatternAssociations: FilePatternAssociation[];
private filePatternAssociations: JSONSchemaService.FilePatternAssociation[];
private contextService: WorkspaceContextService;

constructor(requestService: SchemaRequestService, contextService?: WorkspaceContextService, promiseConstructor?: PromiseConstructor) {
Expand Down Expand Up @@ -219,7 +221,7 @@ export class YAMLSchemaService extends JSONSchemaService {
const schemas: string[] = [];
for (const entry of this.filePatternAssociations) {
if (entry.matchesPattern(resource)) {
for (const schemaId of entry.getSchemas()) {
for (const schemaId of entry.getURIs()) {
if (!seen[schemaId]) {
schemas.push(schemaId);
seen[schemaId] = true;
Expand Down Expand Up @@ -368,7 +370,13 @@ export class YAMLSchemaService extends JSONSchemaService {
*/

normalizeId(id: string) {
return super.normalizeId(id);
// The parent's `super.normalizeId(id)` isn't visible, so duplicated the code here
try {
return URI.parse(id).toString();
}
catch (e) {
return id;
}
}

getOrAddSchemaHandle(id: string, unresolvedSchemaContent?: JSONSchema) {
Expand Down
6 changes: 3 additions & 3 deletions test/autoCompletion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { TextDocument } from 'vscode-languageserver';
import { getLanguageService } from '../src/languageservice/yamlLanguageService';
import { schemaRequestService, workspaceContext } from './utils/testHelper';
import { schemaRequestService, workspaceContext, TEST_URI } from './utils/testHelper';
import assert = require('assert');

const languageService = getLanguageService(schemaRequestService, workspaceContext, [], null);
Expand All @@ -21,7 +21,7 @@ languageService.configure(languageSettings);
suite('Auto Completion Tests', () => {

function setup(content: string) {
return TextDocument.create('file://~/Desktop/vscode-k8s/test.yaml', 'yaml', 0, content);
return TextDocument.create(TEST_URI, 'yaml', 0, content);
}

function parseSetup(content: string, position) {
Expand Down Expand Up @@ -194,7 +194,7 @@ suite('Auto Completion Tests', () => {
};
languageService.configure({
schemas: [{
uri: 'file://test.yaml',
uri: TEST_URI,
fileMatch: ['*.yaml', '*.yml'],
schema
}],
Expand Down
34 changes: 19 additions & 15 deletions test/documentSymbols.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ suite('Document Symbols Tests', () => {
assert.equal(symbols.length, 1);
assert.deepEqual(
symbols[0],
createExpectedSymbolInformation('cwd', 15, undefined, TEST_URI, 0, 0, 0, 9)
createExpectedSymbolInformation('cwd', 15, "", TEST_URI, 0, 0, 0, 9)
);
});

Expand All @@ -42,7 +42,7 @@ suite('Document Symbols Tests', () => {
assert.equal(symbols.length, 1);
assert.deepEqual(
symbols[0],
createExpectedSymbolInformation('node1', 16, undefined, TEST_URI, 0, 0, 0, 12)
createExpectedSymbolInformation('node1', 16, "", TEST_URI, 0, 0, 0, 12)
);
});

Expand All @@ -52,7 +52,7 @@ suite('Document Symbols Tests', () => {
assert.equal(symbols.length, 1);
assert.deepEqual(
symbols[0],
createExpectedSymbolInformation('node1', 17, undefined, TEST_URI, 0, 0, 0, 12)
createExpectedSymbolInformation('node1', 17, "", TEST_URI, 0, 0, 0, 12)
);
});

Expand All @@ -62,7 +62,7 @@ suite('Document Symbols Tests', () => {
assert.equal(symbols.length, 3);
assert.deepEqual(
symbols[0],
createExpectedSymbolInformation('scripts', 2, undefined, TEST_URI, 0, 0, 2, 13)
createExpectedSymbolInformation('scripts', 2, "", TEST_URI, 0, 0, 2, 13)
);
assert.deepEqual(
symbols[1],
Expand All @@ -80,7 +80,7 @@ suite('Document Symbols Tests', () => {
assert.equal(symbols.length, 1);
assert.deepEqual(
symbols[0],
createExpectedSymbolInformation('apiVersion', SymbolKind.Variable, undefined, TEST_URI, 0, 0, 0, 16)
createExpectedSymbolInformation('apiVersion', SymbolKind.Variable, "", TEST_URI, 0, 0, 0, 16)
);
});

Expand All @@ -90,7 +90,7 @@ suite('Document Symbols Tests', () => {
assert.equal(symbols.length, 1);
assert.deepEqual(
symbols[0],
createExpectedSymbolInformation('items', SymbolKind.Array, undefined, TEST_URI, 0, 0, 2, 8)
createExpectedSymbolInformation('items', SymbolKind.Array, "", TEST_URI, 0, 0, 2, 8)
);
});

Expand All @@ -100,7 +100,7 @@ suite('Document Symbols Tests', () => {
assert.equal(symbols.length, 3);
assert.deepEqual(
symbols[0],
createExpectedSymbolInformation('authors', 18, undefined, TEST_URI, 0, 0, 2, 13)
createExpectedSymbolInformation('authors', 18, "", TEST_URI, 0, 0, 2, 13)
);
assert.deepEqual(
symbols[1],
Expand All @@ -116,29 +116,33 @@ suite('Document Symbols Tests', () => {
const content = 'scripts:\n node1: test\n node2: test\nauthors:\n - name: Josh\n - email: jp';
const symbols = parseNonHierarchicalSetup(content);
assert.equal(symbols.length, 6);

// Sort the items first so they have predictable order in the array
symbols.sort((a, b) => a.name.localeCompare(b.name));

assert.deepEqual(
symbols[0],
createExpectedSymbolInformation('scripts', 2, undefined, TEST_URI, 0, 0, 2, 13)
createExpectedSymbolInformation('authors', 18, "", TEST_URI, 3, 0, 5, 13)
);
assert.deepEqual(
symbols[1],
createExpectedSymbolInformation('node1', 15, 'scripts', TEST_URI, 1, 2, 1, 13)
createExpectedSymbolInformation('email', 15, 'authors', TEST_URI, 5, 4, 5, 13)
);
assert.deepEqual(
symbols[2],
createExpectedSymbolInformation('node2', 15, 'scripts', TEST_URI, 2, 2, 2, 13)
createExpectedSymbolInformation('name', 15, 'authors', TEST_URI, 4, 4, 4, 14)
);
assert.deepEqual(
symbols[3],
createExpectedSymbolInformation('authors', 18, undefined, TEST_URI, 3, 0, 5, 13)
createExpectedSymbolInformation('node1', 15, 'scripts', TEST_URI, 1, 2, 1, 13)
);
assert.deepEqual(
symbols[4],
createExpectedSymbolInformation('name', 15, 'authors', TEST_URI, 4, 4, 4, 14)
createExpectedSymbolInformation('node2', 15, 'scripts', TEST_URI, 2, 2, 2, 13)
);
assert.deepEqual(
symbols[5],
createExpectedSymbolInformation('email', 15, 'authors', TEST_URI, 5, 4, 5, 13)
createExpectedSymbolInformation('scripts', 2, "", TEST_URI, 0, 0, 2, 13)
);
});

Expand All @@ -148,11 +152,11 @@ suite('Document Symbols Tests', () => {
assert.equal(symbols.length, 2);
assert.deepEqual(
symbols[0],
createExpectedSymbolInformation('analytics', 17, undefined, TEST_URI, 1, 0, 1, 15)
createExpectedSymbolInformation('analytics', 17, "", TEST_URI, 1, 0, 1, 15)
);
assert.deepEqual(
symbols[1],
createExpectedSymbolInformation('json', 15, undefined, TEST_URI, 4, 0, 4, 10)
createExpectedSymbolInformation('json', 15, "", TEST_URI, 4, 0, 4, 10)
);
});

Expand Down
2 changes: 1 addition & 1 deletion test/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ suite('JSON Schema', () => {

service.getResolvedSchema('main').then(fs => {
const section = fs.getSection(['child', 'grandchild']);
assert.strictEqual(section, null);
assert.strictEqual(section, undefined);
}).then(() => testDone(), error => {
testDone(error);
});
Expand Down
8 changes: 4 additions & 4 deletions test/schemaValidation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Red Hat. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { configureLanguageService, setupTextDocument } from './utils/testHelper';
import { configureLanguageService, setupTextDocument, TEST_URI } from './utils/testHelper';
import { createExpectedError } from './utils/verifyError';
import { ServiceSetup } from './utils/serviceSetup';
import { StringTypeError, BooleanTypeError, ArrayTypeError, ObjectTypeError, IncludeWithoutValueError, ColonMissingError, BlockMappingEntryError } from './utils/errorMessages';
Expand Down Expand Up @@ -406,7 +406,7 @@ suite('Validation Tests', () => {
};
languageService.configure({
schemas: [{
uri: 'file://test.yaml',
uri: TEST_URI,
fileMatch: ['*.yaml', '*.yml'],
schema
}],
Expand All @@ -432,7 +432,7 @@ suite('Validation Tests', () => {
};
languageService.configure({
schemas: [{
uri: 'file://test.yaml',
uri: TEST_URI,
fileMatch: ['*.yaml', '*.yml'],
schema
}],
Expand All @@ -459,7 +459,7 @@ suite('Validation Tests', () => {
};
languageService.configure({
schemas: [{
uri: 'file://test.yaml',
uri: TEST_URI,
fileMatch: ['*.yaml', '*.yml'],
schema
}],
Expand Down
2 changes: 1 addition & 1 deletion test/utils/verifyError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function createExpectedError(

export function createExpectedSymbolInformation(
name: string,
kind: number,
kind: SymbolKind,
containerName: string | undefined,
uri: string,
startLine: number,
Expand Down
Loading