added vscode extensions
This commit is contained in:
parent
7cde0829be
commit
26e2a50441
316 changed files with 37301 additions and 0 deletions
85
.vscode/extensions/pranaygp.vscode-css-peek-4.2.0/server/out/core/findDefinition.js
vendored
Normal file
85
.vscode/extensions/pranaygp.vscode-css-peek-4.2.0/server/out/core/findDefinition.js
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.findDefinition = exports.findSymbols = exports.getLanguageService = exports.isLanguageServiceSupported = void 0;
|
||||
const path = require("path");
|
||||
const vscode_css_languageservice_1 = require("vscode-css-languageservice");
|
||||
const logger_1 = require("./../logger");
|
||||
const languageServices = {
|
||||
css: vscode_css_languageservice_1.getCSSLanguageService(),
|
||||
scss: vscode_css_languageservice_1.getSCSSLanguageService(),
|
||||
less: vscode_css_languageservice_1.getLESSLanguageService(),
|
||||
};
|
||||
function isLanguageServiceSupported(serviceId) {
|
||||
return !!languageServices[serviceId];
|
||||
}
|
||||
exports.isLanguageServiceSupported = isLanguageServiceSupported;
|
||||
function getLanguageService(document) {
|
||||
let service = languageServices[document.languageId];
|
||||
if (!service) {
|
||||
logger_1.console.log("Document type is " + document.languageId + ", using css instead.");
|
||||
service = languageServices["css"];
|
||||
}
|
||||
return service;
|
||||
}
|
||||
exports.getLanguageService = getLanguageService;
|
||||
function getSelection(selector) {
|
||||
switch (selector.attribute) {
|
||||
case "id":
|
||||
return "#" + selector.value;
|
||||
case "class":
|
||||
return "." + selector.value;
|
||||
default:
|
||||
return selector.value;
|
||||
}
|
||||
}
|
||||
function resolveSymbolName(symbols, i) {
|
||||
const name = symbols[i].name;
|
||||
if (name.startsWith("&")) {
|
||||
return resolveSymbolName(symbols, i - 1) + name.slice(1);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
function findSymbols(selector, stylesheetMap) {
|
||||
const foundSymbols = [];
|
||||
// Construct RegExp of selector to test against the symbols
|
||||
let selection = getSelection(selector);
|
||||
const classOrIdSelector = selector.attribute === "class" || selector.attribute === "id";
|
||||
if (selection[0] === ".") {
|
||||
selection = "\\" + selection;
|
||||
}
|
||||
if (!classOrIdSelector) {
|
||||
// Tag selectors must have nothing, whitespace, or a combinator before it.
|
||||
selection = "(^|[\\s>+~])" + selection;
|
||||
}
|
||||
const re = new RegExp(selection + "(\\[[^\\]]*\\]|:{1,2}[\\w-()]+|\\.[\\w-]+|#[\\w-]+)*\\s*$", classOrIdSelector ? "" : "i");
|
||||
// Test all the symbols against the RegExp
|
||||
Object.keys(stylesheetMap).forEach((uri) => {
|
||||
const { symbols } = stylesheetMap[uri];
|
||||
try {
|
||||
logger_1.console.log(`${path.basename(uri)} has ${symbols.length} symbols`);
|
||||
symbols.forEach((symbol, i) => {
|
||||
let name = resolveSymbolName(symbols, i);
|
||||
logger_1.console.log(` ${symbol.location.range.start.line}:${symbol.location.range.start.character} ${symbol.deprecated ? "[deprecated] " : " "}${symbol.containerName ? `[container:${symbol.containerName}] ` : " "} [${symbol.kind}] ${name}`);
|
||||
if (name.search(re) !== -1) {
|
||||
foundSymbols.push(symbol);
|
||||
}
|
||||
else if (!classOrIdSelector) {
|
||||
// Special case for tag selectors - match "*" as the rightmost character
|
||||
if (/\*\s*$/.test(name)) {
|
||||
foundSymbols.push(symbol);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
logger_1.console.log(e.stack);
|
||||
}
|
||||
});
|
||||
return foundSymbols;
|
||||
}
|
||||
exports.findSymbols = findSymbols;
|
||||
function findDefinition(selector, stylesheetMap) {
|
||||
return findSymbols(selector, stylesheetMap).map(({ location }) => location);
|
||||
}
|
||||
exports.findDefinition = findDefinition;
|
||||
//# sourceMappingURL=findDefinition.js.map
|
||||
114
.vscode/extensions/pranaygp.vscode-css-peek-4.2.0/server/out/core/findSelector.js
vendored
Normal file
114
.vscode/extensions/pranaygp.vscode-css-peek-4.2.0/server/out/core/findSelector.js
vendored
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
||||
const logger_1 = require("./../logger");
|
||||
/**
|
||||
* Find the selector given the document and the current cursor position.
|
||||
* This is found by iterating forwards and backwards from the position to find a valid CSS class/id
|
||||
*
|
||||
* @param {vscode.TextDocument} document - The Document to check
|
||||
* @param {vscode.Position} position - The current cursor position
|
||||
* @returns {{attribute: string, value: string}} The valid CSS selector
|
||||
*
|
||||
* @memberOf PeekFileDefinitionProvider
|
||||
*/
|
||||
function findSelector(document, position, settings) {
|
||||
const text = document.getText();
|
||||
const offset = document.offsetAt(position);
|
||||
let start = offset;
|
||||
let end = offset;
|
||||
// expand selection to this word specifically
|
||||
while (start > 0 &&
|
||||
text.charAt(start - 1) !== " " &&
|
||||
text.charAt(start - 1) !== "'" &&
|
||||
text.charAt(start - 1) !== '"' &&
|
||||
text.charAt(start - 1) !== "\n" &&
|
||||
text.charAt(start - 1) !== "/" &&
|
||||
text.charAt(start - 1) !== "<")
|
||||
start -= 1;
|
||||
while (end < text.length &&
|
||||
text.charAt(end) !== " " &&
|
||||
text.charAt(end) !== "'" &&
|
||||
text.charAt(end) !== '"' &&
|
||||
text.charAt(end) !== "\n" &&
|
||||
text.charAt(end) !== ">")
|
||||
end += 1;
|
||||
const selectorWord = text.slice(start, end);
|
||||
let selector = null;
|
||||
const htmlScanner = vscode_html_languageservice_1.getLanguageService().createScanner(text);
|
||||
let attribute = null;
|
||||
logger_1.console.log(`${selectorWord} ${start}`);
|
||||
let tokenType = htmlScanner.scan();
|
||||
while (tokenType !== vscode_html_languageservice_1.TokenType.EOS) {
|
||||
switch (tokenType) {
|
||||
case vscode_html_languageservice_1.TokenType.StartTag:
|
||||
case vscode_html_languageservice_1.TokenType.EndTag:
|
||||
attribute = null;
|
||||
if (!settings.supportTags) {
|
||||
break;
|
||||
}
|
||||
// FOR DEBUGGING
|
||||
logger_1.console.log(` ${htmlScanner.getTokenText()} ${htmlScanner.getTokenOffset()} ${htmlScanner.getTokenEnd()}`);
|
||||
const tokenOffset = htmlScanner.getTokenOffset();
|
||||
if ([
|
||||
"javascript",
|
||||
"typescript",
|
||||
"javascriptreact",
|
||||
"typescriptreact",
|
||||
].includes(document.languageId)) {
|
||||
if (selectorWord[0].toUpperCase() === selectorWord[0]) {
|
||||
// if the first letter is uppercase, this is a JSX component
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start === tokenOffset)
|
||||
selector = { attribute: null, value: selectorWord };
|
||||
break;
|
||||
case vscode_html_languageservice_1.TokenType.AttributeName:
|
||||
attribute = htmlScanner.getTokenText().toLowerCase();
|
||||
// Convert the attribute to a standard class attribute
|
||||
if (attribute === "classname") {
|
||||
attribute = "class";
|
||||
}
|
||||
break;
|
||||
case vscode_html_languageservice_1.TokenType.AttributeValue:
|
||||
// FOR DEBUGGING
|
||||
// console.log(
|
||||
// `${htmlScanner.getTokenText()} ${htmlScanner.getTokenOffset()} ${htmlScanner.getTokenEnd()}`
|
||||
// );
|
||||
if (attribute === "class" || attribute === "id") {
|
||||
const values = htmlScanner.getTokenText().slice(1, -1).split(" ");
|
||||
// calculate startOffsets for each class/id in this attribute
|
||||
// +1 because we sliced earlier, so the first offset is the offset + 1
|
||||
let startOffset = htmlScanner.getTokenOffset() + 1;
|
||||
const offsets = values.map((v) => {
|
||||
const o = startOffset;
|
||||
startOffset += v.length + 1; // add 1 for the space
|
||||
return o;
|
||||
});
|
||||
values.forEach((value, i) => {
|
||||
const startOffset = offsets[i];
|
||||
// FOR DEBUGGING
|
||||
// console.log(` ${value} ${startOffset}`);
|
||||
if (start === startOffset) {
|
||||
selector = { attribute, value };
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (selector) {
|
||||
break;
|
||||
}
|
||||
tokenType = htmlScanner.scan();
|
||||
}
|
||||
if (selector) {
|
||||
logger_1.console.log(`${selector.value} is a "${selector.attribute || "html tag"}"`);
|
||||
}
|
||||
else {
|
||||
logger_1.console.log("Invalid Selector");
|
||||
}
|
||||
return selector;
|
||||
}
|
||||
exports.default = findSelector;
|
||||
//# sourceMappingURL=findSelector.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue