🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

View file

@ -0,0 +1,2 @@
import type { IPseudoClassData } from 'vscode-css-languageservice';
export declare const pseudoClass: IPseudoClassData[];

View file

@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pseudoClass = void 0;
exports.pseudoClass = [
{
name: ':global()',
description: 'Apply styles to a selector globally',
references: [
{
name: 'Astro documentation',
url: 'https://docs.astro.build/en/guides/styling/#global-styles-within-style-tag',
},
],
},
];

View file

@ -0,0 +1,19 @@
import type { Stylesheet } from 'vscode-css-languageservice';
import { CompletionItem, CompletionList } from 'vscode-languageserver';
import type { AttributeContext } from '../../../core/documents/parseHtml';
export declare function getIdClassCompletion(stylesheets: Stylesheet[], attributeContext: AttributeContext): CompletionList | null;
/**
* incomplete see
* https://github.com/microsoft/vscode-css-languageservice/blob/master/src/parser/cssNodes.ts#L14
* The enum is not exported. we have to update this whenever it changes
*/
export declare enum NodeType {
ClassSelector = 14,
IdentifierSelector = 15
}
export type CSSNode = {
type: number;
children: CSSNode[] | undefined;
getText(): string;
};
export declare function collectSelectors(stylesheets: CSSNode[], type: number): CompletionItem[];

View file

@ -0,0 +1,57 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.collectSelectors = exports.NodeType = exports.getIdClassCompletion = void 0;
const vscode_languageserver_1 = require("vscode-languageserver");
function getIdClassCompletion(stylesheets, attributeContext) {
const collectingType = getCollectingType(attributeContext);
if (!collectingType) {
return null;
}
const items = collectSelectors(stylesheets, collectingType);
return vscode_languageserver_1.CompletionList.create(items);
}
exports.getIdClassCompletion = getIdClassCompletion;
function getCollectingType(attributeContext) {
if (attributeContext.inValue) {
if (attributeContext.name === 'class') {
return NodeType.ClassSelector;
}
if (attributeContext.name === 'id') {
return NodeType.IdentifierSelector;
}
}
else if (attributeContext.name.startsWith('class:')) {
return NodeType.ClassSelector;
}
}
/**
* incomplete see
* https://github.com/microsoft/vscode-css-languageservice/blob/master/src/parser/cssNodes.ts#L14
* The enum is not exported. we have to update this whenever it changes
*/
var NodeType;
(function (NodeType) {
NodeType[NodeType["ClassSelector"] = 14] = "ClassSelector";
NodeType[NodeType["IdentifierSelector"] = 15] = "IdentifierSelector";
})(NodeType = exports.NodeType || (exports.NodeType = {}));
function collectSelectors(stylesheets, type) {
const result = [];
stylesheets.forEach((stylesheet) => {
walk(stylesheet, (node) => {
if (node.type === type) {
result.push(node);
}
});
});
return result.map((node) => ({
label: node.getText().substring(1),
kind: vscode_languageserver_1.CompletionItemKind.Keyword,
}));
}
exports.collectSelectors = collectSelectors;
function walk(node, callback) {
callback(node);
if (node.children) {
node.children.forEach((childrenNode) => walk(childrenNode, callback));
}
}