mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-07-07 03:51:01 +00:00
Merge pull request #5 from kpdecker/feat/2.0
build: migrate latest json language service implementation
This commit is contained in:
commit
37dae21bbd
27 changed files with 3781 additions and 2726 deletions
14
.editorconfig
Normal file
14
.editorconfig
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
# Editor configuration, see http://editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
end_of_line = lf
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
max_line_length = off
|
||||||
|
trim_trailing_whitespace = false
|
||||||
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
|
|
@ -5,5 +5,7 @@
|
||||||
"**/node_modules": true,
|
"**/node_modules": true,
|
||||||
"**/release": true,
|
"**/release": true,
|
||||||
"**/out": true
|
"**/out": true
|
||||||
}
|
},
|
||||||
|
"javascript.preferences.quoteStyle": "single",
|
||||||
|
"typescript.preferences.quoteStyle": "single"
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "monaco-yaml",
|
"name": "monaco-yaml",
|
||||||
"version": "1.3.1",
|
"version": "2.0.0",
|
||||||
"description": "YAML plugin for the Monaco Editor",
|
"description": "YAML plugin for the Monaco Editor",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"compile": "rimraf ./out && yarn compile:umd && yarn compile:esm",
|
"compile": "rimraf ./out && yarn compile:umd && yarn compile:esm",
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
"rimraf": "^2.6.2",
|
"rimraf": "^2.6.2",
|
||||||
"typescript": "^3.1.6",
|
"typescript": "^3.1.6",
|
||||||
"uglify-es": "^3.3.9",
|
"uglify-es": "^3.3.9",
|
||||||
"vscode-json-languageservice": "^3.1.6",
|
"vscode-languageserver-types": "3.12.0",
|
||||||
"vscode-languageserver-types": "3.12.0"
|
"yaml-language-server": "^0.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,6 @@ function bundleOne(moduleId, exclude) {
|
||||||
name: 'jsonc-parser',
|
name: 'jsonc-parser',
|
||||||
location: path.join(REPO_ROOT, 'node_modules/jsonc-parser/lib/umd'),
|
location: path.join(REPO_ROOT, 'node_modules/jsonc-parser/lib/umd'),
|
||||||
main: 'main'
|
main: 'main'
|
||||||
}, {
|
|
||||||
name: 'vscode-json-languageservice/lib',
|
|
||||||
location: path.join(REPO_ROOT, 'node_modules/vscode-json-languageservice/lib/umd')
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ helpers.packageESM({
|
||||||
"jsonc-parser/lib/esm": "jsonc-parser",
|
"jsonc-parser/lib/esm": "jsonc-parser",
|
||||||
"vscode-languageserver-types/lib/esm": "vscode-languageserver-types",
|
"vscode-languageserver-types/lib/esm": "vscode-languageserver-types",
|
||||||
"vscode-uri/lib/esm": "vscode-uri",
|
"vscode-uri/lib/esm": "vscode-uri",
|
||||||
"vscode-json-languageservice/lib/esm": "vscode-json-languageservice",
|
|
||||||
// "js-yaml/dist": "js-yaml"
|
// "js-yaml/dist": "js-yaml"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -373,18 +373,22 @@ export class DocumentSymbolAdapter implements monaco.languages.DocumentSymbolPro
|
||||||
if (!items) {
|
if (!items) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return items.map(item => ({
|
return items.map(item => toDocumentSymbol(item));
|
||||||
name: item.name,
|
|
||||||
detail: '',
|
|
||||||
containerName: item.containerName,
|
|
||||||
kind: toSymbolKind(item.kind),
|
|
||||||
range: toRange(item.location.range),
|
|
||||||
selectionRange: toRange(item.location.range)
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toDocumentSymbol(item: ls.DocumentSymbol): monaco.languages.DocumentSymbol {
|
||||||
|
return {
|
||||||
|
detail: '',
|
||||||
|
range: toRange(item.range),
|
||||||
|
name: item.name,
|
||||||
|
kind: toSymbolKind(item.kind),
|
||||||
|
selectionRange: toRange(item.selectionRange),
|
||||||
|
children: item.children.map(child => toDocumentSymbol(child)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function fromFormattingOptions(options: monaco.languages.FormattingOptions): ls.FormattingOptions {
|
function fromFormattingOptions(options: monaco.languages.FormattingOptions): ls.FormattingOptions {
|
||||||
return {
|
return {
|
||||||
|
|
@ -430,3 +434,46 @@ export class DocumentRangeFormattingEditProvider implements monaco.languages.Doc
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export class DocumentColorAdapter implements monaco.languages.DocumentColorProvider {
|
||||||
|
|
||||||
|
constructor(private _worker: WorkerAccessor) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public provideDocumentColors(model: monaco.editor.IReadOnlyModel, token: CancellationToken): Thenable<monaco.languages.IColorInformation[]> {
|
||||||
|
const resource = model.uri;
|
||||||
|
|
||||||
|
return this._worker(resource).then(worker => worker.findDocumentColors(resource.toString())).then(infos => {
|
||||||
|
if (!infos) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return infos.map(item => ({
|
||||||
|
color: item.color,
|
||||||
|
range: toRange(item.range)
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public provideColorPresentations(model: monaco.editor.IReadOnlyModel, info: monaco.languages.IColorInformation, token: CancellationToken): Thenable<monaco.languages.IColorPresentation[]> {
|
||||||
|
const resource = model.uri;
|
||||||
|
|
||||||
|
return this._worker(resource).then(worker => worker.getColorPresentations(resource.toString(), info.color, fromRange(info.range))).then(presentations => {
|
||||||
|
if (!presentations) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return presentations.map(presentation => {
|
||||||
|
let item: monaco.languages.IColorPresentation = {
|
||||||
|
label: presentation.label,
|
||||||
|
};
|
||||||
|
if (presentation.textEdit) {
|
||||||
|
item.textEdit = toTextEdit(presentation.textEdit)
|
||||||
|
}
|
||||||
|
if (presentation.additionalTextEdits) {
|
||||||
|
item.additionalTextEdits = presentation.additionalTextEdits.map(toTextEdit)
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import {Thenable, MarkedString, CompletionItem} from 'vscode-json-languageservice';
|
import { Thenable } from './jsonLanguageTypes';
|
||||||
|
import { MarkedString, CompletionItem } from 'vscode-languageserver-types';
|
||||||
|
|
||||||
export interface JSONWorkerContribution {
|
export interface JSONWorkerContribution {
|
||||||
getInfoContribution(uri: string, location: JSONPath): Thenable<MarkedString[]>;
|
getInfoContribution(uri: string, location: JSONPath): Thenable<MarkedString[]>;
|
||||||
|
|
|
||||||
258
src/languageservice/jsonLanguageTypes.ts
Normal file
258
src/languageservice/jsonLanguageTypes.ts
Normal file
|
|
@ -0,0 +1,258 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import { JSONWorkerContribution, JSONPath, Segment, CompletionsCollector } from './jsonContributions';
|
||||||
|
import { JSONSchema } from './jsonSchema';
|
||||||
|
import { Range, TextEdit, Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind, MarkupKind } from 'vscode-languageserver-types';
|
||||||
|
|
||||||
|
export {
|
||||||
|
Range, TextEdit, JSONSchema, JSONWorkerContribution, JSONPath, Segment, CompletionsCollector,
|
||||||
|
Color, ColorInformation, ColorPresentation, FoldingRange, FoldingRangeKind
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error codes used by diagnostics
|
||||||
|
*/
|
||||||
|
export enum ErrorCode {
|
||||||
|
Undefined = 0,
|
||||||
|
EnumValueMismatch = 1,
|
||||||
|
UnexpectedEndOfComment = 0x101,
|
||||||
|
UnexpectedEndOfString = 0x102,
|
||||||
|
UnexpectedEndOfNumber = 0x103,
|
||||||
|
InvalidUnicode = 0x104,
|
||||||
|
InvalidEscapeCharacter = 0x105,
|
||||||
|
InvalidCharacter = 0x106,
|
||||||
|
PropertyExpected = 0x201,
|
||||||
|
CommaExpected = 0x202,
|
||||||
|
ColonExpected = 0x203,
|
||||||
|
ValueExpected = 0x204,
|
||||||
|
CommaOrCloseBacketExpected = 0x205,
|
||||||
|
CommaOrCloseBraceExpected = 0x206,
|
||||||
|
TrailingComma = 0x207,
|
||||||
|
DuplicateKey = 0x208,
|
||||||
|
CommentNotPermitted = 0x209,
|
||||||
|
SchemaResolveError = 0x300
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ASTNode = ObjectASTNode | PropertyASTNode | ArrayASTNode | StringASTNode | NumberASTNode | BooleanASTNode | NullASTNode;
|
||||||
|
|
||||||
|
export interface BaseASTNode {
|
||||||
|
readonly type: 'object' | 'array' | 'property' | 'string' | 'number' | 'boolean' | 'null';
|
||||||
|
readonly parent?: ASTNode;
|
||||||
|
readonly offset: number;
|
||||||
|
readonly length: number;
|
||||||
|
readonly children?: ASTNode[];
|
||||||
|
readonly value?: string | boolean | number | null;
|
||||||
|
}
|
||||||
|
export interface ObjectASTNode extends BaseASTNode {
|
||||||
|
readonly type: 'object';
|
||||||
|
readonly properties: PropertyASTNode[];
|
||||||
|
readonly children: ASTNode[];
|
||||||
|
}
|
||||||
|
export interface PropertyASTNode extends BaseASTNode {
|
||||||
|
readonly type: 'property';
|
||||||
|
readonly keyNode: StringASTNode;
|
||||||
|
readonly valueNode?: ASTNode;
|
||||||
|
readonly colonOffset?: number;
|
||||||
|
readonly children: ASTNode[];
|
||||||
|
}
|
||||||
|
export interface ArrayASTNode extends BaseASTNode {
|
||||||
|
readonly type: 'array';
|
||||||
|
readonly items: ASTNode[];
|
||||||
|
readonly children: ASTNode[];
|
||||||
|
}
|
||||||
|
export interface StringASTNode extends BaseASTNode {
|
||||||
|
readonly type: 'string';
|
||||||
|
readonly value: string;
|
||||||
|
}
|
||||||
|
export interface NumberASTNode extends BaseASTNode {
|
||||||
|
readonly type: 'number';
|
||||||
|
readonly value: number;
|
||||||
|
readonly isInteger: boolean;
|
||||||
|
}
|
||||||
|
export interface BooleanASTNode extends BaseASTNode {
|
||||||
|
readonly type: 'boolean';
|
||||||
|
readonly value: boolean;
|
||||||
|
}
|
||||||
|
export interface NullASTNode extends BaseASTNode {
|
||||||
|
readonly type: 'null';
|
||||||
|
readonly value: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LanguageSettings {
|
||||||
|
/**
|
||||||
|
* If set, the validator will return syntax and semantic errors.
|
||||||
|
*/
|
||||||
|
validate?: boolean;
|
||||||
|
/**
|
||||||
|
* Defines whether comments are allowed or not. If set to false, comments will be reported as errors.
|
||||||
|
* DocumentLanguageSettings.allowComments will override this setting.
|
||||||
|
*/
|
||||||
|
allowComments?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of known schemas and/or associations of schemas to file names.
|
||||||
|
*/
|
||||||
|
schemas?: SchemaConfiguration[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SeverityLevel = 'error' | 'warning' | 'ignore';
|
||||||
|
|
||||||
|
export interface DocumentLanguageSettings {
|
||||||
|
/**
|
||||||
|
* The severity of reported comments. If not set, 'LanguageSettings.allowComments' defines wheter comments are ignored or reported as errors.
|
||||||
|
*/
|
||||||
|
comments?: SeverityLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The severity of reported trailing commas. If not set, trailing commas will be reported as errors.
|
||||||
|
*/
|
||||||
|
trailingCommas?: SeverityLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SchemaConfiguration {
|
||||||
|
/**
|
||||||
|
* The URI of the schema, which is also the identifier of the schema.
|
||||||
|
*/
|
||||||
|
uri: string;
|
||||||
|
/**
|
||||||
|
* A list of file names that are associated to the schema. The '*' wildcard can be used. For example '*.schema.json', 'package.json'
|
||||||
|
*/
|
||||||
|
fileMatch?: string[];
|
||||||
|
/**
|
||||||
|
* The schema for the given URI.
|
||||||
|
* If no schema is provided, the schema will be fetched with the schema request service (if available).
|
||||||
|
*/
|
||||||
|
schema?: JSONSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WorkspaceContextService {
|
||||||
|
resolveRelativePath(relativePath: string, resource: string): string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The schema request service is used to fetch schemas. The result should the schema file comment, or,
|
||||||
|
* in case of an error, a displayable error string
|
||||||
|
*/
|
||||||
|
export interface SchemaRequestService {
|
||||||
|
(uri: string): Thenable<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PromiseConstructor {
|
||||||
|
/**
|
||||||
|
* Creates a new Promise.
|
||||||
|
* @param executor A callback used to initialize the promise. This callback is passed two arguments:
|
||||||
|
* a resolve callback used resolve the promise with a value or the result of another promise,
|
||||||
|
* and a reject callback used to reject the promise with a provided reason or error.
|
||||||
|
*/
|
||||||
|
new <T>(executor: (resolve: (value?: T | Thenable<T>) => void, reject: (reason?: any) => void) => void): Thenable<T>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Promise that is resolved with an array of results when all of the provided Promises
|
||||||
|
* resolve, or rejected when any Promise is rejected.
|
||||||
|
* @param values An array of Promises.
|
||||||
|
* @returns A new Promise.
|
||||||
|
*/
|
||||||
|
all<T>(values: Array<T | Thenable<T>>): Thenable<T[]>;
|
||||||
|
/**
|
||||||
|
* Creates a new rejected promise for the provided reason.
|
||||||
|
* @param reason The reason the promise was rejected.
|
||||||
|
* @returns A new rejected Promise.
|
||||||
|
*/
|
||||||
|
reject<T>(reason: any): Thenable<T>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new resolved promise for the provided value.
|
||||||
|
* @param value A promise.
|
||||||
|
* @returns A promise whose internal state matches the provided promise.
|
||||||
|
*/
|
||||||
|
resolve<T>(value: T | Thenable<T>): Thenable<T>;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Thenable<R> {
|
||||||
|
/**
|
||||||
|
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||||
|
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||||
|
* @param onrejected The callback to execute when the Promise is rejected.
|
||||||
|
* @returns A Promise for the completion of which ever callback is executed.
|
||||||
|
*/
|
||||||
|
then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
|
||||||
|
then<TResult>(onfulfilled?: (value: R) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LanguageServiceParams {
|
||||||
|
/**
|
||||||
|
* The schema request service is used to fetch schemas. The result should the schema file comment, or,
|
||||||
|
* in case of an error, a displayable error string
|
||||||
|
*/
|
||||||
|
schemaRequestService?: SchemaRequestService;
|
||||||
|
/**
|
||||||
|
* The workspace context is used to resolve relative paths for relative schema references.
|
||||||
|
*/
|
||||||
|
workspaceContext?: WorkspaceContextService;
|
||||||
|
/**
|
||||||
|
* An optional set of completion and hover participants.
|
||||||
|
*/
|
||||||
|
contributions?: JSONWorkerContribution[];
|
||||||
|
/**
|
||||||
|
* A promise constructor. If not set, the ES5 Promise will be used.
|
||||||
|
*/
|
||||||
|
promiseConstructor?: PromiseConstructor;
|
||||||
|
/**
|
||||||
|
* Describes the LSP capabilities the client supports.
|
||||||
|
*/
|
||||||
|
clientCapabilities?: ClientCapabilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes what LSP capabilities the client supports
|
||||||
|
*/
|
||||||
|
export interface ClientCapabilities {
|
||||||
|
/**
|
||||||
|
* The text document client capabilities
|
||||||
|
*/
|
||||||
|
textDocument?: {
|
||||||
|
/**
|
||||||
|
* Capabilities specific to completions.
|
||||||
|
*/
|
||||||
|
completion?: {
|
||||||
|
/**
|
||||||
|
* The client supports the following `CompletionItem` specific
|
||||||
|
* capabilities.
|
||||||
|
*/
|
||||||
|
completionItem?: {
|
||||||
|
/**
|
||||||
|
* Client supports the follow content formats for the documentation
|
||||||
|
* property. The order describes the preferred format of the client.
|
||||||
|
*/
|
||||||
|
documentationFormat?: MarkupKind[];
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Capabilities specific to hovers.
|
||||||
|
*/
|
||||||
|
hover?: {
|
||||||
|
/**
|
||||||
|
* Client supports the follow content formats for the content
|
||||||
|
* property. The order describes the preferred format of the client.
|
||||||
|
*/
|
||||||
|
contentFormat?: MarkupKind[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace ClientCapabilities {
|
||||||
|
export const LATEST: ClientCapabilities = {
|
||||||
|
textDocument: {
|
||||||
|
completion: {
|
||||||
|
completionItem: {
|
||||||
|
documentationFormat: [MarkupKind.Markdown, MarkupKind.PlainText]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,53 +1,76 @@
|
||||||
/*---------------------------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------------------------
|
||||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
export type JSONSchemaRef = JSONSchema | boolean;
|
||||||
|
|
||||||
export interface JSONSchema {
|
export interface JSONSchema {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
$id?: string;
|
||||||
$schema?: string;
|
$schema?: string;
|
||||||
type?: string | string[];
|
type?: string | string[];
|
||||||
title?: string;
|
title?: string;
|
||||||
default?: any;
|
default?: any;
|
||||||
definitions?: JSONSchemaMap;
|
definitions?: { [name: string]: JSONSchema };
|
||||||
description?: string;
|
description?: string;
|
||||||
properties?: JSONSchemaMap;
|
properties?: JSONSchemaMap;
|
||||||
patternProperties?: JSONSchemaMap;
|
patternProperties?: JSONSchemaMap;
|
||||||
additionalProperties?: any;
|
additionalProperties?: boolean | JSONSchemaRef;
|
||||||
minProperties?: number;
|
minProperties?: number;
|
||||||
maxProperties?: number;
|
maxProperties?: number;
|
||||||
dependencies?: JSONSchemaMap | string[];
|
dependencies?: JSONSchemaMap | { [prop: string]: string[] };
|
||||||
items?: any;
|
items?: JSONSchemaRef | JSONSchemaRef[];
|
||||||
minItems?: number;
|
minItems?: number;
|
||||||
maxItems?: number;
|
maxItems?: number;
|
||||||
uniqueItems?: boolean;
|
uniqueItems?: boolean;
|
||||||
additionalItems?: boolean;
|
additionalItems?: boolean | JSONSchemaRef;
|
||||||
pattern?: string;
|
pattern?: string;
|
||||||
minLength?: number;
|
minLength?: number;
|
||||||
maxLength?: number;
|
maxLength?: number;
|
||||||
minimum?: number;
|
minimum?: number;
|
||||||
maximum?: number;
|
maximum?: number;
|
||||||
exclusiveMinimum?: boolean;
|
exclusiveMinimum?: boolean | number;
|
||||||
exclusiveMaximum?: boolean;
|
exclusiveMaximum?: boolean | number;
|
||||||
multipleOf?: number;
|
multipleOf?: number;
|
||||||
required?: string[];
|
required?: string[];
|
||||||
$ref?: string;
|
$ref?: string;
|
||||||
anyOf?: JSONSchema[];
|
anyOf?: JSONSchemaRef[];
|
||||||
allOf?: JSONSchema[];
|
allOf?: JSONSchemaRef[];
|
||||||
oneOf?: JSONSchema[];
|
oneOf?: JSONSchemaRef[];
|
||||||
not?: JSONSchema;
|
not?: JSONSchemaRef;
|
||||||
enum?: any[];
|
enum?: any[];
|
||||||
format?: string;
|
format?: string;
|
||||||
|
|
||||||
|
// schema draft 06
|
||||||
|
const?: any;
|
||||||
|
contains?: JSONSchemaRef;
|
||||||
|
propertyNames?: JSONSchemaRef;
|
||||||
|
examples?: any[];
|
||||||
|
|
||||||
|
// schema draft 07
|
||||||
|
$comment?: string;
|
||||||
|
if?: JSONSchemaRef;
|
||||||
|
then?: JSONSchemaRef;
|
||||||
|
else?: JSONSchemaRef;
|
||||||
|
|
||||||
|
// VSCode extensions
|
||||||
|
|
||||||
|
defaultSnippets?: { label?: string; description?: string; markdownDescription?: string; body?: any; bodyText?: string; }[]; // VSCode extension: body: a object that will be converted to a JSON string. bodyText: text with \t and \n
|
||||||
errorMessage?: string; // VSCode extension
|
errorMessage?: string; // VSCode extension
|
||||||
patternErrorMessage?: string; // VSCode extension
|
patternErrorMessage?: string; // VSCode extension
|
||||||
deprecationMessage?: string; // VSCode extension
|
deprecationMessage?: string; // VSCode extension
|
||||||
enumDescriptions?: string[]; // VSCode extension
|
enumDescriptions?: string[]; // VSCode extension
|
||||||
|
markdownEnumDescriptions?: string[]; // VSCode extension
|
||||||
|
markdownDescription?: string; // VSCode extension
|
||||||
|
doNotSuggest?: boolean; // VSCode extension
|
||||||
|
allowComments?: boolean; // VSCode extension
|
||||||
|
|
||||||
schemaSequence?: JSONSchema[]; // extension for multiple schemas related to multiple documents in single yaml file
|
schemaSequence?: JSONSchema[]; // extension for multiple schemas related to multiple documents in single yaml file
|
||||||
"x-kubernetes-group-version-kind"?; //Kubernetes extension
|
"x-kubernetes-group-version-kind"?; //Kubernetes extension
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface JSONSchemaMap {
|
export interface JSONSchemaMap {
|
||||||
[name: string]:JSONSchema;
|
[name: string]: JSONSchemaRef;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -5,84 +5,17 @@
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { ASTNode, ErrorCode, BooleanASTNode, NullASTNode, ArrayASTNode, NumberASTNode, ObjectASTNode, PropertyASTNode, StringASTNode, IApplicableSchema, JSONDocument } from './jsonParser';
|
|
||||||
|
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
import * as Yaml from '../../yaml-ast-parser/index'
|
import * as Yaml from '../../yaml-ast-parser/index'
|
||||||
import { Kind } from '../../yaml-ast-parser/index'
|
|
||||||
import { Schema, Type } from 'js-yaml';
|
import { Schema, Type } from 'js-yaml';
|
||||||
|
|
||||||
import { getLineStartPositions, getPosition } from '../utils/documentPositionCalculator'
|
import { getLineStartPositions } from '../utils/documentPositionCalculator'
|
||||||
import { parseYamlBoolean } from './scalar-type';
|
import { parseYamlBoolean } from './scalar-type';
|
||||||
|
import { ObjectASTNodeImpl, StringASTNodeImpl, PropertyASTNodeImpl, NullASTNodeImpl, ArrayASTNodeImpl, BooleanASTNodeImpl, NumberASTNodeImpl } from './jsonParser';
|
||||||
export class SingleYAMLDocument extends JSONDocument {
|
import { ASTNode, PropertyASTNode, ErrorCode } from '../jsonLanguageTypes';
|
||||||
private lines;
|
import { SingleYAMLDocument, YAMLDocument } from '../yamlLanguageTypes';
|
||||||
public root;
|
|
||||||
public errors;
|
|
||||||
public warnings;
|
|
||||||
|
|
||||||
constructor(lines: number[]) {
|
|
||||||
super(null, []);
|
|
||||||
this.lines = lines;
|
|
||||||
this.root = null;
|
|
||||||
this.errors = [];
|
|
||||||
this.warnings = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public getSchemas(schema, doc, node) {
|
|
||||||
let matchingSchemas = [];
|
|
||||||
doc.validate(schema, matchingSchemas, node.start);
|
|
||||||
return matchingSchemas;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getNodeFromOffset(offset: number): ASTNode {
|
|
||||||
return this.getNodeFromOffsetEndInclusive(offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
private getNodeByIndent = (lines: number[], offset: number, node: ASTNode) => {
|
|
||||||
|
|
||||||
const { line, column: indent } = getPosition(offset, this.lines)
|
|
||||||
|
|
||||||
const children = node.getChildNodes()
|
|
||||||
|
|
||||||
function findNode(children) {
|
|
||||||
for (var idx = 0; idx < children.length; idx++) {
|
|
||||||
var child = children[idx];
|
|
||||||
|
|
||||||
const { line: childLine, column: childCol } = getPosition(child.start, lines);
|
|
||||||
|
|
||||||
if (childCol > indent) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const newChildren = child.getChildNodes()
|
|
||||||
const foundNode = findNode(newChildren)
|
|
||||||
|
|
||||||
if (foundNode) {
|
|
||||||
return foundNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We have the right indentation, need to return based on line
|
|
||||||
if (childLine == line) {
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
if (childLine > line) {
|
|
||||||
// Get previous
|
|
||||||
(idx - 1) >= 0 ? children[idx - 1] : child;
|
|
||||||
}
|
|
||||||
// Else continue loop to try next element
|
|
||||||
}
|
|
||||||
|
|
||||||
// Special case, we found the correct
|
|
||||||
return children[children.length - 1]
|
|
||||||
}
|
|
||||||
|
|
||||||
return findNode(children) || node
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function recursivelyBuildAst(parent: ASTNode, node: Yaml.YAMLNode): ASTNode {
|
function recursivelyBuildAst(parent: ASTNode, node: Yaml.YAMLNode): ASTNode {
|
||||||
|
|
||||||
|
|
@ -94,11 +27,10 @@ function recursivelyBuildAst(parent: ASTNode, node: Yaml.YAMLNode): ASTNode {
|
||||||
case Yaml.Kind.MAP: {
|
case Yaml.Kind.MAP: {
|
||||||
const instance = <Yaml.YamlMap>node;
|
const instance = <Yaml.YamlMap>node;
|
||||||
|
|
||||||
const result = new ObjectASTNode(parent, null, node.startPosition, node.endPosition)
|
const result = new ObjectASTNodeImpl(parent, node.startPosition, node.endPosition - node.startPosition)
|
||||||
result.addProperty
|
|
||||||
|
|
||||||
for (const mapping of instance.mappings) {
|
for (const mapping of instance.mappings) {
|
||||||
result.addProperty(<PropertyASTNode>recursivelyBuildAst(result, mapping))
|
result.properties.push(<PropertyASTNode>recursivelyBuildAst(result, mapping));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -107,25 +39,25 @@ function recursivelyBuildAst(parent: ASTNode, node: Yaml.YAMLNode): ASTNode {
|
||||||
const instance = <Yaml.YAMLMapping>node;
|
const instance = <Yaml.YAMLMapping>node;
|
||||||
const key = instance.key;
|
const key = instance.key;
|
||||||
|
|
||||||
|
const result = new PropertyASTNodeImpl(<ObjectASTNodeImpl>parent, key.startPosition, instance.endPosition - key.startPosition);
|
||||||
|
|
||||||
|
|
||||||
// Technically, this is an arbitrary node in YAML
|
// Technically, this is an arbitrary node in YAML
|
||||||
// I doubt we would get a better string representation by parsing it
|
// I doubt we would get a better string representation by parsing it
|
||||||
const keyNode = new StringASTNode(null, null, true, key.startPosition, key.endPosition);
|
const keyNode = new StringASTNodeImpl(result, key.startPosition, key.endPosition - key.startPosition);
|
||||||
keyNode.value = key.value;
|
keyNode.value = key.value;
|
||||||
|
|
||||||
const result = new PropertyASTNode(parent, keyNode)
|
const valueNode = (instance.value) ? recursivelyBuildAst(result, instance.value) : new NullASTNodeImpl(parent, instance.startPosition)
|
||||||
result.end = instance.endPosition
|
|
||||||
|
|
||||||
const valueNode = (instance.value) ? recursivelyBuildAst(result, instance.value) : new NullASTNode(parent, key.value, instance.endPosition, instance.endPosition)
|
result.keyNode = keyNode;
|
||||||
valueNode.location = key.value
|
result.valueNode = valueNode;
|
||||||
|
|
||||||
result.setValue(valueNode)
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
case Yaml.Kind.SEQ: {
|
case Yaml.Kind.SEQ: {
|
||||||
const instance = <Yaml.YAMLSequence>node;
|
const instance = <Yaml.YAMLSequence>node;
|
||||||
|
|
||||||
const result = new ArrayASTNode(parent, null, instance.startPosition, instance.endPosition);
|
const result = new ArrayASTNodeImpl(parent, instance.startPosition, instance.endPosition - instance.startPosition);
|
||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
for (const item of instance.items) {
|
for (const item of instance.items) {
|
||||||
|
|
@ -135,10 +67,9 @@ function recursivelyBuildAst(parent: ASTNode, node: Yaml.YAMLNode): ASTNode {
|
||||||
|
|
||||||
// Be aware of https://github.com/nodeca/js-yaml/issues/321
|
// Be aware of https://github.com/nodeca/js-yaml/issues/321
|
||||||
// Cannot simply work around it here because we need to know if we are in Flow or Block
|
// Cannot simply work around it here because we need to know if we are in Flow or Block
|
||||||
var itemNode = (item === null) ? new NullASTNode(parent, null, instance.endPosition, instance.endPosition) : recursivelyBuildAst(result, item);
|
var itemNode = (item === null) ? new NullASTNodeImpl(parent, instance.startPosition, instance.endPosition - instance.startPosition) : recursivelyBuildAst(result, item);
|
||||||
|
|
||||||
itemNode.location = count++;
|
result.items.push(itemNode);
|
||||||
result.addItem(itemNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -154,30 +85,30 @@ function recursivelyBuildAst(parent: ASTNode, node: Yaml.YAMLNode): ASTNode {
|
||||||
//This is a patch for redirecting values with these strings to be boolean nodes because its not supported in the parser.
|
//This is a patch for redirecting values with these strings to be boolean nodes because its not supported in the parser.
|
||||||
let possibleBooleanValues = ['y', 'Y', 'yes', 'Yes', 'YES', 'n', 'N', 'no', 'No', 'NO', 'on', 'On', 'ON', 'off', 'Off', 'OFF'];
|
let possibleBooleanValues = ['y', 'Y', 'yes', 'Yes', 'YES', 'n', 'N', 'no', 'No', 'NO', 'on', 'On', 'ON', 'off', 'Off', 'OFF'];
|
||||||
if (instance.plainScalar && possibleBooleanValues.indexOf(value.toString()) !== -1) {
|
if (instance.plainScalar && possibleBooleanValues.indexOf(value.toString()) !== -1) {
|
||||||
return new BooleanASTNode(parent, name, parseYamlBoolean(value), node.startPosition, node.endPosition)
|
return new BooleanASTNodeImpl(parent, parseYamlBoolean(value), node.startPosition, node.endPosition - node.startPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Yaml.ScalarType.null: {
|
case Yaml.ScalarType.null: {
|
||||||
return new StringASTNode(parent, name, false, instance.startPosition, instance.endPosition);
|
return new NullASTNodeImpl(parent, instance.startPosition, instance.endPosition - instance.startPosition);
|
||||||
}
|
}
|
||||||
case Yaml.ScalarType.bool: {
|
case Yaml.ScalarType.bool: {
|
||||||
return new BooleanASTNode(parent, name, Yaml.parseYamlBoolean(value), node.startPosition, node.endPosition)
|
return new BooleanASTNodeImpl(parent, Yaml.parseYamlBoolean(value), node.startPosition, node.endPosition - node.startPosition)
|
||||||
}
|
}
|
||||||
case Yaml.ScalarType.int: {
|
case Yaml.ScalarType.int: {
|
||||||
const result = new NumberASTNode(parent, name, node.startPosition, node.endPosition);
|
const result = new NumberASTNodeImpl(parent, node.startPosition, node.endPosition - node.startPosition);
|
||||||
result.value = Yaml.parseYamlInteger(value);
|
result.value = Yaml.parseYamlInteger(value);
|
||||||
result.isInteger = true;
|
result.isInteger = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
case Yaml.ScalarType.float: {
|
case Yaml.ScalarType.float: {
|
||||||
const result = new NumberASTNode(parent, name, node.startPosition, node.endPosition);
|
const result = new NumberASTNodeImpl(parent, node.startPosition, node.endPosition - node.startPosition);
|
||||||
result.value = Yaml.parseYamlFloat(value);
|
result.value = Yaml.parseYamlFloat(value);
|
||||||
result.isInteger = false;
|
result.isInteger = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
case Yaml.ScalarType.string: {
|
case Yaml.ScalarType.string: {
|
||||||
const result = new StringASTNode(parent, name, false, node.startPosition, node.endPosition);
|
const result = new StringASTNodeImpl(parent, node.startPosition, node.endPosition - node.startPosition);
|
||||||
result.value = node.value;
|
result.value = node.value;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -189,10 +120,10 @@ function recursivelyBuildAst(parent: ASTNode, node: Yaml.YAMLNode): ASTNode {
|
||||||
const instance = (<Yaml.YAMLAnchorReference>node).value
|
const instance = (<Yaml.YAMLAnchorReference>node).value
|
||||||
|
|
||||||
return recursivelyBuildAst(parent, instance) ||
|
return recursivelyBuildAst(parent, instance) ||
|
||||||
new NullASTNode(parent, null, node.startPosition, node.endPosition);
|
new NullASTNodeImpl(parent, node.startPosition, node.endPosition - node.startPosition);
|
||||||
}
|
}
|
||||||
case Yaml.Kind.INCLUDE_REF: {
|
case Yaml.Kind.INCLUDE_REF: {
|
||||||
const result = new StringASTNode(parent, null, false, node.startPosition, node.endPosition);
|
const result = new StringASTNodeImpl(parent, node.startPosition, node.endPosition - node.startPosition);
|
||||||
result.value = node.value;
|
result.value = node.value;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -233,19 +164,6 @@ function createJSONDocument(yamlDoc: Yaml.YAMLNode, startPositions: number[], te
|
||||||
return _doc;
|
return _doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class YAMLDocument {
|
|
||||||
public documents: JSONDocument[]
|
|
||||||
private errors;
|
|
||||||
private warnings;
|
|
||||||
|
|
||||||
constructor(documents: JSONDocument[]) {
|
|
||||||
this.documents = documents;
|
|
||||||
this.errors = [];
|
|
||||||
this.warnings = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export function parse(text: string, customTags = []): YAMLDocument {
|
export function parse(text: string, customTags = []): YAMLDocument {
|
||||||
|
|
||||||
const startPositions = getLineStartPositions(text)
|
const startPositions = getLineStartPositions(text)
|
||||||
|
|
|
||||||
|
|
@ -5,35 +5,42 @@
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import * as Parser from '../parser/jsonParser';
|
import { SymbolKind, TextDocument, Range, DocumentSymbol, ColorInformation, ColorPresentation, Color, TextEdit } from 'vscode-languageserver-types';
|
||||||
|
import { ASTNode, PropertyASTNode, Thenable } from '../jsonLanguageTypes';
|
||||||
import { SymbolInformation, SymbolKind, TextDocument, Range, Location } from 'vscode-languageserver-types';
|
import { YAMLDocument, SingleYAMLDocument } from '../yamlLanguageTypes';
|
||||||
import { Thenable } from "../yamlLanguageService";
|
import { IJSONSchemaService } from './jsonSchemaService';
|
||||||
import { IJSONSchemaService } from "./jsonSchemaService";
|
import { colorFromHex } from '../utils/colors';
|
||||||
|
import { getNodeValue } from '../parser/jsonParser';
|
||||||
|
|
||||||
export class YAMLDocumentSymbols {
|
export class YAMLDocumentSymbols {
|
||||||
|
constructor(private schemaService: IJSONSchemaService) {
|
||||||
|
}
|
||||||
|
|
||||||
public findDocumentSymbols(document: TextDocument, doc: Parser.JSONDocument): SymbolInformation[] {
|
public findDocumentSymbols(document: TextDocument, doc: YAMLDocument): DocumentSymbol[] {
|
||||||
|
if (!doc || doc.documents.length === 0) {
|
||||||
if(!doc || doc["documents"].length === 0){
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let collectOutlineEntries = (result: SymbolInformation[], node: Parser.ASTNode, containerName: string): SymbolInformation[] => {
|
let collectOutlineEntries = (result: DocumentSymbol[], node: ASTNode): DocumentSymbol[] => {
|
||||||
if (node.type === 'array') {
|
if (node.type === 'array') {
|
||||||
(<Parser.ArrayASTNode>node).items.forEach((node: Parser.ASTNode) => {
|
node.items.forEach((node, index) => {
|
||||||
collectOutlineEntries(result, node, containerName);
|
if (node) {
|
||||||
|
let range = getRange(document, node);
|
||||||
|
let selectionRange = range;
|
||||||
|
let name = String(index);
|
||||||
|
let children = collectOutlineEntries([], node);
|
||||||
|
result.push({ name, kind: this.getSymbolKind(node.type), range, selectionRange, children });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else if (node.type === 'object') {
|
} else if (node.type === 'object') {
|
||||||
let objectNode = <Parser.ObjectASTNode>node;
|
node.properties.forEach((property: PropertyASTNode) => {
|
||||||
|
let valueNode = property.valueNode;
|
||||||
objectNode.properties.forEach((property: Parser.PropertyASTNode) => {
|
|
||||||
let location = Location.create(document.uri, Range.create(document.positionAt(property.start), document.positionAt(property.end)));
|
|
||||||
let valueNode = property.value;
|
|
||||||
if (valueNode) {
|
if (valueNode) {
|
||||||
let childContainerName = containerName ? containerName + '.' + property.key.value : property.key.value;
|
let range = getRange(document, property);
|
||||||
result.push({ name: property.key.getValue(), kind: this.getSymbolKind(valueNode.type), location: location, containerName: containerName });
|
let selectionRange = getRange(document, property.keyNode);
|
||||||
collectOutlineEntries(result, valueNode, childContainerName);
|
let name = property.keyNode.value;
|
||||||
|
let children = collectOutlineEntries([], valueNode);
|
||||||
|
result.push({ name, kind: this.getSymbolKind(valueNode.type), range, selectionRange, children });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -41,10 +48,9 @@ export class YAMLDocumentSymbols {
|
||||||
};
|
};
|
||||||
|
|
||||||
let results = [];
|
let results = [];
|
||||||
for(let yamlDoc in doc["documents"]){
|
for (let yamlDoc of doc.documents) {
|
||||||
let currentYAMLDoc = doc["documents"][yamlDoc];
|
if (yamlDoc.root) {
|
||||||
if(currentYAMLDoc.root){
|
const result = collectOutlineEntries([], yamlDoc.root);
|
||||||
let result = collectOutlineEntries([], currentYAMLDoc.root, void 0);
|
|
||||||
results = results.concat(result);
|
results = results.concat(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -69,4 +75,60 @@ export class YAMLDocumentSymbols {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public findDocumentColors(document: TextDocument, doc: YAMLDocument): Thenable<ColorInformation[]> {
|
||||||
|
if (!doc || doc.documents.length === 0) {
|
||||||
|
return Promise.resolve([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const _findDocumentColors = (currentDoc: SingleYAMLDocument) => {
|
||||||
|
return this.schemaService.getSchemaForResource(document.uri, currentDoc).then(schema => {
|
||||||
|
let result: ColorInformation[] = [];
|
||||||
|
if (schema) {
|
||||||
|
let matchingSchemas = currentDoc.getMatchingSchemas(schema.schema);
|
||||||
|
let visitedNode = {};
|
||||||
|
for (let s of matchingSchemas) {
|
||||||
|
if (!s.inverted && s.schema && (s.schema.format === 'color' || s.schema.format === 'color-hex') && s.node && s.node.type === 'string') {
|
||||||
|
let nodeId = String(s.node.offset);
|
||||||
|
if (!visitedNode[nodeId]) {
|
||||||
|
let color = colorFromHex(getNodeValue(s.node));
|
||||||
|
if (color) {
|
||||||
|
let range = getRange(document, s.node);
|
||||||
|
result.push({ color, range });
|
||||||
|
}
|
||||||
|
visitedNode[nodeId] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.all(doc.documents.map(currentDoc => _findDocumentColors(currentDoc)))
|
||||||
|
.then(infoArray => infoArray.reduce((acc, infos) => ([...acc, ...infos]), []));
|
||||||
|
}
|
||||||
|
|
||||||
|
public getColorPresentations(document: TextDocument, doc: YAMLDocument, color: Color, range: Range): ColorPresentation[] {
|
||||||
|
let result: ColorPresentation[] = [];
|
||||||
|
let red256 = Math.round(color.red * 255), green256 = Math.round(color.green * 255), blue256 = Math.round(color.blue * 255);
|
||||||
|
|
||||||
|
function toTwoDigitHex(n: number): string {
|
||||||
|
const r = n.toString(16);
|
||||||
|
return r.length !== 2 ? '0' + r : r;
|
||||||
|
}
|
||||||
|
|
||||||
|
let label;
|
||||||
|
if (color.alpha === 1) {
|
||||||
|
label = `#${toTwoDigitHex(red256)}${toTwoDigitHex(green256)}${toTwoDigitHex(blue256)}`;
|
||||||
|
} else {
|
||||||
|
label = `#${toTwoDigitHex(red256)}${toTwoDigitHex(green256)}${toTwoDigitHex(blue256)}${toTwoDigitHex(Math.round(color.alpha * 255))}`;
|
||||||
|
}
|
||||||
|
result.push({ label: label, textEdit: TextEdit.replace(range, JSON.stringify(label)) });
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRange(document: TextDocument, node: ASTNode) {
|
||||||
|
return Range.create(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
|
||||||
}
|
}
|
||||||
|
|
@ -6,36 +6,17 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import * as Json from 'jsonc-parser';
|
import * as Json from 'jsonc-parser';
|
||||||
import {JSONSchema, JSONSchemaMap} from '../jsonSchema';
|
import {JSONSchema, JSONSchemaMap, JSONSchemaRef} from '../jsonSchema';
|
||||||
import URI from 'vscode-uri';
|
import URI from 'vscode-uri';
|
||||||
import * as Strings from '../utils/strings';
|
import * as Strings from '../utils/strings';
|
||||||
|
import * as Parser from '../parser/jsonParser';
|
||||||
import {SchemaRequestService, WorkspaceContextService, Thenable} from '../yamlLanguageService';
|
import {SchemaRequestService, WorkspaceContextService, Thenable} from '../yamlLanguageService';
|
||||||
|
|
||||||
|
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
/**
|
export declare type CustomSchemaProvider = (uri: string) => Thenable<string>;
|
||||||
* getParseErrorMessage has been removed from jsonc-parser since 1.0.0
|
|
||||||
*
|
|
||||||
* see https://github.com/Microsoft/node-jsonc-parser/blob/42ec16f9c91582d4267a0c48199cdac283c90fc9/CHANGELOG.md
|
|
||||||
* 1.0.0
|
|
||||||
* remove nls dependency (remove getParseErrorMessage)
|
|
||||||
*/
|
|
||||||
function getParseErrorMessage(errorCode: Json.ParseErrorCode): string {
|
|
||||||
switch (errorCode) {
|
|
||||||
case Json.ParseErrorCode.InvalidSymbol: return localize('error.invalidSymbol', 'Invalid symbol');
|
|
||||||
case Json.ParseErrorCode.InvalidNumberFormat: return localize('error.invalidNumberFormat', 'Invalid number format');
|
|
||||||
case Json.ParseErrorCode.PropertyNameExpected: return localize('error.propertyNameExpected', 'Property name expected');
|
|
||||||
case Json.ParseErrorCode.ValueExpected: return localize('error.valueExpected', 'Value expected');
|
|
||||||
case Json.ParseErrorCode.ColonExpected: return localize('error.colonExpected', 'Colon expected');
|
|
||||||
case Json.ParseErrorCode.CommaExpected: return localize('error.commaExpected', 'Comma expected');
|
|
||||||
case Json.ParseErrorCode.CloseBraceExpected: return localize('error.closeBraceExpected', 'Closing brace expected');
|
|
||||||
case Json.ParseErrorCode.CloseBracketExpected: return localize('error.closeBracketExpected', 'Closing bracket expected');
|
|
||||||
case Json.ParseErrorCode.EndOfFileExpected: return localize('error.endOfFileExpected', 'End of file expected');
|
|
||||||
default: return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IJSONSchemaService {
|
export interface IJSONSchemaService {
|
||||||
|
|
||||||
|
|
@ -57,7 +38,7 @@ export interface IJSONSchemaService {
|
||||||
/**
|
/**
|
||||||
* Looks up the appropriate schema for the given URI
|
* Looks up the appropriate schema for the given URI
|
||||||
*/
|
*/
|
||||||
getSchemaForResource(resource: string): Thenable<ResolvedSchema>;
|
getSchemaForResource(resource: string, document?: Parser.JSONDocument): Thenable<ResolvedSchema>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all registered schema ids
|
* Returns all registered schema ids
|
||||||
|
|
@ -74,8 +55,6 @@ export interface ISchemaContributions {
|
||||||
schemaAssociations?: ISchemaAssociations;
|
schemaAssociations?: ISchemaAssociations;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare type CustomSchemaProvider = (uri: string) => Thenable<string>;
|
|
||||||
|
|
||||||
export interface ISchemaHandle {
|
export interface ISchemaHandle {
|
||||||
/**
|
/**
|
||||||
* The schema id
|
* The schema id
|
||||||
|
|
@ -94,39 +73,31 @@ export interface ISchemaHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export class FilePatternAssociation {
|
class FilePatternAssociation {
|
||||||
|
|
||||||
private schemas: string[];
|
private schemas: string[];
|
||||||
private combinedSchemaId: string;
|
|
||||||
private patternRegExp: RegExp;
|
private patternRegExp: RegExp;
|
||||||
private combinedSchema: ISchemaHandle;
|
|
||||||
|
|
||||||
constructor(pattern: string) {
|
constructor(pattern: string) {
|
||||||
this.combinedSchemaId = 'schemaservice://combinedSchema/' + encodeURIComponent(pattern);
|
|
||||||
try {
|
try {
|
||||||
this.patternRegExp = Strings.convertSimple2RegExp(pattern);
|
this.patternRegExp = new RegExp(Strings.convertSimple2RegExpPattern(pattern) + '$');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// invalid pattern
|
// invalid pattern
|
||||||
this.patternRegExp = null;
|
this.patternRegExp = null;
|
||||||
}
|
}
|
||||||
this.schemas = [];
|
this.schemas = [];
|
||||||
this.combinedSchema = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public addSchema(id: string) {
|
public addSchema(id: string) {
|
||||||
this.schemas.push(id);
|
this.schemas.push(id);
|
||||||
this.combinedSchema = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public matchesPattern(fileName: string): boolean {
|
public matchesPattern(fileName: string): boolean {
|
||||||
return this.patternRegExp && this.patternRegExp.test(fileName);
|
return this.patternRegExp && this.patternRegExp.test(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCombinedSchema(service: JSONSchemaService): ISchemaHandle {
|
public getSchemas() {
|
||||||
if (!this.combinedSchema) {
|
return this.schemas;
|
||||||
this.combinedSchema = service.createCombinedSchema(this.combinedSchemaId, this.schemas);
|
|
||||||
}
|
|
||||||
return this.combinedSchema;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,40 +159,34 @@ export class ResolvedSchema {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSection(path: string[]): JSONSchema {
|
public getSection(path: string[]): JSONSchema {
|
||||||
return this.getSectionRecursive(path, this.schema);
|
return Parser.asSchema(this.getSectionRecursive(path, this.schema));
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSectionRecursive(path: string[], schema: JSONSchema): JSONSchema {
|
private getSectionRecursive(path: string[], schema: JSONSchemaRef): JSONSchemaRef {
|
||||||
if (!schema || path.length === 0) {
|
if (!schema || typeof schema === 'boolean' || path.length === 0) {
|
||||||
return schema;
|
return schema;
|
||||||
}
|
}
|
||||||
let next = path.shift();
|
let next = path.shift();
|
||||||
|
|
||||||
if (schema.properties && schema.properties[next]) {
|
if (schema.properties && typeof schema.properties[next]) {
|
||||||
return this.getSectionRecursive(path, schema.properties[next]);
|
return this.getSectionRecursive(path, schema.properties[next]);
|
||||||
} else if (schema.patternProperties) {
|
} else if (schema.patternProperties) {
|
||||||
Object.keys(schema.patternProperties).forEach((pattern) => {
|
for (const pattern of Object.keys(schema.patternProperties)) {
|
||||||
let regex = new RegExp(pattern);
|
let regex = new RegExp(pattern);
|
||||||
if (regex.test(next)) {
|
if (regex.test(next)) {
|
||||||
return this.getSectionRecursive(path, schema.patternProperties[pattern]);
|
return this.getSectionRecursive(path, schema.patternProperties[pattern]);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
} else if (schema.additionalProperties) {
|
} else if (typeof schema.additionalProperties === 'object') {
|
||||||
return this.getSectionRecursive(path, schema.additionalProperties);
|
return this.getSectionRecursive(path, schema.additionalProperties);
|
||||||
} else if (next.match('[0-9]+')) {
|
} else if (next.match('[0-9]+')) {
|
||||||
if (schema.items) {
|
if (Array.isArray(schema.items)) {
|
||||||
return this.getSectionRecursive(path, schema.items);
|
|
||||||
} else if (Array.isArray(schema.items)) {
|
|
||||||
try {
|
|
||||||
let index = parseInt(next, 10);
|
let index = parseInt(next, 10);
|
||||||
if (schema.items[index]) {
|
if (!isNaN(index) && schema.items[index]) {
|
||||||
return this.getSectionRecursive(path, schema.items[index]);
|
return this.getSectionRecursive(path, schema.items[index]);
|
||||||
}
|
}
|
||||||
return null;
|
} else if (schema.items) {
|
||||||
}
|
return this.getSectionRecursive(path, schema.items);
|
||||||
catch (e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,7 +213,7 @@ export class JSONSchemaService implements IJSONSchemaService {
|
||||||
this.contextService = contextService;
|
this.contextService = contextService;
|
||||||
this.requestService = requestService;
|
this.requestService = requestService;
|
||||||
this.callOnDispose = [];
|
this.callOnDispose = [];
|
||||||
this.customSchemaProvider = undefined;
|
|
||||||
this.contributionSchemas = {};
|
this.contributionSchemas = {};
|
||||||
this.contributionAssociations = {};
|
this.contributionAssociations = {};
|
||||||
this.schemasById = {};
|
this.schemasById = {};
|
||||||
|
|
@ -257,10 +222,6 @@ export class JSONSchemaService implements IJSONSchemaService {
|
||||||
this.registeredSchemasIds = {};
|
this.registeredSchemasIds = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
registerCustomSchemaProvider(customSchemaProvider: CustomSchemaProvider) {
|
|
||||||
this.customSchemaProvider = customSchemaProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getRegisteredSchemaIds(filter?: (scheme) => boolean): string[] {
|
public getRegisteredSchemaIds(filter?: (scheme) => boolean): string[] {
|
||||||
return Object.keys(this.registeredSchemasIds).filter(id => {
|
return Object.keys(this.registeredSchemasIds).filter(id => {
|
||||||
let scheme = URI.parse(id).scheme;
|
let scheme = URI.parse(id).scheme;
|
||||||
|
|
@ -268,6 +229,10 @@ export class JSONSchemaService implements IJSONSchemaService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
registerCustomSchemaProvider(customSchemaProvider: CustomSchemaProvider) {
|
||||||
|
this.customSchemaProvider = customSchemaProvider;
|
||||||
|
}
|
||||||
|
|
||||||
public dispose(): void {
|
public dispose(): void {
|
||||||
while (this.callOnDispose.length > 0) {
|
while (this.callOnDispose.length > 0) {
|
||||||
this.callOnDispose.pop()();
|
this.callOnDispose.pop()();
|
||||||
|
|
@ -304,10 +269,10 @@ export class JSONSchemaService implements IJSONSchemaService {
|
||||||
this.contributionAssociations[pattern] = associations;
|
this.contributionAssociations[pattern] = associations;
|
||||||
|
|
||||||
var fpa = this.getOrAddFilePatternAssociation(pattern);
|
var fpa = this.getOrAddFilePatternAssociation(pattern);
|
||||||
associations.forEach(schemaId => {
|
for (const schemaId of associations) {
|
||||||
let id = this.normalizeId(schemaId);
|
let id = this.normalizeId(schemaId);
|
||||||
fpa.addSchema(id);
|
fpa.addSchema(id);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -337,9 +302,9 @@ export class JSONSchemaService implements IJSONSchemaService {
|
||||||
this.registeredSchemasIds[id] = true;
|
this.registeredSchemasIds[id] = true;
|
||||||
|
|
||||||
if (filePatterns) {
|
if (filePatterns) {
|
||||||
filePatterns.forEach(pattern => {
|
for (const pattern of filePatterns) {
|
||||||
this.getOrAddFilePatternAssociation(pattern).addSchema(id);
|
this.getOrAddFilePatternAssociation(pattern).addSchema(id);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
return unresolvedSchemaContent ? this.addSchemaHandle(id, unresolvedSchemaContent) : this.getOrAddSchemaHandle(id);
|
return unresolvedSchemaContent ? this.addSchemaHandle(id, unresolvedSchemaContent) : this.getOrAddSchemaHandle(id);
|
||||||
}
|
}
|
||||||
|
|
@ -356,11 +321,10 @@ export class JSONSchemaService implements IJSONSchemaService {
|
||||||
}
|
}
|
||||||
for (let pattern in this.contributionAssociations) {
|
for (let pattern in this.contributionAssociations) {
|
||||||
var fpa = this.getOrAddFilePatternAssociation(pattern);
|
var fpa = this.getOrAddFilePatternAssociation(pattern);
|
||||||
|
for (const schemaId of this.contributionAssociations[pattern]) {
|
||||||
this.contributionAssociations[pattern].forEach(schemaId => {
|
|
||||||
let id = this.normalizeId(schemaId);
|
let id = this.normalizeId(schemaId);
|
||||||
fpa.addSchema(id);
|
fpa.addSchema(id);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -386,13 +350,18 @@ export class JSONSchemaService implements IJSONSchemaService {
|
||||||
}
|
}
|
||||||
|
|
||||||
let schemaContent: JSONSchema = {};
|
let schemaContent: JSONSchema = {};
|
||||||
let jsonErrors = [];
|
let jsonErrors: Json.ParseError[] = [];
|
||||||
schemaContent = Json.parse(content, jsonErrors);
|
schemaContent = Json.parse(content, jsonErrors);
|
||||||
let errors = jsonErrors.length ? [localize('json.schema.invalidFormat', 'Unable to parse content from \'{0}\': {1}.', toDisplayString(url), getParseErrorMessage(jsonErrors[0]))] : [];
|
let errors = jsonErrors.length ? [localize('json.schema.invalidFormat', 'Unable to parse content from \'{0}\': Parse error at offset {1}.', toDisplayString(url), jsonErrors[0].offset)] : [];
|
||||||
return new UnresolvedSchema(schemaContent, errors);
|
return new UnresolvedSchema(schemaContent, errors);
|
||||||
},
|
},
|
||||||
(error: any) => {
|
(error: any) => {
|
||||||
let errorMessage = localize('json.schema.unabletoload', 'Unable to load schema from \'{0}\': {1}', toDisplayString(url), error.toString());
|
let errorMessage = error.toString();
|
||||||
|
let errorSplit = error.toString().split('Error: ');
|
||||||
|
if(errorSplit.length > 1) {
|
||||||
|
// more concise error message, URL and context are attached by caller anyways
|
||||||
|
errorMessage = errorSplit[1];
|
||||||
|
}
|
||||||
return new UnresolvedSchema(<JSONSchema>{}, [errorMessage]);
|
return new UnresolvedSchema(<JSONSchema>{}, [errorMessage]);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -419,21 +388,20 @@ export class JSONSchemaService implements IJSONSchemaService {
|
||||||
return current;
|
return current;
|
||||||
};
|
};
|
||||||
|
|
||||||
let resolveLink = (node: any, linkedSchema: JSONSchema, linkPath: string): void => {
|
let merge = (target: JSONSchema, sourceRoot: JSONSchema, sourceURI: string, path: string): void => {
|
||||||
let section = findSection(linkedSchema, linkPath);
|
let section = findSection(sourceRoot, path);
|
||||||
if (section) {
|
if (section) {
|
||||||
for (let key in section) {
|
for (let key in section) {
|
||||||
if (section.hasOwnProperty(key) && !node.hasOwnProperty(key)) {
|
if (section.hasOwnProperty(key) && !target.hasOwnProperty(key)) {
|
||||||
node[key] = section[key];
|
target[key] = section[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
resolveErrors.push(localize('json.schema.invalidref', '$ref \'{0}\' in {1} can not be resolved.', linkPath, linkedSchema.id));
|
resolveErrors.push(localize('json.schema.invalidref', '$ref \'{0}\' in \'{1}\' can not be resolved.', path, sourceURI));
|
||||||
}
|
}
|
||||||
delete node.$ref;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let resolveExternalLink = (node: any, uri: string, linkPath: string, parentSchemaURL: string): Thenable<any> => {
|
let resolveExternalLink = (node: JSONSchema, uri: string, linkPath: string, parentSchemaURL: string): Thenable<any> => {
|
||||||
if (contextService && !/^\w+:\/\/.*/.test(uri)) {
|
if (contextService && !/^\w+:\/\/.*/.test(uri)) {
|
||||||
uri = contextService.resolveRelativePath(uri, parentSchemaURL);
|
uri = contextService.resolveRelativePath(uri, parentSchemaURL);
|
||||||
}
|
}
|
||||||
|
|
@ -443,13 +411,13 @@ export class JSONSchemaService implements IJSONSchemaService {
|
||||||
let loc = linkPath ? uri + '#' + linkPath : uri;
|
let loc = linkPath ? uri + '#' + linkPath : uri;
|
||||||
resolveErrors.push(localize('json.schema.problemloadingref', 'Problems loading reference \'{0}\': {1}', loc, unresolvedSchema.errors[0]));
|
resolveErrors.push(localize('json.schema.problemloadingref', 'Problems loading reference \'{0}\': {1}', loc, unresolvedSchema.errors[0]));
|
||||||
}
|
}
|
||||||
resolveLink(node, unresolvedSchema.schema, linkPath);
|
merge(node, unresolvedSchema.schema, uri, linkPath);
|
||||||
return resolveRefs(node, unresolvedSchema.schema, uri);
|
return resolveRefs(node, unresolvedSchema.schema, uri);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let resolveRefs = (node: JSONSchema, parentSchema: JSONSchema, parentSchemaURL: string): Thenable<any> => {
|
let resolveRefs = (node: JSONSchema, parentSchema: JSONSchema, parentSchemaURL: string): Thenable<any> => {
|
||||||
if (!node) {
|
if (!node || typeof node !== 'object') {
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -458,7 +426,7 @@ export class JSONSchemaService implements IJSONSchemaService {
|
||||||
|
|
||||||
let openPromises: Thenable<any>[] = [];
|
let openPromises: Thenable<any>[] = [];
|
||||||
|
|
||||||
let collectEntries = (...entries: JSONSchema[]) => {
|
let collectEntries = (...entries: JSONSchemaRef[]) => {
|
||||||
for (let entry of entries) {
|
for (let entry of entries) {
|
||||||
if (typeof entry === 'object') {
|
if (typeof entry === 'object') {
|
||||||
toWalk.push(entry);
|
toWalk.push(entry);
|
||||||
|
|
@ -470,36 +438,48 @@ export class JSONSchemaService implements IJSONSchemaService {
|
||||||
if (typeof map === 'object') {
|
if (typeof map === 'object') {
|
||||||
for (let key in map) {
|
for (let key in map) {
|
||||||
let entry = map[key];
|
let entry = map[key];
|
||||||
|
if (typeof entry === 'object') {
|
||||||
toWalk.push(entry);
|
toWalk.push(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let collectArrayEntries = (...arrays: JSONSchema[][]) => {
|
let collectArrayEntries = (...arrays: JSONSchemaRef[][]) => {
|
||||||
for (let array of arrays) {
|
for (let array of arrays) {
|
||||||
if (Array.isArray(array)) {
|
if (Array.isArray(array)) {
|
||||||
toWalk.push.apply(toWalk, array);
|
for (let entry of array) {
|
||||||
|
if (typeof entry === 'object') {
|
||||||
|
toWalk.push(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
let handleRef = (next: JSONSchema) => {
|
||||||
|
while (next.$ref) {
|
||||||
|
let segments = next.$ref.split('#', 2);
|
||||||
|
delete next.$ref;
|
||||||
|
if (segments[0].length > 0) {
|
||||||
|
openPromises.push(resolveExternalLink(next, segments[0], segments[1], parentSchemaURL));
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
merge(next, parentSchema, parentSchemaURL, segments[1]); // can set next.$ref again
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
collectEntries(<JSONSchema>next.items, <JSONSchema>next.additionalProperties, next.not, next.contains, next.propertyNames, next.if, next.then, next.else);
|
||||||
|
collectMapEntries(next.definitions, next.properties, next.patternProperties, <JSONSchemaMap>next.dependencies);
|
||||||
|
collectArrayEntries(next.anyOf, next.allOf, next.oneOf, <JSONSchema[]>next.items);
|
||||||
|
};
|
||||||
|
|
||||||
while (toWalk.length) {
|
while (toWalk.length) {
|
||||||
let next = toWalk.pop();
|
let next = toWalk.pop();
|
||||||
if (seen.indexOf(next) >= 0) {
|
if (seen.indexOf(next) >= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
seen.push(next);
|
seen.push(next);
|
||||||
if (next.$ref) {
|
handleRef(next);
|
||||||
let segments = next.$ref.split('#', 2);
|
|
||||||
if (segments[0].length > 0) {
|
|
||||||
openPromises.push(resolveExternalLink(next, segments[0], segments[1], parentSchemaURL));
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
resolveLink(next, parentSchema, segments[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
collectEntries(next.items, next.additionalProperties, next.not);
|
|
||||||
collectMapEntries(next.definitions, next.properties, next.patternProperties, <JSONSchemaMap>next.dependencies);
|
|
||||||
collectArrayEntries(next.anyOf, next.allOf, next.oneOf, <JSONSchema[]>next.items, next.schemaSequence);
|
|
||||||
}
|
}
|
||||||
return Promise.all(openPromises);
|
return Promise.all(openPromises);
|
||||||
};
|
};
|
||||||
|
|
@ -507,32 +487,47 @@ export class JSONSchemaService implements IJSONSchemaService {
|
||||||
return resolveRefs(schema, schema, schemaURL).then(_ => new ResolvedSchema(schema, resolveErrors));
|
return resolveRefs(schema, schema, schemaURL).then(_ => new ResolvedSchema(schema, resolveErrors));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSchemaForResource(resource: string ): Thenable<ResolvedSchema> {
|
public getSchemaForResource(resource: string, document?: Parser.JSONDocument): Thenable<ResolvedSchema> {
|
||||||
const resolveSchema = () => {
|
|
||||||
// check for matching file names, last to first
|
// first use $schema if present
|
||||||
for (let i = this.filePatternAssociations.length - 1; i >= 0; i--) {
|
if (document && document.root && document.root.type === 'object') {
|
||||||
let entry = this.filePatternAssociations[i];
|
let schemaProperties = document.root.properties.filter(p => (p.keyNode.value === '$schema') && p.valueNode && p.valueNode.type === 'string');
|
||||||
if (entry.matchesPattern(resource)) {
|
if (schemaProperties.length > 0) {
|
||||||
return entry.getCombinedSchema(this).getResolvedSchema();
|
let schemeId = <string>Parser.getNodeValue(schemaProperties[0].valueNode);
|
||||||
|
if (schemeId && Strings.startsWith(schemeId, '.') && this.contextService) {
|
||||||
|
schemeId = this.contextService.resolveRelativePath(schemeId, resource);
|
||||||
}
|
}
|
||||||
|
if (schemeId) {
|
||||||
|
let id = this.normalizeId(schemeId);
|
||||||
|
return this.getOrAddSchemaHandle(id).getResolvedSchema();
|
||||||
}
|
}
|
||||||
return Promise.resolve(null);
|
|
||||||
};
|
|
||||||
if (this.customSchemaProvider) {
|
|
||||||
return this.customSchemaProvider(resource).then(schemaUri => {
|
|
||||||
return this.loadSchema(schemaUri).then(unsolvedSchema => this.resolveSchemaContent(unsolvedSchema, schemaUri));
|
|
||||||
}).then(schema => schema, err => {
|
|
||||||
return resolveSchema();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return resolveSchema();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public createCombinedSchema(combinedSchemaId: string, schemaIds: string[]): ISchemaHandle {
|
let seen: { [schemaId: string]: boolean } = Object.create(null);
|
||||||
|
let schemas: string[] = [];
|
||||||
|
for (let entry of this.filePatternAssociations) {
|
||||||
|
if (entry.matchesPattern(resource)) {
|
||||||
|
for (let schemaId of entry.getSchemas()) {
|
||||||
|
if (!seen[schemaId]) {
|
||||||
|
schemas.push(schemaId);
|
||||||
|
seen[schemaId] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (schemas.length > 0) {
|
||||||
|
return this.createCombinedSchema(resource, schemas).getResolvedSchema();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private createCombinedSchema(resource: string, schemaIds: string[]): ISchemaHandle {
|
||||||
if (schemaIds.length === 1) {
|
if (schemaIds.length === 1) {
|
||||||
return this.getOrAddSchemaHandle(schemaIds[0]);
|
return this.getOrAddSchemaHandle(schemaIds[0]);
|
||||||
} else {
|
} else {
|
||||||
|
let combinedSchemaId = 'schemaservice://combinedSchema/' + encodeURIComponent(resource);
|
||||||
let combinedSchema: JSONSchema = {
|
let combinedSchema: JSONSchema = {
|
||||||
allOf: schemaIds.map(schemaId => ({ $ref: schemaId }))
|
allOf: schemaIds.map(schemaId => ({ $ref: schemaId }))
|
||||||
};
|
};
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -12,32 +12,15 @@ import {JSONWorkerContribution} from '../jsonContributions';
|
||||||
import { Thenable } from 'vscode-json-languageservice';
|
import { Thenable } from 'vscode-json-languageservice';
|
||||||
|
|
||||||
import { Hover, TextDocument, Position, Range, MarkedString } from 'vscode-languageserver-types';
|
import { Hover, TextDocument, Position, Range, MarkedString } from 'vscode-languageserver-types';
|
||||||
|
import { YAMLDocument } from '../yamlLanguageTypes';
|
||||||
import { matchOffsetToDocument } from '../utils/arrUtils';
|
import { matchOffsetToDocument } from '../utils/arrUtils';
|
||||||
import { LanguageSettings } from '../yamlLanguageService';
|
|
||||||
|
|
||||||
export class YAMLHover {
|
export class YAMLHover {
|
||||||
|
|
||||||
private schemaService: SchemaService.IJSONSchemaService;
|
constructor(private schemaService: SchemaService.IJSONSchemaService, private contributions: JSONWorkerContribution[] = []) {
|
||||||
private contributions: JSONWorkerContribution[];
|
|
||||||
private shouldHover: boolean;
|
|
||||||
|
|
||||||
constructor(schemaService: SchemaService.IJSONSchemaService, contributions: JSONWorkerContribution[] = []) {
|
|
||||||
this.schemaService = schemaService;
|
|
||||||
this.contributions = contributions;
|
|
||||||
this.shouldHover = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public configure(languageSettings: LanguageSettings){
|
public doHover(document: TextDocument, position: Position, doc: YAMLDocument): Thenable<Hover> {
|
||||||
if(languageSettings){
|
|
||||||
this.shouldHover = languageSettings.hover;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public doHover(document: TextDocument, position: Position, doc): Thenable<Hover> {
|
|
||||||
|
|
||||||
if(!this.shouldHover || !document){
|
|
||||||
return Promise.resolve(void 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
let offset = document.offsetAt(position);
|
let offset = document.offsetAt(position);
|
||||||
let currentDoc = matchOffsetToDocument(offset, doc);
|
let currentDoc = matchOffsetToDocument(offset, doc);
|
||||||
|
|
@ -46,24 +29,23 @@ export class YAMLHover {
|
||||||
}
|
}
|
||||||
const currentDocIndex = doc.documents.indexOf(currentDoc);
|
const currentDocIndex = doc.documents.indexOf(currentDoc);
|
||||||
let node = currentDoc.getNodeFromOffset(offset);
|
let node = currentDoc.getNodeFromOffset(offset);
|
||||||
if (!node || (node.type === 'object' || node.type === 'array') && offset > node.start + 1 && offset < node.end - 1) {
|
if (!node || (node.type === 'object' || node.type === 'array') && offset > node.offset + 1 && offset < node.offset + node.length - 1) {
|
||||||
return Promise.resolve(void 0);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
let hoverRangeNode = node;
|
let hoverRangeNode = node;
|
||||||
|
|
||||||
// use the property description when hovering over an object key
|
// use the property description when hovering over an object key
|
||||||
if (node.type === 'string') {
|
if (node.type === 'string') {
|
||||||
let stringNode = <Parser.StringASTNode>node;
|
let parent = node.parent;
|
||||||
if (stringNode.isKey) {
|
if (parent && parent.type === 'property' && parent.keyNode === node) {
|
||||||
let propertyNode = <Parser.PropertyASTNode>node.parent;
|
node = parent.valueNode;
|
||||||
node = propertyNode.value;
|
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return Promise.resolve(void 0);
|
return Promise.resolve(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let hoverRange = Range.create(document.positionAt(hoverRangeNode.start), document.positionAt(hoverRangeNode.end));
|
let hoverRange = Range.create(document.positionAt(hoverRangeNode.offset), document.positionAt(hoverRangeNode.offset + hoverRangeNode.length));
|
||||||
|
|
||||||
var createHover = (contents: MarkedString[]) => {
|
var createHover = (contents: MarkedString[]) => {
|
||||||
let result: Hover = {
|
let result: Hover = {
|
||||||
|
|
@ -73,7 +55,7 @@ export class YAMLHover {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
let location = node.getPath();
|
let location = Parser.getNodePath(node);
|
||||||
for (let i = this.contributions.length - 1; i >= 0; i--) {
|
for (let i = this.contributions.length - 1; i >= 0; i--) {
|
||||||
let contribution = this.contributions[i];
|
let contribution = this.contributions[i];
|
||||||
let promise = contribution.getInfoContribution(document.uri, location);
|
let promise = contribution.getInfoContribution(document.uri, location);
|
||||||
|
|
@ -82,25 +64,21 @@ export class YAMLHover {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.schemaService.getSchemaForResource(document.uri).then((schema) => {
|
return this.schemaService.getSchemaForResource(document.uri, currentDoc).then((schema) => {
|
||||||
if (schema) {
|
if (schema) {
|
||||||
let newSchema = schema;
|
let matchingSchemas = currentDoc.getMatchingSchemas(schema.schema, node.offset);
|
||||||
if (schema.schema && schema.schema.schemaSequence && schema.schema.schemaSequence[currentDocIndex]) {
|
|
||||||
newSchema = new SchemaService.ResolvedSchema(schema.schema.schemaSequence[currentDocIndex]);
|
|
||||||
}
|
|
||||||
let matchingSchemas = currentDoc.getMatchingSchemas(newSchema.schema, node.start);
|
|
||||||
|
|
||||||
let title: string = null;
|
let title: string = null;
|
||||||
let markdownDescription: string = null;
|
let markdownDescription: string = null;
|
||||||
let markdownEnumValueDescription = null, enumValue = null;
|
let markdownEnumValueDescription = null, enumValue = null;
|
||||||
matchingSchemas.every((s) => {
|
matchingSchemas.forEach((s) => {
|
||||||
if (s.node === node && !s.inverted && s.schema) {
|
if (s.node === node && !s.inverted && s.schema) {
|
||||||
title = title || s.schema.title;
|
title = title || s.schema.title;
|
||||||
markdownDescription = markdownDescription || s.schema["markdownDescription"] || toMarkdown(s.schema.description);
|
markdownDescription = markdownDescription || s.schema.markdownDescription || toMarkdown(s.schema.description);
|
||||||
if (s.schema.enum) {
|
if (s.schema.enum) {
|
||||||
let idx = s.schema.enum.indexOf(node.getValue());
|
let idx = s.schema.enum.indexOf(Parser.getNodeValue(node));
|
||||||
if (s.schema["markdownEnumDescriptions"]) {
|
if (s.schema.markdownEnumDescriptions) {
|
||||||
markdownEnumValueDescription = s.schema["markdownEnumDescriptions"][idx];
|
markdownEnumValueDescription = s.schema.markdownEnumDescriptions[idx];
|
||||||
} else if (s.schema.enumDescriptions) {
|
} else if (s.schema.enumDescriptions) {
|
||||||
markdownEnumValueDescription = toMarkdown(s.schema.enumDescriptions[idx]);
|
markdownEnumValueDescription = toMarkdown(s.schema.enumDescriptions[idx]);
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +110,7 @@ export class YAMLHover {
|
||||||
}
|
}
|
||||||
return createHover([result]);
|
return createHover([result]);
|
||||||
}
|
}
|
||||||
return void 0;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,31 +6,27 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { JSONSchemaService, ResolvedSchema } from './jsonSchemaService';
|
import { JSONSchemaService, ResolvedSchema } from './jsonSchemaService';
|
||||||
import { DiagnosticSeverity } from 'vscode-languageserver-types';
|
import { DiagnosticSeverity, TextDocument } from 'vscode-languageserver-types';
|
||||||
import { LanguageSettings } from '../yamlLanguageService';
|
import { LanguageSettings } from '../yamlLanguageService';
|
||||||
|
import { YAMLDocument } from '../yamlLanguageTypes';
|
||||||
|
|
||||||
export class YAMLValidation {
|
export class YAMLValidation {
|
||||||
|
|
||||||
private jsonSchemaService: JSONSchemaService;
|
|
||||||
private validationEnabled: boolean;
|
private validationEnabled: boolean;
|
||||||
|
public constructor(private jsonSchemaService: JSONSchemaService) {
|
||||||
public constructor(jsonSchemaService) {
|
|
||||||
this.jsonSchemaService = jsonSchemaService;
|
|
||||||
this.validationEnabled = true;
|
this.validationEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public configure(shouldValidate: LanguageSettings){
|
public configure(raw: LanguageSettings) {
|
||||||
if(shouldValidate){
|
if (raw) {
|
||||||
this.validationEnabled = shouldValidate.validate;
|
this.validationEnabled = raw.validate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public doValidation(textDocument, yamlDocument) {
|
public doValidation(textDocument: TextDocument, yamlDocument: YAMLDocument) {
|
||||||
|
|
||||||
if (!this.validationEnabled) {
|
if (!this.validationEnabled) {
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.jsonSchemaService.getSchemaForResource(textDocument.uri).then(function (schema) {
|
return this.jsonSchemaService.getSchemaForResource(textDocument.uri).then(function (schema) {
|
||||||
var diagnostics = [];
|
var diagnostics = [];
|
||||||
var added = {};
|
var added = {};
|
||||||
|
|
@ -42,10 +38,10 @@ export class YAMLValidation {
|
||||||
if (schema.schema && schema.schema.schemaSequence && schema.schema.schemaSequence[documentIndex]) {
|
if (schema.schema && schema.schema.schemaSequence && schema.schema.schemaSequence[documentIndex]) {
|
||||||
newSchema = new ResolvedSchema(schema.schema.schemaSequence[documentIndex]);
|
newSchema = new ResolvedSchema(schema.schema.schemaSequence[documentIndex]);
|
||||||
}
|
}
|
||||||
let diagnostics = currentDoc.getValidationProblems(newSchema.schema);
|
let diagnostics = currentDoc.validate(textDocument, newSchema.schema);
|
||||||
for(let diag in diagnostics){
|
for(let diag in diagnostics){
|
||||||
let curDiagnostic = diagnostics[diag];
|
let curDiagnostic = diagnostics[diag];
|
||||||
currentDoc.errors.push({ location: { start: curDiagnostic.location.start, end: curDiagnostic.location.end }, message: curDiagnostic.message })
|
currentDoc.errors.push({ location: { start: curDiagnostic.range.start, end: curDiagnostic.range.end }, message: curDiagnostic.message })
|
||||||
}
|
}
|
||||||
documentIndex++;
|
documentIndex++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
|
import { SingleYAMLDocument, YAMLDocument } from '../yamlLanguageTypes';
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------------------------
|
||||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
import { SingleYAMLDocument } from "../parser/yamlParser";
|
|
||||||
|
|
||||||
export function removeDuplicates(arr, prop) {
|
export function removeDuplicates(arr, prop) {
|
||||||
var new_arr = [];
|
var new_arr = [];
|
||||||
var lookup = {};
|
var lookup = {};
|
||||||
|
|
@ -61,15 +61,11 @@ export function removeDuplicatesObj(objArray){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function matchOffsetToDocument(offset: number, jsonDocuments): SingleYAMLDocument {
|
export function matchOffsetToDocument(offset: number, doc: YAMLDocument): SingleYAMLDocument {
|
||||||
|
for (let currDoc of doc.documents) {
|
||||||
for(let jsonDoc in jsonDocuments.documents){
|
if (currDoc.root && (currDoc.root.length + currDoc.root.offset) >= offset && currDoc.root.offset <= offset) {
|
||||||
let currJsonDoc = jsonDocuments.documents[jsonDoc];
|
return currDoc;
|
||||||
if(currJsonDoc.root && currJsonDoc.root.end >= offset && currJsonDoc.root.start <= offset){
|
|
||||||
return currJsonDoc;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
75
src/languageservice/utils/colors.ts
Normal file
75
src/languageservice/utils/colors.ts
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import { Color } from "../jsonLanguageTypes";
|
||||||
|
|
||||||
|
const Digit0 = 48;
|
||||||
|
const Digit9 = 57;
|
||||||
|
const A = 65;
|
||||||
|
const a = 97;
|
||||||
|
const f = 102;
|
||||||
|
|
||||||
|
export function hexDigit(charCode: number) {
|
||||||
|
if (charCode < Digit0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (charCode <= Digit9) {
|
||||||
|
return charCode - Digit0;
|
||||||
|
}
|
||||||
|
if (charCode < a) {
|
||||||
|
charCode += (a - A);
|
||||||
|
}
|
||||||
|
if (charCode >= a && charCode <= f) {
|
||||||
|
return charCode - a + 10;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function colorFromHex(text: string): Color {
|
||||||
|
if (text[0] !== '#') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
switch (text.length) {
|
||||||
|
case 4:
|
||||||
|
return {
|
||||||
|
red: (hexDigit(text.charCodeAt(1)) * 0x11) / 255.0,
|
||||||
|
green: (hexDigit(text.charCodeAt(2)) * 0x11) / 255.0,
|
||||||
|
blue: (hexDigit(text.charCodeAt(3)) * 0x11) / 255.0,
|
||||||
|
alpha: 1
|
||||||
|
};
|
||||||
|
case 5:
|
||||||
|
return {
|
||||||
|
red: (hexDigit(text.charCodeAt(1)) * 0x11) / 255.0,
|
||||||
|
green: (hexDigit(text.charCodeAt(2)) * 0x11) / 255.0,
|
||||||
|
blue: (hexDigit(text.charCodeAt(3)) * 0x11) / 255.0,
|
||||||
|
alpha: (hexDigit(text.charCodeAt(4)) * 0x11) / 255.0,
|
||||||
|
};
|
||||||
|
case 7:
|
||||||
|
return {
|
||||||
|
red: (hexDigit(text.charCodeAt(1)) * 0x10 + hexDigit(text.charCodeAt(2))) / 255.0,
|
||||||
|
green: (hexDigit(text.charCodeAt(3)) * 0x10 + hexDigit(text.charCodeAt(4))) / 255.0,
|
||||||
|
blue: (hexDigit(text.charCodeAt(5)) * 0x10 + hexDigit(text.charCodeAt(6))) / 255.0,
|
||||||
|
alpha: 1
|
||||||
|
};
|
||||||
|
case 9:
|
||||||
|
return {
|
||||||
|
red: (hexDigit(text.charCodeAt(1)) * 0x10 + hexDigit(text.charCodeAt(2))) / 255.0,
|
||||||
|
green: (hexDigit(text.charCodeAt(3)) * 0x10 + hexDigit(text.charCodeAt(4))) / 255.0,
|
||||||
|
blue: (hexDigit(text.charCodeAt(5)) * 0x10 + hexDigit(text.charCodeAt(6))) / 255.0,
|
||||||
|
alpha: (hexDigit(text.charCodeAt(7)) * 0x10 + hexDigit(text.charCodeAt(8))) / 255.0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function colorFrom256RGB(red: number, green: number, blue: number, alpha: number = 1.0) {
|
||||||
|
return {
|
||||||
|
red: red / 255.0,
|
||||||
|
green: green / 255.0,
|
||||||
|
blue: blue / 255.0,
|
||||||
|
alpha
|
||||||
|
};
|
||||||
|
}
|
||||||
44
src/languageservice/utils/json.ts
Normal file
44
src/languageservice/utils/json.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
export function stringifyObject(obj: any, indent: string, stringifyLiteral: (val: any) => string) : string {
|
||||||
|
if (obj !== null && typeof obj === 'object') {
|
||||||
|
let newIndent = indent + '\t';
|
||||||
|
if (Array.isArray(obj)) {
|
||||||
|
if (obj.length === 0) {
|
||||||
|
return '[]';
|
||||||
|
}
|
||||||
|
let result = '[\n';
|
||||||
|
for (let i = 0; i < obj.length; i++) {
|
||||||
|
result += newIndent + stringifyObject(obj[i], newIndent, stringifyLiteral);
|
||||||
|
if (i < obj.length - 1) {
|
||||||
|
result += ',';
|
||||||
|
}
|
||||||
|
result += '\n';
|
||||||
|
}
|
||||||
|
result += indent + ']';
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
let keys = Object.keys(obj);
|
||||||
|
if (keys.length === 0) {
|
||||||
|
return '{}';
|
||||||
|
}
|
||||||
|
let result = '{\n';
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
let key = keys[i];
|
||||||
|
|
||||||
|
result += newIndent + JSON.stringify(key) + ': ' + stringifyObject(obj[key], newIndent, stringifyLiteral);
|
||||||
|
if (i < keys.length - 1) {
|
||||||
|
result += ',';
|
||||||
|
}
|
||||||
|
result += '\n';
|
||||||
|
}
|
||||||
|
result += indent + '}';
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stringifyLiteral(obj);
|
||||||
|
}
|
||||||
|
|
@ -56,3 +56,19 @@ export function equals(one: any, other: any): boolean {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isNumber(val: any): val is number {
|
||||||
|
return typeof val === 'number';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isDefined(val: any): val is object {
|
||||||
|
return typeof val !== 'undefined';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isBoolean(val: any): val is boolean {
|
||||||
|
return typeof val === 'boolean';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isString(val: any): val is string {
|
||||||
|
return typeof val === 'string';
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,10 @@ export function convertSimple2RegExp(pattern: string): RegExp {
|
||||||
: convertGlobalPattern2RegExp(pattern)
|
: convertGlobalPattern2RegExp(pattern)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function convertSimple2RegExpPattern(pattern: string): string {
|
||||||
|
return pattern.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&').replace(/[\*]/g, '.*');
|
||||||
|
}
|
||||||
|
|
||||||
function convertGlobalPattern2RegExp(pattern: string): RegExp {
|
function convertGlobalPattern2RegExp(pattern: string): RegExp {
|
||||||
return new RegExp(pattern.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&').replace(/[\*]/g, '.*') + '$');
|
return new RegExp(pattern.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&').replace(/[\*]/g, '.*') + '$');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,16 @@
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { JSONSchemaService, CustomSchemaProvider } from './services/jsonSchemaService'
|
import { JSONSchemaService, CustomSchemaProvider } from './services/jsonSchemaService'
|
||||||
import { TextDocument, Position, CompletionList, Diagnostic, FormattingOptions } from 'vscode-languageserver-types';
|
import { TextDocument, Position, CompletionList, Diagnostic, FormattingOptions, DocumentSymbol, CompletionItem, Color, ColorInformation, ColorPresentation, Range } from 'vscode-languageserver-types';
|
||||||
import { JSONSchema } from './jsonSchema';
|
import { JSONSchema } from './jsonSchema';
|
||||||
import { YAMLDocumentSymbols } from './services/documentSymbols';
|
import { YAMLDocumentSymbols } from './services/documentSymbols';
|
||||||
import { YAMLCompletion } from './services/yamlCompletion';
|
import { YAMLCompletion } from './services/yamlCompletion';
|
||||||
import { YAMLHover } from './services/yamlHover';
|
import { YAMLHover } from './services/yamlHover';
|
||||||
import { YAMLValidation } from './services/yamlValidation';
|
import { YAMLValidation } from './services/yamlValidation';
|
||||||
import { format } from './services/yamlFormatter';
|
import { format } from './services/yamlFormatter';
|
||||||
import { JSONDocument, JSONWorkerContribution } from 'vscode-json-languageservice';
|
import { parse as parseYAML } from './parser/yamlParser';
|
||||||
import { parse as parseYAML } from "./parser/yamlParser";
|
import { JSONWorkerContribution } from './jsonContributions';
|
||||||
|
import { YAMLDocument } from './yamlLanguageTypes';
|
||||||
|
|
||||||
export interface LanguageSettings {
|
export interface LanguageSettings {
|
||||||
validate?: boolean; //Setting for whether we want to validate the schema
|
validate?: boolean; //Setting for whether we want to validate the schema
|
||||||
|
|
@ -24,8 +25,6 @@ export interface LanguageSettings {
|
||||||
customTags?: Array<String>; //Array of Custom Tags
|
customTags?: Array<String>; //Array of Custom Tags
|
||||||
}
|
}
|
||||||
|
|
||||||
export type YAMLDocument = { documents: JSONDocument[] };
|
|
||||||
|
|
||||||
export interface Thenable<R> {
|
export interface Thenable<R> {
|
||||||
/**
|
/**
|
||||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||||
|
|
@ -67,11 +66,13 @@ export interface SchemaConfiguration {
|
||||||
export interface LanguageService {
|
export interface LanguageService {
|
||||||
configure(settings: LanguageSettings): void;
|
configure(settings: LanguageSettings): void;
|
||||||
registerCustomSchemaProvider(schemaProvider: CustomSchemaProvider): void; // Register a custom schema provider
|
registerCustomSchemaProvider(schemaProvider: CustomSchemaProvider): void; // Register a custom schema provider
|
||||||
doComplete(document: TextDocument, position: Position, doc): Thenable<CompletionList>;
|
doComplete(document: TextDocument, position: Position, doc: YAMLDocument): Thenable<CompletionList>;
|
||||||
doValidation(document: TextDocument, yamlDocument): Thenable<Diagnostic[]>;
|
doValidation(document: TextDocument, yamlDocument: YAMLDocument): Thenable<Diagnostic[]>;
|
||||||
doHover(document: TextDocument, position: Position, doc);
|
doHover(document: TextDocument, position: Position, doc: YAMLDocument);
|
||||||
findDocumentSymbols(document: TextDocument, doc);
|
findDocumentSymbols(document: TextDocument, doc: YAMLDocument): DocumentSymbol[];
|
||||||
doResolve(completionItem);
|
findDocumentColors(document: TextDocument, doc: YAMLDocument): Thenable<ColorInformation[]>;
|
||||||
|
getColorPresentations(document: TextDocument, doc: YAMLDocument, color: Color, range: Range): ColorPresentation[];
|
||||||
|
doResolve(completionItem: CompletionItem): Thenable<CompletionItem>;
|
||||||
resetSchema(uri: string): boolean;
|
resetSchema(uri: string): boolean;
|
||||||
doFormat(document: TextDocument, options: FormattingOptions, customTags: Array<String>);
|
doFormat(document: TextDocument, options: FormattingOptions, customTags: Array<String>);
|
||||||
parseYAMLDocument(document: TextDocument): YAMLDocument;
|
parseYAMLDocument(document: TextDocument): YAMLDocument;
|
||||||
|
|
@ -82,7 +83,7 @@ export function getLanguageService(schemaRequestService: SchemaRequestService, w
|
||||||
|
|
||||||
let completer = new YAMLCompletion(schemaService, contributions);
|
let completer = new YAMLCompletion(schemaService, contributions);
|
||||||
let hover = new YAMLHover(schemaService, contributions);
|
let hover = new YAMLHover(schemaService, contributions);
|
||||||
let yamlDocumentSymbols = new YAMLDocumentSymbols();
|
let yamlDocumentSymbols = new YAMLDocumentSymbols(schemaService);
|
||||||
let yamlValidation = new YAMLValidation(schemaService);
|
let yamlValidation = new YAMLValidation(schemaService);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -93,10 +94,6 @@ export function getLanguageService(schemaRequestService: SchemaRequestService, w
|
||||||
schemaService.registerExternalSchema(settings.uri, settings.fileMatch, settings.schema);
|
schemaService.registerExternalSchema(settings.uri, settings.fileMatch, settings.schema);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
yamlValidation.configure(settings);
|
|
||||||
hover.configure(settings);
|
|
||||||
let customTagsSetting = settings && settings['customTags'] ? settings['customTags'] : [];
|
|
||||||
completer.configure(settings, customTagsSetting);
|
|
||||||
},
|
},
|
||||||
registerCustomSchemaProvider: (schemaProvider: CustomSchemaProvider) => {
|
registerCustomSchemaProvider: (schemaProvider: CustomSchemaProvider) => {
|
||||||
schemaService.registerCustomSchemaProvider(schemaProvider);
|
schemaService.registerCustomSchemaProvider(schemaProvider);
|
||||||
|
|
@ -106,6 +103,8 @@ export function getLanguageService(schemaRequestService: SchemaRequestService, w
|
||||||
doValidation: yamlValidation.doValidation.bind(yamlValidation),
|
doValidation: yamlValidation.doValidation.bind(yamlValidation),
|
||||||
doHover: hover.doHover.bind(hover),
|
doHover: hover.doHover.bind(hover),
|
||||||
findDocumentSymbols: yamlDocumentSymbols.findDocumentSymbols.bind(yamlDocumentSymbols),
|
findDocumentSymbols: yamlDocumentSymbols.findDocumentSymbols.bind(yamlDocumentSymbols),
|
||||||
|
findDocumentColors: yamlDocumentSymbols.findDocumentColors.bind(yamlDocumentSymbols),
|
||||||
|
getColorPresentations: yamlDocumentSymbols.getColorPresentations.bind(yamlDocumentSymbols),
|
||||||
resetSchema: (uri: string) => schemaService.onResourceChange(uri),
|
resetSchema: (uri: string) => schemaService.onResourceChange(uri),
|
||||||
doFormat: format,
|
doFormat: format,
|
||||||
parseYAMLDocument: (document: TextDocument) => parseYAML(document.getText()),
|
parseYAMLDocument: (document: TextDocument) => parseYAML(document.getText()),
|
||||||
|
|
|
||||||
37
src/languageservice/yamlLanguageTypes.ts
Normal file
37
src/languageservice/yamlLanguageTypes.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
import { JSONDocument } from './parser/jsonParser';
|
||||||
|
import { ASTNode } from './jsonLanguageTypes';
|
||||||
|
|
||||||
|
export class SingleYAMLDocument extends JSONDocument {
|
||||||
|
public lines;
|
||||||
|
public errors;
|
||||||
|
public warnings;
|
||||||
|
|
||||||
|
constructor(lines: number[]) {
|
||||||
|
super(null, []);
|
||||||
|
this.lines = lines;
|
||||||
|
this.errors = [];
|
||||||
|
this.warnings = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public getSchemas(schema, doc, node) {
|
||||||
|
let matchingSchemas = [];
|
||||||
|
doc.validate(schema, matchingSchemas, node.start);
|
||||||
|
return matchingSchemas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getNodeFromOffset(offset: number, includeRightBound = false): ASTNode {
|
||||||
|
return super.getNodeFromOffset(offset, includeRightBound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class YAMLDocument {
|
||||||
|
public documents: SingleYAMLDocument[]
|
||||||
|
public errors;
|
||||||
|
public warnings;
|
||||||
|
|
||||||
|
constructor(documents: SingleYAMLDocument[]) {
|
||||||
|
this.documents = documents;
|
||||||
|
this.errors = [];
|
||||||
|
this.warnings = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -26,13 +26,14 @@ export function setupMode(defaults: LanguageServiceDefaultsImpl): void {
|
||||||
|
|
||||||
let languageId = defaults.languageId;
|
let languageId = defaults.languageId;
|
||||||
|
|
||||||
disposables.push(monaco.languages.registerCompletionItemProvider(languageId, new languageFeatures.CompletionAdapter(worker)));
|
// TODO:
|
||||||
|
// disposables.push(monaco.languages.registerCompletionItemProvider(languageId, new languageFeatures.CompletionAdapter(worker)));
|
||||||
disposables.push(monaco.languages.registerHoverProvider(languageId, new languageFeatures.HoverAdapter(worker)));
|
disposables.push(monaco.languages.registerHoverProvider(languageId, new languageFeatures.HoverAdapter(worker)));
|
||||||
disposables.push(monaco.languages.registerDocumentSymbolProvider(languageId, new languageFeatures.DocumentSymbolAdapter(worker)));
|
disposables.push(monaco.languages.registerDocumentSymbolProvider(languageId, new languageFeatures.DocumentSymbolAdapter(worker)));
|
||||||
|
disposables.push(monaco.languages.registerColorProvider(languageId, new languageFeatures.DocumentColorAdapter(worker)));
|
||||||
disposables.push(monaco.languages.registerDocumentFormattingEditProvider(languageId, new languageFeatures.DocumentFormattingEditProvider(worker)));
|
disposables.push(monaco.languages.registerDocumentFormattingEditProvider(languageId, new languageFeatures.DocumentFormattingEditProvider(worker)));
|
||||||
disposables.push(monaco.languages.registerDocumentRangeFormattingEditProvider(languageId, new languageFeatures.DocumentRangeFormattingEditProvider(worker)));
|
disposables.push(monaco.languages.registerDocumentRangeFormattingEditProvider(languageId, new languageFeatures.DocumentRangeFormattingEditProvider(worker)));
|
||||||
disposables.push(new languageFeatures.DiagnosticsAdapter(languageId, worker, defaults));
|
disposables.push(new languageFeatures.DiagnosticsAdapter(languageId, worker, defaults));
|
||||||
// disposables.push(monaco.languages.setTokensProvider(languageId, createTokenizationSupport(true)));
|
|
||||||
disposables.push(monaco.languages.setLanguageConfiguration(languageId, richEditConfiguration));
|
disposables.push(monaco.languages.setLanguageConfiguration(languageId, richEditConfiguration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,12 +63,24 @@ export class YAMLWorker {
|
||||||
resetSchema(uri: string): Thenable<boolean> {
|
resetSchema(uri: string): Thenable<boolean> {
|
||||||
return Promise.as(this._languageService.resetSchema(uri));
|
return Promise.as(this._languageService.resetSchema(uri));
|
||||||
}
|
}
|
||||||
findDocumentSymbols(uri: string): Thenable<ls.SymbolInformation[]> {
|
findDocumentSymbols(uri: string): Thenable<ls.DocumentSymbol[]> {
|
||||||
let document = this._getTextDocument(uri);
|
let document = this._getTextDocument(uri);
|
||||||
let yamlDocument = this._languageService.parseYAMLDocument(document);
|
let yamlDocument = this._languageService.parseYAMLDocument(document);
|
||||||
let symbols = this._languageService.findDocumentSymbols(document, yamlDocument);
|
let symbols = this._languageService.findDocumentSymbols(document, yamlDocument);
|
||||||
return Promise.as(symbols);
|
return Promise.as(symbols);
|
||||||
}
|
}
|
||||||
|
findDocumentColors(uri: string): Thenable<ls.ColorInformation[]> {
|
||||||
|
let document = this._getTextDocument(uri);
|
||||||
|
let stylesheet = this._languageService.parseYAMLDocument(document);
|
||||||
|
let colorSymbols = this._languageService.findDocumentColors(document, stylesheet);
|
||||||
|
return Promise.as(colorSymbols);
|
||||||
|
}
|
||||||
|
getColorPresentations(uri: string, color: ls.Color, range: ls.Range): Thenable<ls.ColorPresentation[]> {
|
||||||
|
let document = this._getTextDocument(uri);
|
||||||
|
let stylesheet = this._languageService.parseYAMLDocument(document);
|
||||||
|
let colorPresentations = this._languageService.getColorPresentations(document, stylesheet, color, range);
|
||||||
|
return Promise.as(colorPresentations);
|
||||||
|
}
|
||||||
private _getTextDocument(uri: string): ls.TextDocument {
|
private _getTextDocument(uri: string): ls.TextDocument {
|
||||||
let models = this._ctx.getMirrorModels();
|
let models = this._ctx.getMirrorModels();
|
||||||
for (let model of models) {
|
for (let model of models) {
|
||||||
|
|
|
||||||
159
yarn.lock
159
yarn.lock
|
|
@ -14,6 +14,13 @@
|
||||||
version "10.9.3"
|
version "10.9.3"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.9.3.tgz#85f288502503ade0b3bfc049fe1777b05d0327d5"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.9.3.tgz#85f288502503ade0b3bfc049fe1777b05d0327d5"
|
||||||
|
|
||||||
|
agent-base@4, agent-base@^4.1.0:
|
||||||
|
version "4.2.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9"
|
||||||
|
integrity sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==
|
||||||
|
dependencies:
|
||||||
|
es6-promisify "^5.0.0"
|
||||||
|
|
||||||
argparse@^1.0.7:
|
argparse@^1.0.7:
|
||||||
version "1.0.10"
|
version "1.0.10"
|
||||||
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
|
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
|
||||||
|
|
@ -39,6 +46,32 @@ concat-map@0.0.1:
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||||
|
|
||||||
|
debug@3.1.0:
|
||||||
|
version "3.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
|
||||||
|
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
|
||||||
|
dependencies:
|
||||||
|
ms "2.0.0"
|
||||||
|
|
||||||
|
debug@^3.1.0:
|
||||||
|
version "3.2.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b"
|
||||||
|
integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==
|
||||||
|
dependencies:
|
||||||
|
ms "^2.1.1"
|
||||||
|
|
||||||
|
es6-promise@^4.0.3:
|
||||||
|
version "4.2.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.5.tgz#da6d0d5692efb461e082c14817fe2427d8f5d054"
|
||||||
|
integrity sha512-n6wvpdE43VFtJq+lUDYDBFUwV8TZbuGXLV4D6wKafg13ldznKsyEvatubnmUe31zcvelSzOHF+XbaT+Bl9ObDg==
|
||||||
|
|
||||||
|
es6-promisify@^5.0.0:
|
||||||
|
version "5.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203"
|
||||||
|
integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=
|
||||||
|
dependencies:
|
||||||
|
es6-promise "^4.0.3"
|
||||||
|
|
||||||
esprima@^4.0.0:
|
esprima@^4.0.0:
|
||||||
version "4.0.1"
|
version "4.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
|
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
|
||||||
|
|
@ -58,6 +91,22 @@ glob@^7.0.5:
|
||||||
once "^1.3.0"
|
once "^1.3.0"
|
||||||
path-is-absolute "^1.0.0"
|
path-is-absolute "^1.0.0"
|
||||||
|
|
||||||
|
http-proxy-agent@^2.1.0:
|
||||||
|
version "2.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz#e4821beef5b2142a2026bd73926fe537631c5405"
|
||||||
|
integrity sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==
|
||||||
|
dependencies:
|
||||||
|
agent-base "4"
|
||||||
|
debug "3.1.0"
|
||||||
|
|
||||||
|
https-proxy-agent@^2.2.1:
|
||||||
|
version "2.2.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0"
|
||||||
|
integrity sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==
|
||||||
|
dependencies:
|
||||||
|
agent-base "^4.1.0"
|
||||||
|
debug "^3.1.0"
|
||||||
|
|
||||||
inflight@^1.0.4:
|
inflight@^1.0.4:
|
||||||
version "1.0.6"
|
version "1.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
|
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
|
||||||
|
|
@ -76,7 +125,12 @@ js-yaml@^3.12.0:
|
||||||
argparse "^1.0.7"
|
argparse "^1.0.7"
|
||||||
esprima "^4.0.0"
|
esprima "^4.0.0"
|
||||||
|
|
||||||
jsonc-parser@^2.0.1, jsonc-parser@^2.0.2:
|
jsonc-parser@^1.0.3:
|
||||||
|
version "1.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-1.0.3.tgz#1d53d7160e401a783dbceabaad82473f80e6ad7e"
|
||||||
|
integrity sha512-hk/69oAeaIzchq/v3lS50PXuzn5O2ynldopMC+SWBql7J2WtdptfB9dy8Y7+Og5rPkTCpn83zTiO8FMcqlXJ/g==
|
||||||
|
|
||||||
|
jsonc-parser@^2.0.0-next.1, jsonc-parser@^2.0.2:
|
||||||
version "2.0.2"
|
version "2.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.0.2.tgz#42fcf56d70852a043fadafde51ddb4a85649978d"
|
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.0.2.tgz#42fcf56d70852a043fadafde51ddb4a85649978d"
|
||||||
|
|
||||||
|
|
@ -102,6 +156,16 @@ monaco-plugin-helpers@^1.0.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
typescript "^2.7.2"
|
typescript "^2.7.2"
|
||||||
|
|
||||||
|
ms@2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
|
||||||
|
integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=
|
||||||
|
|
||||||
|
ms@^2.1.1:
|
||||||
|
version "2.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
|
||||||
|
integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==
|
||||||
|
|
||||||
once@^1.3.0:
|
once@^1.3.0:
|
||||||
version "1.4.0"
|
version "1.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
|
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
|
||||||
|
|
@ -112,6 +176,20 @@ path-is-absolute@^1.0.0:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
|
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
|
||||||
|
|
||||||
|
prettier@^1.14.3:
|
||||||
|
version "1.15.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.15.2.tgz#d31abe22afa4351efa14c7f8b94b58bb7452205e"
|
||||||
|
integrity sha512-YgPLFFA0CdKL4Eg2IHtUSjzj/BWgszDHiNQAe0VAIBse34148whfdzLagRL+QiKS+YfK5ftB6X4v/MBw8yCoug==
|
||||||
|
|
||||||
|
request-light@^0.2.3:
|
||||||
|
version "0.2.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.2.4.tgz#3cea29c126682e6bcadf7915353322eeba01a755"
|
||||||
|
integrity sha512-pM9Fq5jRnSb+82V7M97rp8FE9/YNeP2L9eckB4Szd7lyeclSIx02aIpPO/6e4m6Dy31+FBN/zkFMTd2HkNO3ow==
|
||||||
|
dependencies:
|
||||||
|
http-proxy-agent "^2.1.0"
|
||||||
|
https-proxy-agent "^2.2.1"
|
||||||
|
vscode-nls "^4.0.0"
|
||||||
|
|
||||||
requirejs@^2.3.5:
|
requirejs@^2.3.5:
|
||||||
version "2.3.6"
|
version "2.3.6"
|
||||||
resolved "https://registry.yarnpkg.com/requirejs/-/requirejs-2.3.6.tgz#e5093d9601c2829251258c0b9445d4d19fa9e7c9"
|
resolved "https://registry.yarnpkg.com/requirejs/-/requirejs-2.3.6.tgz#e5093d9601c2829251258c0b9445d4d19fa9e7c9"
|
||||||
|
|
@ -146,27 +224,86 @@ uglify-es@^3.3.9:
|
||||||
commander "~2.13.0"
|
commander "~2.13.0"
|
||||||
source-map "~0.6.1"
|
source-map "~0.6.1"
|
||||||
|
|
||||||
vscode-json-languageservice@^3.1.6:
|
vscode-json-languageservice@3.0.12:
|
||||||
version "3.1.6"
|
version "3.0.12"
|
||||||
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.1.6.tgz#272e21eb9abcefe6c1ed38be141f0a76d5ddf0cd"
|
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.0.12.tgz#85258632f2f7718028fbdfbb95b4ad009107b821"
|
||||||
|
integrity sha512-XSgRVY/vsPqOa//ZwLD5DWx1wzTQGgeZfsOlVqFlLya10dpimSnd27kbuL45hzxh4B+MvmHZtZeWQKjSYnNF0A==
|
||||||
dependencies:
|
dependencies:
|
||||||
jsonc-parser "^2.0.1"
|
jsonc-parser "^2.0.0-next.1"
|
||||||
vscode-languageserver-types "^3.12.0"
|
vscode-languageserver-types "^3.6.1"
|
||||||
vscode-nls "^3.2.4"
|
vscode-nls "^3.2.1"
|
||||||
vscode-uri "^1.0.6"
|
vscode-uri "^1.0.3"
|
||||||
|
|
||||||
vscode-languageserver-types@3.12.0, vscode-languageserver-types@^3.12.0:
|
vscode-jsonrpc@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-4.0.0.tgz#a7bf74ef3254d0a0c272fab15c82128e378b3be9"
|
||||||
|
integrity sha512-perEnXQdQOJMTDFNv+UF3h1Y0z4iSiaN9jIlb0OqIYgosPCZGYh/MCUlkFtV2668PL69lRDO32hmvL2yiidUYg==
|
||||||
|
|
||||||
|
vscode-languageserver-protocol@^3.10.3:
|
||||||
|
version "3.13.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.13.0.tgz#710d8e42119bb3affb1416e1e104bd6b4d503595"
|
||||||
|
integrity sha512-2ZGKwI+P2ovQll2PGAp+2UfJH+FK9eait86VBUdkPd9HRlm8e58aYT9pV/NYanHOcp3pL6x2yTLVCFMcTer0mg==
|
||||||
|
dependencies:
|
||||||
|
vscode-jsonrpc "^4.0.0"
|
||||||
|
vscode-languageserver-types "3.13.0"
|
||||||
|
|
||||||
|
vscode-languageserver-types@3.12.0:
|
||||||
version "3.12.0"
|
version "3.12.0"
|
||||||
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.12.0.tgz#f96051381b6a050b7175b37d6cb5d2f2eb64b944"
|
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.12.0.tgz#f96051381b6a050b7175b37d6cb5d2f2eb64b944"
|
||||||
|
integrity sha512-UxqnpzBToPO7Mi2tr/s5JeyPOSKSJtLB8lIdxCg9ZNdvP2cU8wS7iTDtwQKz91Ne4CUmTdf85ddR5SIZKXmMjQ==
|
||||||
|
|
||||||
vscode-nls@^3.2.4:
|
vscode-languageserver-types@3.13.0, vscode-languageserver-types@^3.6.1:
|
||||||
|
version "3.13.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.13.0.tgz#b704b024cef059f7b326611c99b9c8753c0a18b4"
|
||||||
|
integrity sha512-BnJIxS+5+8UWiNKCP7W3g9FlE7fErFw0ofP5BXJe7c2tl0VeWh+nNHFbwAS2vmVC4a5kYxHBjRy0UeOtziemVA==
|
||||||
|
|
||||||
|
vscode-languageserver@^4.0.0:
|
||||||
|
version "4.4.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.4.2.tgz#600ae9cc7a6ff1e84d93c7807840c2cb5b22821b"
|
||||||
|
integrity sha512-61y8Raevi9EigDgg9NelvT9cUAohiEbUl1LOwQQgOCAaNX62yKny/ddi0uC+FUTm4CzsjhBu+06R+vYgfCYReA==
|
||||||
|
dependencies:
|
||||||
|
vscode-languageserver-protocol "^3.10.3"
|
||||||
|
vscode-uri "^1.0.5"
|
||||||
|
|
||||||
|
vscode-nls@^3.2.1, vscode-nls@^3.2.2:
|
||||||
version "3.2.5"
|
version "3.2.5"
|
||||||
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.5.tgz#25520c1955108036dec607c85e00a522f247f1a4"
|
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.5.tgz#25520c1955108036dec607c85e00a522f247f1a4"
|
||||||
|
|
||||||
vscode-uri@^1.0.6:
|
vscode-nls@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.0.0.tgz#4001c8a6caba5cedb23a9c5ce1090395c0e44002"
|
||||||
|
integrity sha512-qCfdzcH+0LgQnBpZA53bA32kzp9rpq/f66Som577ObeuDlFIrtbEJ+A/+CCxjIh4G8dpJYNCKIsxpRAHIfsbNw==
|
||||||
|
|
||||||
|
vscode-uri@1.0.3:
|
||||||
|
version "1.0.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.3.tgz#631bdbf716dccab0e65291a8dc25c23232085a52"
|
||||||
|
integrity sha1-Yxvb9xbcyrDmUpGo3CXCMjIIWlI=
|
||||||
|
|
||||||
|
vscode-uri@^1.0.3, vscode-uri@^1.0.5:
|
||||||
version "1.0.6"
|
version "1.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.6.tgz#6b8f141b0bbc44ad7b07e94f82f168ac7608ad4d"
|
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.6.tgz#6b8f141b0bbc44ad7b07e94f82f168ac7608ad4d"
|
||||||
|
|
||||||
wrappy@1:
|
wrappy@1:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
||||||
|
|
||||||
|
yaml-ast-parser@0.0.40:
|
||||||
|
version "0.0.40"
|
||||||
|
resolved "https://registry.yarnpkg.com/yaml-ast-parser/-/yaml-ast-parser-0.0.40.tgz#08536d4e73d322b1c9ce207ab8dd70e04d20ae6e"
|
||||||
|
integrity sha1-CFNtTnPTIrHJziB6uN1w4E0grm4=
|
||||||
|
|
||||||
|
yaml-language-server@^0.1.0:
|
||||||
|
version "0.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/yaml-language-server/-/yaml-language-server-0.1.0.tgz#ab3aff5c601ae33e03dc08c0960fd7c70296e635"
|
||||||
|
integrity sha512-2sA9eMgBnvEnjcQVIxbakIkiL8PQ6xJw1yXfdiVRn8ms+dI3EuaaatoUuIPhYnwmDOeaobDwkJs1bpQvFO4nqQ==
|
||||||
|
dependencies:
|
||||||
|
js-yaml "^3.12.0"
|
||||||
|
jsonc-parser "^1.0.3"
|
||||||
|
prettier "^1.14.3"
|
||||||
|
request-light "^0.2.3"
|
||||||
|
vscode-json-languageservice "3.0.12"
|
||||||
|
vscode-languageserver "^4.0.0"
|
||||||
|
vscode-languageserver-types "^3.6.1"
|
||||||
|
vscode-nls "^3.2.2"
|
||||||
|
vscode-uri "1.0.3"
|
||||||
|
yaml-ast-parser "0.0.40"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue