Complete residential site build with Docker Compose & Gitea Actions deployment
This commit is contained in:
+49
@@ -0,0 +1,49 @@
|
||||
import { Node, Pair } from 'yaml';
|
||||
export type YamlNode = Node | Pair;
|
||||
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;
|
||||
readonly internalNode: YamlNode;
|
||||
location: string;
|
||||
getNodeFromOffsetEndInclusive(offset: number): ASTNode;
|
||||
}
|
||||
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;
|
||||
readonly source: string;
|
||||
}
|
||||
export interface NullASTNode extends BaseASTNode {
|
||||
readonly type: 'null';
|
||||
readonly value: null;
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
});
|
||||
//# sourceMappingURL=jsonASTTypes.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"jsonASTTypes.js","sourceRoot":"","sources":["../../../src/languageservice/jsonASTTypes.ts"],"names":[],"mappings":"AAAA;;;gGAGgG"}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
import { CompletionItemKind } from 'vscode-json-languageservice';
|
||||
import { SchemaVersions } from './yamlTypes';
|
||||
export type JSONSchemaRef = JSONSchema | boolean;
|
||||
export declare enum SchemaDialect {
|
||||
draft04 = "draft04",
|
||||
draft07 = "draft07",
|
||||
draft2019 = "draft2019-09",
|
||||
draft2020 = "draft2020-12"
|
||||
}
|
||||
export interface JSONSchema {
|
||||
_dialect?: SchemaDialect;
|
||||
_baseUrl?: string;
|
||||
_$ref?: string;
|
||||
id?: string;
|
||||
$id?: string;
|
||||
$schema?: string;
|
||||
url?: string;
|
||||
type?: string | string[];
|
||||
title?: string;
|
||||
closestTitle?: string;
|
||||
versions?: SchemaVersions;
|
||||
default?: any;
|
||||
definitions?: {
|
||||
[name: string]: JSONSchema;
|
||||
};
|
||||
description?: string;
|
||||
properties?: JSONSchemaMap;
|
||||
patternProperties?: JSONSchemaMap;
|
||||
additionalProperties?: JSONSchemaRef;
|
||||
minProperties?: number;
|
||||
maxProperties?: number;
|
||||
dependencies?: JSONSchemaMap | {
|
||||
[prop: string]: string[];
|
||||
};
|
||||
items?: JSONSchemaRef | JSONSchemaRef[];
|
||||
minItems?: number;
|
||||
maxItems?: number;
|
||||
uniqueItems?: boolean;
|
||||
additionalItems?: JSONSchemaRef;
|
||||
pattern?: string;
|
||||
minLength?: number;
|
||||
maxLength?: number;
|
||||
minimum?: number;
|
||||
maximum?: number;
|
||||
exclusiveMinimum?: boolean | number;
|
||||
exclusiveMaximum?: boolean | number;
|
||||
multipleOf?: number;
|
||||
required?: string[];
|
||||
$ref?: string;
|
||||
anyOf?: JSONSchemaRef[];
|
||||
allOf?: JSONSchemaRef[];
|
||||
oneOf?: JSONSchemaRef[];
|
||||
not?: JSONSchemaRef;
|
||||
enum?: any[];
|
||||
format?: string;
|
||||
const?: any;
|
||||
contains?: JSONSchemaRef;
|
||||
propertyNames?: JSONSchemaRef;
|
||||
examples?: any[];
|
||||
$comment?: string;
|
||||
if?: JSONSchemaRef;
|
||||
then?: JSONSchemaRef;
|
||||
else?: JSONSchemaRef;
|
||||
$anchor?: string;
|
||||
$defs?: {
|
||||
[name: string]: JSONSchema;
|
||||
};
|
||||
$recursiveAnchor?: boolean;
|
||||
$recursiveRef?: string;
|
||||
$vocabulary?: Record<string, boolean>;
|
||||
dependentSchemas?: JSONSchemaMap;
|
||||
unevaluatedItems?: JSONSchemaRef;
|
||||
unevaluatedProperties?: JSONSchemaRef;
|
||||
dependentRequired?: Record<string, string[]>;
|
||||
minContains?: number;
|
||||
maxContains?: number;
|
||||
prefixItems?: JSONSchemaRef[];
|
||||
$dynamicRef?: string;
|
||||
$dynamicAnchor?: string;
|
||||
defaultSnippets?: {
|
||||
label?: string;
|
||||
description?: string;
|
||||
markdownDescription?: string;
|
||||
type?: string;
|
||||
suggestionKind?: CompletionItemKind;
|
||||
sortText?: string;
|
||||
body?: any;
|
||||
bodyText?: string;
|
||||
}[];
|
||||
errorMessage?: string;
|
||||
patternErrorMessage?: string;
|
||||
deprecationMessage?: string;
|
||||
enumDescriptions?: string[];
|
||||
markdownEnumDescriptions?: string[];
|
||||
markdownDescription?: string;
|
||||
doNotSuggest?: boolean;
|
||||
allowComments?: boolean;
|
||||
schemaSequence?: JSONSchema[];
|
||||
filePatternAssociation?: string;
|
||||
}
|
||||
export interface JSONSchemaMap {
|
||||
[name: string]: JSONSchemaRef;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SchemaDialect = void 0;
|
||||
var SchemaDialect;
|
||||
(function (SchemaDialect) {
|
||||
SchemaDialect["draft04"] = "draft04";
|
||||
SchemaDialect["draft07"] = "draft07";
|
||||
SchemaDialect["draft2019"] = "draft2019-09";
|
||||
SchemaDialect["draft2020"] = "draft2020-12";
|
||||
})(SchemaDialect = exports.SchemaDialect || (exports.SchemaDialect = {}));
|
||||
});
|
||||
//# sourceMappingURL=jsonSchema.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"jsonSchema.js","sourceRoot":"","sources":["../../../src/languageservice/jsonSchema.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAMhG,IAAY,aAKX;IALD,WAAY,aAAa;QACvB,oCAAmB,CAAA;QACnB,oCAAmB,CAAA;QACnB,2CAA0B,CAAA;QAC1B,2CAA0B,CAAA;IAC5B,CAAC,EALW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAKxB"}
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import { Alias, Document, LineCounter } from 'yaml';
|
||||
import { ASTNode, YamlNode } from '../jsonASTTypes';
|
||||
type NodeRange = [number, number, number];
|
||||
export declare const aliasDepth: {
|
||||
maxRefCount: number;
|
||||
currentRefDepth: number;
|
||||
aliasResolutionCache: Map<Alias, ASTNode>;
|
||||
};
|
||||
export declare function convertAST(parent: ASTNode, node: YamlNode, doc: Document, lineCounter: LineCounter): ASTNode | undefined;
|
||||
export declare function toOffsetLength(range: NodeRange): [number, number];
|
||||
export {};
|
||||
Generated
Vendored
+191
@@ -0,0 +1,191 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "yaml", "./jsonDocument"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.toOffsetLength = exports.convertAST = exports.aliasDepth = void 0;
|
||||
const yaml_1 = require("yaml");
|
||||
const jsonDocument_1 = require("./jsonDocument");
|
||||
// Exported for tests
|
||||
exports.aliasDepth = {
|
||||
maxRefCount: 1000,
|
||||
currentRefDepth: 0,
|
||||
aliasResolutionCache: new Map(),
|
||||
};
|
||||
function convertAST(parent, node, doc, lineCounter) {
|
||||
if (!parent) {
|
||||
// first invocation
|
||||
exports.aliasDepth.currentRefDepth = 0;
|
||||
exports.aliasDepth.aliasResolutionCache = new Map();
|
||||
}
|
||||
if (!node) {
|
||||
return null;
|
||||
}
|
||||
if ((0, yaml_1.isMap)(node)) {
|
||||
return convertMap(node, parent, doc, lineCounter);
|
||||
}
|
||||
if ((0, yaml_1.isPair)(node)) {
|
||||
return convertPair(node, parent, doc, lineCounter);
|
||||
}
|
||||
if ((0, yaml_1.isSeq)(node)) {
|
||||
return convertSeq(node, parent, doc, lineCounter);
|
||||
}
|
||||
if ((0, yaml_1.isScalar)(node)) {
|
||||
return convertScalar(node, parent);
|
||||
}
|
||||
if ((0, yaml_1.isAlias)(node) && exports.aliasDepth.currentRefDepth < exports.aliasDepth.maxRefCount) {
|
||||
return convertAlias(node, parent, doc, lineCounter);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
exports.convertAST = convertAST;
|
||||
function convertMap(node, parent, doc, lineCounter) {
|
||||
let range;
|
||||
if (node.flow && !node.range) {
|
||||
range = collectFlowMapRange(node);
|
||||
}
|
||||
else {
|
||||
range = node.range;
|
||||
}
|
||||
const result = new jsonDocument_1.ObjectASTNodeImpl(parent, node, ...toFixedOffsetLength(range, lineCounter));
|
||||
for (const it of node.items) {
|
||||
if ((0, yaml_1.isPair)(it)) {
|
||||
result.properties.push(convertAST(result, it, doc, lineCounter));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function convertPair(node, parent, doc, lineCounter) {
|
||||
const keyNode = node.key;
|
||||
const valueNode = node.value;
|
||||
const rangeStart = keyNode.range[0];
|
||||
let rangeEnd = keyNode.range[1];
|
||||
let nodeEnd = keyNode.range[2];
|
||||
if (valueNode) {
|
||||
rangeEnd = valueNode.range[1];
|
||||
nodeEnd = valueNode.range[2];
|
||||
}
|
||||
// Pair does not return a range using the key/value ranges to fake one.
|
||||
const result = new jsonDocument_1.PropertyASTNodeImpl(parent, node, ...toFixedOffsetLength([rangeStart, rangeEnd, nodeEnd], lineCounter));
|
||||
if ((0, yaml_1.isAlias)(keyNode)) {
|
||||
const keyAlias = new jsonDocument_1.StringASTNodeImpl(parent, keyNode, ...toOffsetLength(keyNode.range));
|
||||
keyAlias.value = keyNode.source;
|
||||
result.keyNode = keyAlias;
|
||||
}
|
||||
else {
|
||||
result.keyNode = convertAST(result, keyNode, doc, lineCounter);
|
||||
}
|
||||
result.valueNode = convertAST(result, valueNode, doc, lineCounter);
|
||||
return result;
|
||||
}
|
||||
function convertSeq(node, parent, doc, lineCounter) {
|
||||
const result = new jsonDocument_1.ArrayASTNodeImpl(parent, node, ...toOffsetLength(node.range));
|
||||
for (const it of node.items) {
|
||||
if ((0, yaml_1.isNode)(it)) {
|
||||
const convertedNode = convertAST(result, it, doc, lineCounter);
|
||||
// due to recursion protection, convertAST may return undefined
|
||||
if (convertedNode) {
|
||||
result.children.push(convertedNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function convertScalar(node, parent) {
|
||||
if (node.value === null) {
|
||||
return new jsonDocument_1.NullASTNodeImpl(parent, node, ...toOffsetLength(node.range));
|
||||
}
|
||||
switch (typeof node.value) {
|
||||
case 'string': {
|
||||
const result = new jsonDocument_1.StringASTNodeImpl(parent, node, ...toOffsetLength(node.range));
|
||||
result.value = node.value;
|
||||
return result;
|
||||
}
|
||||
case 'boolean':
|
||||
return new jsonDocument_1.BooleanASTNodeImpl(parent, node, node.value, node.source, ...toOffsetLength(node.range));
|
||||
case 'number': {
|
||||
const result = new jsonDocument_1.NumberASTNodeImpl(parent, node, ...toOffsetLength(node.range));
|
||||
result.value = node.value;
|
||||
result.isInteger = Number.isInteger(result.value);
|
||||
return result;
|
||||
}
|
||||
default: {
|
||||
// fail safe converting, we need to return some node anyway
|
||||
const result = new jsonDocument_1.StringASTNodeImpl(parent, node, ...toOffsetLength(node.range));
|
||||
result.value = node.source;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
function convertAlias(node, parent, doc, lineCounter) {
|
||||
if (exports.aliasDepth.aliasResolutionCache.has(node)) {
|
||||
return exports.aliasDepth.aliasResolutionCache.get(node);
|
||||
}
|
||||
exports.aliasDepth.currentRefDepth++;
|
||||
const resolvedNode = node.resolve(doc);
|
||||
let ans;
|
||||
if (resolvedNode) {
|
||||
ans = convertAST(parent, resolvedNode, doc, lineCounter);
|
||||
}
|
||||
else {
|
||||
const resultNode = new jsonDocument_1.StringASTNodeImpl(parent, node, ...toOffsetLength(node.range));
|
||||
resultNode.value = node.source;
|
||||
ans = resultNode;
|
||||
}
|
||||
exports.aliasDepth.currentRefDepth--;
|
||||
exports.aliasDepth.aliasResolutionCache.set(node, ans);
|
||||
return ans;
|
||||
}
|
||||
function toOffsetLength(range) {
|
||||
return [range[0], range[1] - range[0]];
|
||||
}
|
||||
exports.toOffsetLength = toOffsetLength;
|
||||
/**
|
||||
* Convert offsets to offset+length with fix length to not include '\n' character in some cases
|
||||
* @param range the yaml ast range
|
||||
* @param lineCounter the line counter
|
||||
* @returns the offset and length
|
||||
*/
|
||||
function toFixedOffsetLength(range, lineCounter) {
|
||||
const start = lineCounter.linePos(range[0]);
|
||||
const end = lineCounter.linePos(range[1]);
|
||||
const result = [range[0], range[1] - range[0]];
|
||||
// -1 as range may include '\n'
|
||||
if (start.line !== end.line && (lineCounter.lineStarts.length !== end.line || end.col === 1)) {
|
||||
result[1]--;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function collectFlowMapRange(node) {
|
||||
let start = Number.MAX_SAFE_INTEGER;
|
||||
let end = 0;
|
||||
for (const it of node.items) {
|
||||
if ((0, yaml_1.isPair)(it)) {
|
||||
if ((0, yaml_1.isNode)(it.key)) {
|
||||
if (it.key.range && it.key.range[0] <= start) {
|
||||
start = it.key.range[0];
|
||||
}
|
||||
}
|
||||
if ((0, yaml_1.isNode)(it.value)) {
|
||||
if (it.value.range && it.value.range[2] >= end) {
|
||||
end = it.value.range[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return [start, end, end];
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=ast-converter.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import type { ASTNode } from '../jsonASTTypes';
|
||||
export declare function getNodeValue(node: ASTNode): any;
|
||||
export declare function contains(node: ASTNode, offset: number, includeRightBound?: boolean): boolean;
|
||||
export declare function findNodeAtOffset(node: ASTNode, offset: number, includeRightBound: boolean): ASTNode;
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.findNodeAtOffset = exports.contains = exports.getNodeValue = void 0;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function getNodeValue(node) {
|
||||
switch (node.type) {
|
||||
case 'array':
|
||||
return node.children.map(getNodeValue);
|
||||
case 'object': {
|
||||
const obj = Object.create(null);
|
||||
for (let _i = 0, _a = node.children; _i < _a.length; _i++) {
|
||||
const prop = _a[_i];
|
||||
const valueNode = prop.children[1];
|
||||
if (valueNode) {
|
||||
obj[prop.children[0].value] = getNodeValue(valueNode);
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
case 'null':
|
||||
case 'string':
|
||||
case 'number':
|
||||
return node.value;
|
||||
case 'boolean':
|
||||
return node.source;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.getNodeValue = getNodeValue;
|
||||
function contains(node, offset, includeRightBound = false) {
|
||||
return ((offset >= node.offset && offset <= node.offset + node.length) || (includeRightBound && offset === node.offset + node.length));
|
||||
}
|
||||
exports.contains = contains;
|
||||
function findNodeAtOffset(node, offset, includeRightBound) {
|
||||
if (includeRightBound === void 0) {
|
||||
includeRightBound = false;
|
||||
}
|
||||
if (contains(node, offset, includeRightBound)) {
|
||||
const children = node.children;
|
||||
if (Array.isArray(children)) {
|
||||
for (let i = 0; i < children.length && children[i].offset <= offset; i++) {
|
||||
const item = findNodeAtOffset(children[i], offset, includeRightBound);
|
||||
if (item) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
exports.findNodeAtOffset = findNodeAtOffset;
|
||||
});
|
||||
//# sourceMappingURL=astNodeUtils.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"astNodeUtils.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/astNodeUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;IAEA,8DAA8D;IAC9D,SAAgB,YAAY,CAAC,IAAa;QACxC,QAAQ,IAAI,CAAC,IAAI,EAAE;YACjB,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACzC,KAAK,QAAQ,CAAC,CAAC;gBACb,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBAChC,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE;oBACzD,MAAM,IAAI,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;oBACpB,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;oBACnC,IAAI,SAAS,EAAE;wBACb,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAe,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;qBACjE;iBACF;gBACD,OAAO,GAAG,CAAC;aACZ;YACD,KAAK,MAAM,CAAC;YACZ,KAAK,QAAQ,CAAC;YACd,KAAK,QAAQ;gBACX,OAAO,IAAI,CAAC,KAAK,CAAC;YACpB,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAC,MAAM,CAAC;YACrB;gBACE,OAAO,SAAS,CAAC;SACpB;IACH,CAAC;IAxBD,oCAwBC;IAED,SAAgB,QAAQ,CAAC,IAAa,EAAE,MAAc,EAAE,iBAAiB,GAAG,KAAK;QAC/E,OAAO,CACL,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI,MAAM,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAC9H,CAAC;IACJ,CAAC;IAJD,4BAIC;IAED,SAAgB,gBAAgB,CAAC,IAAa,EAAE,MAAc,EAAE,iBAA0B;QACxF,IAAI,iBAAiB,KAAK,KAAK,CAAC,EAAE;YAChC,iBAAiB,GAAG,KAAK,CAAC;SAC3B;QACD,IAAI,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE;YAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;YAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,MAAM,EAAE,CAAC,EAAE,EAAE;oBACxE,MAAM,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;oBACtE,IAAI,IAAI,EAAE;wBACR,OAAO,IAAI,CAAC;qBACb;iBACF;aACF;YACD,OAAO,IAAI,CAAC;SACb;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAjBD,4CAiBC"}
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import { Tags } from 'yaml';
|
||||
/**
|
||||
* Converts the tags from settings and adds known tags such as !include
|
||||
* and returns Tags that can be used by the parser.
|
||||
* @param customTags Tags for parser
|
||||
*/
|
||||
export declare function getCustomTags(customTags: string[]): Tags;
|
||||
Generated
Vendored
+72
@@ -0,0 +1,72 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "yaml", "../utils/arrUtils"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getCustomTags = void 0;
|
||||
const yaml_1 = require("yaml");
|
||||
const arrUtils_1 = require("../utils/arrUtils");
|
||||
class CommonTagImpl {
|
||||
constructor(tag, type) {
|
||||
this.tag = tag;
|
||||
this.type = type;
|
||||
}
|
||||
get collection() {
|
||||
if (this.type === 'mapping') {
|
||||
return 'map';
|
||||
}
|
||||
if (this.type === 'sequence') {
|
||||
return 'seq';
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
resolve(value) {
|
||||
if ((0, yaml_1.isMap)(value) && this.type === 'mapping') {
|
||||
return value;
|
||||
}
|
||||
if ((0, yaml_1.isSeq)(value) && this.type === 'sequence') {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === 'string' && this.type === 'scalar') {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
class IncludeTag {
|
||||
constructor() {
|
||||
this.tag = '!include';
|
||||
this.type = 'scalar';
|
||||
}
|
||||
resolve(value, onError) {
|
||||
if (value && value.length > 0 && value.trim()) {
|
||||
return value;
|
||||
}
|
||||
onError('!include without value');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts the tags from settings and adds known tags such as !include
|
||||
* and returns Tags that can be used by the parser.
|
||||
* @param customTags Tags for parser
|
||||
*/
|
||||
function getCustomTags(customTags) {
|
||||
const tags = [];
|
||||
const filteredTags = (0, arrUtils_1.filterInvalidCustomTags)(customTags);
|
||||
for (const tag of filteredTags) {
|
||||
const typeInfo = tag.split(' ');
|
||||
const tagName = typeInfo[0];
|
||||
const tagType = (typeInfo[1] && typeInfo[1].toLowerCase()) || 'scalar';
|
||||
tags.push(new CommonTagImpl(tagName, tagType));
|
||||
}
|
||||
tags.push(new IncludeTag());
|
||||
return tags;
|
||||
}
|
||||
exports.getCustomTags = getCustomTags;
|
||||
});
|
||||
//# sourceMappingURL=custom-tag-provider.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"custom-tag-provider.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/custom-tag-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,+BAA4D;IAC5D,gDAA4D;IAE5D,MAAM,aAAa;QAIjB,YAAY,GAAW,EAAE,IAAY;YACnC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;YACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC;QACD,IAAI,UAAU;YACZ,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;gBAC3B,OAAO,KAAK,CAAC;aACd;YACD,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;gBAC5B,OAAO,KAAK,CAAC;aACd;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,CAAC,KAAiC;YACvC,IAAI,IAAA,YAAK,EAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;gBAC3C,OAAO,KAAK,CAAC;aACd;YACD,IAAI,IAAA,YAAK,EAAC,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;gBAC5C,OAAO,KAAK,CAAC;aACd;YACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACvD,OAAO,KAAK,CAAC;aACd;QACH,CAAC;KACF;IAED,MAAM,UAAU;QAAhB;YACkB,QAAG,GAAG,UAAU,CAAC;YACjB,SAAI,GAAG,QAAQ,CAAC;QAUlC,CAAC;QANC,OAAO,CAAC,KAAa,EAAE,OAAkC;YACvD,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE;gBAC7C,OAAO,KAAK,CAAC;aACd;YACD,OAAO,CAAC,wBAAwB,CAAC,CAAC;QACpC,CAAC;KACF;IAED;;;;OAIG;IACH,SAAgB,aAAa,CAAC,UAAoB;QAChD,MAAM,IAAI,GAAG,EAAE,CAAC;QAChB,MAAM,YAAY,GAAG,IAAA,kCAAuB,EAAC,UAAU,CAAC,CAAC;QACzD,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE;YAC9B,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC5B,MAAM,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,QAAQ,CAAC;YACvE,IAAI,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;SAChD;QACD,IAAI,CAAC,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAXD,sCAWC"}
|
||||
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import * as Parser from './jsonDocument';
|
||||
export declare function setKubernetesParserOption(jsonDocuments: Parser.JSONDocument[], option: boolean): void;
|
||||
export declare function isKubernetesAssociatedDocument(textDocument: TextDocument, paths: string[]): boolean;
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "../utils/filePatternAssociation"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isKubernetesAssociatedDocument = exports.setKubernetesParserOption = void 0;
|
||||
const filePatternAssociation_1 = require("../utils/filePatternAssociation");
|
||||
function setKubernetesParserOption(jsonDocuments, option) {
|
||||
for (const jsonDoc of jsonDocuments) {
|
||||
jsonDoc.isKubernetes = option;
|
||||
}
|
||||
}
|
||||
exports.setKubernetesParserOption = setKubernetesParserOption;
|
||||
function isKubernetesAssociatedDocument(textDocument, paths) {
|
||||
for (const path in paths) {
|
||||
const globPath = paths[path];
|
||||
const fpa = new filePatternAssociation_1.FilePatternAssociation(globPath);
|
||||
if (fpa.matchesPattern(textDocument.uri)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.isKubernetesAssociatedDocument = isKubernetesAssociatedDocument;
|
||||
});
|
||||
//# sourceMappingURL=isKubernetes.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"isKubernetes.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/isKubernetes.ts"],"names":[],"mappings":";;;;;;;;;;;;IAKA,4EAAyE;IAGzE,SAAgB,yBAAyB,CAAC,aAAoC,EAAE,MAAe;QAC7F,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE;YACnC,OAAO,CAAC,YAAY,GAAG,MAAM,CAAC;SAC/B;IACH,CAAC;IAJD,8DAIC;IAED,SAAgB,8BAA8B,CAAC,YAA0B,EAAE,KAAe;QACxF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;YAC7B,MAAM,GAAG,GAAG,IAAI,+CAAsB,CAAC,QAAQ,CAAC,CAAC;YAEjD,IAAI,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;gBACxC,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAVD,wEAUC"}
|
||||
Generated
Vendored
+83
@@ -0,0 +1,83 @@
|
||||
import { JSONSchema } from '../jsonSchema';
|
||||
import { ASTNode, ObjectASTNode, ArrayASTNode, BooleanASTNode, NumberASTNode, StringASTNode, NullASTNode, PropertyASTNode, YamlNode } from '../jsonASTTypes';
|
||||
import { Diagnostic, Range } from 'vscode-languageserver-types';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Node, Pair } from 'yaml';
|
||||
import { type IApplicableSchema } from './schemaValidation/baseValidator';
|
||||
declare abstract class ASTNodeImpl {
|
||||
abstract readonly type: 'object' | 'property' | 'array' | 'number' | 'boolean' | 'null' | 'string';
|
||||
offset: number;
|
||||
length: number;
|
||||
readonly parent: ASTNode;
|
||||
location: string;
|
||||
readonly internalNode: YamlNode;
|
||||
constructor(parent: ASTNode, internalNode: YamlNode, offset: number, length?: number);
|
||||
getNodeFromOffsetEndInclusive(offset: number): ASTNode;
|
||||
get children(): ASTNode[];
|
||||
toString(): string;
|
||||
}
|
||||
export declare class NullASTNodeImpl extends ASTNodeImpl implements NullASTNode {
|
||||
type: 'null';
|
||||
value: any;
|
||||
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
|
||||
}
|
||||
export declare class BooleanASTNodeImpl extends ASTNodeImpl implements BooleanASTNode {
|
||||
type: 'boolean';
|
||||
value: boolean;
|
||||
source: string;
|
||||
constructor(parent: ASTNode, internalNode: Node, boolValue: boolean, boolSource: string, offset: number, length?: number);
|
||||
}
|
||||
export declare class ArrayASTNodeImpl extends ASTNodeImpl implements ArrayASTNode {
|
||||
type: 'array';
|
||||
items: ASTNode[];
|
||||
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
|
||||
get children(): ASTNode[];
|
||||
}
|
||||
export declare class NumberASTNodeImpl extends ASTNodeImpl implements NumberASTNode {
|
||||
type: 'number';
|
||||
isInteger: boolean;
|
||||
value: number;
|
||||
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
|
||||
}
|
||||
export declare class StringASTNodeImpl extends ASTNodeImpl implements StringASTNode {
|
||||
type: 'string';
|
||||
value: string;
|
||||
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
|
||||
}
|
||||
export declare class PropertyASTNodeImpl extends ASTNodeImpl implements PropertyASTNode {
|
||||
type: 'property';
|
||||
keyNode: StringASTNode;
|
||||
valueNode: ASTNode;
|
||||
colonOffset: number;
|
||||
constructor(parent: ObjectASTNode, internalNode: Pair, offset: number, length?: number);
|
||||
get children(): ASTNode[];
|
||||
}
|
||||
export declare class ObjectASTNodeImpl extends ASTNodeImpl implements ObjectASTNode {
|
||||
type: 'object';
|
||||
properties: PropertyASTNode[];
|
||||
constructor(parent: ASTNode, internalNode: Node, offset: number, length?: number);
|
||||
get children(): ASTNode[];
|
||||
}
|
||||
export interface JSONDocumentConfig {
|
||||
collectComments?: boolean;
|
||||
}
|
||||
export declare enum EnumMatch {
|
||||
Key = 0,
|
||||
Enum = 1
|
||||
}
|
||||
export declare function newJSONDocument(root: ASTNode, diagnostics?: Diagnostic[]): JSONDocument;
|
||||
export declare class JSONDocument {
|
||||
readonly root: ASTNode;
|
||||
readonly syntaxErrors: Diagnostic[];
|
||||
readonly comments: Range[];
|
||||
isKubernetes: boolean;
|
||||
disableAdditionalProperties: boolean;
|
||||
uri: string;
|
||||
constructor(root: ASTNode, syntaxErrors?: Diagnostic[], comments?: Range[]);
|
||||
getNodeFromOffset(offset: number, includeRightBound?: boolean): ASTNode | undefined;
|
||||
getNodeFromOffsetEndInclusive(offset: number): ASTNode;
|
||||
visit(visitor: (node: ASTNode) => boolean): void;
|
||||
validate(textDocument: TextDocument, schema: JSONSchema): Diagnostic[];
|
||||
getMatchingSchemas(schema: JSONSchema, focusOffset?: number, exclude?: ASTNode, didCallFromAutoComplete?: boolean): IApplicableSchema[];
|
||||
}
|
||||
export {};
|
||||
+193
@@ -0,0 +1,193 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "./astNodeUtils", "./schemaValidation/validatorFactory"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.JSONDocument = exports.newJSONDocument = exports.EnumMatch = exports.ObjectASTNodeImpl = exports.PropertyASTNodeImpl = exports.StringASTNodeImpl = exports.NumberASTNodeImpl = exports.ArrayASTNodeImpl = exports.BooleanASTNodeImpl = exports.NullASTNodeImpl = void 0;
|
||||
const astNodeUtils_1 = require("./astNodeUtils");
|
||||
const validatorFactory_1 = require("./schemaValidation/validatorFactory");
|
||||
class ASTNodeImpl {
|
||||
constructor(parent, internalNode, offset, length) {
|
||||
this.offset = offset;
|
||||
this.length = length;
|
||||
this.parent = parent;
|
||||
this.internalNode = internalNode;
|
||||
}
|
||||
getNodeFromOffsetEndInclusive(offset) {
|
||||
const collector = [];
|
||||
const findNode = (node) => {
|
||||
if (offset >= node.offset && offset <= node.offset + node.length) {
|
||||
const children = node.children;
|
||||
for (let i = 0; i < children.length && children[i].offset <= offset; i++) {
|
||||
const item = findNode(children[i]);
|
||||
if (item) {
|
||||
collector.push(item);
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
const foundNode = findNode(this);
|
||||
let currMinDist = Number.MAX_VALUE;
|
||||
let currMinNode = null;
|
||||
for (const currNode of collector) {
|
||||
const minDist = currNode.length + currNode.offset - offset + (offset - currNode.offset);
|
||||
if (minDist < currMinDist) {
|
||||
currMinNode = currNode;
|
||||
currMinDist = minDist;
|
||||
}
|
||||
}
|
||||
return currMinNode || foundNode;
|
||||
}
|
||||
get children() {
|
||||
return [];
|
||||
}
|
||||
toString() {
|
||||
return ('type: ' +
|
||||
this.type +
|
||||
' (' +
|
||||
this.offset +
|
||||
'/' +
|
||||
this.length +
|
||||
')' +
|
||||
(this.parent ? ' parent: {' + this.parent.toString() + '}' : ''));
|
||||
}
|
||||
}
|
||||
class NullASTNodeImpl extends ASTNodeImpl {
|
||||
constructor(parent, internalNode, offset, length) {
|
||||
super(parent, internalNode, offset, length);
|
||||
this.type = 'null';
|
||||
this.value = null;
|
||||
}
|
||||
}
|
||||
exports.NullASTNodeImpl = NullASTNodeImpl;
|
||||
class BooleanASTNodeImpl extends ASTNodeImpl {
|
||||
constructor(parent, internalNode, boolValue, boolSource, offset, length) {
|
||||
super(parent, internalNode, offset, length);
|
||||
this.type = 'boolean';
|
||||
this.value = boolValue;
|
||||
this.source = boolSource;
|
||||
}
|
||||
}
|
||||
exports.BooleanASTNodeImpl = BooleanASTNodeImpl;
|
||||
class ArrayASTNodeImpl extends ASTNodeImpl {
|
||||
constructor(parent, internalNode, offset, length) {
|
||||
super(parent, internalNode, offset, length);
|
||||
this.type = 'array';
|
||||
this.items = [];
|
||||
}
|
||||
get children() {
|
||||
return this.items;
|
||||
}
|
||||
}
|
||||
exports.ArrayASTNodeImpl = ArrayASTNodeImpl;
|
||||
class NumberASTNodeImpl extends ASTNodeImpl {
|
||||
constructor(parent, internalNode, offset, length) {
|
||||
super(parent, internalNode, offset, length);
|
||||
this.type = 'number';
|
||||
this.isInteger = true;
|
||||
this.value = Number.NaN;
|
||||
}
|
||||
}
|
||||
exports.NumberASTNodeImpl = NumberASTNodeImpl;
|
||||
class StringASTNodeImpl extends ASTNodeImpl {
|
||||
constructor(parent, internalNode, offset, length) {
|
||||
super(parent, internalNode, offset, length);
|
||||
this.type = 'string';
|
||||
this.value = '';
|
||||
}
|
||||
}
|
||||
exports.StringASTNodeImpl = StringASTNodeImpl;
|
||||
class PropertyASTNodeImpl extends ASTNodeImpl {
|
||||
constructor(parent, internalNode, offset, length) {
|
||||
super(parent, internalNode, offset, length);
|
||||
this.type = 'property';
|
||||
this.colonOffset = -1;
|
||||
}
|
||||
get children() {
|
||||
return this.valueNode ? [this.keyNode, this.valueNode] : [this.keyNode];
|
||||
}
|
||||
}
|
||||
exports.PropertyASTNodeImpl = PropertyASTNodeImpl;
|
||||
class ObjectASTNodeImpl extends ASTNodeImpl {
|
||||
constructor(parent, internalNode, offset, length) {
|
||||
super(parent, internalNode, offset, length);
|
||||
this.type = 'object';
|
||||
this.properties = [];
|
||||
}
|
||||
get children() {
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
exports.ObjectASTNodeImpl = ObjectASTNodeImpl;
|
||||
var EnumMatch;
|
||||
(function (EnumMatch) {
|
||||
EnumMatch[EnumMatch["Key"] = 0] = "Key";
|
||||
EnumMatch[EnumMatch["Enum"] = 1] = "Enum";
|
||||
})(EnumMatch = exports.EnumMatch || (exports.EnumMatch = {}));
|
||||
function newJSONDocument(root, diagnostics = []) {
|
||||
return new JSONDocument(root, diagnostics, []);
|
||||
}
|
||||
exports.newJSONDocument = newJSONDocument;
|
||||
class JSONDocument {
|
||||
constructor(root, syntaxErrors = [], comments = []) {
|
||||
this.root = root;
|
||||
this.syntaxErrors = syntaxErrors;
|
||||
this.comments = comments;
|
||||
}
|
||||
getNodeFromOffset(offset, includeRightBound = false) {
|
||||
if (this.root) {
|
||||
return (0, astNodeUtils_1.findNodeAtOffset)(this.root, offset, includeRightBound);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
getNodeFromOffsetEndInclusive(offset) {
|
||||
return this.root && this.root.getNodeFromOffsetEndInclusive(offset);
|
||||
}
|
||||
visit(visitor) {
|
||||
if (this.root) {
|
||||
const doVisit = (node) => {
|
||||
let ctn = visitor(node);
|
||||
const children = node.children;
|
||||
if (Array.isArray(children)) {
|
||||
for (let i = 0; i < children.length && ctn; i++) {
|
||||
ctn = doVisit(children[i]);
|
||||
}
|
||||
}
|
||||
return ctn;
|
||||
};
|
||||
doVisit(this.root);
|
||||
}
|
||||
}
|
||||
validate(textDocument, schema) {
|
||||
if (!this.root || !schema)
|
||||
return null;
|
||||
const validator = (0, validatorFactory_1.getValidator)(schema._dialect);
|
||||
return validator.validateDocument(this.root, textDocument, schema, {
|
||||
isKubernetes: this.isKubernetes,
|
||||
disableAdditionalProperties: this.disableAdditionalProperties,
|
||||
uri: this.uri,
|
||||
});
|
||||
}
|
||||
getMatchingSchemas(schema, focusOffset = -1, exclude = null, didCallFromAutoComplete) {
|
||||
if (!this.root || !schema)
|
||||
return [];
|
||||
const validator = (0, validatorFactory_1.getValidator)(schema._dialect);
|
||||
return validator.getMatchingSchemas(this.root, schema, {
|
||||
isKubernetes: this.isKubernetes,
|
||||
disableAdditionalProperties: this.disableAdditionalProperties,
|
||||
uri: this.uri,
|
||||
callFromAutoComplete: didCallFromAutoComplete,
|
||||
}, focusOffset, exclude);
|
||||
}
|
||||
}
|
||||
exports.JSONDocument = JSONDocument;
|
||||
});
|
||||
//# sourceMappingURL=jsonDocument.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Parse a boolean according to the specification
|
||||
*
|
||||
* Return:
|
||||
* true if its a true value
|
||||
* false if its a false value
|
||||
*/
|
||||
export declare function parseYamlBoolean(input: string): boolean;
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseYamlBoolean = void 0;
|
||||
/**
|
||||
* Parse a boolean according to the specification
|
||||
*
|
||||
* Return:
|
||||
* true if its a true value
|
||||
* false if its a false value
|
||||
*/
|
||||
function parseYamlBoolean(input) {
|
||||
if (['true', 'True', 'TRUE', 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON'].lastIndexOf(input) >= 0) {
|
||||
return true;
|
||||
}
|
||||
else if (['false', 'False', 'FALSE', 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'].lastIndexOf(input) >= 0) {
|
||||
return false;
|
||||
}
|
||||
throw `Invalid boolean "${input}"`;
|
||||
}
|
||||
exports.parseYamlBoolean = parseYamlBoolean;
|
||||
});
|
||||
//# sourceMappingURL=scalar-type.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"scalar-type.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/scalar-type.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA;;;;;;OAMG;IACH,SAAgB,gBAAgB,CAAC,KAAa;QAC5C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YACrG,OAAO,IAAI,CAAC;SACb;aAAM,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;YAC/G,OAAO,KAAK,CAAC;SACd;QACD,MAAM,oBAAoB,KAAK,GAAG,CAAC;IACrC,CAAC;IAPD,4CAOC"}
|
||||
node_modules/yaml-language-server/lib/umd/languageservice/parser/schemaValidation/baseValidator.d.ts
Generated
Vendored
+124
@@ -0,0 +1,124 @@
|
||||
import type { JSONSchema, JSONSchemaRef, SchemaDialect } from '../../jsonSchema';
|
||||
import type { ASTNode, ArrayASTNode, NumberASTNode, ObjectASTNode, StringASTNode } from '../../jsonASTTypes';
|
||||
import { ErrorCode } from 'vscode-json-languageservice';
|
||||
import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver-types';
|
||||
import type { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
export declare const YAML_SOURCE = "YAML";
|
||||
export interface IRange {
|
||||
offset: number;
|
||||
length: number;
|
||||
}
|
||||
export declare enum ProblemType {
|
||||
missingRequiredPropWarning = "missingRequiredPropWarning",
|
||||
typeMismatchWarning = "typeMismatchWarning",
|
||||
constWarning = "constWarning"
|
||||
}
|
||||
export declare const ProblemTypeMessages: Record<ProblemType, string>;
|
||||
export interface IProblem {
|
||||
location: IRange;
|
||||
severity: DiagnosticSeverity;
|
||||
code?: ErrorCode;
|
||||
message: string;
|
||||
source?: string;
|
||||
problemType?: ProblemType;
|
||||
problemArgs?: string[];
|
||||
schemaUri?: string[];
|
||||
data?: Record<string, unknown>;
|
||||
}
|
||||
export interface IApplicableSchema {
|
||||
node: ASTNode;
|
||||
inverted?: boolean;
|
||||
schema: JSONSchema;
|
||||
}
|
||||
export interface ISchemaCollector {
|
||||
schemas: IApplicableSchema[];
|
||||
add(schema: IApplicableSchema): void;
|
||||
merge(other: ISchemaCollector): void;
|
||||
include(node: ASTNode): boolean;
|
||||
newSub(): ISchemaCollector;
|
||||
}
|
||||
export declare const formats: Record<string, {
|
||||
errorMessage: string;
|
||||
pattern: RegExp;
|
||||
}>;
|
||||
export declare class ValidationResult {
|
||||
problems: IProblem[];
|
||||
propertiesMatches: number;
|
||||
propertiesValueMatches: number;
|
||||
primaryValueMatches: number;
|
||||
enumValueMatch: boolean;
|
||||
enumValues: any[];
|
||||
/**
|
||||
* Optional bookkeeping for newer drafts (2019/2020).
|
||||
* BaseValidator only populates evaluatedProperties conservatively for object keywords it processes directly.
|
||||
*/
|
||||
evaluatedProperties?: Set<string>;
|
||||
evaluatedItemsByNode?: Map<ASTNode, Set<number>>;
|
||||
constructor(isKubernetes: boolean);
|
||||
getEvaluatedItems(node: ASTNode): Set<number>;
|
||||
hasProblems(): boolean;
|
||||
merge(other: ValidationResult): void;
|
||||
mergeEnumValues(other: ValidationResult): void;
|
||||
mergeWarningGeneric(sub: ValidationResult, problemTypesToMerge: ProblemType[]): void;
|
||||
mergePropertyMatch(propertyValidationResult: ValidationResult, mergeEvaluated?: boolean): void;
|
||||
private mergeSources;
|
||||
compareGeneric(other: ValidationResult): number;
|
||||
compareKubernetes(other: ValidationResult): number;
|
||||
}
|
||||
export interface Options {
|
||||
isKubernetes: boolean;
|
||||
disableAdditionalProperties: boolean;
|
||||
uri: string;
|
||||
callFromAutoComplete?: boolean;
|
||||
}
|
||||
interface IValidationMatch {
|
||||
schema: JSONSchema;
|
||||
validationResult: ValidationResult;
|
||||
matchingSchemas: ISchemaCollector;
|
||||
}
|
||||
export declare abstract class BaseValidator {
|
||||
protected collectSeenKeys(node: ObjectASTNode): Record<string, ASTNode>;
|
||||
validateDocument(root: ASTNode, textDocument: TextDocument, schema: JSONSchema, options: Options): Diagnostic[];
|
||||
getMatchingSchemas(root: ASTNode, schema: JSONSchema, options: Options, focusOffset: number, exclude: ASTNode | null): IApplicableSchema[];
|
||||
protected getNoOpCollector(): ISchemaCollector;
|
||||
protected getSchemaSource(schema: JSONSchema, originalSchema: JSONSchema): string;
|
||||
protected getSchemaUri(schema: JSONSchema, originalSchema: JSONSchema): string[];
|
||||
/**
|
||||
* Draft-specific hook: interpret numeric bounds in the draft’s way.
|
||||
* - Draft07+: numeric exclusiveMinimum/exclusiveMaximum
|
||||
* - Draft04: boolean exclusiveMinimum/exclusiveMaximum that modify minimum/maximum
|
||||
*/
|
||||
protected abstract getNumberLimits(schema: JSONSchema): {
|
||||
minimum?: number;
|
||||
maximum?: number;
|
||||
exclusiveMinimum?: number;
|
||||
exclusiveMaximum?: number;
|
||||
};
|
||||
/**
|
||||
* Get the current validator's dialect.
|
||||
*/
|
||||
protected abstract getCurrentDialect(): SchemaDialect;
|
||||
protected validateNode(node: ASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, matchingSchemas: ISchemaCollector, options: Options): void;
|
||||
protected validateGenericNode(node: ASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, matchingSchemas: ISchemaCollector, options: Options): void;
|
||||
protected validateStringNode(node: StringASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult): void;
|
||||
protected validateNumberNode(node: NumberASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult): void;
|
||||
protected validateArrayNode(node: ArrayASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, matchingSchemas: ISchemaCollector, options: Options): void;
|
||||
protected applyContains(node: ArrayASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, _matchingSchemas: ISchemaCollector, options: Options): void;
|
||||
protected applyArrayLength(node: ArrayASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, _options: Options): void;
|
||||
protected applyUniqueItems(node: ArrayASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult): void;
|
||||
protected validateObjectNode(node: ObjectASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, matchingSchemas: ISchemaCollector, options: Options): void;
|
||||
protected applyRequired(node: ObjectASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, _options: Options, seenKeys: Record<string, ASTNode>): void;
|
||||
protected applyProperties(_node: ObjectASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, matchingSchemas: ISchemaCollector, options: Options, seenKeys: Record<string, ASTNode>, _unprocessedProperties: string[], propertyProcessed: (prop: string) => void): void;
|
||||
protected applyPatternProperties(_node: ObjectASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, matchingSchemas: ISchemaCollector, options: Options, seenKeys: Record<string, ASTNode>, unprocessedProperties: string[], propertyProcessed: (prop: string) => void): void;
|
||||
protected applyAdditionalProperties(_node: ObjectASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, matchingSchemas: ISchemaCollector, options: Options, seenKeys: Record<string, ASTNode>, unprocessedProperties: string[]): void;
|
||||
protected applyPropertyCount(node: ObjectASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult): void;
|
||||
protected applyDependencies(node: ObjectASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, matchingSchemas: ISchemaCollector, options: Options, seenKeys: Record<string, ASTNode>): void;
|
||||
protected applyPropertyNames(node: ObjectASTNode, schema: JSONSchema, validationResult: ValidationResult, options: Options): void;
|
||||
protected applyUnevaluatedProperties(_node: ObjectASTNode, _schema: JSONSchema, _originalSchema: JSONSchema, _validationResult: ValidationResult, _matchingSchemas: ISchemaCollector, _options: Options, _seenKeys?: Record<string, ASTNode>, _unprocessedProperties?: string[]): void;
|
||||
protected applyUnevaluatedItems(_node: ArrayASTNode | ASTNode, _schema: JSONSchema, _originalSchema: JSONSchema, _validationResult: ValidationResult, _matchingSchemas: ISchemaCollector, _options: Options): void;
|
||||
protected alternativeComparison(subValidationResult: ValidationResult, bestMatch: IValidationMatch, subSchema: JSONSchema, subMatchingSchemas: ISchemaCollector): IValidationMatch;
|
||||
protected genericComparison(node: ASTNode, maxOneMatch: boolean, subValidationResult: ValidationResult, bestMatch: IValidationMatch, subSchema: JSONSchema, subMatchingSchemas: ISchemaCollector): IValidationMatch;
|
||||
protected mergeValidationMatches(bestMatch: IValidationMatch, subMatchingSchemas: ISchemaCollector, subValidationResult: ValidationResult): void;
|
||||
}
|
||||
export declare function asSchema(schema: JSONSchemaRef): JSONSchema | undefined;
|
||||
export {};
|
||||
Generated
Vendored
+1270
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
import type { JSONSchema } from '../../jsonSchema';
|
||||
import { SchemaDialect } from '../../jsonSchema';
|
||||
import { BaseValidator } from './baseValidator';
|
||||
export declare class Draft04Validator extends BaseValidator {
|
||||
protected getCurrentDialect(): SchemaDialect;
|
||||
/**
|
||||
* Keyword: exclusiveMinimum/exclusiveMaximum
|
||||
*
|
||||
* Booleans that make minimum/maximum exclusive.
|
||||
*/
|
||||
protected getNumberLimits(schema: JSONSchema): {
|
||||
minimum?: number;
|
||||
maximum?: number;
|
||||
exclusiveMinimum?: number;
|
||||
exclusiveMaximum?: number;
|
||||
};
|
||||
}
|
||||
Generated
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) IBM Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "../../jsonSchema", "../../utils/objects", "./baseValidator"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Draft04Validator = void 0;
|
||||
const jsonSchema_1 = require("../../jsonSchema");
|
||||
const objects_1 = require("../../utils/objects");
|
||||
const baseValidator_1 = require("./baseValidator");
|
||||
class Draft04Validator extends baseValidator_1.BaseValidator {
|
||||
getCurrentDialect() {
|
||||
return jsonSchema_1.SchemaDialect.draft04;
|
||||
}
|
||||
/**
|
||||
* Keyword: exclusiveMinimum/exclusiveMaximum
|
||||
*
|
||||
* Booleans that make minimum/maximum exclusive.
|
||||
*/
|
||||
getNumberLimits(schema) {
|
||||
const minimum = (0, objects_1.isNumber)(schema.minimum) ? schema.minimum : undefined;
|
||||
const maximum = (0, objects_1.isNumber)(schema.maximum) ? schema.maximum : undefined;
|
||||
const exclusiveMinimum = (0, objects_1.isBoolean)(schema.exclusiveMinimum) && schema.exclusiveMinimum ? minimum : undefined;
|
||||
const exclusiveMaximum = (0, objects_1.isBoolean)(schema.exclusiveMaximum) && schema.exclusiveMaximum ? maximum : undefined;
|
||||
return {
|
||||
minimum: exclusiveMinimum === undefined ? minimum : undefined,
|
||||
maximum: exclusiveMaximum === undefined ? maximum : undefined,
|
||||
exclusiveMinimum,
|
||||
exclusiveMaximum,
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.Draft04Validator = Draft04Validator;
|
||||
});
|
||||
//# sourceMappingURL=draft04Validator.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"draft04Validator.js","sourceRoot":"","sources":["../../../../../src/languageservice/parser/schemaValidation/draft04Validator.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAGhG,iDAAiD;IACjD,iDAA0D;IAC1D,mDAAgD;IAEhD,MAAa,gBAAiB,SAAQ,6BAAa;QAC9B,iBAAiB;YAClC,OAAO,0BAAa,CAAC,OAAO,CAAC;QAC/B,CAAC;QAED;;;;WAIG;QACgB,eAAe,CAAC,MAAkB;YAMnD,MAAM,OAAO,GAAG,IAAA,kBAAQ,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;YACtE,MAAM,OAAO,GAAG,IAAA,kBAAQ,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;YAEtE,MAAM,gBAAgB,GAAG,IAAA,mBAAS,EAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;YAC7G,MAAM,gBAAgB,GAAG,IAAA,mBAAS,EAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;YAE7G,OAAO;gBACL,OAAO,EAAE,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;gBAC7D,OAAO,EAAE,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;gBAC7D,gBAAgB;gBAChB,gBAAgB;aACjB,CAAC;QACJ,CAAC;KACF;IA7BD,4CA6BC"}
|
||||
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
import type { JSONSchema } from '../../jsonSchema';
|
||||
import { SchemaDialect } from '../../jsonSchema';
|
||||
import { BaseValidator } from './baseValidator';
|
||||
export declare class Draft07Validator extends BaseValidator {
|
||||
protected getCurrentDialect(): SchemaDialect;
|
||||
/**
|
||||
* Keyword: exclusiveMinimum/exclusiveMaximum are treated as numeric bounds
|
||||
*/
|
||||
protected getNumberLimits(schema: JSONSchema): {
|
||||
minimum?: number;
|
||||
maximum?: number;
|
||||
exclusiveMinimum?: number;
|
||||
exclusiveMaximum?: number;
|
||||
};
|
||||
}
|
||||
Generated
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) IBM Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "../../jsonSchema", "../../utils/objects", "./baseValidator"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Draft07Validator = void 0;
|
||||
const jsonSchema_1 = require("../../jsonSchema");
|
||||
const objects_1 = require("../../utils/objects");
|
||||
const baseValidator_1 = require("./baseValidator");
|
||||
class Draft07Validator extends baseValidator_1.BaseValidator {
|
||||
getCurrentDialect() {
|
||||
return jsonSchema_1.SchemaDialect.draft07;
|
||||
}
|
||||
/**
|
||||
* Keyword: exclusiveMinimum/exclusiveMaximum are treated as numeric bounds
|
||||
*/
|
||||
getNumberLimits(schema) {
|
||||
const minimum = (0, objects_1.isNumber)(schema.minimum) ? schema.minimum : undefined;
|
||||
const maximum = (0, objects_1.isNumber)(schema.maximum) ? schema.maximum : undefined;
|
||||
const exclusiveMinimum = (0, objects_1.isNumber)(schema.exclusiveMinimum) ? schema.exclusiveMinimum : undefined;
|
||||
const exclusiveMaximum = (0, objects_1.isNumber)(schema.exclusiveMaximum) ? schema.exclusiveMaximum : undefined;
|
||||
return {
|
||||
minimum: exclusiveMinimum === undefined ? minimum : undefined,
|
||||
maximum: exclusiveMaximum === undefined ? maximum : undefined,
|
||||
exclusiveMinimum,
|
||||
exclusiveMaximum,
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.Draft07Validator = Draft07Validator;
|
||||
});
|
||||
//# sourceMappingURL=draft07Validator.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"draft07Validator.js","sourceRoot":"","sources":["../../../../../src/languageservice/parser/schemaValidation/draft07Validator.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAGhG,iDAAiD;IACjD,iDAA+C;IAC/C,mDAAgD;IAEhD,MAAa,gBAAiB,SAAQ,6BAAa;QAC9B,iBAAiB;YAClC,OAAO,0BAAa,CAAC,OAAO,CAAC;QAC/B,CAAC;QAED;;WAEG;QACO,eAAe,CAAC,MAAkB;YAM1C,MAAM,OAAO,GAAG,IAAA,kBAAQ,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;YACtE,MAAM,OAAO,GAAG,IAAA,kBAAQ,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;YAEtE,MAAM,gBAAgB,GAAG,IAAA,kBAAQ,EAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;YACjG,MAAM,gBAAgB,GAAG,IAAA,kBAAQ,EAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;YAEjG,OAAO;gBACL,OAAO,EAAE,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;gBAC7D,OAAO,EAAE,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;gBAC7D,gBAAgB;gBAChB,gBAAgB;aACjB,CAAC;QACJ,CAAC;KACF;IA3BD,4CA2BC"}
|
||||
Generated
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
import type { JSONSchema } from '../../jsonSchema';
|
||||
import { SchemaDialect } from '../../jsonSchema';
|
||||
import type { ASTNode, ArrayASTNode, ObjectASTNode } from '../../jsonASTTypes';
|
||||
import { Draft07Validator } from './draft07Validator';
|
||||
import { ValidationResult } from './baseValidator';
|
||||
import type { ISchemaCollector, Options } from './baseValidator';
|
||||
export declare class Draft2019Validator extends Draft07Validator {
|
||||
protected getCurrentDialect(): SchemaDialect;
|
||||
/**
|
||||
* Keyword: contains + minContains/maxContains
|
||||
*
|
||||
* Draft-07 behavior: contains must match at least 1 item.
|
||||
* Draft-2019-09 behavior: minContains/maxContains constrain how many matches are required/allowed.
|
||||
*/
|
||||
protected applyContains(node: ArrayASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, _matchingSchemas: ISchemaCollector, options: Options): void;
|
||||
/**
|
||||
* Keyword: dependentRequired + dependentSchemas.
|
||||
*/
|
||||
protected applyDependencies(node: ObjectASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, matchingSchemas: ISchemaCollector, options: Options, seenKeys: Record<string, ASTNode>): void;
|
||||
/**
|
||||
* Keyword: unevaluatedProperties
|
||||
*/
|
||||
protected applyUnevaluatedProperties(node: ObjectASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, matchingSchemas: ISchemaCollector, options: Options, seenKeys?: Record<string, ASTNode>): void;
|
||||
/**
|
||||
* Keyword: unevaluatedItems
|
||||
*/
|
||||
protected applyUnevaluatedItems(node: ArrayASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, matchingSchemas: ISchemaCollector, options: Options): void;
|
||||
}
|
||||
Generated
Vendored
+238
@@ -0,0 +1,238 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) IBM Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "../../jsonSchema", "../../utils/objects", "@vscode/l10n", "vscode-languageserver-types", "vscode-json-languageservice", "./draft07Validator", "./baseValidator"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Draft2019Validator = void 0;
|
||||
const jsonSchema_1 = require("../../jsonSchema");
|
||||
const objects_1 = require("../../utils/objects");
|
||||
const l10n = require("@vscode/l10n");
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const vscode_json_languageservice_1 = require("vscode-json-languageservice");
|
||||
const draft07Validator_1 = require("./draft07Validator");
|
||||
const baseValidator_1 = require("./baseValidator");
|
||||
class Draft2019Validator extends draft07Validator_1.Draft07Validator {
|
||||
getCurrentDialect() {
|
||||
return jsonSchema_1.SchemaDialect.draft2019;
|
||||
}
|
||||
/**
|
||||
* Keyword: contains + minContains/maxContains
|
||||
*
|
||||
* Draft-07 behavior: contains must match at least 1 item.
|
||||
* Draft-2019-09 behavior: minContains/maxContains constrain how many matches are required/allowed.
|
||||
*/
|
||||
applyContains(node, schema, originalSchema, validationResult, _matchingSchemas, options) {
|
||||
const containsSchema = (0, baseValidator_1.asSchema)(schema.contains);
|
||||
if (!containsSchema)
|
||||
return;
|
||||
const minContainsRaw = schema.minContains;
|
||||
const maxContainsRaw = schema.maxContains;
|
||||
const minContains = (0, objects_1.isNumber)(minContainsRaw) ? minContainsRaw : 1;
|
||||
const maxContains = (0, objects_1.isNumber)(maxContainsRaw) ? maxContainsRaw : undefined;
|
||||
let matchCount = 0;
|
||||
const items = (node.items ?? []);
|
||||
for (const item of items) {
|
||||
const itemValidationResult = new baseValidator_1.ValidationResult(options.isKubernetes);
|
||||
this.validateNode(item, containsSchema, schema, itemValidationResult, this.getNoOpCollector(), options);
|
||||
if (!itemValidationResult.hasProblems()) {
|
||||
matchCount++;
|
||||
if (maxContains !== undefined && matchCount > maxContains) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (matchCount < minContains) {
|
||||
validationResult.problems.push({
|
||||
location: { offset: node.offset, length: node.length },
|
||||
severity: vscode_languageserver_types_1.DiagnosticSeverity.Warning,
|
||||
message: schema.errorMessage || l10n.t('Array has too few items matching "contains". Expected {0} or more.', minContains),
|
||||
source: this.getSchemaSource(schema, originalSchema),
|
||||
schemaUri: this.getSchemaUri(schema, originalSchema),
|
||||
});
|
||||
}
|
||||
if (maxContains !== undefined && matchCount > maxContains) {
|
||||
validationResult.problems.push({
|
||||
location: { offset: node.offset, length: node.length },
|
||||
severity: vscode_languageserver_types_1.DiagnosticSeverity.Warning,
|
||||
message: schema.errorMessage || l10n.t('Array has too many items matching "contains". Expected {0} or fewer.', maxContains),
|
||||
source: this.getSchemaSource(schema, originalSchema),
|
||||
schemaUri: this.getSchemaUri(schema, originalSchema),
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Keyword: dependentRequired + dependentSchemas.
|
||||
*/
|
||||
applyDependencies(node, schema, originalSchema, validationResult, matchingSchemas, options, seenKeys) {
|
||||
// keep draft-07 dependencies support
|
||||
super.applyDependencies(node, schema, originalSchema, validationResult, matchingSchemas, options, seenKeys);
|
||||
const dependentRequired = schema.dependentRequired;
|
||||
if (dependentRequired && typeof dependentRequired === 'object') {
|
||||
for (const prop of Object.keys(dependentRequired)) {
|
||||
if (!seenKeys[prop])
|
||||
continue;
|
||||
const requiredProps = dependentRequired[prop];
|
||||
if (!Array.isArray(requiredProps))
|
||||
continue;
|
||||
for (const requiredProp of requiredProps) {
|
||||
if (!seenKeys[requiredProp]) {
|
||||
validationResult.problems.push({
|
||||
location: { offset: node.offset, length: node.length },
|
||||
severity: vscode_languageserver_types_1.DiagnosticSeverity.Warning,
|
||||
message: l10n.t('Object is missing property {0} required by property {1}.', requiredProp, prop),
|
||||
source: this.getSchemaSource(schema, originalSchema),
|
||||
schemaUri: this.getSchemaUri(schema, originalSchema),
|
||||
});
|
||||
}
|
||||
else {
|
||||
validationResult.propertiesValueMatches++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const dependentSchemas = schema.dependentSchemas;
|
||||
if (dependentSchemas && typeof dependentSchemas === 'object') {
|
||||
for (const prop of Object.keys(dependentSchemas)) {
|
||||
if (!seenKeys[prop])
|
||||
continue;
|
||||
const depSchema = (0, baseValidator_1.asSchema)(dependentSchemas[prop]);
|
||||
if (!depSchema)
|
||||
continue;
|
||||
const depValidationResult = new baseValidator_1.ValidationResult(options.isKubernetes);
|
||||
this.validateNode(node, depSchema, schema, depValidationResult, matchingSchemas, options);
|
||||
validationResult.mergePropertyMatch(depValidationResult);
|
||||
validationResult.mergeEnumValues(depValidationResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Keyword: unevaluatedProperties
|
||||
*/
|
||||
applyUnevaluatedProperties(node, schema, originalSchema, validationResult, matchingSchemas, options, seenKeys) {
|
||||
const unevaluated = schema.unevaluatedProperties;
|
||||
if (unevaluated === undefined)
|
||||
return;
|
||||
if (!seenKeys)
|
||||
return;
|
||||
// ensure evaluatedProperties exists
|
||||
validationResult.evaluatedProperties ?? (validationResult.evaluatedProperties = new Set());
|
||||
// remaining = properties not evaluated by properties/patternProperties/additionalProperties
|
||||
const remaining = Object.keys(seenKeys).filter((name) => !validationResult.evaluatedProperties?.has(name));
|
||||
if (remaining.length === 0)
|
||||
return;
|
||||
// unevaluatedProperties: false => forbid remaining properties
|
||||
if (unevaluated === false) {
|
||||
for (const propName of remaining) {
|
||||
const child = seenKeys[propName];
|
||||
if (!child)
|
||||
continue;
|
||||
const propertyNode = child.type === 'property' ? child : child.parent;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const keyNode = propertyNode.keyNode;
|
||||
if (!keyNode)
|
||||
continue;
|
||||
validationResult.problems.push({
|
||||
location: { offset: keyNode.offset, length: keyNode.length },
|
||||
severity: vscode_languageserver_types_1.DiagnosticSeverity.Warning,
|
||||
code: vscode_json_languageservice_1.ErrorCode.PropertyExpected,
|
||||
message: schema.errorMessage || l10n.t('Property {0} is not allowed.', propName),
|
||||
source: this.getSchemaSource(schema, originalSchema),
|
||||
schemaUri: this.getSchemaUri(schema, originalSchema),
|
||||
});
|
||||
validationResult.evaluatedProperties?.add(propName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// unevaluatedProperties: true => allow anything remaining, but mark evaluated
|
||||
if (unevaluated === true) {
|
||||
for (const propName of remaining) {
|
||||
validationResult.evaluatedProperties?.add(propName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// unevaluatedProperties: <schema> => validate value of each remaining property
|
||||
const unevaluatedSchema = (0, baseValidator_1.asSchema)(unevaluated);
|
||||
if (!unevaluatedSchema)
|
||||
return;
|
||||
for (const propName of remaining) {
|
||||
const child = seenKeys[propName];
|
||||
if (!child)
|
||||
continue;
|
||||
const valueNode = child.type === 'property' ? child.valueNode : child;
|
||||
if (!valueNode)
|
||||
continue;
|
||||
const subResult = new baseValidator_1.ValidationResult(options.isKubernetes);
|
||||
this.validateNode(valueNode, unevaluatedSchema, schema, subResult, matchingSchemas, options);
|
||||
validationResult.mergePropertyMatch(subResult);
|
||||
validationResult.mergeEnumValues(subResult);
|
||||
validationResult.evaluatedProperties?.add(propName);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Keyword: unevaluatedItems
|
||||
*/
|
||||
applyUnevaluatedItems(node, schema, originalSchema, validationResult, matchingSchemas, options) {
|
||||
const unevaluated = schema.unevaluatedItems;
|
||||
if (unevaluated === undefined)
|
||||
return;
|
||||
const items = (node.items ?? []);
|
||||
if (items.length === 0)
|
||||
return;
|
||||
const evaluated = validationResult.getEvaluatedItems(node);
|
||||
const remaining = [];
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (!evaluated.has(i))
|
||||
remaining.push(i);
|
||||
}
|
||||
if (remaining.length === 0)
|
||||
return;
|
||||
// unevaluatedItems: false => forbid remaining indices
|
||||
if (unevaluated === false) {
|
||||
for (const idx of remaining) {
|
||||
const item = items[idx];
|
||||
validationResult.problems.push({
|
||||
location: { offset: item.offset, length: item.length || 1 },
|
||||
severity: vscode_languageserver_types_1.DiagnosticSeverity.Warning,
|
||||
code: vscode_json_languageservice_1.ErrorCode.PropertyExpected,
|
||||
message: schema.errorMessage || l10n.t('Array has too many items according to schema. Expected {0} or fewer.', idx),
|
||||
source: this.getSchemaSource(schema, originalSchema),
|
||||
schemaUri: this.getSchemaUri(schema, originalSchema),
|
||||
});
|
||||
evaluated.add(idx);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// unevaluatedItems: true => allow everything remaining, but mark evaluated
|
||||
if (unevaluated === true) {
|
||||
for (const idx of remaining)
|
||||
evaluated.add(idx);
|
||||
return;
|
||||
}
|
||||
// unevaluatedItems: <schema> => validate remaining items against that schema
|
||||
const unevaluatedSchema = (0, baseValidator_1.asSchema)(unevaluated);
|
||||
if (!unevaluatedSchema)
|
||||
return;
|
||||
for (const idx of remaining) {
|
||||
const item = items[idx];
|
||||
const subResult = new baseValidator_1.ValidationResult(options.isKubernetes);
|
||||
// validate the item node with the unevaluatedItems subschema
|
||||
this.validateNode(item, unevaluatedSchema, schema, subResult, matchingSchemas, options);
|
||||
validationResult.merge(subResult);
|
||||
validationResult.mergeEnumValues(subResult);
|
||||
evaluated.add(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Draft2019Validator = Draft2019Validator;
|
||||
});
|
||||
//# sourceMappingURL=draft2019Validator.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
import type { JSONSchema } from '../../jsonSchema';
|
||||
import { SchemaDialect } from '../../jsonSchema';
|
||||
import type { ArrayASTNode } from '../../jsonASTTypes';
|
||||
import { Draft2019Validator } from './draft2019Validator';
|
||||
import type { ISchemaCollector, Options } from './baseValidator';
|
||||
import { ValidationResult } from './baseValidator';
|
||||
export declare class Draft2020Validator extends Draft2019Validator {
|
||||
protected getCurrentDialect(): SchemaDialect;
|
||||
/**
|
||||
* Keyword: prefixItems + items
|
||||
*/
|
||||
protected validateArrayNode(node: ArrayASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, matchingSchemas: ISchemaCollector, options: Options): void;
|
||||
/**
|
||||
* Draft 2020-12: contains keyword affects the unevaluatedItems keyword
|
||||
*/
|
||||
protected applyContains(node: ArrayASTNode, schema: JSONSchema, originalSchema: JSONSchema, validationResult: ValidationResult, _matchingSchemas: ISchemaCollector, options: Options): void;
|
||||
}
|
||||
Generated
Vendored
+140
@@ -0,0 +1,140 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) IBM Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "../../jsonSchema", "../../utils/objects", "@vscode/l10n", "vscode-languageserver-types", "./draft2019Validator", "./baseValidator"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Draft2020Validator = void 0;
|
||||
const jsonSchema_1 = require("../../jsonSchema");
|
||||
const objects_1 = require("../../utils/objects");
|
||||
const l10n = require("@vscode/l10n");
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const draft2019Validator_1 = require("./draft2019Validator");
|
||||
const baseValidator_1 = require("./baseValidator");
|
||||
class Draft2020Validator extends draft2019Validator_1.Draft2019Validator {
|
||||
getCurrentDialect() {
|
||||
return jsonSchema_1.SchemaDialect.draft2020;
|
||||
}
|
||||
/**
|
||||
* Keyword: prefixItems + items
|
||||
*/
|
||||
validateArrayNode(node, schema, originalSchema, validationResult, matchingSchemas, options) {
|
||||
const items = (node.items ?? []);
|
||||
// prefixItems/items/contains contribute to evaluatedItems
|
||||
const evaluatedItems = validationResult.getEvaluatedItems(node);
|
||||
const prefixItems = schema.prefixItems;
|
||||
// validate prefixItems
|
||||
if (Array.isArray(prefixItems)) {
|
||||
const limit = Math.min(prefixItems.length, items.length);
|
||||
for (let i = 0; i < limit; i++) {
|
||||
const subSchema = (0, baseValidator_1.asSchema)(prefixItems[i]);
|
||||
if (!subSchema) {
|
||||
evaluatedItems.add(i);
|
||||
continue;
|
||||
}
|
||||
const itemValidationResult = new baseValidator_1.ValidationResult(options.isKubernetes);
|
||||
this.validateNode(items[i], subSchema, schema, itemValidationResult, matchingSchemas, options);
|
||||
validationResult.mergePropertyMatch(itemValidationResult, false);
|
||||
validationResult.mergeEnumValues(itemValidationResult);
|
||||
// mark as evaluated even if invalid (avoids duplicate unevaluatedItems noise)
|
||||
evaluatedItems.add(i);
|
||||
}
|
||||
}
|
||||
// validate remaining items against items
|
||||
const itemsKeyword = schema.items;
|
||||
const prefixLen = Array.isArray(prefixItems) ? prefixItems.length : 0;
|
||||
if (items.length > prefixLen) {
|
||||
if (itemsKeyword === false) {
|
||||
// "items": false => no items allowed beyond prefixItems
|
||||
validationResult.problems.push({
|
||||
location: { offset: node.offset, length: node.length },
|
||||
severity: vscode_languageserver_types_1.DiagnosticSeverity.Warning,
|
||||
message: l10n.t('Array has too many items according to schema. Expected {0} or fewer.', prefixLen),
|
||||
source: this.getSchemaSource(schema, originalSchema),
|
||||
schemaUri: this.getSchemaUri(schema, originalSchema),
|
||||
});
|
||||
// mark these as evaluated by "items": false (so unevaluatedItems doesn't also complain)
|
||||
for (let i = prefixLen; i < items.length; i++) {
|
||||
evaluatedItems.add(i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const tailSchema = (0, baseValidator_1.asSchema)(itemsKeyword);
|
||||
// if items is undefined, there's no constraint for remaining items and they remain unevaluated
|
||||
if (tailSchema) {
|
||||
for (let i = prefixLen; i < items.length; i++) {
|
||||
const itemValidationResult = new baseValidator_1.ValidationResult(options.isKubernetes);
|
||||
this.validateNode(items[i], tailSchema, schema, itemValidationResult, matchingSchemas, options);
|
||||
validationResult.mergePropertyMatch(itemValidationResult, false);
|
||||
validationResult.mergeEnumValues(itemValidationResult);
|
||||
// mark as evaluated even if invalid (avoids duplicate unevaluatedItems noise)
|
||||
evaluatedItems.add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// contains enforces min/max and marks matching indices as evaluated
|
||||
this.applyContains(node, schema, originalSchema, validationResult, matchingSchemas, options);
|
||||
// generic array keywords
|
||||
this.applyArrayLength(node, schema, originalSchema, validationResult, options);
|
||||
this.applyUniqueItems(node, schema, originalSchema, validationResult);
|
||||
}
|
||||
/**
|
||||
* Draft 2020-12: contains keyword affects the unevaluatedItems keyword
|
||||
*/
|
||||
applyContains(node, schema, originalSchema, validationResult, _matchingSchemas, options) {
|
||||
const containsSchema = (0, baseValidator_1.asSchema)(schema.contains);
|
||||
if (!containsSchema)
|
||||
return;
|
||||
const items = (node.items ?? []);
|
||||
const minContainsRaw = schema.minContains;
|
||||
const maxContainsRaw = schema.maxContains;
|
||||
const minContains = (0, objects_1.isNumber)(minContainsRaw) ? minContainsRaw : 1;
|
||||
const maxContains = (0, objects_1.isNumber)(maxContainsRaw) ? maxContainsRaw : undefined;
|
||||
let matchCount = 0;
|
||||
// ensure evaluatedItems exists
|
||||
const evaluatedItems = validationResult.getEvaluatedItems(node);
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const itemValidationResult = new baseValidator_1.ValidationResult(options.isKubernetes);
|
||||
this.validateNode(items[i], containsSchema, schema, itemValidationResult, this.getNoOpCollector(), options);
|
||||
if (!itemValidationResult.hasProblems()) {
|
||||
// items that match contains are considered evaluated
|
||||
evaluatedItems.add(i);
|
||||
matchCount++;
|
||||
if (maxContains !== undefined && matchCount > maxContains) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (matchCount < minContains) {
|
||||
validationResult.problems.push({
|
||||
location: { offset: node.offset, length: node.length },
|
||||
severity: vscode_languageserver_types_1.DiagnosticSeverity.Warning,
|
||||
message: schema.errorMessage || l10n.t('Array has too few items matching "contains". Expected {0} or more.', minContains),
|
||||
source: this.getSchemaSource(schema, originalSchema),
|
||||
schemaUri: this.getSchemaUri(schema, originalSchema),
|
||||
});
|
||||
}
|
||||
if (maxContains !== undefined && matchCount > maxContains) {
|
||||
validationResult.problems.push({
|
||||
location: { offset: node.offset, length: node.length },
|
||||
severity: vscode_languageserver_types_1.DiagnosticSeverity.Warning,
|
||||
message: schema.errorMessage || l10n.t('Array has too many items matching "contains". Expected {0} or fewer.', maxContains),
|
||||
source: this.getSchemaSource(schema, originalSchema),
|
||||
schemaUri: this.getSchemaUri(schema, originalSchema),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Draft2020Validator = Draft2020Validator;
|
||||
});
|
||||
//# sourceMappingURL=draft2020Validator.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"draft2020Validator.js","sourceRoot":"","sources":["../../../../../src/languageservice/parser/schemaValidation/draft2020Validator.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAGhG,iDAAiD;IAEjD,iDAA+C;IAC/C,qCAAqC;IACrC,6EAAiE;IACjE,6DAA0D;IAE1D,mDAA6D;IAE7D,MAAa,kBAAmB,SAAQ,uCAAkB;QACrC,iBAAiB;YAClC,OAAO,0BAAa,CAAC,SAAS,CAAC;QACjC,CAAC;QAED;;WAEG;QACgB,iBAAiB,CAClC,IAAkB,EAClB,MAAkB,EAClB,cAA0B,EAC1B,gBAAkC,EAClC,eAAiC,EACjC,OAAgB;YAEhB,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAc,CAAC;YAC9C,0DAA0D;YAC1D,MAAM,cAAc,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YAEhE,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;YACvC,uBAAuB;YACvB,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;gBAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBACzD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE;oBAC9B,MAAM,SAAS,GAAG,IAAA,wBAAQ,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC3C,IAAI,CAAC,SAAS,EAAE;wBACd,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;wBACtB,SAAS;qBACV;oBACD,MAAM,oBAAoB,GAAG,IAAI,gCAAgB,CAAC,OAAO,CAAC,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BACtD,QAAQ,EAAE,gDAAkB,CAAC,OAAO;oBACpC,OAAO,EAAE,MAAM,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,oEAAoE,EAAE,WAAW,CAAC;oBACzH,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,cAAc,CAAC;oBACpD,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,cAAc,CAAC;iBACrD,CAAC,CAAC;aACJ;YAED,IAAI,WAAW,KAAK,SAAS,IAAI,UAAU,GAAG,WAAW,EAAE;gBACzD,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAC7B,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;oBACtD,QAAQ,EAAE,gDAAkB,CAAC,OAAO;oBACpC,OAAO,EACL,MAAM,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,sEAAsE,EAAE,WAAW,CAAC;oBACpH,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,cAAc,CAAC;oBACpD,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,cAAc,CAAC;iBACrD,CAAC,CAAC;aACJ;QACH,CAAC;KACF;IAnJD,gDAmJC"}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import { SchemaDialect } from '../../jsonSchema';
|
||||
import { BaseValidator } from './baseValidator';
|
||||
export declare function getValidator(dialect: SchemaDialect): BaseValidator;
|
||||
Generated
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) IBM Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "../../jsonSchema", "./draft04Validator", "./draft07Validator", "./draft2019Validator", "./draft2020Validator"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getValidator = void 0;
|
||||
const jsonSchema_1 = require("../../jsonSchema");
|
||||
const draft04Validator_1 = require("./draft04Validator");
|
||||
const draft07Validator_1 = require("./draft07Validator");
|
||||
const draft2019Validator_1 = require("./draft2019Validator");
|
||||
const draft2020Validator_1 = require("./draft2020Validator");
|
||||
function getValidator(dialect) {
|
||||
switch (dialect) {
|
||||
case jsonSchema_1.SchemaDialect.draft04:
|
||||
return new draft04Validator_1.Draft04Validator();
|
||||
case jsonSchema_1.SchemaDialect.draft07:
|
||||
return new draft07Validator_1.Draft07Validator();
|
||||
case jsonSchema_1.SchemaDialect.draft2019:
|
||||
return new draft2019Validator_1.Draft2019Validator();
|
||||
case jsonSchema_1.SchemaDialect.draft2020:
|
||||
return new draft2020Validator_1.Draft2020Validator();
|
||||
default:
|
||||
return new draft07Validator_1.Draft07Validator(); // fallback
|
||||
}
|
||||
}
|
||||
exports.getValidator = getValidator;
|
||||
});
|
||||
//# sourceMappingURL=validatorFactory.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"validatorFactory.js","sourceRoot":"","sources":["../../../../../src/languageservice/parser/schemaValidation/validatorFactory.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAEhG,iDAAiD;IAEjD,yDAAsD;IACtD,yDAAsD;IACtD,6DAA0D;IAC1D,6DAA0D;IAE1D,SAAgB,YAAY,CAAC,OAAsB;QACjD,QAAQ,OAAO,EAAE;YACf,KAAK,0BAAa,CAAC,OAAO;gBACxB,OAAO,IAAI,mCAAgB,EAAE,CAAC;YAChC,KAAK,0BAAa,CAAC,OAAO;gBACxB,OAAO,IAAI,mCAAgB,EAAE,CAAC;YAChC,KAAK,0BAAa,CAAC,SAAS;gBAC1B,OAAO,IAAI,uCAAkB,EAAE,CAAC;YAClC,KAAK,0BAAa,CAAC,SAAS;gBAC1B,OAAO,IAAI,uCAAkB,EAAE,CAAC;YAClC;gBACE,OAAO,IAAI,mCAAgB,EAAE,CAAC,CAAC,WAAW;SAC7C;IACH,CAAC;IAbD,oCAaC"}
|
||||
Generated
Vendored
+71
@@ -0,0 +1,71 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { JSONDocument } from './jsonDocument';
|
||||
import { Document, LineCounter } from 'yaml';
|
||||
import { ASTNode, YamlNode } from '../jsonASTTypes';
|
||||
import { ParserOptions } from './yamlParser07';
|
||||
import { YAMLDocDiagnostic } from '../utils/parseUtils';
|
||||
import { TextBuffer } from '../utils/textBuffer';
|
||||
import { Token } from 'yaml/dist/parse/cst';
|
||||
/**
|
||||
* These documents are collected into a final YAMLDocument
|
||||
* and passed to the `parseYAML` caller.
|
||||
*/
|
||||
export declare class SingleYAMLDocument extends JSONDocument {
|
||||
private lineCounter;
|
||||
private _internalDocument;
|
||||
root: ASTNode;
|
||||
currentDocIndex: number;
|
||||
private _lineComments;
|
||||
constructor(lineCounter?: LineCounter);
|
||||
/**
|
||||
* Create a deep copy of this document
|
||||
*/
|
||||
clone(): SingleYAMLDocument;
|
||||
private collectLineComments;
|
||||
/**
|
||||
* Updates the internal AST tree of the object
|
||||
* from the internal node. This is call whenever the
|
||||
* internalDocument is set but also can be called to
|
||||
* reflect any changes on the underlying document
|
||||
* without setting the internalDocument explicitly.
|
||||
*/
|
||||
updateFromInternalDocument(): void;
|
||||
set internalDocument(document: Document);
|
||||
get internalDocument(): Document;
|
||||
get lineComments(): string[];
|
||||
set lineComments(val: string[]);
|
||||
get errors(): YAMLDocDiagnostic[];
|
||||
get warnings(): YAMLDocDiagnostic[];
|
||||
getNodeFromPosition(positionOffset: number, textBuffer: TextBuffer, configuredIndentation?: number): [YamlNode | undefined, boolean];
|
||||
findClosestNode(offset: number, textBuffer: TextBuffer, configuredIndentation?: number): YamlNode;
|
||||
private getProperParentByIndentation;
|
||||
getParent(node: YamlNode): YamlNode | undefined;
|
||||
}
|
||||
/**
|
||||
* Contains the SingleYAMLDocuments, to be passed
|
||||
* to the `parseYAML` caller.
|
||||
*/
|
||||
export declare class YAMLDocument {
|
||||
documents: SingleYAMLDocument[];
|
||||
tokens: Token[];
|
||||
private errors;
|
||||
private warnings;
|
||||
constructor(documents: SingleYAMLDocument[], tokens: Token[]);
|
||||
}
|
||||
export declare class YamlDocuments {
|
||||
private cache;
|
||||
/**
|
||||
* Get cached YAMLDocument
|
||||
* @param document TextDocument to parse
|
||||
* @param parserOptions YAML parserOptions
|
||||
* @param addRootObject if true and document is empty add empty object {} to force schema usage
|
||||
* @returns the YAMLDocument
|
||||
*/
|
||||
getYamlDocument(document: TextDocument, parserOptions?: ParserOptions, addRootObject?: boolean): YAMLDocument;
|
||||
/**
|
||||
* For test purpose only!
|
||||
*/
|
||||
clear(): void;
|
||||
private ensureCache;
|
||||
}
|
||||
export declare const yamlDocumentsCache: YamlDocuments;
|
||||
Generated
Vendored
+274
@@ -0,0 +1,274 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "./jsonDocument", "yaml", "./yamlParser07", "vscode-json-languageservice", "./ast-converter", "../utils/arrUtils", "../utils/yamlAstUtils", "../utils/strings"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.yamlDocumentsCache = exports.YamlDocuments = exports.YAMLDocument = exports.SingleYAMLDocument = void 0;
|
||||
const jsonDocument_1 = require("./jsonDocument");
|
||||
const yaml_1 = require("yaml");
|
||||
const yamlParser07_1 = require("./yamlParser07");
|
||||
const vscode_json_languageservice_1 = require("vscode-json-languageservice");
|
||||
const ast_converter_1 = require("./ast-converter");
|
||||
const arrUtils_1 = require("../utils/arrUtils");
|
||||
const yamlAstUtils_1 = require("../utils/yamlAstUtils");
|
||||
const strings_1 = require("../utils/strings");
|
||||
/**
|
||||
* These documents are collected into a final YAMLDocument
|
||||
* and passed to the `parseYAML` caller.
|
||||
*/
|
||||
class SingleYAMLDocument extends jsonDocument_1.JSONDocument {
|
||||
constructor(lineCounter) {
|
||||
super(null, []);
|
||||
this.lineCounter = lineCounter;
|
||||
}
|
||||
/**
|
||||
* Create a deep copy of this document
|
||||
*/
|
||||
clone() {
|
||||
const copy = new SingleYAMLDocument(this.lineCounter);
|
||||
copy.isKubernetes = this.isKubernetes;
|
||||
copy.disableAdditionalProperties = this.disableAdditionalProperties;
|
||||
copy.uri = this.uri;
|
||||
copy.currentDocIndex = this.currentDocIndex;
|
||||
copy._lineComments = this.lineComments.slice();
|
||||
// this will re-create root node
|
||||
copy.internalDocument = this._internalDocument.clone();
|
||||
return copy;
|
||||
}
|
||||
collectLineComments() {
|
||||
this._lineComments = [];
|
||||
if (this._internalDocument.commentBefore) {
|
||||
const comments = this._internalDocument.commentBefore.split('\n');
|
||||
comments.forEach((comment) => this._lineComments.push(`#${comment}`));
|
||||
}
|
||||
(0, yaml_1.visit)(this.internalDocument, (_key, node) => {
|
||||
if (node?.commentBefore) {
|
||||
const comments = node?.commentBefore.split('\n');
|
||||
comments.forEach((comment) => this._lineComments.push(`#${comment}`));
|
||||
}
|
||||
if (node?.comment) {
|
||||
this._lineComments.push(`#${node.comment}`);
|
||||
}
|
||||
});
|
||||
if (this._internalDocument.comment) {
|
||||
this._lineComments.push(`#${this._internalDocument.comment}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Updates the internal AST tree of the object
|
||||
* from the internal node. This is call whenever the
|
||||
* internalDocument is set but also can be called to
|
||||
* reflect any changes on the underlying document
|
||||
* without setting the internalDocument explicitly.
|
||||
*/
|
||||
updateFromInternalDocument() {
|
||||
this.root = (0, ast_converter_1.convertAST)(null, this._internalDocument.contents, this._internalDocument, this.lineCounter);
|
||||
}
|
||||
set internalDocument(document) {
|
||||
this._internalDocument = document;
|
||||
this.updateFromInternalDocument();
|
||||
}
|
||||
get internalDocument() {
|
||||
return this._internalDocument;
|
||||
}
|
||||
get lineComments() {
|
||||
if (!this._lineComments) {
|
||||
this.collectLineComments();
|
||||
}
|
||||
return this._lineComments;
|
||||
}
|
||||
set lineComments(val) {
|
||||
this._lineComments = val;
|
||||
}
|
||||
get errors() {
|
||||
return this.internalDocument.errors.map(YAMLErrorToYamlDocDiagnostics);
|
||||
}
|
||||
get warnings() {
|
||||
return this.internalDocument.warnings.map(YAMLErrorToYamlDocDiagnostics);
|
||||
}
|
||||
getNodeFromPosition(positionOffset, textBuffer, configuredIndentation) {
|
||||
const position = textBuffer.getPosition(positionOffset);
|
||||
const lineContent = textBuffer.getLineContent(position.line);
|
||||
if (lineContent.trim().length === 0) {
|
||||
return [this.findClosestNode(positionOffset, textBuffer, configuredIndentation), true];
|
||||
}
|
||||
const textAfterPosition = lineContent.substring(position.character);
|
||||
const spacesAfterPositionMatch = textAfterPosition.match(/^([ ]+)\n?$/);
|
||||
const areOnlySpacesAfterPosition = !!spacesAfterPositionMatch;
|
||||
const countOfSpacesAfterPosition = spacesAfterPositionMatch?.[1].length;
|
||||
let closestNode;
|
||||
(0, yaml_1.visit)(this.internalDocument, (key, node) => {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
const range = node.range;
|
||||
if (!range) {
|
||||
return;
|
||||
}
|
||||
const isNullNodeOnTheLine = () => areOnlySpacesAfterPosition &&
|
||||
positionOffset + countOfSpacesAfterPosition === range[2] &&
|
||||
(0, yaml_1.isScalar)(node) &&
|
||||
node.value === null;
|
||||
if ((range[0] <= positionOffset && range[1] >= positionOffset) || isNullNodeOnTheLine()) {
|
||||
closestNode = node;
|
||||
}
|
||||
else {
|
||||
return yaml_1.visit.SKIP;
|
||||
}
|
||||
});
|
||||
return [closestNode, false];
|
||||
}
|
||||
findClosestNode(offset, textBuffer, configuredIndentation) {
|
||||
let offsetDiff = this.internalDocument.range[2];
|
||||
let maxOffset = this.internalDocument.range[0];
|
||||
let closestNode;
|
||||
(0, yaml_1.visit)(this.internalDocument, (key, node) => {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
const range = node.range;
|
||||
if (!range) {
|
||||
return;
|
||||
}
|
||||
const diff = range[1] - offset;
|
||||
if (maxOffset <= range[0] && diff <= 0 && Math.abs(diff) <= offsetDiff) {
|
||||
offsetDiff = Math.abs(diff);
|
||||
maxOffset = range[0];
|
||||
closestNode = node;
|
||||
}
|
||||
});
|
||||
const position = textBuffer.getPosition(offset);
|
||||
const lineContent = textBuffer.getLineContent(position.line);
|
||||
const indentation = (0, strings_1.getIndentation)(lineContent, position.character);
|
||||
if ((0, yaml_1.isScalar)(closestNode) && closestNode.value === null) {
|
||||
return closestNode;
|
||||
}
|
||||
if (indentation === position.character) {
|
||||
closestNode = this.getProperParentByIndentation(indentation, closestNode, textBuffer, '', configuredIndentation);
|
||||
}
|
||||
return closestNode;
|
||||
}
|
||||
getProperParentByIndentation(indentation, node, textBuffer, currentLine, configuredIndentation, rootParent) {
|
||||
if (!node) {
|
||||
return this.internalDocument.contents;
|
||||
}
|
||||
configuredIndentation = !configuredIndentation ? 2 : configuredIndentation;
|
||||
if ((0, yaml_1.isNode)(node) && node.range) {
|
||||
const position = textBuffer.getPosition(node.range[0]);
|
||||
const lineContent = textBuffer.getLineContent(position.line);
|
||||
currentLine = currentLine === '' ? lineContent.trim() : currentLine;
|
||||
if (currentLine.startsWith('-') && indentation === configuredIndentation && currentLine === lineContent.trim()) {
|
||||
position.character += indentation;
|
||||
}
|
||||
if (position.character > indentation && position.character > 0) {
|
||||
const parent = this.getParent(node);
|
||||
if (parent) {
|
||||
return this.getProperParentByIndentation(indentation, parent, textBuffer, currentLine, configuredIndentation, rootParent);
|
||||
}
|
||||
}
|
||||
else if (position.character < indentation) {
|
||||
const parent = this.getParent(node);
|
||||
if ((0, yaml_1.isPair)(parent) && (0, yaml_1.isNode)(parent.value)) {
|
||||
return parent.value;
|
||||
}
|
||||
else if ((0, yaml_1.isPair)(rootParent) && (0, yaml_1.isNode)(rootParent.value)) {
|
||||
return rootParent.value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
else if ((0, yaml_1.isPair)(node)) {
|
||||
rootParent = node;
|
||||
const parent = this.getParent(node);
|
||||
return this.getProperParentByIndentation(indentation, parent, textBuffer, currentLine, configuredIndentation, rootParent);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
getParent(node) {
|
||||
return (0, yamlAstUtils_1.getParent)(this.internalDocument, node);
|
||||
}
|
||||
}
|
||||
exports.SingleYAMLDocument = SingleYAMLDocument;
|
||||
/**
|
||||
* Contains the SingleYAMLDocuments, to be passed
|
||||
* to the `parseYAML` caller.
|
||||
*/
|
||||
class YAMLDocument {
|
||||
constructor(documents, tokens) {
|
||||
this.documents = documents;
|
||||
this.tokens = tokens;
|
||||
this.errors = [];
|
||||
this.warnings = [];
|
||||
}
|
||||
}
|
||||
exports.YAMLDocument = YAMLDocument;
|
||||
class YamlDocuments {
|
||||
constructor() {
|
||||
// a mapping of URIs to cached documents
|
||||
this.cache = new Map();
|
||||
}
|
||||
/**
|
||||
* Get cached YAMLDocument
|
||||
* @param document TextDocument to parse
|
||||
* @param parserOptions YAML parserOptions
|
||||
* @param addRootObject if true and document is empty add empty object {} to force schema usage
|
||||
* @returns the YAMLDocument
|
||||
*/
|
||||
getYamlDocument(document, parserOptions, addRootObject = false) {
|
||||
this.ensureCache(document, parserOptions ?? yamlParser07_1.defaultOptions, addRootObject);
|
||||
return this.cache.get(document.uri).document;
|
||||
}
|
||||
/**
|
||||
* For test purpose only!
|
||||
*/
|
||||
clear() {
|
||||
this.cache.clear();
|
||||
}
|
||||
ensureCache(document, parserOptions, addRootObject) {
|
||||
const key = document.uri;
|
||||
if (!this.cache.has(key)) {
|
||||
this.cache.set(key, { version: -1, document: new YAMLDocument([], []), parserOptions: yamlParser07_1.defaultOptions });
|
||||
}
|
||||
const cacheEntry = this.cache.get(key);
|
||||
if (cacheEntry.version !== document.version ||
|
||||
(parserOptions.customTags && !(0, arrUtils_1.isArrayEqual)(cacheEntry.parserOptions.customTags, parserOptions.customTags))) {
|
||||
let text = document.getText();
|
||||
// if text is contains only whitespace wrap all text in object to force schema selection
|
||||
if (addRootObject && !/\S/.test(text)) {
|
||||
text = `{${text}}`;
|
||||
}
|
||||
const doc = (0, yamlParser07_1.parse)(text, parserOptions, document);
|
||||
cacheEntry.document = doc;
|
||||
cacheEntry.version = document.version;
|
||||
cacheEntry.parserOptions = parserOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.YamlDocuments = YamlDocuments;
|
||||
exports.yamlDocumentsCache = new YamlDocuments();
|
||||
function YAMLErrorToYamlDocDiagnostics(error) {
|
||||
return {
|
||||
message: error.message,
|
||||
location: {
|
||||
start: error.pos[0],
|
||||
end: error.pos[1],
|
||||
toLineEnd: true,
|
||||
},
|
||||
severity: 1,
|
||||
code: vscode_json_languageservice_1.ErrorCode.Undefined,
|
||||
};
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=yaml-documents.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
import { YAMLDocument, SingleYAMLDocument } from './yaml-documents';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
export { YAMLDocument, SingleYAMLDocument };
|
||||
export type YamlVersion = '1.1' | '1.2';
|
||||
export interface ParserOptions {
|
||||
customTags: string[];
|
||||
yamlVersion: YamlVersion;
|
||||
}
|
||||
export declare const defaultOptions: ParserOptions;
|
||||
/**
|
||||
* `yaml-ast-parser-custom-tags` parses the AST and
|
||||
* returns YAML AST nodes, which are then formatted
|
||||
* for consumption via the language server.
|
||||
*/
|
||||
export declare function parse(text: string, parserOptions?: ParserOptions, document?: TextDocument): YAMLDocument;
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Copyright (c) Adam Voss. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "yaml", "./yaml-documents", "./custom-tag-provider", "../utils/textBuffer"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parse = exports.defaultOptions = exports.SingleYAMLDocument = exports.YAMLDocument = void 0;
|
||||
const yaml_1 = require("yaml");
|
||||
const yaml_documents_1 = require("./yaml-documents");
|
||||
Object.defineProperty(exports, "YAMLDocument", { enumerable: true, get: function () { return yaml_documents_1.YAMLDocument; } });
|
||||
Object.defineProperty(exports, "SingleYAMLDocument", { enumerable: true, get: function () { return yaml_documents_1.SingleYAMLDocument; } });
|
||||
const custom_tag_provider_1 = require("./custom-tag-provider");
|
||||
const textBuffer_1 = require("../utils/textBuffer");
|
||||
exports.defaultOptions = {
|
||||
customTags: [],
|
||||
yamlVersion: '1.2',
|
||||
};
|
||||
/**
|
||||
* `yaml-ast-parser-custom-tags` parses the AST and
|
||||
* returns YAML AST nodes, which are then formatted
|
||||
* for consumption via the language server.
|
||||
*/
|
||||
function parse(text, parserOptions = exports.defaultOptions, document) {
|
||||
const options = {
|
||||
strict: false,
|
||||
customTags: (0, custom_tag_provider_1.getCustomTags)(parserOptions.customTags),
|
||||
version: parserOptions.yamlVersion ?? exports.defaultOptions.yamlVersion,
|
||||
keepSourceTokens: true,
|
||||
};
|
||||
const composer = new yaml_1.Composer(options);
|
||||
const lineCounter = new yaml_1.LineCounter();
|
||||
let isLastLineEmpty = false;
|
||||
if (document) {
|
||||
const textBuffer = new textBuffer_1.TextBuffer(document);
|
||||
const position = textBuffer.getPosition(text.length);
|
||||
const lineContent = textBuffer.getLineContent(position.line);
|
||||
isLastLineEmpty = lineContent.trim().length === 0;
|
||||
}
|
||||
const parser = isLastLineEmpty ? new yaml_1.Parser() : new yaml_1.Parser(lineCounter.addNewLine);
|
||||
const tokens = parser.parse(text);
|
||||
const tokensArr = Array.from(tokens);
|
||||
const docs = composer.compose(tokensArr, true, text.length);
|
||||
// Generate the SingleYAMLDocs from the AST nodes
|
||||
const yamlDocs = Array.from(docs, (doc) => parsedDocToSingleYAMLDocument(doc, lineCounter));
|
||||
// Consolidate the SingleYAMLDocs
|
||||
return new yaml_documents_1.YAMLDocument(yamlDocs, tokensArr);
|
||||
}
|
||||
exports.parse = parse;
|
||||
function parsedDocToSingleYAMLDocument(parsedDoc, lineCounter) {
|
||||
const syd = new yaml_documents_1.SingleYAMLDocument(lineCounter);
|
||||
syd.internalDocument = parsedDoc;
|
||||
return syd;
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=yamlParser07.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlParser07.js","sourceRoot":"","sources":["../../../../src/languageservice/parser/yamlParser07.ts"],"names":[],"mappings":"AAAA;;;;gGAIgG;;;;;;;;;;;;;IAEhG,+BAA6G;IAC7G,qDAAoE;IAK3D,6FALA,6BAAY,OAKA;IAAE,mGALA,mCAAkB,OAKA;IAJzC,+DAAsD;IAEtD,oDAAiD;IASpC,QAAA,cAAc,GAAkB;QAC3C,UAAU,EAAE,EAAE;QAC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AAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,6BAA6B,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;QAElH,iCAAiC;QACjC,OAAO,IAAI,6BAAY,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC/C,CAAC;IAzBD,sBAyBC;IAED,SAAS,6BAA6B,CAAC,SAAmB,EAAE,WAAwB;QAClF,MAAM,GAAG,GAAG,IAAI,mCAAkB,CAAC,WAAW,CAAC,CAAC;QAChD,GAAG,CAAC,gBAAgB,GAAG,SAAS,CAAC;QACjC,OAAO,GAAG,CAAC;IACb,CAAC"}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import { SingleYAMLDocument } from '../parser/yamlParser07';
|
||||
import { JSONDocument } from '../parser/jsonDocument';
|
||||
import { ResolvedSchema } from 'vscode-json-languageservice/lib/umd/services/jsonSchemaService';
|
||||
/**
|
||||
* Retrieve schema by auto-detecting the Kubernetes GroupVersionKind (GVK) from the document.
|
||||
* If there is no definition for the GVK in the main kubernetes schema,
|
||||
* the schema is then retrieved from the CRD catalog.
|
||||
* Public for testing purpose, not part of the API.
|
||||
* @param doc
|
||||
* @param crdCatalogURI The URL of the CRD catalog to retrieve the schema from
|
||||
* @param kubernetesSchema The main kubernetes schema, if it includes a definition for the GVK it will be used
|
||||
*/
|
||||
export declare function autoDetectKubernetesSchemaFromDocument(doc: SingleYAMLDocument | JSONDocument, crdCatalogURI: string, kubernetesSchema: ResolvedSchema): string | undefined;
|
||||
/**
|
||||
* Retrieve the group, version and kind from the document.
|
||||
* Public for testing purpose, not part of the API.
|
||||
* @param doc
|
||||
*/
|
||||
export declare function getGroupVersionKindFromDocument(doc: SingleYAMLDocument | JSONDocument): {
|
||||
group: string;
|
||||
version: string;
|
||||
kind: string;
|
||||
} | undefined;
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "../parser/yamlParser07"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getGroupVersionKindFromDocument = exports.autoDetectKubernetesSchemaFromDocument = void 0;
|
||||
const yamlParser07_1 = require("../parser/yamlParser07");
|
||||
/**
|
||||
* Retrieve schema by auto-detecting the Kubernetes GroupVersionKind (GVK) from the document.
|
||||
* If there is no definition for the GVK in the main kubernetes schema,
|
||||
* the schema is then retrieved from the CRD catalog.
|
||||
* Public for testing purpose, not part of the API.
|
||||
* @param doc
|
||||
* @param crdCatalogURI The URL of the CRD catalog to retrieve the schema from
|
||||
* @param kubernetesSchema The main kubernetes schema, if it includes a definition for the GVK it will be used
|
||||
*/
|
||||
function autoDetectKubernetesSchemaFromDocument(doc, crdCatalogURI, kubernetesSchema) {
|
||||
const res = getGroupVersionKindFromDocument(doc);
|
||||
if (!res) {
|
||||
return undefined;
|
||||
}
|
||||
const { group, version, kind } = res;
|
||||
if (!group || !version || !kind) {
|
||||
return undefined;
|
||||
}
|
||||
const k8sSchema = kubernetesSchema.schema;
|
||||
const kubernetesBuildIns = (k8sSchema.oneOf || [])
|
||||
.map((s) => {
|
||||
if (typeof s === 'boolean') {
|
||||
return undefined;
|
||||
}
|
||||
return s._$ref || s.$ref;
|
||||
})
|
||||
.filter((ref) => ref)
|
||||
.map((ref) => ref.replace('_definitions.json#/definitions/', '').toLowerCase());
|
||||
const groupWithoutK8sIO = group.replace('.k8s.io', '');
|
||||
const k8sTypeName = `io.k8s.api.${groupWithoutK8sIO.toLowerCase()}.${version.toLowerCase()}.${kind.toLowerCase()}`;
|
||||
if (kubernetesBuildIns.includes(k8sTypeName)) {
|
||||
return undefined;
|
||||
}
|
||||
if (k8sTypeName.includes('openshift.io')) {
|
||||
return `${crdCatalogURI}/openshift/v4.15-strict/${kind.toLowerCase()}_${group.toLowerCase()}_${version.toLowerCase()}.json`;
|
||||
}
|
||||
const schemaURL = `${crdCatalogURI}/${group.toLowerCase()}/${kind.toLowerCase()}_${version.toLowerCase()}.json`;
|
||||
return schemaURL;
|
||||
}
|
||||
exports.autoDetectKubernetesSchemaFromDocument = autoDetectKubernetesSchemaFromDocument;
|
||||
/**
|
||||
* Retrieve the group, version and kind from the document.
|
||||
* Public for testing purpose, not part of the API.
|
||||
* @param doc
|
||||
*/
|
||||
function getGroupVersionKindFromDocument(doc) {
|
||||
if (doc instanceof yamlParser07_1.SingleYAMLDocument) {
|
||||
try {
|
||||
const rootJSON = doc.root.internalNode.toJSON();
|
||||
if (!rootJSON) {
|
||||
return undefined;
|
||||
}
|
||||
const groupVersion = rootJSON['apiVersion'];
|
||||
if (!groupVersion) {
|
||||
return undefined;
|
||||
}
|
||||
const [group, version] = groupVersion.split('/');
|
||||
if (!group || !version) {
|
||||
return undefined;
|
||||
}
|
||||
const kind = rootJSON['kind'];
|
||||
if (!kind) {
|
||||
return undefined;
|
||||
}
|
||||
return { group, version, kind };
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Error parsing YAML document:', error);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
exports.getGroupVersionKindFromDocument = getGroupVersionKindFromDocument;
|
||||
});
|
||||
//# sourceMappingURL=crdUtil.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"crdUtil.js","sourceRoot":"","sources":["../../../../src/languageservice/services/crdUtil.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,yDAA4D;IAM5D;;;;;;;;OAQG;IACH,SAAgB,sCAAsC,CACpD,GAAsC,EACtC,aAAqB,EACrB,gBAAgC;QAEhC,MAAM,GAAG,GAAG,+BAA+B,CAAC,GAAG,CAAC,CAAC;QACjD,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,EAAE,KAAK,EAA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OAAO,CAAC,WAAW,EAAE,OAAO,CAAC;QAChH,OAAO,SAAS,CAAC;IACnB,CAAC;IArCD,wFAqCC;IAED;;;;OAIG;IACH,SAAgB,+BAA+B,CAC7C,GAAsC;QAEtC,IAAI,GAAG,YAAY,iCAAkB,EAAE;YACrC,IAAI;gBACF,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;gBAChD,IAAI,CAAC,QAAQ,EAAE;oBACb,OAAO,SAAS,CAAC;iBAClB;gBAED,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;gBAC5C,IAAI,CAAC,YAAY,EAAE;oBACjB,OAAO,SAAS,CAAC;iBAClB;gBAED,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACjD,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE;oBACtB,OAAO,SAAS,CAAC;iBAClB;gBAED,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;gBAC9B,IAAI,CAAC,IAAI,EAAE;oBACT,OAAO,SAAS,CAAC;iBAClB;gBAED,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;aACjC;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;gBACrD,OAAO,SAAS,CAAC;aAClB;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAhCD,0EAgCC"}
|
||||
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
import { SymbolInformation, DocumentSymbol } from 'vscode-languageserver-types';
|
||||
import { YAMLSchemaService } from './yamlSchemaService';
|
||||
import { DocumentSymbolsContext } from 'vscode-json-languageservice/lib/umd/jsonLanguageTypes';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Telemetry } from '../telemetry';
|
||||
export declare class YAMLDocumentSymbols {
|
||||
private readonly telemetry?;
|
||||
private jsonDocumentSymbols;
|
||||
constructor(schemaService: YAMLSchemaService, telemetry?: Telemetry);
|
||||
findDocumentSymbols(document: TextDocument, context?: DocumentSymbolsContext): SymbolInformation[];
|
||||
findHierarchicalDocumentSymbols(document: TextDocument, context?: DocumentSymbolsContext): DocumentSymbol[];
|
||||
}
|
||||
Generated
Vendored
+81
@@ -0,0 +1,81 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. 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.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-json-languageservice/lib/umd/services/jsonDocumentSymbols", "../parser/yaml-documents", "yaml"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YAMLDocumentSymbols = void 0;
|
||||
const jsonDocumentSymbols_1 = require("vscode-json-languageservice/lib/umd/services/jsonDocumentSymbols");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
const yaml_1 = require("yaml");
|
||||
class YAMLDocumentSymbols {
|
||||
constructor(schemaService, telemetry) {
|
||||
this.telemetry = telemetry;
|
||||
this.jsonDocumentSymbols = new jsonDocumentSymbols_1.JSONDocumentSymbols(schemaService);
|
||||
// override 'getKeyLabel' to handle complex mapping
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
this.jsonDocumentSymbols.getKeyLabel = (property) => {
|
||||
const keyNode = property.keyNode.internalNode;
|
||||
let name = '';
|
||||
if ((0, yaml_1.isMap)(keyNode)) {
|
||||
name = '{}';
|
||||
}
|
||||
else if ((0, yaml_1.isSeq)(keyNode)) {
|
||||
name = '[]';
|
||||
}
|
||||
else {
|
||||
name = keyNode.source;
|
||||
}
|
||||
return name;
|
||||
};
|
||||
}
|
||||
findDocumentSymbols(document, context = { resultLimit: Number.MAX_VALUE }) {
|
||||
let results = [];
|
||||
try {
|
||||
const doc = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
if (!doc || doc['documents'].length === 0) {
|
||||
return null;
|
||||
}
|
||||
for (const yamlDoc of doc['documents']) {
|
||||
if (yamlDoc.root) {
|
||||
results = results.concat(this.jsonDocumentSymbols.findDocumentSymbols(document, yamlDoc, context));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.documentSymbols.error', err);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
findHierarchicalDocumentSymbols(document, context = { resultLimit: Number.MAX_VALUE }) {
|
||||
let results = [];
|
||||
try {
|
||||
const doc = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
if (!doc || doc['documents'].length === 0) {
|
||||
return null;
|
||||
}
|
||||
for (const yamlDoc of doc['documents']) {
|
||||
if (yamlDoc.root) {
|
||||
results = results.concat(this.jsonDocumentSymbols.findDocumentSymbols2(document, yamlDoc, context));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.hierarchicalDocumentSymbols.error', err);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
exports.YAMLDocumentSymbols = YAMLDocumentSymbols;
|
||||
});
|
||||
//# sourceMappingURL=documentSymbols.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"documentSymbols.js","sourceRoot":"","sources":["../../../../src/languageservice/services/documentSymbols.ts"],"names":[],"mappings":"AAAA;;;;gGAIgG;;;;;;;;;;;;;IAIhG,0GAAuG;IAGvG,6DAA8D;IAE9D,+BAA0C;IAE1C,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,CAAC,SAAS,EAAE,SAAS,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC;aAC9D;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QAEM,+BAA+B,CACpC,QAAsB,EACtB,UAAkC,EAAE,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE;YAEnE,IAAI,OAAO,GAAG,EAAE,CAAC;YACjB,IAAI;gBACF,MAAM,GAAG,GAAG,mCAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;gBACzD,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;oBACzC,OAAO,IAAI,CAAC;iBACb;gBAED,KAAK,MAAM,OAAO,IAAI,GAAG,CAAC,WAAW,CAAC,EAAE;oBACtC,IAAI,OAAO,CAAC,IAAI,EAAE;wBAChB,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;qBACrG;iBACF;aACF;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,wCAAwC,EAAE,GAAG,CAAC,CAAC;aAC1E;YAED,OAAO,OAAO,CAAC;QACjB,CAAC;KACF;IArED,kDAqEC"}
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import { SingleYAMLDocument } from '../parser/yamlParser07';
|
||||
import { JSONDocument } from '../parser/jsonDocument';
|
||||
/**
|
||||
* Retrieve schema if declared as modeline.
|
||||
* Public for testing purpose, not part of the API.
|
||||
* @param doc
|
||||
*/
|
||||
export declare function getSchemaFromModeline(doc: SingleYAMLDocument | JSONDocument): string;
|
||||
export declare function isModeline(lineText: string): boolean;
|
||||
Generated
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "../parser/yamlParser07"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isModeline = exports.getSchemaFromModeline = void 0;
|
||||
const yamlParser07_1 = require("../parser/yamlParser07");
|
||||
/**
|
||||
* Retrieve schema if declared as modeline.
|
||||
* Public for testing purpose, not part of the API.
|
||||
* @param doc
|
||||
*/
|
||||
function getSchemaFromModeline(doc) {
|
||||
if (doc instanceof yamlParser07_1.SingleYAMLDocument) {
|
||||
const yamlLanguageServerModeline = doc.lineComments.find((lineComment) => {
|
||||
return isModeline(lineComment);
|
||||
});
|
||||
if (yamlLanguageServerModeline != undefined) {
|
||||
const schemaMatchs = yamlLanguageServerModeline.match(/\$schema=\S+/g);
|
||||
if (schemaMatchs !== null && schemaMatchs.length >= 1) {
|
||||
if (schemaMatchs.length >= 2) {
|
||||
console.log('Several $schema attributes have been found on the yaml-language-server modeline. The first one will be picked.');
|
||||
}
|
||||
return schemaMatchs[0].substring('$schema='.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
exports.getSchemaFromModeline = getSchemaFromModeline;
|
||||
function isModeline(lineText) {
|
||||
const matchModeline = lineText.match(/^#\s+yaml-language-server\s*:/g);
|
||||
return matchModeline !== null && matchModeline.length === 1;
|
||||
}
|
||||
exports.isModeline = isModeline;
|
||||
});
|
||||
//# sourceMappingURL=modelineUtil.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"modelineUtil.js","sourceRoot":"","sources":["../../../../src/languageservice/services/modelineUtil.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAEhG,yDAA4D;IAG5D;;;;OAIG;IACH,SAAgB,qBAAqB,CAAC,GAAsC;QAC1E,IAAI,GAAG,YAAY,iCAAkB,EAAE;YACrC,MAAM,0BAA0B,GAAG,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;gBACvE,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;YACjC,CAAC,CAAC,CAAC;YACH,IAAI,0BAA0B,IAAI,SAAS,EAAE;gBAC3C,MAAM,YAAY,GAAG,0BAA0B,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;gBACvE,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;oBACrD,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE;wBAC5B,OAAO,CAAC,GAAG,CACT,gHAAgH,CACjH,CAAC;qBACH;oBACD,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;iBACrD;aACF;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAlBD,sDAkBC;IAED,SAAgB,UAAU,CAAC,QAAgB;QACzC,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACvE,OAAO,aAAa,KAAK,IAAI,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC;IAC9D,CAAC;IAHD,gCAGC"}
|
||||
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
import { Connection, WorkspaceFolder } from 'vscode-languageserver';
|
||||
import { URI } from 'vscode-uri';
|
||||
import { WorkspaceContextService } from '../yamlLanguageService';
|
||||
export interface FileSystem {
|
||||
readFile(fsPath: string, encoding?: string): Promise<string>;
|
||||
}
|
||||
/**
|
||||
* Handles schema content requests given the schema URI
|
||||
* @param uri can be a local file, vscode request, http(s) request or a custom request
|
||||
*/
|
||||
export declare const schemaRequestHandler: (connection: Connection, uri: string, workspaceFolders: WorkspaceFolder[], workspaceRoot: URI, useVSCodeContentRequest: boolean, fs: FileSystem, isWeb: boolean) => Promise<string>;
|
||||
export declare const workspaceContext: WorkspaceContextService;
|
||||
Generated
Vendored
+98
@@ -0,0 +1,98 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "path", "request-light", "url", "vscode-languageserver", "vscode-uri", "../../requestTypes", "../utils/paths"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.workspaceContext = exports.schemaRequestHandler = void 0;
|
||||
const path_1 = require("path");
|
||||
const request_light_1 = require("request-light");
|
||||
const URL = require("url");
|
||||
const vscode_languageserver_1 = require("vscode-languageserver");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const requestTypes_1 = require("../../requestTypes");
|
||||
const paths_1 = require("../utils/paths");
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
var FSReadUri;
|
||||
(function (FSReadUri) {
|
||||
FSReadUri.type = new vscode_languageserver_1.RequestType('fs/readUri');
|
||||
})(FSReadUri || (FSReadUri = {}));
|
||||
/**
|
||||
* Handles schema content requests given the schema URI
|
||||
* @param uri can be a local file, vscode request, http(s) request or a custom request
|
||||
*/
|
||||
const schemaRequestHandler = async (connection, uri, workspaceFolders, workspaceRoot, useVSCodeContentRequest, fs, isWeb) => {
|
||||
if (!uri) {
|
||||
return Promise.reject('No schema specified');
|
||||
}
|
||||
// If the requested schema URI is a relative file path
|
||||
// Convert it into a proper absolute path URI
|
||||
if ((0, paths_1.isRelativePath)(uri)) {
|
||||
// HACK: the fs/readUri extension is only available with vscode-yaml,
|
||||
// and this fix is specific to vscode-yaml on web, so don't use it in other cases
|
||||
if (workspaceFolders.length === 1 && isWeb) {
|
||||
const wsUri = vscode_uri_1.URI.parse(workspaceFolders[0].uri);
|
||||
const wsDirname = wsUri.path;
|
||||
const modifiedUri = wsUri.with({ path: (0, path_1.join)(wsDirname, uri) });
|
||||
try {
|
||||
return connection.sendRequest(FSReadUri.type, modifiedUri.toString());
|
||||
}
|
||||
catch (e) {
|
||||
connection.window.showErrorMessage(`failed to get content of '${modifiedUri}': ${e}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
uri = (0, paths_1.relativeToAbsolutePath)(workspaceFolders, workspaceRoot, uri);
|
||||
}
|
||||
}
|
||||
let scheme = vscode_uri_1.URI.parse(uri).scheme.toLowerCase();
|
||||
// test if uri is windows path, ie starts with 'c:\'
|
||||
if (/^[a-z]:[\\/]/i.test(uri)) {
|
||||
const winUri = vscode_uri_1.URI.file(uri);
|
||||
scheme = winUri.scheme.toLowerCase();
|
||||
uri = winUri.toString();
|
||||
}
|
||||
// If the requested schema is a local file, read and return the file contents
|
||||
if (scheme === 'file') {
|
||||
const fsPath = vscode_uri_1.URI.parse(uri).fsPath;
|
||||
return fs.readFile(fsPath, 'UTF-8').catch(() => {
|
||||
// If there was an error reading the file, return empty error message
|
||||
// Otherwise return the file contents as a string
|
||||
return '';
|
||||
});
|
||||
}
|
||||
// HTTP(S) requests are sent and the response result is either the schema content or an error
|
||||
if (scheme === 'http' || scheme === 'https') {
|
||||
// If we are running inside of VSCode we need to make a content request. This content request
|
||||
// will make it so that schemas behind VPN's will resolve correctly
|
||||
if (useVSCodeContentRequest) {
|
||||
return connection.sendRequest(requestTypes_1.VSCodeContentRequest.type, uri).then((responseText) => {
|
||||
return responseText;
|
||||
}, (error) => {
|
||||
return Promise.reject(error.message);
|
||||
});
|
||||
}
|
||||
// Send the HTTP(S) schema content request and return the result
|
||||
const headers = { 'Accept-Encoding': 'gzip, deflate' };
|
||||
return (0, request_light_1.xhr)({ url: uri, followRedirects: 5, headers }).then((response) => {
|
||||
return response.responseText;
|
||||
}, (error) => {
|
||||
return Promise.reject(error.responseText || (0, request_light_1.getErrorStatusDescription)(error.status) || error.toString());
|
||||
});
|
||||
}
|
||||
// Neither local file nor vscode, nor HTTP(S) schema request, so send it off as a custom request
|
||||
return connection.sendRequest(requestTypes_1.CustomSchemaContentRequest.type, uri);
|
||||
};
|
||||
exports.schemaRequestHandler = schemaRequestHandler;
|
||||
exports.workspaceContext = {
|
||||
resolveRelativePath: (relativePath, resource) => {
|
||||
return URL.resolve(resource, relativePath);
|
||||
},
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=schemaRequestHandler.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"schemaRequestHandler.js","sourceRoot":"","sources":["../../../../src/languageservice/services/schemaRequestHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,+BAA4B;IAC5B,iDAA4E;IAC5E,2BAA2B;IAC3B,iEAAiF;IACjF,2CAAiC;IACjC,qDAAsF;IACtF,0CAAwE;IAOxE,2DAA2D;IAC3D,IAAU,SAAS,CAElB;IAFD,WAAU,SAAS;QACJ,cAAI,GAAyC,IAAI,mCAAW,CAAC,YAAY,CAAC,CAAC;IAC1F,CAAC,EAFS,SAAS,KAAT,SAAS,QAElB;IAED;;;OAGG;IACI,MAAM,oBAAoB,GAAG,KAAK,EACvC,UAAsB,EACtB,GAAW,EACX,gBAAmC,EACnC,aAAkB,EAClB,uBAAgC,EAChC,EAAc,EACd,KAAc,EACG,EAAE;QACnB,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;SAC9C;QAED,sDAAsD;QACtD,6CAA6C;QAC7C,IAAI,IAAA,sBAAc,EAAC,GAAG,CAAC,EAAE;YACvB,qEAAqE;YACrE,iFAAiF;YACjF,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,EAAE;gBAC1C,MAAM,KAAK,GAAG,gBAAG,CAAC,KAAK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
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Diagnostic } from 'vscode-languageserver-types';
|
||||
import { SingleYAMLDocument } from '../../parser/yaml-documents';
|
||||
import { AdditionalValidator } from './types';
|
||||
export declare class MapKeyOrderValidator implements AdditionalValidator {
|
||||
validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[];
|
||||
}
|
||||
Generated
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "yaml"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MapKeyOrderValidator = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_1 = require("yaml");
|
||||
class MapKeyOrderValidator {
|
||||
validate(document, yamlDoc) {
|
||||
const result = [];
|
||||
(0, yaml_1.visit)(yamlDoc.internalDocument, (key, node) => {
|
||||
if ((0, yaml_1.isMap)(node)) {
|
||||
for (let i = 1; i < node.items.length; i++) {
|
||||
if (compare(node.items[i - 1], node.items[i]) > 0) {
|
||||
const range = createRange(document, node.items[i - 1]);
|
||||
result.push(vscode_languageserver_types_1.Diagnostic.create(range, `Wrong ordering of key "${node.items[i - 1].key}" in mapping`, vscode_languageserver_types_1.DiagnosticSeverity.Error, 'mapKeyOrder'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
exports.MapKeyOrderValidator = MapKeyOrderValidator;
|
||||
function createRange(document, node) {
|
||||
const keySourceToken = node.key.srcToken;
|
||||
const start = keySourceToken.offset;
|
||||
const end = start + keySourceToken.source.length;
|
||||
return vscode_languageserver_types_1.Range.create(document.positionAt(start), document.positionAt(end));
|
||||
}
|
||||
function compare(thiz, that) {
|
||||
const thatKey = String(that.key);
|
||||
const thisKey = String(thiz.key);
|
||||
return thisKey.localeCompare(thatKey);
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=map-key-order.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"map-key-order.js","sourceRoot":"","sources":["../../../../../src/languageservice/services/validation/map-key-order.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAGhG,6EAAoF;IACpF,+BAAgD;IAKhD,MAAa,oBAAoB;QAC/B,QAAQ,CAAC,QAAsB,EAAE,OAA2B;YAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;YAElB,IAAA,YAAK,EAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBAC5C,IAAI,IAAA,YAAK,EAAC,IAAI,CAAC,EAAE;oBACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBAC1C,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;4BACjD,MAAM,KAAK,GAAG,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;4BACvD,MAAM,CAAC,IAAI,CACT,wCAAU,CAAC,MAAM,CACf,KAAK,EACL,0BAA0B,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,cAAc,EAC7D,gDAAkB,CAAC,KAAK,EACxB,aAAa,CACd,CACF,CAAC;4BACF,MAAM;yBACP;qBACF;iBACF;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;KACF;IAzBD,oDAyBC;IAED,SAAS,WAAW,CAAC,QAAsB,EAAE,IAAU;QACrD,MAAM,cAAc,GAAI,IAAI,CAAC,GAAY,CAAC,QAAuB,CAAC;QAClE,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC;QACpC,MAAM,GAAG,GAAG,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC;QACjD,OAAO,mCAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,SAAS,OAAO,CAAC,IAAU,EAAE,IAAU;QACrC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjC,OAAO,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC"}
|
||||
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Diagnostic } from 'vscode-languageserver-types';
|
||||
import { SingleYAMLDocument } from '../../parser/yaml-documents';
|
||||
export interface AdditionalValidator {
|
||||
validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[];
|
||||
}
|
||||
Generated
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
});
|
||||
//# sourceMappingURL=types.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/languageservice/services/validation/types.ts"],"names":[],"mappings":"AAAA;;;gGAGgG"}
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Diagnostic } from 'vscode-languageserver-types';
|
||||
import { SingleYAMLDocument } from '../../parser/yaml-documents';
|
||||
import { AdditionalValidator } from './types';
|
||||
export declare class UnusedAnchorsValidator implements AdditionalValidator {
|
||||
validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[];
|
||||
private getAnchorNode;
|
||||
}
|
||||
Generated
Vendored
+105
@@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "yaml", "../../utils/yamlAstUtils", "@vscode/l10n"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UnusedAnchorsValidator = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_1 = require("yaml");
|
||||
const yamlAstUtils_1 = require("../../utils/yamlAstUtils");
|
||||
const l10n = require("@vscode/l10n");
|
||||
class UnusedAnchorsValidator {
|
||||
validate(document, yamlDoc) {
|
||||
const result = [];
|
||||
const anchors = new Set();
|
||||
const usedAnchors = new Set();
|
||||
const unIdentifiedAlias = new Set();
|
||||
const anchorParent = new Map();
|
||||
(0, yaml_1.visit)(yamlDoc.internalDocument, (key, node, path) => {
|
||||
if (!(0, yaml_1.isNode)(node)) {
|
||||
return;
|
||||
}
|
||||
if (((0, yaml_1.isCollection)(node) || (0, yaml_1.isScalar)(node)) && node.anchor) {
|
||||
anchors.add(node);
|
||||
anchorParent.set(node, path[path.length - 1]);
|
||||
}
|
||||
if ((0, yaml_1.isAlias)(node)) {
|
||||
if (!node.resolve(yamlDoc.internalDocument)) {
|
||||
unIdentifiedAlias.add(node);
|
||||
}
|
||||
else {
|
||||
usedAnchors.add(node.resolve(yamlDoc.internalDocument));
|
||||
}
|
||||
}
|
||||
});
|
||||
for (const anchor of anchors) {
|
||||
if (!usedAnchors.has(anchor)) {
|
||||
const aToken = this.getAnchorNode(anchorParent.get(anchor), anchor);
|
||||
if (aToken) {
|
||||
const range = vscode_languageserver_types_1.Range.create(document.positionAt(aToken.offset), document.positionAt(aToken.offset + aToken.source.length));
|
||||
const warningDiagnostic = vscode_languageserver_types_1.Diagnostic.create(range, l10n.t('Unused anchor "{0}"', aToken.source), vscode_languageserver_types_1.DiagnosticSeverity.Information, 0);
|
||||
warningDiagnostic.tags = [vscode_languageserver_types_1.DiagnosticTag.Unnecessary];
|
||||
result.push(warningDiagnostic);
|
||||
}
|
||||
}
|
||||
}
|
||||
unIdentifiedAlias.forEach((node) => {
|
||||
const nodeRange = node.range;
|
||||
if (nodeRange) {
|
||||
const startOffset = nodeRange[0];
|
||||
const endOffset = nodeRange[1];
|
||||
const range = vscode_languageserver_types_1.Range.create(document.positionAt(startOffset), document.positionAt(endOffset));
|
||||
const warningDiagnostic = vscode_languageserver_types_1.Diagnostic.create(range, l10n.t('Unresolved alias "{0}"', node.toString()), vscode_languageserver_types_1.DiagnosticSeverity.Information, 0);
|
||||
warningDiagnostic.tags = [vscode_languageserver_types_1.DiagnosticTag.Unnecessary];
|
||||
result.push(warningDiagnostic);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
getAnchorNode(parentNode, node) {
|
||||
if (parentNode && parentNode.srcToken) {
|
||||
const token = parentNode.srcToken;
|
||||
if ((0, yamlAstUtils_1.isCollectionItem)(token)) {
|
||||
return getAnchorFromCollectionItem(token);
|
||||
}
|
||||
else if (yaml_1.CST.isCollection(token)) {
|
||||
for (const t of token.items) {
|
||||
if (node.srcToken !== t.value)
|
||||
continue;
|
||||
const anchor = getAnchorFromCollectionItem(t);
|
||||
if (anchor) {
|
||||
return anchor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.UnusedAnchorsValidator = UnusedAnchorsValidator;
|
||||
function getAnchorFromCollectionItem(token) {
|
||||
for (const t of token.start) {
|
||||
if (t.type === 'anchor') {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
if (token.sep && Array.isArray(token.sep)) {
|
||||
for (const t of token.sep) {
|
||||
if (t.type === 'anchor') {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=unused-anchors.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"unused-anchors.js","sourceRoot":"","sources":["../../../../../src/languageservice/services/validation/unused-anchors.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAGhG,6EAAmG;IACnG,+BAAiH;IAIjH,2DAA4D;IAC5D,qCAAqC;IAErC,MAAa,sBAAsB;QACjC,QAAQ,CAAC,QAAsB,EAAE,OAA2B;YAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;YAClB,MAAM,OAAO,GAAG,IAAI,GAAG,EAA8B,CAAC;YACtD,MAAM,WAA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U;YACpD,IAAI,UAAU,IAAI,UAAU,CAAC,QAAQ,EAAE;gBACrC,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC;gBAClC,IAAI,IAAA,+BAAgB,EAAC,KAAK,CAAC,EAAE;oBAC3B,OAAO,2BAA2B,CAAC,KAAK,CAAC,CAAC;iBAC3C;qBAAM,IAAI,UAAG,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;oBAClC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE;wBAC3B,IAAI,IAAI,CAAC,QAAQ,KAAK,CAAC,CAAC,KAAK;4BAAE,SAAS;wBACxC,MAAM,MAAM,GAAG,2BAA2B,CAAC,CAAC,CAAC,CAAC;wBAC9C,IAAI,MAAM,EAAE;4BACV,OAAO,MAAM,CAAC;yBACf;qBACF;iBACF;aACF;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;KACF;IAhFD,wDAgFC;IACD,SAAS,2BAA2B,CAAC,KAAyB;QAC5D,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE;YAC3B,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACvB,OAAO,CAAC,CAAC;aACV;SACF;QACD,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YACzC,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,EAAE;gBACzB,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACvB,OAAO,CAAC,CAAC;iBACV;aACF;SACF;IACH,CAAC"}
|
||||
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Diagnostic } from 'vscode-languageserver-types';
|
||||
import { SingleYAMLDocument } from '../../parser/yaml-documents';
|
||||
import { LanguageSettings } from '../../yamlLanguageService';
|
||||
import { AdditionalValidator } from './types';
|
||||
export declare class YAMLStyleValidator implements AdditionalValidator {
|
||||
private forbidSequence;
|
||||
private forbidMapping;
|
||||
constructor(settings: LanguageSettings);
|
||||
validate(document: TextDocument, yamlDoc: SingleYAMLDocument): Diagnostic[];
|
||||
private getRangeOf;
|
||||
}
|
||||
Generated
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "yaml", "@vscode/l10n"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YAMLStyleValidator = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_1 = require("yaml");
|
||||
const l10n = require("@vscode/l10n");
|
||||
class YAMLStyleValidator {
|
||||
constructor(settings) {
|
||||
this.forbidMapping = settings.flowMapping === 'forbid';
|
||||
this.forbidSequence = settings.flowSequence === 'forbid';
|
||||
}
|
||||
validate(document, yamlDoc) {
|
||||
const result = [];
|
||||
(0, yaml_1.visit)(yamlDoc.internalDocument, (key, node) => {
|
||||
if (this.forbidMapping && (0, yaml_1.isMap)(node) && node.srcToken?.type === 'flow-collection') {
|
||||
result.push(vscode_languageserver_types_1.Diagnostic.create(this.getRangeOf(document, node.srcToken), l10n.t('Flow style mapping is forbidden'), vscode_languageserver_types_1.DiagnosticSeverity.Error, 'flowMap'));
|
||||
}
|
||||
if (this.forbidSequence && (0, yaml_1.isSeq)(node) && node.srcToken?.type === 'flow-collection') {
|
||||
result.push(vscode_languageserver_types_1.Diagnostic.create(this.getRangeOf(document, node.srcToken), l10n.t('Flow style sequence is forbidden'), vscode_languageserver_types_1.DiagnosticSeverity.Error, 'flowSeq'));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
getRangeOf(document, node) {
|
||||
const endOffset = node.end[0].offset;
|
||||
let endPosition = document.positionAt(endOffset);
|
||||
endPosition = { character: endPosition.character + 1, line: endPosition.line };
|
||||
return vscode_languageserver_types_1.Range.create(document.positionAt(node.start.offset), endPosition);
|
||||
}
|
||||
}
|
||||
exports.YAMLStyleValidator = YAMLStyleValidator;
|
||||
});
|
||||
//# sourceMappingURL=yaml-style.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yaml-style.js","sourceRoot":"","sources":["../../../../../src/languageservice/services/validation/yaml-style.ts"],"names":[],"mappings":";;;;;;;;;;;;IACA,6EAAoF;IACpF,+BAA2C;IAK3C,qCAAqC;IAErC,MAAa,kBAAkB;QAI7B,YAAY,QAA0B;YACpC,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,WAAW,KAAK,QAAQ,CAAC;YACvD,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC,YAAY,KAAK,QAAQ,CAAC;QAC3D,CAAC;QACD,QAAQ,CAAC,QAAsB,EAAE,OAA2B;YAC1D,MAAM,MAAM,GAAG,EAAE,CAAC;YAClB,IAAA,YAAK,EAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBAC5C,IAAI,IAAI,CAAC,aAAa,IAAI,IAAA,YAAK,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,KAAK,iBAAiB,EAAE;oBAClF,MAAM,CAAC,IAAI,CACT,wCAAU,CAAC,MAAM,CACf,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EACxC,IAAI,CAAC,CAAC,CAAC,iCAAiC,CAAC,EACzC,gDAAkB,CAAC,KAAK,EACxB,SAAS,CACV,CACF,CAAC;iBACH;gBACD,IAAI,IAAI,CAAC,cAAc,IAAI,IAAA,YAAK,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,KAAK,iBAAiB,EAAE;oBACnF,MAAM,CAAC,IAAI,CACT,wCAAU,CAAC,MAAM,CACf,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EACxC,IAAI,CAAC,CAAC,CAAC,kCAAkC,CAAC,EAC1C,gDAAkB,CAAC,KAAK,EACxB,SAAS,CACV,CACF,CAAC;iBACH;YACH,CAAC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;QAChB,CAAC;QAEO,UAAU,CAAC,QAAsB,EAAE,IAAoB;YAC7D,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACrC,IAAI,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;YACjD,WAAW,GAAG,EAAE,SAAS,EAAE,WAAW,CAAC,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;YAC/E,OAAO,mCAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;QAC3E,CAAC;KACF;IAzCD,gDAyCC"}
|
||||
Generated
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
import { CodeAction } from 'vscode-languageserver-types';
|
||||
import { ClientCapabilities, CodeActionParams } from 'vscode-languageserver-protocol';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { LanguageSettings } from '../yamlLanguageService';
|
||||
export declare class YamlCodeActions {
|
||||
private readonly clientCapabilities;
|
||||
private indentation;
|
||||
private lineWidth;
|
||||
constructor(clientCapabilities: ClientCapabilities);
|
||||
configure(settings: LanguageSettings, printWidth: number): void;
|
||||
getCodeAction(document: TextDocument, params: CodeActionParams): CodeAction[] | undefined;
|
||||
private getJumpToSchemaActions;
|
||||
private getTabToSpaceConverting;
|
||||
private getUnusedAnchorsDelete;
|
||||
private getConvertToBooleanActions;
|
||||
private getConvertToBlockStyleActions;
|
||||
private getConvertStringToBlockStyleActions;
|
||||
private getKeyOrderActions;
|
||||
/**
|
||||
* Check if diagnostic contains info for quick fix
|
||||
* Supports Enum/Const/Property mismatch
|
||||
*/
|
||||
private getPossibleQuickFixValues;
|
||||
private getQuickFixForPropertyOrValueMismatch;
|
||||
}
|
||||
Generated
Vendored
+356
@@ -0,0 +1,356 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "@vscode/l10n", "path", "vscode-json-languageservice", "vscode-languageserver-types", "yaml", "../../commands", "../utils/textBuffer", "../utils/yamlScalar", "../parser/schemaValidation/baseValidator", "../utils/strings", "../utils/arrUtils", "../parser/yaml-documents", "../utils/block-string-rewriter", "../utils/flow-style-rewriter"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YamlCodeActions = void 0;
|
||||
const l10n = require("@vscode/l10n");
|
||||
const path = require("path");
|
||||
const vscode_json_languageservice_1 = require("vscode-json-languageservice");
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_1 = require("yaml");
|
||||
const commands_1 = require("../../commands");
|
||||
const textBuffer_1 = require("../utils/textBuffer");
|
||||
const yamlScalar_1 = require("../utils/yamlScalar");
|
||||
const baseValidator_1 = require("../parser/schemaValidation/baseValidator");
|
||||
const strings_1 = require("../utils/strings");
|
||||
const arrUtils_1 = require("../utils/arrUtils");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
const block_string_rewriter_1 = require("../utils/block-string-rewriter");
|
||||
const flow_style_rewriter_1 = require("../utils/flow-style-rewriter");
|
||||
class YamlCodeActions {
|
||||
constructor(clientCapabilities) {
|
||||
this.clientCapabilities = clientCapabilities;
|
||||
this.indentation = ' ';
|
||||
this.lineWidth = 80;
|
||||
}
|
||||
configure(settings, printWidth) {
|
||||
this.indentation = settings.indentation;
|
||||
this.lineWidth = printWidth;
|
||||
}
|
||||
getCodeAction(document, params) {
|
||||
if (!params.context.diagnostics) {
|
||||
return;
|
||||
}
|
||||
const result = [];
|
||||
result.push(...this.getConvertToBooleanActions(params.context.diagnostics, document));
|
||||
result.push(...this.getJumpToSchemaActions(params.context.diagnostics));
|
||||
result.push(...this.getTabToSpaceConverting(params.context.diagnostics, document));
|
||||
result.push(...this.getUnusedAnchorsDelete(params.context.diagnostics, document));
|
||||
result.push(...this.getConvertToBlockStyleActions(params.context.diagnostics, document));
|
||||
result.push(...this.getConvertStringToBlockStyleActions(params.range, document));
|
||||
result.push(...this.getKeyOrderActions(params.context.diagnostics, document));
|
||||
result.push(...this.getQuickFixForPropertyOrValueMismatch(params.context.diagnostics, document));
|
||||
return result;
|
||||
}
|
||||
getJumpToSchemaActions(diagnostics) {
|
||||
const isOpenTextDocumentEnabled = this.clientCapabilities?.window?.showDocument?.support ?? false;
|
||||
if (!isOpenTextDocumentEnabled) {
|
||||
return [];
|
||||
}
|
||||
const schemaUriToDiagnostic = new Map();
|
||||
for (const diagnostic of diagnostics) {
|
||||
const schemaUri = diagnostic.data?.schemaUri || [];
|
||||
for (const schemaUriStr of schemaUri) {
|
||||
if (schemaUriStr) {
|
||||
if (!schemaUriToDiagnostic.has(schemaUriStr)) {
|
||||
schemaUriToDiagnostic.set(schemaUriStr, []);
|
||||
}
|
||||
schemaUriToDiagnostic.get(schemaUriStr).push(diagnostic);
|
||||
}
|
||||
}
|
||||
}
|
||||
const result = [];
|
||||
for (const schemaUri of schemaUriToDiagnostic.keys()) {
|
||||
const action = vscode_languageserver_types_1.CodeAction.create(l10n.t('Jump to schema location ({0})', path.basename(schemaUri)), vscode_languageserver_types_1.Command.create('JumpToSchema', commands_1.YamlCommands.JUMP_TO_SCHEMA, schemaUri));
|
||||
action.diagnostics = schemaUriToDiagnostic.get(schemaUri);
|
||||
result.push(action);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
getTabToSpaceConverting(diagnostics, document) {
|
||||
const result = [];
|
||||
const textBuff = new textBuffer_1.TextBuffer(document);
|
||||
const processedLine = [];
|
||||
for (const diag of diagnostics) {
|
||||
if (diag.message === 'Tabs are not allowed as indentation') {
|
||||
if (processedLine.includes(diag.range.start.line)) {
|
||||
continue;
|
||||
}
|
||||
const lineContent = textBuff.getLineContent(diag.range.start.line);
|
||||
let replacedTabs = 0;
|
||||
let newText = '';
|
||||
for (let i = diag.range.start.character; i <= diag.range.end.character; i++) {
|
||||
const char = lineContent.charAt(i);
|
||||
if (char !== '\t') {
|
||||
break;
|
||||
}
|
||||
replacedTabs++;
|
||||
newText += this.indentation;
|
||||
}
|
||||
processedLine.push(diag.range.start.line);
|
||||
let resultRange = diag.range;
|
||||
if (replacedTabs !== diag.range.end.character - diag.range.start.character) {
|
||||
resultRange = vscode_languageserver_types_1.Range.create(diag.range.start, vscode_languageserver_types_1.Position.create(diag.range.end.line, diag.range.start.character + replacedTabs));
|
||||
}
|
||||
result.push(vscode_languageserver_types_1.CodeAction.create(l10n.t('Convert Tab to Spaces'), createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.replace(resultRange, newText)]), vscode_languageserver_types_1.CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
if (result.length !== 0) {
|
||||
const replaceEdits = [];
|
||||
for (let i = 0; i <= textBuff.getLineCount(); i++) {
|
||||
const lineContent = textBuff.getLineContent(i);
|
||||
let replacedTabs = 0;
|
||||
let newText = '';
|
||||
for (let j = 0; j < lineContent.length; j++) {
|
||||
const char = lineContent.charAt(j);
|
||||
if (char !== ' ' && char !== '\t') {
|
||||
if (replacedTabs !== 0) {
|
||||
replaceEdits.push(vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(i, j - replacedTabs, i, j), newText));
|
||||
replacedTabs = 0;
|
||||
newText = '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (char === ' ' && replacedTabs !== 0) {
|
||||
replaceEdits.push(vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(i, j - replacedTabs, i, j), newText));
|
||||
replacedTabs = 0;
|
||||
newText = '';
|
||||
continue;
|
||||
}
|
||||
if (char === '\t') {
|
||||
newText += this.indentation;
|
||||
replacedTabs++;
|
||||
}
|
||||
}
|
||||
// line contains only tabs
|
||||
if (replacedTabs !== 0) {
|
||||
replaceEdits.push(vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(i, 0, i, textBuff.getLineLength(i)), newText));
|
||||
}
|
||||
}
|
||||
if (replaceEdits.length > 0) {
|
||||
result.push(vscode_languageserver_types_1.CodeAction.create(l10n.t('Convert all Tabs to Spaces'), createWorkspaceEdit(document.uri, replaceEdits), vscode_languageserver_types_1.CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
getUnusedAnchorsDelete(diagnostics, document) {
|
||||
const result = [];
|
||||
const buffer = new textBuffer_1.TextBuffer(document);
|
||||
for (const diag of diagnostics) {
|
||||
if (diag.message.startsWith('Unused anchor') && diag.source === baseValidator_1.YAML_SOURCE) {
|
||||
const range = vscode_languageserver_types_1.Range.create(diag.range.start, diag.range.end);
|
||||
const actual = buffer.getText(range);
|
||||
const lineContent = buffer.getLineContent(range.end.line);
|
||||
const lastWhitespaceChar = (0, strings_1.getFirstNonWhitespaceCharacterAfterOffset)(lineContent, range.end.character);
|
||||
range.end.character = lastWhitespaceChar;
|
||||
const action = vscode_languageserver_types_1.CodeAction.create(l10n.t('Delete unused anchor: {0}', actual), createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.del(range)]), vscode_languageserver_types_1.CodeActionKind.QuickFix);
|
||||
action.diagnostics = [diag];
|
||||
result.push(action);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
getConvertToBooleanActions(diagnostics, document) {
|
||||
const results = [];
|
||||
for (const diagnostic of diagnostics) {
|
||||
if (diagnostic.message === 'Incorrect type. Expected "boolean".') {
|
||||
const value = document.getText(diagnostic.range).toLocaleLowerCase();
|
||||
if (value === '"true"' || value === '"false"' || value === "'true'" || value === "'false'") {
|
||||
const newValue = value.includes('true') ? 'true' : 'false';
|
||||
results.push(vscode_languageserver_types_1.CodeAction.create(l10n.t('Convert to boolean'), createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.replace(diagnostic.range, newValue)]), vscode_languageserver_types_1.CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
getConvertToBlockStyleActions(diagnostics, document) {
|
||||
const results = [];
|
||||
for (const diagnostic of diagnostics) {
|
||||
if (diagnostic.code === 'flowMap' || diagnostic.code === 'flowSeq') {
|
||||
const node = getNodeForDiagnostic(document, diagnostic);
|
||||
if ((0, yaml_1.isMap)(node.internalNode) || (0, yaml_1.isSeq)(node.internalNode)) {
|
||||
const blockTypeDescription = (0, yaml_1.isMap)(node.internalNode) ? 'map' : 'sequence';
|
||||
const rewriter = new flow_style_rewriter_1.FlowStyleRewriter(this.indentation);
|
||||
results.push(vscode_languageserver_types_1.CodeAction.create(l10n.t('Convert to block style {0}', blockTypeDescription), createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.replace(diagnostic.range, rewriter.write(node))]), vscode_languageserver_types_1.CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
getConvertStringToBlockStyleActions(range, document) {
|
||||
const yamlDocument = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
const startOffset = range ? document.offsetAt(range.start) : 0;
|
||||
const endOffset = range ? document.offsetAt(range.end) : Infinity;
|
||||
const results = [];
|
||||
for (const singleYamlDocument of yamlDocument.documents) {
|
||||
const matchingNodes = [];
|
||||
(0, yaml_1.visit)(singleYamlDocument.internalDocument, (key, node) => {
|
||||
if ((0, yaml_1.isScalar)(node)) {
|
||||
if ((startOffset <= node.range[0] && node.range[2] <= endOffset) ||
|
||||
(node.range[0] <= startOffset && endOffset <= node.range[2])) {
|
||||
if (node.type === 'QUOTE_DOUBLE' || node.type === 'QUOTE_SINGLE') {
|
||||
if (typeof node.value === 'string' && (node.value.indexOf('\n') >= 0 || node.value.length > this.lineWidth)) {
|
||||
matchingNodes.push(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
for (const node of matchingNodes) {
|
||||
const range = vscode_languageserver_types_1.Range.create(document.positionAt(node.range[0]), document.positionAt(node.range[1]));
|
||||
const rewriter = new block_string_rewriter_1.BlockStringRewriter(this.indentation, this.lineWidth);
|
||||
const foldedBlockScalar = rewriter.writeFoldedBlockScalar(node);
|
||||
if (foldedBlockScalar !== null) {
|
||||
results.push(vscode_languageserver_types_1.CodeAction.create(l10n.t('Convert string to folded block string'), createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.replace(range, foldedBlockScalar)]), vscode_languageserver_types_1.CodeActionKind.Refactor));
|
||||
}
|
||||
const literalBlockScalar = rewriter.writeLiteralBlockScalar(node);
|
||||
if (literalBlockScalar !== null) {
|
||||
results.push(vscode_languageserver_types_1.CodeAction.create(l10n.t('Convert string to literal block string'), createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.replace(range, literalBlockScalar)]), vscode_languageserver_types_1.CodeActionKind.Refactor));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
getKeyOrderActions(diagnostics, document) {
|
||||
const results = [];
|
||||
for (const diagnostic of diagnostics) {
|
||||
if (diagnostic?.code === 'mapKeyOrder') {
|
||||
let node = getNodeForDiagnostic(document, diagnostic);
|
||||
while (node && node.type !== 'object') {
|
||||
node = node.parent;
|
||||
}
|
||||
if (node && (0, yaml_1.isMap)(node.internalNode)) {
|
||||
const sorted = structuredClone(node.internalNode);
|
||||
const _getTrailingTokens = (value) => {
|
||||
if (!value)
|
||||
return;
|
||||
if (yaml_1.CST.isScalar(value)) {
|
||||
if (value.type === 'block-scalar') {
|
||||
value.props ?? (value.props = []);
|
||||
return value.props;
|
||||
}
|
||||
value.end ?? (value.end = []);
|
||||
return value.end;
|
||||
}
|
||||
if (value.type === 'flow-collection') {
|
||||
value.end ?? (value.end = []);
|
||||
return value.end;
|
||||
}
|
||||
if (value.type === 'block-map') {
|
||||
const lastItem = value.items[value.items.length - 1];
|
||||
return lastItem ? _getTrailingTokens(lastItem.value) : undefined;
|
||||
}
|
||||
return;
|
||||
};
|
||||
if ((sorted.srcToken.type === 'block-map' || sorted.srcToken.type === 'flow-collection') &&
|
||||
(node.internalNode.srcToken.type === 'block-map' || node.internalNode.srcToken.type === 'flow-collection')) {
|
||||
sorted.srcToken.items.sort((a, b) => {
|
||||
if (a.key && b.key && yaml_1.CST.isScalar(a.key) && yaml_1.CST.isScalar(b.key)) {
|
||||
return a.key.source.localeCompare(b.key.source);
|
||||
}
|
||||
if (!a.key && b.key) {
|
||||
return -1;
|
||||
}
|
||||
if (a.key && !b.key) {
|
||||
return 1;
|
||||
}
|
||||
if (!a.key && !b.key) {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
for (let i = 0; i < sorted.srcToken.items.length; i++) {
|
||||
const item = sorted.srcToken.items[i];
|
||||
const uItem = node.internalNode.srcToken.items[i];
|
||||
item.start = uItem.start;
|
||||
// strip leading blank lines so reordered entries stay one-per-line
|
||||
while (item.start?.[0]?.type === 'newline')
|
||||
item.start.shift();
|
||||
const itemTokens = _getTrailingTokens(item.value);
|
||||
const itemNewLineIndex = itemTokens?.findIndex((p) => p.type === 'newline') ?? -1;
|
||||
const uNewLineToken = _getTrailingTokens(uItem.value)?.find((p) => p.type === 'newline' && p.offset < node.offset + node.length) ??
|
||||
null;
|
||||
if (uNewLineToken && itemNewLineIndex < 0 && itemTokens) {
|
||||
itemTokens.push({ type: 'newline', indent: 0, offset: item.value.offset, source: '\n' });
|
||||
}
|
||||
if (!uNewLineToken && itemNewLineIndex > -1 && itemTokens) {
|
||||
itemTokens.splice(itemNewLineIndex, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
const replaceRange = vscode_languageserver_types_1.Range.create(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
|
||||
results.push(vscode_languageserver_types_1.CodeAction.create(l10n.t('Fix key order for this map'), createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.replace(replaceRange, yaml_1.CST.stringify(sorted.srcToken))]), vscode_languageserver_types_1.CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
/**
|
||||
* Check if diagnostic contains info for quick fix
|
||||
* Supports Enum/Const/Property mismatch
|
||||
*/
|
||||
getPossibleQuickFixValues(diagnostic) {
|
||||
if (typeof diagnostic.data !== 'object') {
|
||||
return;
|
||||
}
|
||||
if (diagnostic.code === vscode_json_languageservice_1.ErrorCode.EnumValueMismatch &&
|
||||
'values' in diagnostic.data &&
|
||||
Array.isArray(diagnostic.data.values)) {
|
||||
return diagnostic.data.values;
|
||||
}
|
||||
else if (diagnostic.code === vscode_json_languageservice_1.ErrorCode.PropertyExpected &&
|
||||
'properties' in diagnostic.data &&
|
||||
Array.isArray(diagnostic.data.properties)) {
|
||||
return diagnostic.data.properties;
|
||||
}
|
||||
}
|
||||
getQuickFixForPropertyOrValueMismatch(diagnostics, document) {
|
||||
const results = [];
|
||||
for (const diagnostic of diagnostics) {
|
||||
const values = this.getPossibleQuickFixValues(diagnostic);
|
||||
if (!values?.length) {
|
||||
continue;
|
||||
}
|
||||
for (const value of values) {
|
||||
const scalar = typeof value === 'string' ? (0, yamlScalar_1.toYamlStringScalar)(value) : String(value);
|
||||
results.push(vscode_languageserver_types_1.CodeAction.create(scalar, createWorkspaceEdit(document.uri, [vscode_languageserver_types_1.TextEdit.replace(diagnostic.range, scalar)]), vscode_languageserver_types_1.CodeActionKind.QuickFix));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
exports.YamlCodeActions = YamlCodeActions;
|
||||
function getNodeForDiagnostic(document, diagnostic) {
|
||||
const yamlDocuments = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
const startOffset = document.offsetAt(diagnostic.range.start);
|
||||
const endOffset = document.offsetAt(diagnostic.range.end);
|
||||
const yamlDoc = (0, arrUtils_1.matchOffsetToDocument)(startOffset, yamlDocuments);
|
||||
let node = yamlDoc.getNodeFromOffset(startOffset);
|
||||
if (node && startOffset < endOffset && node.offset + node.length === startOffset) {
|
||||
const nodeInsideRange = yamlDoc.getNodeFromOffset(startOffset + 1);
|
||||
if (nodeInsideRange) {
|
||||
node = nodeInsideRange;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
function createWorkspaceEdit(uri, edits) {
|
||||
const changes = {};
|
||||
changes[uri] = edits;
|
||||
const edit = {
|
||||
changes,
|
||||
};
|
||||
return edit;
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=yamlCodeActions.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { CodeLens } from 'vscode-languageserver-types';
|
||||
import { YAMLSchemaService } from './yamlSchemaService';
|
||||
import { Telemetry } from '../telemetry';
|
||||
export declare class YamlCodeLens {
|
||||
private schemaService;
|
||||
private readonly telemetry?;
|
||||
constructor(schemaService: YAMLSchemaService, telemetry?: Telemetry);
|
||||
getCodeLens(document: TextDocument): Promise<CodeLens[]>;
|
||||
resolveCodeLens(param: CodeLens): PromiseLike<CodeLens> | CodeLens;
|
||||
}
|
||||
Generated
Vendored
+60
@@ -0,0 +1,60 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "../../commands", "../parser/yaml-documents", "../utils/schemaUrls", "../utils/schemaUtils"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YamlCodeLens = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const commands_1 = require("../../commands");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
const schemaUrls_1 = require("../utils/schemaUrls");
|
||||
const schemaUtils_1 = require("../utils/schemaUtils");
|
||||
class YamlCodeLens {
|
||||
constructor(schemaService, telemetry) {
|
||||
this.schemaService = schemaService;
|
||||
this.telemetry = telemetry;
|
||||
}
|
||||
async getCodeLens(document) {
|
||||
const result = [];
|
||||
try {
|
||||
const yamlDocument = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
let schemaUrls = new Map();
|
||||
for (const currentYAMLDoc of yamlDocument.documents) {
|
||||
const schema = await this.schemaService.getSchemaForResource(document.uri, currentYAMLDoc);
|
||||
if (schema?.schema) {
|
||||
// merge schemas from all docs to avoid duplicates
|
||||
schemaUrls = new Map([...(0, schemaUrls_1.getSchemaUrls)(schema?.schema), ...schemaUrls]);
|
||||
}
|
||||
}
|
||||
for (const urlToSchema of schemaUrls) {
|
||||
const lens = vscode_languageserver_types_1.CodeLens.create(vscode_languageserver_types_1.Range.create(0, 0, 0, 0));
|
||||
lens.command = {
|
||||
title: (0, schemaUtils_1.getSchemaTitle)(urlToSchema[1], urlToSchema[0]),
|
||||
command: commands_1.YamlCommands.JUMP_TO_SCHEMA,
|
||||
arguments: [urlToSchema[0]],
|
||||
};
|
||||
result.push(lens);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.codeLens.error', err);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
resolveCodeLens(param) {
|
||||
return param;
|
||||
}
|
||||
}
|
||||
exports.YamlCodeLens = YamlCodeLens;
|
||||
});
|
||||
//# sourceMappingURL=yamlCodeLens.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlCodeLens.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlCodeLens.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAGhG,6EAA8D;IAC9D,6CAA8C;IAC9C,6DAA8D;IAI9D,oDAAoD;IACpD,sDAAsD;IAEtD,MAAa,YAAY;QACvB,YACU,aAAgC,EACvB,SAAqB;YAD9B,kBAAa,GAAb,aAAa,CAAmB;YACvB,cAAS,GAAT,SAAS,CAAY;QACrC,CAAC;QAEJ,KAAK,CAAC,WAAW,CAAC,QAAsB;YACtC,MAAM,MAAM,GAAG,EAAE,CAAC;YAClB,IAAI;gBACF,MAAM,YAAY,GAAG,mCAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;gBAClE,IAAI,UAAU,GAAG,IAAI,GAAG,EAAsB,CAAC;gBAC/C,KAAK,MAAM,cAAc,IAAI,YAAY,CAAC,SAAS,EAAE;oBACnD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;oBAC3F,IAAI,MAAM,EAAE,MAAM,EAAE;wBAClB,kDAAkD;wBAClD,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,IAAA,0BAAa,EAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC;qBACzE;iBACF;gBACD,KAAK,MAAM,WAAW,IAAI,UAAU,EAAE;oBACpC,MAAM,IAAI,GAAG,sCAAQ,CAAC,MAAM,CAAC,mCAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;oBACvD,IAAI,CAAC,OAAO,GAAG;wBACb,KAAK,EAAE,IAAA,4BAAc,EAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;wBACrD,OAAO,EAAE,uBAAY,CAAC,cAAc;wBACpC,SAAS,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;qBAC5B,CAAC;oBACF,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBACnB;aACF;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;aACvD;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,eAAe,CAAC,KAAe;YAC7B,OAAO,KAAK,CAAC;QACf,CAAC;KACF;IApCD,oCAoCC"}
|
||||
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import { Connection } from 'vscode-languageserver';
|
||||
import { CommandExecutor } from '../../languageserver/commandExecutor';
|
||||
export declare function registerCommands(commandExecutor: CommandExecutor, connection: Connection): void;
|
||||
Generated
Vendored
+60
@@ -0,0 +1,60 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "../../commands", "vscode-uri"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.registerCommands = void 0;
|
||||
const commands_1 = require("../../commands");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
function registerCommands(commandExecutor, connection) {
|
||||
commandExecutor.registerCommand(commands_1.YamlCommands.JUMP_TO_SCHEMA, async (uri) => {
|
||||
if (!uri) {
|
||||
return;
|
||||
}
|
||||
const wsFolders = await connection.workspace.getWorkspaceFolders();
|
||||
if (uri.indexOf('://') < 0 && !uri.startsWith('/')) {
|
||||
if (wsFolders.length === 1) {
|
||||
const wsUri = vscode_uri_1.URI.parse(wsFolders[0].uri);
|
||||
uri = wsUri.with({ path: wsUri.path + uri }).toString();
|
||||
}
|
||||
}
|
||||
else if (uri.startsWith('file://') && wsFolders.length === 1 && vscode_uri_1.URI.parse(wsFolders[0].uri).scheme != 'file') {
|
||||
const wsUri = vscode_uri_1.URI.parse(wsFolders[0].uri);
|
||||
const pathFromUri = vscode_uri_1.URI.parse(uri).path;
|
||||
uri = wsUri.with({ path: pathFromUri }).toString();
|
||||
}
|
||||
else if (!uri.startsWith('file') && !/^[a-z]:[\\/]/i.test(uri)) {
|
||||
// if uri points to local file of its a windows path
|
||||
const origUri = vscode_uri_1.URI.parse(uri);
|
||||
const customUri = vscode_uri_1.URI.from({
|
||||
scheme: 'json-schema',
|
||||
authority: origUri.authority,
|
||||
path: origUri.path.endsWith('.json') ? origUri.path : origUri.path + '.json',
|
||||
fragment: uri,
|
||||
});
|
||||
uri = customUri.toString();
|
||||
}
|
||||
// test if uri is windows path, ie starts with 'c:\' and convert to URI
|
||||
if (/^[a-z]:[\\/]/i.test(uri)) {
|
||||
const winUri = vscode_uri_1.URI.file(uri);
|
||||
uri = winUri.toString();
|
||||
}
|
||||
const result = await connection.window.showDocument({ uri: uri, external: false, takeFocus: true });
|
||||
if (!result) {
|
||||
connection.window.showErrorMessage(`Cannot open ${uri}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.registerCommands = registerCommands;
|
||||
});
|
||||
//# sourceMappingURL=yamlCommands.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlCommands.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlCommands.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAGhG,6CAA8C;IAE9C,2CAAiC;IAEjC,SAAgB,gBAAgB,CAAC,eAAgC,EAAE,UAAsB;QACvF,eAAe,CAAC,eAAe,CAAC,uBAAY,CAAC,cAAc,EAAE,KAAK,EAAE,GAAW,EAAE,EAAE;YACjF,IAAI,CAAC,GAAG,EAAE;gBACR,OAAO;aACR;YACD,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,mBAAmB,EAAE,CAAC;YAEnE,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;gBAClD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;oBAC1B,MAAM,KAAK,GAAG,gBAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;oBAC1C,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,GAAG,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;iBACzD;aACF;iBAAM,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,gBAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,MAAM,EAAE;gBAC9G,MAAM,KAAK,GAAG,gBAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBAC1C,MAAM,WAAW,GAAG,gBAAG,CAAC,KAA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||
Generated
Vendored
+77
@@ -0,0 +1,77 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { ClientCapabilities } from 'vscode-languageserver';
|
||||
import { CompletionItem as CompletionItemBase, CompletionList, Position } from 'vscode-languageserver-types';
|
||||
import { Telemetry } from '../telemetry';
|
||||
import { YamlDocuments } from '../parser/yaml-documents';
|
||||
import { LanguageSettings } from '../yamlLanguageService';
|
||||
import { YAMLSchemaService } from './yamlSchemaService';
|
||||
import { JSONSchema } from '../jsonSchema';
|
||||
import { SettingsState } from '../../yamlSettings';
|
||||
interface ParentCompletionItemOptions {
|
||||
schema: JSONSchema;
|
||||
indent?: string;
|
||||
insertTexts?: string[];
|
||||
}
|
||||
interface CompletionItem extends CompletionItemBase {
|
||||
parent?: ParentCompletionItemOptions;
|
||||
}
|
||||
export declare class YamlCompletion {
|
||||
private schemaService;
|
||||
private clientCapabilities;
|
||||
private yamlDocument;
|
||||
private readonly telemetry?;
|
||||
private customTags;
|
||||
private completionEnabled;
|
||||
private configuredIndentation;
|
||||
private yamlVersion;
|
||||
private isSingleQuote;
|
||||
private indentation;
|
||||
private arrayPrefixIndentation;
|
||||
private supportsMarkdown;
|
||||
private disableDefaultProperties;
|
||||
private parentSkeletonSelectedFirst;
|
||||
constructor(schemaService: YAMLSchemaService, clientCapabilities: ClientCapabilities, yamlDocument: YamlDocuments, telemetry?: Telemetry);
|
||||
configure(languageSettings: LanguageSettings, yamlSettings?: SettingsState): void;
|
||||
doComplete(document: TextDocument, position: Position, isKubernetes?: boolean, doComplete?: boolean): Promise<CompletionList>;
|
||||
updateCompletionText(completionItem: CompletionItem, text: string): void;
|
||||
mergeSimpleInsertTexts(label: string, existingText: string, addingText: string, oneOfSchema: boolean): string | undefined;
|
||||
getValuesFromInsertText(insertText: string): string[];
|
||||
private finalizeParentCompletion;
|
||||
private createTempObjNode;
|
||||
private addPropertyCompletions;
|
||||
private getValueCompletions;
|
||||
private addArrayItemValueCompletion;
|
||||
private getInsertTextForProperty;
|
||||
private getInsertTextForObject;
|
||||
private getInsertTextForArray;
|
||||
private getInsertTextForGuessedValue;
|
||||
private getInsertTextForPlainText;
|
||||
private getInsertTextForValue;
|
||||
private getInsertTemplateForValue;
|
||||
private addSchemaValueCompletions;
|
||||
private collectTypes;
|
||||
private addDefaultValueCompletions;
|
||||
private addEnumValueCompletions;
|
||||
private getLabelForValue;
|
||||
private collectDefaultSnippets;
|
||||
private getInsertTextForSnippetValue;
|
||||
private addBooleanValueCompletion;
|
||||
private addNullValueCompletion;
|
||||
private getLabelForSnippetValue;
|
||||
private getCustomTagValueCompletions;
|
||||
private addCustomTagValueCompletion;
|
||||
private getDocumentationWithMarkdownText;
|
||||
private getSuggestionKind;
|
||||
private getCurrentWord;
|
||||
private fromMarkup;
|
||||
private doesSupportMarkdown;
|
||||
private findItemAtOffset;
|
||||
private getPropertyNamesCandidates;
|
||||
getQuote(): string;
|
||||
/**
|
||||
* simplify `{$1:value}` to `value`
|
||||
*/
|
||||
evaluateTab1Symbol(value: string): string;
|
||||
isParentCompletionItem(item: CompletionItemBase): item is CompletionItem;
|
||||
}
|
||||
export {};
|
||||
Generated
Vendored
+1512
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import { DefinitionParams } from 'vscode-languageserver-protocol';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { DefinitionLink } from 'vscode-languageserver-types';
|
||||
import { Telemetry } from '../telemetry';
|
||||
export declare class YamlDefinition {
|
||||
private readonly telemetry?;
|
||||
constructor(telemetry?: Telemetry);
|
||||
getDefinition(document: TextDocument, params: DefinitionParams): DefinitionLink[] | undefined;
|
||||
}
|
||||
Generated
Vendored
+51
@@ -0,0 +1,51 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "yaml", "../parser/yaml-documents", "../utils/arrUtils", "../utils/textBuffer"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YamlDefinition = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_1 = require("yaml");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
const arrUtils_1 = require("../utils/arrUtils");
|
||||
const textBuffer_1 = require("../utils/textBuffer");
|
||||
class YamlDefinition {
|
||||
constructor(telemetry) {
|
||||
this.telemetry = telemetry;
|
||||
}
|
||||
getDefinition(document, params) {
|
||||
try {
|
||||
const yamlDocument = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
const offset = document.offsetAt(params.position);
|
||||
const currentDoc = (0, arrUtils_1.matchOffsetToDocument)(offset, yamlDocument);
|
||||
if (currentDoc) {
|
||||
const [node] = currentDoc.getNodeFromPosition(offset, new textBuffer_1.TextBuffer(document));
|
||||
if (node && (0, yaml_1.isAlias)(node)) {
|
||||
const defNode = node.resolve(currentDoc.internalDocument);
|
||||
if (defNode && defNode.range) {
|
||||
const targetRange = vscode_languageserver_types_1.Range.create(document.positionAt(defNode.range[0]), document.positionAt(defNode.range[2]));
|
||||
const selectionRange = vscode_languageserver_types_1.Range.create(document.positionAt(defNode.range[0]), document.positionAt(defNode.range[1]));
|
||||
return [vscode_languageserver_types_1.LocationLink.create(document.uri, targetRange, selectionRange)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.definition.error', err);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.YamlDefinition = YamlDefinition;
|
||||
});
|
||||
//# sourceMappingURL=yamlDefinition.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlDefinition.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlDefinition.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;IAIhG,6EAAkF;IAClF,+BAA+B;IAE/B,6DAA8D;IAC9D,gDAA0D;IAC1D,oDAAiD;IAEjD,MAAa,cAAc;QACzB,YAA6B,SAAqB;YAArB,cAAS,GAAT,SAAS,CAAY;QAAG,CAAC;QAEtD,aAAa,CAAC,QAAsB,EAAE,MAAwB;YAC5D,IAAI;gBACF,MAAM,YAAY,GAAG,mCAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;gBAClE,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAClD,MAAM,UAAU,GAAG,IAAA,gCAAqB,EAAC,MAAM,EAAE,YAAY,CAAC,CAAC;gBAC/D,IAAI,UAAU,EAAE;oBACd,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,uBAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAChF,IAAI,IAAI,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;wBACzB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;wBAC1D,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE;4BAC5B,MAAM,WAAW,GAAG,mCAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;4BAC/G,MAAM,cAAc,GAAG,mCAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;4BAClH,OAAO,CAAC,0CAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;yBACzE;qBACF;iBACF;aACF;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,uBAAuB,EAAE,GAAG,CAAC,CAAC;aACzD;YAED,OAAO,SAAS,CAAC;QACnB,CAAC;KACF;IAzBD,wCAyBC"}
|
||||
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import { FoldingRange } from 'vscode-languageserver-types';
|
||||
import { FoldingRangesContext } from '../yamlTypes';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
export declare function getFoldingRanges(document: TextDocument, context: FoldingRangesContext): FoldingRange[] | undefined;
|
||||
Generated
Vendored
+76
@@ -0,0 +1,76 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "../parser/yaml-documents"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getFoldingRanges = void 0;
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
function getFoldingRanges(document, context) {
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
const result = [];
|
||||
const doc = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
for (const ymlDoc of doc.documents) {
|
||||
if (doc.documents.length > 1) {
|
||||
result.push(createNormalizedFolding(document, ymlDoc.root));
|
||||
}
|
||||
ymlDoc.visit((node) => {
|
||||
if (node.type === 'object' && node.parent?.type === 'array') {
|
||||
result.push(createNormalizedFolding(document, node));
|
||||
}
|
||||
if (node.type === 'property' && node.valueNode) {
|
||||
switch (node.valueNode.type) {
|
||||
case 'array':
|
||||
case 'object':
|
||||
result.push(createNormalizedFolding(document, node));
|
||||
break;
|
||||
case 'string': {
|
||||
// check if it is a multi-line string
|
||||
const nodePosn = document.positionAt(node.offset);
|
||||
const valuePosn = document.positionAt(node.valueNode.offset + node.valueNode.length);
|
||||
if (nodePosn.line !== valuePosn.line) {
|
||||
result.push(createNormalizedFolding(document, node));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
const rangeLimit = context && context.rangeLimit;
|
||||
if (typeof rangeLimit !== 'number' || result.length <= rangeLimit) {
|
||||
return result;
|
||||
}
|
||||
if (context && context.onRangeLimitExceeded) {
|
||||
context.onRangeLimitExceeded(document.uri);
|
||||
}
|
||||
return result.slice(0, context.rangeLimit);
|
||||
}
|
||||
exports.getFoldingRanges = getFoldingRanges;
|
||||
function createNormalizedFolding(document, node) {
|
||||
const startPos = document.positionAt(node.offset);
|
||||
let endPos = document.positionAt(node.offset + node.length);
|
||||
const textFragment = document.getText(vscode_languageserver_types_1.Range.create(startPos, endPos));
|
||||
const newLength = textFragment.length - textFragment.trimRight().length;
|
||||
if (newLength > 0) {
|
||||
endPos = document.positionAt(node.offset + node.length - newLength);
|
||||
}
|
||||
return vscode_languageserver_types_1.FoldingRange.create(startPos.line, endPos.line, startPos.character, endPos.character);
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=yamlFolding.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlFolding.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlFolding.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA;;;oGAGgG;IAChG,6EAAkE;IAGlE,6DAA8D;IAG9D,SAAgB,gBAAgB,CAAC,QAAsB,EAAE,OAA6B;QACpF,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO;SACR;QACD,MAAM,MAAM,GAAmB,EAAE,CAAC;QAClC,MAAM,GAAG,GAAG,mCAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACzD,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,SAAS,EAAE;YAClC,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5B,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;aAC7D;YACD,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;gBACpB,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,KAAK,OAAO,EAAE;oBAC3D,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;iBACtD;gBACD,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,SAAS,EAAE;oBAC9C,QAAQ,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;wBAC3B,KAAK,OAAO,CAAC;wBACb,KAAK,QAAQ;4BACX,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;4BACrD,MAAM;wBACR,KAAK,QAAQ,CAAC,CAAC;4BACb,qCAAqC;4BACrC,MAAM,QAAQ,GAAG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AG,YAAY,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;QACxE,IAAI,SAAS,GAAG,CAAC,EAAE;YACjB,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;SACrE;QACD,OAAO,0CAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;IAC/F,CAAC"}
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { TextEdit, FormattingOptions } from 'vscode-languageserver-types';
|
||||
import { CustomFormatterOptions, LanguageSettings } from '../yamlLanguageService';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
export declare class YAMLFormatter {
|
||||
private formatterEnabled;
|
||||
configure(shouldFormat: LanguageSettings): void;
|
||||
format(document: TextDocument, options?: Partial<FormattingOptions> & CustomFormatterOptions): Promise<TextEdit[]>;
|
||||
}
|
||||
Generated
Vendored
+60
@@ -0,0 +1,60 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Copyright (c) Adam Voss. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-languageserver-types", "prettier/plugins/yaml", "prettier/plugins/estree", "prettier/standalone"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YAMLFormatter = void 0;
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const yamlPlugin = require("prettier/plugins/yaml");
|
||||
const estreePlugin = require("prettier/plugins/estree");
|
||||
const standalone_1 = require("prettier/standalone");
|
||||
class YAMLFormatter {
|
||||
constructor() {
|
||||
this.formatterEnabled = true;
|
||||
}
|
||||
configure(shouldFormat) {
|
||||
if (shouldFormat) {
|
||||
this.formatterEnabled = shouldFormat.format;
|
||||
}
|
||||
}
|
||||
async format(document, options = {}) {
|
||||
if (!this.formatterEnabled) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
const text = document.getText();
|
||||
const prettierOptions = {
|
||||
parser: 'yaml',
|
||||
plugins: [yamlPlugin, estreePlugin],
|
||||
// --- FormattingOptions ---
|
||||
tabWidth: options.tabWidth || options.tabSize,
|
||||
// --- CustomFormatterOptions ---
|
||||
singleQuote: options.singleQuote,
|
||||
bracketSpacing: options.bracketSpacing,
|
||||
// 'preserve' is the default for Options.proseWrap. See also server.ts
|
||||
proseWrap: 'always' === options.proseWrap ? 'always' : 'never' === options.proseWrap ? 'never' : 'preserve',
|
||||
printWidth: options.printWidth,
|
||||
trailingComma: options.trailingComma === false ? 'none' : 'all',
|
||||
};
|
||||
const formatted = await (0, standalone_1.format)(text, prettierOptions);
|
||||
return [vscode_languageserver_types_1.TextEdit.replace(vscode_languageserver_types_1.Range.create(vscode_languageserver_types_1.Position.create(0, 0), document.positionAt(text.length)), formatted)];
|
||||
}
|
||||
catch (error) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.YAMLFormatter = YAMLFormatter;
|
||||
});
|
||||
//# sourceMappingURL=yamlFormatter.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlFormatter.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlFormatter.ts"],"names":[],"mappings":"AAAA;;;;gGAIgG;;;;;;;;;;;;;IAEhG,6EAA2F;IAG3F,oDAAoD;IACpD,wDAAwD;IACxD,oDAA6C;IAG7C,MAAa,aAAa;QAA1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AC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;aAC7G;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,EAAE,CAAC;aACX;QACH,CAAC;KACF;IA3CD,sCA2CC"}
|
||||
Generated
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Hover, Position } from 'vscode-languageserver-types';
|
||||
import { Telemetry } from '../telemetry';
|
||||
import { LanguageSettings } from '../yamlLanguageService';
|
||||
import { YAMLSchemaService } from './yamlSchemaService';
|
||||
export declare class YAMLHover {
|
||||
private readonly telemetry?;
|
||||
private shouldHover;
|
||||
private shouldHoverAnchor;
|
||||
private indentation;
|
||||
private schemaService;
|
||||
constructor(schemaService: YAMLSchemaService, telemetry?: Telemetry);
|
||||
configure(languageSettings: LanguageSettings): void;
|
||||
doHover(document: TextDocument, position: Position, isKubernetes?: boolean): Promise<Hover | null>;
|
||||
private getHover;
|
||||
/**
|
||||
* Resolves merge keys (<<) and anchors recursively in an object node
|
||||
* @param node The object AST node to resolve
|
||||
* @param doc The YAML document for resolving anchors
|
||||
* @param currentRecursionLevel Current recursion level (default: 0)
|
||||
* @returns A plain JavaScript object with all merges resolved
|
||||
*/
|
||||
private resolveMergeKeys;
|
||||
/**
|
||||
* Resolves a merge value (which might be an alias) and recursively resolves its merge keys
|
||||
* @param node The AST node that might be an alias or object
|
||||
* @param doc The YAML document for resolving anchors
|
||||
* @param currentRecursionLevel Current recursion level
|
||||
* @returns The resolved value
|
||||
*/
|
||||
private resolveMergeValue;
|
||||
/**
|
||||
* Converts an AST node to a plain JavaScript value
|
||||
* @param node The AST node to convert
|
||||
* @param doc The YAML document for resolving anchors
|
||||
* @param currentRecursionLevel Current recursion level
|
||||
* @returns The converted value
|
||||
*/
|
||||
private astNodeToValue;
|
||||
/**
|
||||
* Converts a YAML Node to a plain JavaScript value
|
||||
* @param node The YAML node to convert
|
||||
* @returns The converted value
|
||||
*/
|
||||
private nodeToValue;
|
||||
private toMarkdown;
|
||||
}
|
||||
+380
@@ -0,0 +1,380 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. 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.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "@vscode/l10n", "path", "vscode-languageserver-types", "vscode-uri", "yaml", "../parser/isKubernetes", "../parser/astNodeUtils", "../parser/yaml-documents", "../utils/arrUtils", "../utils/yamlScalar"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YAMLHover = void 0;
|
||||
const l10n = require("@vscode/l10n");
|
||||
const path = require("path");
|
||||
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const yaml_1 = require("yaml");
|
||||
const isKubernetes_1 = require("../parser/isKubernetes");
|
||||
const astNodeUtils_1 = require("../parser/astNodeUtils");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
const arrUtils_1 = require("../utils/arrUtils");
|
||||
const yamlScalar_1 = require("../utils/yamlScalar");
|
||||
class YAMLHover {
|
||||
constructor(schemaService, telemetry) {
|
||||
this.telemetry = telemetry;
|
||||
this.shouldHover = true;
|
||||
this.schemaService = schemaService;
|
||||
}
|
||||
configure(languageSettings) {
|
||||
if (languageSettings) {
|
||||
this.shouldHover = languageSettings.hover;
|
||||
this.shouldHoverAnchor = languageSettings.hoverAnchor;
|
||||
this.indentation = languageSettings.indentation;
|
||||
}
|
||||
}
|
||||
doHover(document, position, isKubernetes = false) {
|
||||
try {
|
||||
if (!this.shouldHover || !document) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
const doc = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
const offset = document.offsetAt(position);
|
||||
const currentDoc = (0, arrUtils_1.matchOffsetToDocument)(offset, doc);
|
||||
if (currentDoc === null) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
(0, isKubernetes_1.setKubernetesParserOption)(doc.documents, isKubernetes);
|
||||
const currentDocIndex = doc.documents.indexOf(currentDoc);
|
||||
currentDoc.currentDocIndex = currentDocIndex;
|
||||
return this.getHover(document, position, currentDoc);
|
||||
}
|
||||
catch (error) {
|
||||
this.telemetry?.sendError('yaml.hover.error', error);
|
||||
}
|
||||
}
|
||||
// method copied from https://github.com/microsoft/vscode-json-languageservice/blob/2ea5ad3d2ffbbe40dea11cfe764a502becf113ce/src/services/jsonHover.ts#L23
|
||||
getHover(document, position, doc) {
|
||||
const offset = document.offsetAt(position);
|
||||
let node = doc.getNodeFromOffset(offset);
|
||||
if (!node ||
|
||||
((node.type === 'object' || node.type === 'array') && offset > node.offset + 1 && offset < node.offset + node.length - 1)) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
const hoverRangeNode = node;
|
||||
// use the property description when hovering over an object key
|
||||
if (node.type === 'string') {
|
||||
const parent = node.parent;
|
||||
if (parent && parent.type === 'property' && parent.keyNode === node) {
|
||||
node = parent.valueNode;
|
||||
if (!node) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
const hoverRange = vscode_languageserver_types_1.Range.create(document.positionAt(hoverRangeNode.offset), document.positionAt(hoverRangeNode.offset + hoverRangeNode.length));
|
||||
const createHover = (contents) => {
|
||||
const markupContent = {
|
||||
kind: vscode_languageserver_types_1.MarkupKind.Markdown,
|
||||
value: contents,
|
||||
};
|
||||
const result = {
|
||||
contents: markupContent,
|
||||
range: hoverRange,
|
||||
};
|
||||
return result;
|
||||
};
|
||||
if (this.shouldHoverAnchor && node.type === 'property' && node.valueNode) {
|
||||
if (node.valueNode.type === 'object') {
|
||||
const resolved = this.resolveMergeKeys(node.valueNode, doc);
|
||||
const contents = '```yaml\n' + (0, yaml_1.stringify)(resolved, null, 2) + '\n```';
|
||||
return Promise.resolve(createHover(contents));
|
||||
}
|
||||
}
|
||||
const removePipe = (value) => {
|
||||
return value.replace(/\s\|\|\s*$/, '');
|
||||
};
|
||||
return this.schemaService.getSchemaForResource(document.uri, doc).then((schema) => {
|
||||
if (schema && node && !schema.errors.length) {
|
||||
const matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset);
|
||||
let title = undefined;
|
||||
let markdownDescription = undefined;
|
||||
let markdownEnumDescriptions = [];
|
||||
const markdownExamples = [];
|
||||
const markdownEnums = [];
|
||||
let enumIdx = undefined;
|
||||
matchingSchemas.every((s) => {
|
||||
if ((s.node === node || (node.type === 'property' && node.valueNode === s.node)) && !s.inverted && s.schema) {
|
||||
title = title || s.schema.title || s.schema.closestTitle;
|
||||
markdownDescription = markdownDescription || s.schema.markdownDescription || this.toMarkdown(s.schema.description);
|
||||
if (s.schema.enum) {
|
||||
enumIdx = s.schema.enum.indexOf((0, astNodeUtils_1.getNodeValue)(node));
|
||||
if (s.schema.markdownEnumDescriptions) {
|
||||
markdownEnumDescriptions = s.schema.markdownEnumDescriptions;
|
||||
}
|
||||
else if (s.schema.enumDescriptions) {
|
||||
markdownEnumDescriptions = s.schema.enumDescriptions.map(this.toMarkdown, this);
|
||||
}
|
||||
else {
|
||||
markdownEnumDescriptions = [];
|
||||
}
|
||||
s.schema.enum.forEach((enumValue, idx) => {
|
||||
var _a;
|
||||
enumValue = typeof enumValue === 'string' ? (0, yamlScalar_1.toYamlStringScalar)(enumValue, false) : JSON.stringify(enumValue);
|
||||
//insert only if the value is not present yet (avoiding duplicates)
|
||||
//but it also adds or keeps the description of the enum value
|
||||
const foundIdx = markdownEnums.findIndex((me) => me.value === enumValue);
|
||||
if (foundIdx < 0) {
|
||||
markdownEnums.push({
|
||||
value: enumValue,
|
||||
description: markdownEnumDescriptions[idx],
|
||||
});
|
||||
}
|
||||
else {
|
||||
(_a = markdownEnums[foundIdx]).description || (_a.description = markdownEnumDescriptions[idx]);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (s.schema.anyOf && isAllSchemasMatched(node, matchingSchemas, s.schema)) {
|
||||
//if append title and description of all matched schemas on hover
|
||||
title = '';
|
||||
markdownDescription = s.schema.description ? s.schema.description + '\n' : '';
|
||||
s.schema.anyOf.forEach((childSchema, index) => {
|
||||
title += childSchema.title || s.schema.closestTitle || '';
|
||||
markdownDescription += childSchema.markdownDescription || this.toMarkdown(childSchema.description) || '';
|
||||
if (index !== s.schema.anyOf.length - 1) {
|
||||
title += ' || ';
|
||||
markdownDescription += ' || ';
|
||||
}
|
||||
});
|
||||
title = removePipe(title);
|
||||
markdownDescription = removePipe(markdownDescription);
|
||||
}
|
||||
if (s.schema.examples) {
|
||||
s.schema.examples.forEach((example) => {
|
||||
markdownExamples.push((0, yaml_1.stringify)(example, null, 2));
|
||||
});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
let result = '';
|
||||
if (title) {
|
||||
result = '#### ' + this.toMarkdown(title);
|
||||
}
|
||||
if (markdownDescription) {
|
||||
result = ensureLineBreak(result);
|
||||
result += markdownDescription;
|
||||
}
|
||||
if (markdownEnums.length !== 0) {
|
||||
result = ensureLineBreak(result);
|
||||
result += l10n.t('Allowed Values:') + '\n\n';
|
||||
if (enumIdx) {
|
||||
markdownEnums.unshift(markdownEnums.splice(enumIdx, 1)[0]);
|
||||
}
|
||||
markdownEnums.forEach((me) => {
|
||||
if (me.description) {
|
||||
result += `* \`${toMarkdownCodeBlock(me.value)}\`: ${me.description}\n`;
|
||||
}
|
||||
else {
|
||||
result += `* \`${toMarkdownCodeBlock(me.value)}\`\n`;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (markdownExamples.length !== 0) {
|
||||
markdownExamples.forEach((example) => {
|
||||
result = ensureLineBreak(result);
|
||||
result += l10n.t('Example:') + '\n\n';
|
||||
result += `\`\`\`yaml\n${example}\`\`\`\n`;
|
||||
});
|
||||
}
|
||||
if (result.length > 0 && schema.schema.url) {
|
||||
result = ensureLineBreak(result);
|
||||
result += l10n.t('Source: [{0}]({1})', getSchemaName(schema.schema), schema.schema.url);
|
||||
}
|
||||
return createHover(result);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Resolves merge keys (<<) and anchors recursively in an object node
|
||||
* @param node The object AST node to resolve
|
||||
* @param doc The YAML document for resolving anchors
|
||||
* @param currentRecursionLevel Current recursion level (default: 0)
|
||||
* @returns A plain JavaScript object with all merges resolved
|
||||
*/
|
||||
resolveMergeKeys(node, doc, currentRecursionLevel = 0) {
|
||||
const result = {};
|
||||
const unprocessedProperties = [...node.properties];
|
||||
while (unprocessedProperties.length > 0) {
|
||||
const propertyNode = unprocessedProperties.shift();
|
||||
const key = propertyNode.keyNode.value;
|
||||
if (key === '<<' && propertyNode.valueNode) {
|
||||
// Handle merge key
|
||||
const mergeValue = this.resolveMergeValue(propertyNode.valueNode, doc, currentRecursionLevel + 1);
|
||||
if (mergeValue && typeof mergeValue === 'object' && !Array.isArray(mergeValue)) {
|
||||
// Merge properties from the resolved value
|
||||
const mergeKeys = Object.keys(mergeValue);
|
||||
for (const mergeKey of mergeKeys) {
|
||||
result[mergeKey] = mergeValue[mergeKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Regular property
|
||||
result[key] = this.astNodeToValue(propertyNode.valueNode, doc, currentRecursionLevel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Resolves a merge value (which might be an alias) and recursively resolves its merge keys
|
||||
* @param node The AST node that might be an alias or object
|
||||
* @param doc The YAML document for resolving anchors
|
||||
* @param currentRecursionLevel Current recursion level
|
||||
* @returns The resolved value
|
||||
*/
|
||||
resolveMergeValue(node, doc, currentRecursionLevel) {
|
||||
const MAX_MERGE_RECURSION_LEVEL = 10;
|
||||
// Check if we've exceeded max recursion level
|
||||
if (currentRecursionLevel >= MAX_MERGE_RECURSION_LEVEL) {
|
||||
return { '<<': node.parent.internalNode['value'] + ' (recursion limit reached)' };
|
||||
}
|
||||
// If it's an object node, resolve its merge keys
|
||||
if (node.type === 'object') {
|
||||
return this.resolveMergeKeys(node, doc, currentRecursionLevel);
|
||||
}
|
||||
// Otherwise, convert to value
|
||||
return this.astNodeToValue(node, doc, currentRecursionLevel);
|
||||
}
|
||||
/**
|
||||
* Converts an AST node to a plain JavaScript value
|
||||
* @param node The AST node to convert
|
||||
* @param doc The YAML document for resolving anchors
|
||||
* @param currentRecursionLevel Current recursion level
|
||||
* @returns The converted value
|
||||
*/
|
||||
astNodeToValue(node, doc, currentRecursionLevel) {
|
||||
if (!node) {
|
||||
return null;
|
||||
}
|
||||
switch (node.type) {
|
||||
case 'object': {
|
||||
return this.resolveMergeKeys(node, doc, currentRecursionLevel);
|
||||
}
|
||||
case 'array': {
|
||||
return node.children.map((child) => this.astNodeToValue(child, doc, currentRecursionLevel));
|
||||
}
|
||||
case 'string':
|
||||
case 'number':
|
||||
case 'boolean':
|
||||
case 'null': {
|
||||
return node.value;
|
||||
}
|
||||
default: {
|
||||
return this.nodeToValue(node.internalNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Converts a YAML Node to a plain JavaScript value
|
||||
* @param node The YAML node to convert
|
||||
* @returns The converted value
|
||||
*/
|
||||
nodeToValue(node) {
|
||||
if ((0, yaml_1.isAlias)(node)) {
|
||||
return node.source;
|
||||
}
|
||||
if ((0, yaml_1.isMap)(node)) {
|
||||
const result = {};
|
||||
for (const pair of node.items) {
|
||||
if (pair.key && pair.value) {
|
||||
const key = this.nodeToValue(pair.key);
|
||||
const value = this.nodeToValue(pair.value);
|
||||
if (typeof key === 'string') {
|
||||
result[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if ((0, yaml_1.isSeq)(node)) {
|
||||
return node.items.map((item) => this.nodeToValue(item));
|
||||
}
|
||||
return node.value;
|
||||
}
|
||||
// copied from https://github.com/microsoft/vscode-json-languageservice/blob/2ea5ad3d2ffbbe40dea11cfe764a502becf113ce/src/services/jsonHover.ts#L112
|
||||
toMarkdown(plain) {
|
||||
if (plain) {
|
||||
let escaped = plain.replace(/([^\n\r])(\r?\n)([^\n\r])/gm, '$1\n\n$3'); // single new lines to \n\n (Markdown paragraph)
|
||||
escaped = escaped.replace(/[\\`*_{}[\]#+\-!]/g, '\\$&'); // escape some of the markdown syntax tokens http://daringfireball.net/projects/markdown/syntax#backslash to avoid unintended formatting
|
||||
if (this.indentation !== undefined) {
|
||||
// escape indentation whitespace to prevent it from being converted to markdown code blocks.
|
||||
const indentationMatchRegex = new RegExp(` {${this.indentation.length}}`, 'g');
|
||||
escaped = escaped.replace(indentationMatchRegex, ' ');
|
||||
}
|
||||
return escaped;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.YAMLHover = YAMLHover;
|
||||
function ensureLineBreak(content) {
|
||||
if (content.length === 0) {
|
||||
return content;
|
||||
}
|
||||
if (!content.endsWith('\n')) {
|
||||
content += '\n';
|
||||
}
|
||||
return content + '\n';
|
||||
}
|
||||
function getSchemaName(schema) {
|
||||
let result = 'JSON Schema';
|
||||
const urlString = schema.url;
|
||||
if (urlString) {
|
||||
const url = vscode_uri_1.URI.parse(urlString);
|
||||
result = path.basename(url.fsPath);
|
||||
}
|
||||
else if (schema.title) {
|
||||
result = schema.title;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// copied from https://github.com/microsoft/vscode-json-languageservice/blob/2ea5ad3d2ffbbe40dea11cfe764a502becf113ce/src/services/jsonHover.ts#L122
|
||||
function toMarkdownCodeBlock(content) {
|
||||
// see https://daringfireball.net/projects/markdown/syntax#precode
|
||||
if (content.indexOf('`') !== -1) {
|
||||
return '`` ' + content + ' ``';
|
||||
}
|
||||
return content;
|
||||
}
|
||||
/**
|
||||
* check all the schemas which is inside anyOf presented or not in matching schema.
|
||||
* @param node node
|
||||
* @param matchingSchemas all matching schema
|
||||
* @param schema scheam which is having anyOf
|
||||
* @returns true if all the schemas which inside anyOf presents in matching schema
|
||||
*/
|
||||
function isAllSchemasMatched(node, matchingSchemas, schema) {
|
||||
let count = 0;
|
||||
for (const matchSchema of matchingSchemas) {
|
||||
if (node === matchSchema.node && matchSchema.schema !== schema) {
|
||||
schema.anyOf.forEach((childSchema) => {
|
||||
if (matchSchema.schema.title === childSchema.title &&
|
||||
matchSchema.schema.description === childSchema.description &&
|
||||
matchSchema.schema.properties === childSchema.properties) {
|
||||
count++;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return count === schema.anyOf.length;
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=yamlHover.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { DocumentLink } from 'vscode-languageserver-types';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
import { Telemetry } from '../telemetry';
|
||||
export declare class YamlLinks {
|
||||
private readonly telemetry?;
|
||||
constructor(telemetry?: Telemetry);
|
||||
findLinks(document: TextDocument): Promise<DocumentLink[]>;
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
(function (factory) {
|
||||
if (typeof module === "object" && typeof module.exports === "object") {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
}
|
||||
else if (typeof define === "function" && define.amd) {
|
||||
define(["require", "exports", "vscode-json-languageservice/lib/umd/services/jsonLinks", "../parser/yaml-documents"], factory);
|
||||
}
|
||||
})(function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.YamlLinks = void 0;
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Red Hat, Inc. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
const jsonLinks_1 = require("vscode-json-languageservice/lib/umd/services/jsonLinks");
|
||||
const yaml_documents_1 = require("../parser/yaml-documents");
|
||||
class YamlLinks {
|
||||
constructor(telemetry) {
|
||||
this.telemetry = telemetry;
|
||||
}
|
||||
findLinks(document) {
|
||||
try {
|
||||
const doc = yaml_documents_1.yamlDocumentsCache.getYamlDocument(document);
|
||||
// Find links across all YAML Documents then report them back once finished
|
||||
const linkPromises = [];
|
||||
for (const yamlDoc of doc.documents) {
|
||||
linkPromises.push((0, jsonLinks_1.findLinks)(document, yamlDoc));
|
||||
}
|
||||
// Wait for all the promises to return and then flatten them into one DocumentLink array
|
||||
return Promise.all(linkPromises).then((yamlLinkArray) => [].concat(...yamlLinkArray));
|
||||
}
|
||||
catch (err) {
|
||||
this.telemetry?.sendError('yaml.documentLink.error', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.YamlLinks = YamlLinks;
|
||||
});
|
||||
//# sourceMappingURL=yamlLinks.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"yamlLinks.js","sourceRoot":"","sources":["../../../../src/languageservice/services/yamlLinks.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA;;;oGAGgG;IAChG,sFAAoG;IAIpG,6DAA8D;IAE9D,MAAa,SAAS;QACpB,YAA6B,SAAqB;YAArB,cAAS,GAAT,SAAS,CAAY;QAAG,CAAC;QAEtD,SAAS,CAAC,QAAsB;YAC9B,IAAI;gBACF,MAAM,GAAG,GAAG,mCAAkB,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;gBACzD,2EAA2E;gBAC3E,MAAM,YAAY,GAAG,EAAE,CAAC;gBACxB,KAAK,MAAM,OAAO,IAAI,GAAG,CAAC,SAAS,EAAE;oBACnC,YAAY,CAAC,IAAI,CAAC,IAAA,qBAAa,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;iBACrD;gBACD,wFAAwF;gBACxF,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;aACvF;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,yBAAyB,EAAE,GAAG,CAAC,CAAC;aAC3D;QACH,CAAC;KACF;IAjBD,8BAiBC"}
|
||||
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import { DocumentOnTypeFormattingParams } from 'vscode-languageserver';
|
||||
import { TextEdit } from 'vscode-languageserver-types';
|
||||
import { TextDocument } from 'vscode-languageserver-textdocument';
|
||||
export declare function doDocumentOnTypeFormatting(document: TextDocument, params: DocumentOnTypeFormattingParams): TextEdit[] | undefined;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user