Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
languageFacts.cssDataManager.getProperties().forEach(function (p) {
var score = strings_1.difference(propertyName, p.name);
if (score >= propertyName.length / 2 /*score_lim*/) {
candidates.push({ property: p.name, score: score });
}
});
// Sort in descending order.
candidates.sort(function (a, b) {
return b.score - a.score;
});
var maxActions = 3;
for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
var candidate = candidates_1[_i];
var propertyName_1 = candidate.property;
var title = localize('css.codeaction.rename', "Rename to '{0}'", propertyName_1);
var edit = vscode_languageserver_types_1.TextEdit.replace(marker.range, propertyName_1);
var documentIdentifier = vscode_languageserver_types_1.VersionedTextDocumentIdentifier.create(document.uri, document.version);
var workspaceEdit = { documentChanges: [vscode_languageserver_types_1.TextDocumentEdit.create(documentIdentifier, [edit])] };
var codeAction = vscode_languageserver_types_1.CodeAction.create(title, workspaceEdit, vscode_languageserver_types_1.CodeActionKind.QuickFix);
codeAction.diagnostics = [marker];
result.push(codeAction);
if (--maxActions <= 0) {
return;
}
}
};
CSSCodeActions.prototype.appendFixesForMarker = function (document, stylesheet, marker, result) {
for (var p in languageFacts.getProperties()) {
var score = strings_1.difference(propertyName, p);
if (score >= propertyName.length / 2 /*score_lim*/) {
candidates.push({ property: p, score: score });
}
}
// Sort in descending order.
candidates.sort(function (a, b) {
return b.score - a.score;
});
var maxActions = 3;
for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
var candidate = candidates_1[_i];
var propertyName_1 = candidate.property;
var title = localize('css.codeaction.rename', "Rename to '{0}'", propertyName_1);
var edit = vscode_languageserver_types_1.TextEdit.replace(marker.range, propertyName_1);
result.push(vscode_languageserver_types_1.Command.create(title, '_css.applyCodeAction', document.uri, document.version, [edit]));
if (--maxActions <= 0) {
return;
}
}
};
CSSCodeActions.prototype.appendFixesForMarker = function (document, stylesheet, marker, result) {
})(function (require, exports) {
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var vscode_languageserver_types_1 = require("vscode-languageserver-types");
exports.Range = vscode_languageserver_types_1.Range;
exports.TextEdit = vscode_languageserver_types_1.TextEdit;
exports.Position = vscode_languageserver_types_1.Position;
});
//# sourceMappingURL=cssLanguageTypes.js.map
}
for (var color in languageFacts.colorKeywords) {
result.items.push({
label: color,
documentation: languageFacts.colorKeywords[color],
textEdit: vscode_languageserver_types_1.TextEdit.replace(this.getCompletionRange(existingNode), color),
kind: vscode_languageserver_types_1.CompletionItemKind.Value
});
}
var colorValues = new Set();
this.styleSheet.acceptVisitor(new ColorValueCollector(colorValues));
for (var _i = 0, _a = colorValues.getEntries(); _i < _a.length; _i++) {
var color = _a[_i];
result.items.push({
label: color,
textEdit: vscode_languageserver_types_1.TextEdit.replace(this.getCompletionRange(existingNode), color),
kind: vscode_languageserver_types_1.CompletionItemKind.Color
});
}
var _loop_1 = function (p) {
var tabStop = 1;
var replaceFunction = function (match, p1) { return '${' + tabStop++ + ':' + p1 + '}'; };
var insertText = p.func.replace(/\[?\$(\w+)\]?/g, replaceFunction);
result.items.push({
label: p.func.substr(0, p.func.indexOf('(')),
detail: p.func,
documentation: p.desc,
textEdit: vscode_languageserver_types_1.TextEdit.replace(this_1.getCompletionRange(existingNode), insertText),
insertTextFormat: SnippetFormat,
kind: vscode_languageserver_types_1.CompletionItemKind.Function
});
};
result.push({ label: label, textEdit: vscode_languageserver_types_1.TextEdit.replace(range, label) });
if (color.alpha === 1) {
label = "#" + toTwoDigitHex(red256) + toTwoDigitHex(green256) + toTwoDigitHex(blue256);
}
else {
label = "#" + toTwoDigitHex(red256) + toTwoDigitHex(green256) + toTwoDigitHex(blue256) + toTwoDigitHex(Math.round(color.alpha * 255));
}
result.push({ label: label, textEdit: vscode_languageserver_types_1.TextEdit.replace(range, label) });
var hsl = languageFacts_1.hslFromColor(color);
if (hsl.a === 1) {
label = "hsl(" + hsl.h + ", " + Math.round(hsl.s * 100) + "%, " + Math.round(hsl.l * 100) + "%)";
}
else {
label = "hsla(" + hsl.h + ", " + Math.round(hsl.s * 100) + "%, " + Math.round(hsl.l * 100) + "%, " + hsl.a + ")";
}
result.push({ label: label, textEdit: vscode_languageserver_types_1.TextEdit.replace(range, label) });
return result;
};
CSSNavigation.prototype.doRename = function (document, position, newName, stylesheet) {
tagProvider.collectAttributes(currentTag, (attribute, type) => {
let codeSnippet = attribute;
if (type !== 'v' && value.length) {
codeSnippet = codeSnippet + value;
}
result.items.push({
textEdit: vscode_languageserver_types_1.TextEdit.replace(range, codeSnippet),
kind: type === 'handler' ? vscode_languageserver_types_1.CompletionItemKind.Function : vscode_languageserver_types_1.CompletionItemKind.Value,
label: attribute,
insertTextFormat: vscode_languageserver_types_1.InsertTextFormat.Snippet
});
});
return result;
SCSSCompletion.prototype.createFunctionProposals = function (proposals, existingNode, sortToEnd, result) {
for (var _i = 0, proposals_1 = proposals; _i < proposals_1.length; _i++) {
var p = proposals_1[_i];
var insertText = p.func.replace(/\[?(\$\w+)\]?/g, this.createReplaceFunction());
var label = p.func.substr(0, p.func.indexOf('('));
var item = {
label: label,
detail: p.func,
documentation: p.desc,
textEdit: vscode_languageserver_types_1.TextEdit.replace(this.getCompletionRange(existingNode), insertText),
insertTextFormat: vscode_languageserver_types_1.InsertTextFormat.Snippet,
kind: vscode_languageserver_types_1.CompletionItemKind.Function
};
if (sortToEnd) {
item.sortText = 'z';
}
result.items.push(item);
}
return result;
};
SCSSCompletion.prototype.getCompletionsForSelector = function (ruleSet, isNested, result) {
CSSCompletion.prototype.getLineWidthProposals = function (entry, existingNode, result) {
for (var _i = 0, _a = languageFacts.lineWidthKeywords; _i < _a.length; _i++) {
var lineWidth = _a[_i];
result.items.push({
label: lineWidth,
textEdit: vscode_languageserver_types_1.TextEdit.replace(this.getCompletionRange(existingNode), lineWidth),
kind: vscode_languageserver_types_1.CompletionItemKind.Value
});
}
return result;
};
CSSCompletion.prototype.getGeometryBoxProposals = function (entry, existingNode, result) {
const createExpandedAbbr = (abbr) => {
try {
expandedText = expand_full_1.expand(abbr, expandOptions);
}
catch (e) {
}
if (expandedText && isExpandedTextNoise(syntax, abbr, expandedText)) {
expandedText = '';
}
if (expandedText) {
expandedAbbr = vscode_languageserver_types_1.CompletionItem.create(abbr);
expandedAbbr.textEdit = vscode_languageserver_types_1.TextEdit.replace(abbreviationRange, escapeNonTabStopDollar(addFinalTabStop(expandedText)));
expandedAbbr.documentation = replaceTabStopsWithCursors(expandedText);
expandedAbbr.insertTextFormat = vscode_languageserver_types_1.InsertTextFormat.Snippet;
expandedAbbr.detail = 'Emmet Abbreviation';
expandedAbbr.label = abbreviation;
expandedAbbr.label += filter ? '|' + filter.replace(',', '|') : "";
completionItems = [expandedAbbr];
}
};
if (isStyleSheet(syntax)) {