amazon-states-language-service
Advanced tools
Comparing version 1.6.2 to 1.6.3
@@ -26,3 +26,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const js_yaml_1 = require("js-yaml"); | ||
const prettier = __importStar(require("prettier")); | ||
@@ -112,3 +111,3 @@ const vscode_json_languageservice_1 = require("vscode-json-languageservice"); | ||
if (!hasCursorLineNonSpace && numberOfSpacesCursorLine > 0) { | ||
for (let lineNum = prevText.length - 2; lineNum > 0; lineNum--) { | ||
for (let lineNum = prevText.length - 2; lineNum >= 0; lineNum--) { | ||
let leftLineSpaces = 0; | ||
@@ -162,8 +161,5 @@ const line = prevText[lineNum]; | ||
const modifiedAslCompletionItems = aslCompletions.items.map(completionItem => { | ||
var _a; | ||
const completionItemCopy = Object.assign({}, completionItem); // Copy completion to new object to avoid overwriting any snippets | ||
if (completionItemCopy.insertText && completionItemCopy.kind === vscode_json_languageservice_1.CompletionItemKind.Snippet && document.languageId === constants_1.LANGUAGE_IDS.YAML) { | ||
completionItemCopy.insertText = js_yaml_1.safeDump(js_yaml_1.safeLoad(completionItemCopy.insertText)); | ||
// Remove quotation marks | ||
completionItemCopy.insertText = (_a = completionItemCopy.insertText) === null || _a === void 0 ? void 0 : _a.replace(/[']/g, ''); | ||
completionItemCopy.insertText = yamlUtils_1.convertJsonSnippetToYaml(completionItemCopy.insertText); | ||
} | ||
@@ -170,0 +166,0 @@ else { |
@@ -1,5 +0,1 @@ | ||
/*! | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
@@ -24,1 +20,2 @@ import { Position } from 'vscode-languageserver-types'; | ||
export declare function isStateNameReservedYamlKeyword(stateName: string): boolean; | ||
export declare function convertJsonSnippetToYaml(snippetText: string): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/*! | ||
@@ -6,3 +7,3 @@ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const js_yaml_1 = require("js-yaml"); | ||
const YAML_RESERVED_KEYWORDS = ['y', 'yes', 'n', 'no', 'true', 'false', 'on', 'off']; | ||
@@ -235,2 +236,32 @@ /** | ||
exports.isStateNameReservedYamlKeyword = isStateNameReservedYamlKeyword; | ||
function convertJsonSnippetToYaml(snippetText) { | ||
// Convert to YAML with indendation of 1 space | ||
return js_yaml_1.safeDump(js_yaml_1.safeLoad(snippetText), { indent: 1 }) | ||
// Remove quotation marks | ||
.replace(/[']/g, '') | ||
.split('\n') | ||
// For each line replace left padding spaces with tabs | ||
.map(line => { | ||
if (line.length) { | ||
let numOfSpaces = 0; | ||
// Count number of spaces that the line begins with | ||
for (const char of line) { | ||
if (char === ' ') { | ||
numOfSpaces++; | ||
} | ||
else { | ||
break; | ||
} | ||
} | ||
// Convert each space to tab character. Even though tab carracters are not valid yaml whitespace characters | ||
// the vscode will convert them to the correct number of spaces according to user preferences. | ||
return '\t'.repeat(numOfSpaces) + line.slice(numOfSpaces, line.length); | ||
} | ||
else { | ||
return line; | ||
} | ||
}) | ||
.join('\n'); | ||
} | ||
exports.convertJsonSnippetToYaml = convertJsonSnippetToYaml; | ||
//# sourceMappingURL=yamlUtils.js.map |
@@ -15,3 +15,3 @@ { | ||
"license": "MIT", | ||
"version": "1.6.2", | ||
"version": "1.6.3", | ||
"publisher": "aws", | ||
@@ -18,0 +18,0 @@ "categories": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
284942
4404