@master/css-language-service 2.0.0-rc.71 → 2.0.0-rc.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.d.ts +6 -2
- package/dist/core.mjs +8 -6
- package/dist/features/inspect-syntax.mjs +6 -6
- package/dist/features/render-syntax-colors.mjs +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/utils/completion-index.d.ts +4 -2
- package/dist/utils/completion-index.mjs +15 -14
- package/dist/utils/get-class-completion-items.mjs +12 -13
- package/dist/utils/get-pseudo-class-completion-items.mjs +2 -2
- package/dist/utils/get-pseudo-element-completion-items.mjs +2 -2
- package/dist/utils/get-query-completion-items.mjs +4 -4
- package/dist/utils/get-value-completion-items.mjs +8 -9
- package/dist/utils/query-syntax-completions.mjs +1 -1
- package/package.json +1 -1
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MasterCSS, type ClassPosition } from '@master/css-language';
|
|
1
|
+
import { type CSSLanguageRuntime, type MasterCSS, type ClassPosition } from '@master/css-language';
|
|
2
2
|
import EventEmitter from 'node:events';
|
|
3
3
|
import type { Position } from 'vscode-languageserver-protocol';
|
|
4
4
|
import { type Settings } from './settings';
|
|
@@ -9,13 +9,17 @@ import renderSemanticTokens, { renderSemanticTokensAtPosition } from './features
|
|
|
9
9
|
import suggestSyntax from './features/suggest-syntax';
|
|
10
10
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
11
11
|
export type { ClassPosition };
|
|
12
|
+
export interface CSSLanguageServiceOptions {
|
|
13
|
+
runtime?: CSSLanguageRuntime;
|
|
14
|
+
}
|
|
12
15
|
export default class CSSLanguageService extends EventEmitter {
|
|
13
16
|
customSettings?: Settings | undefined;
|
|
14
17
|
css: MasterCSS;
|
|
18
|
+
runtime: CSSLanguageRuntime;
|
|
15
19
|
settings: Settings;
|
|
16
20
|
private completionIndex?;
|
|
17
21
|
private classPositionCache;
|
|
18
|
-
constructor(customSettings?: Settings | undefined);
|
|
22
|
+
constructor(customSettings?: Settings | undefined, options?: CSSLanguageServiceOptions);
|
|
19
23
|
private getCompletionIndex;
|
|
20
24
|
inspectSyntax(...params: Parameters<typeof inspectSyntax>): import("vscode-languageserver-protocol").Hover | undefined;
|
|
21
25
|
renderSyntaxColors(...params: Parameters<typeof renderSyntaxColors>): Promise<import("vscode-languageserver-protocol").ColorInformation[] | undefined> | undefined;
|
package/dist/core.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClassPositionCache,
|
|
1
|
+
import { ClassPositionCache, defaultCSSLanguageRuntime, getClassPositions } from '@master/css-language';
|
|
2
2
|
import extend from '@techor/extend';
|
|
3
3
|
import EventEmitter from 'node:events';
|
|
4
4
|
import settings from './settings.mjs';
|
|
@@ -13,19 +13,21 @@ import { createCompletionIndex } from './utils/completion-index.mjs';
|
|
|
13
13
|
class CSSLanguageService extends EventEmitter {
|
|
14
14
|
customSettings;
|
|
15
15
|
css;
|
|
16
|
+
runtime;
|
|
16
17
|
settings;
|
|
17
18
|
completionIndex;
|
|
18
19
|
classPositionCache = new ClassPositionCache();
|
|
19
|
-
constructor(customSettings){
|
|
20
|
+
constructor(customSettings, options = {}){
|
|
20
21
|
super(), this.customSettings = customSettings;
|
|
22
|
+
this.runtime = options.runtime ?? defaultCSSLanguageRuntime;
|
|
21
23
|
this.settings = extend(settings, customSettings);
|
|
22
|
-
this.css = MasterCSS.create({
|
|
23
|
-
manifest: this.settings.manifest || defaultManifest,
|
|
24
|
-
nativeDeclarationMatcher:
|
|
24
|
+
this.css = this.runtime.MasterCSS.create({
|
|
25
|
+
manifest: this.settings.manifest || this.runtime.defaultManifest,
|
|
26
|
+
nativeDeclarationMatcher: this.runtime.nativeDeclarationMatcher
|
|
25
27
|
});
|
|
26
28
|
}
|
|
27
29
|
getCompletionIndex() {
|
|
28
|
-
this.completionIndex ??= createCompletionIndex(this.css);
|
|
30
|
+
this.completionIndex ??= createCompletionIndex(this.css, this.runtime);
|
|
29
31
|
return this.completionIndex;
|
|
30
32
|
}
|
|
31
33
|
inspectSyntax(...params) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import createCSSMarkdownDocumentation from '../utils/create-css-markdown-documentation.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { generateCSS } from '@master/css-language';
|
|
3
3
|
|
|
4
4
|
function inspectSyntax(document, position) {
|
|
5
5
|
const classPosition = this.getClassPosition(document, position);
|
|
@@ -10,11 +10,11 @@ function inspectSyntax(document, position) {
|
|
|
10
10
|
end: document.positionAt(classPosition.range.end)
|
|
11
11
|
};
|
|
12
12
|
const utilities = this.css.generate(token);
|
|
13
|
-
const component = utilities.find((utility)=>utility.type === UtilityType.Semantic && utility.layerName === 'components');
|
|
13
|
+
const component = utilities.find((utility)=>utility.type === this.runtime.UtilityType.Semantic && utility.layerName === 'components');
|
|
14
14
|
if (component) {
|
|
15
15
|
const documentation = createCSSMarkdownDocumentation(generateCSS([
|
|
16
16
|
token
|
|
17
|
-
], this.css));
|
|
17
|
+
], this.css, this.runtime));
|
|
18
18
|
if (documentation) {
|
|
19
19
|
return {
|
|
20
20
|
contents: {
|
|
@@ -26,10 +26,10 @@ function inspectSyntax(document, position) {
|
|
|
26
26
|
} else {
|
|
27
27
|
const utility = utilities[0];
|
|
28
28
|
if (utility) {
|
|
29
|
-
if (utility.type === UtilityType.Semantic) {
|
|
29
|
+
if (utility.type === this.runtime.UtilityType.Semantic) {
|
|
30
30
|
const documentation = createCSSMarkdownDocumentation(generateCSS([
|
|
31
31
|
token
|
|
32
|
-
], this.css));
|
|
32
|
+
], this.css, this.runtime));
|
|
33
33
|
if (documentation) {
|
|
34
34
|
return {
|
|
35
35
|
contents: documentation,
|
|
@@ -39,7 +39,7 @@ function inspectSyntax(document, position) {
|
|
|
39
39
|
} else {
|
|
40
40
|
const documentation = createCSSMarkdownDocumentation(generateCSS([
|
|
41
41
|
token
|
|
42
|
-
], this.css));
|
|
42
|
+
], this.css, this.runtime));
|
|
43
43
|
if (documentation) {
|
|
44
44
|
return {
|
|
45
45
|
contents: documentation,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { instancePattern } from '../utils/regex.mjs';
|
|
2
2
|
import Color from 'colorjs.io';
|
|
3
|
-
import { UtilityType } from '@master/css-language';
|
|
4
3
|
|
|
5
4
|
function resolveVariableColorValue(variable, variables) {
|
|
6
5
|
let current = variable;
|
|
@@ -23,7 +22,7 @@ async function renderSyntaxColors(document) {
|
|
|
23
22
|
const instanceStartIndex = instanceMatch.index;
|
|
24
23
|
const syntax = instanceMatch[0];
|
|
25
24
|
const rule = this.css.generate(syntax)[0];
|
|
26
|
-
if (rule && rule.type !== UtilityType.Semantic) {
|
|
25
|
+
if (rule && rule.type !== this.runtime.UtilityType.Semantic) {
|
|
27
26
|
const keyTokenLength = rule.keyToken?.length ?? 0;
|
|
28
27
|
let currentLength = 0;
|
|
29
28
|
const resolveValueComponent = (valueComponent)=>{
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default, default as CSSLanguageService } from './core';
|
|
1
|
+
export { default, default as CSSLanguageService, type CSSLanguageServiceOptions } from './core';
|
|
2
2
|
export { default as settings, type Settings } from './settings';
|
|
3
3
|
export * from './common';
|
|
4
4
|
export { default as inspectSyntax } from './features/inspect-syntax';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CompletionItem } from 'vscode-languageserver-protocol';
|
|
2
|
-
import { type AtRule, type MasterCSS } from '@master/css-language';
|
|
2
|
+
import { type AtRule, type CSSLanguageRuntime, type MasterCSS } from '@master/css-language';
|
|
3
3
|
import type { Variable } from '@master/css-language';
|
|
4
4
|
export interface ClassCompletionEntry extends CompletionItem {
|
|
5
5
|
documentationClassName?: string;
|
|
@@ -19,6 +19,8 @@ export interface SelectorVariantCandidate {
|
|
|
19
19
|
selector: string;
|
|
20
20
|
}
|
|
21
21
|
export interface CompletionIndex {
|
|
22
|
+
runtime: CSSLanguageRuntime;
|
|
23
|
+
keyAliases: CSSLanguageRuntime['builtinKeyAliases'];
|
|
22
24
|
classEntries: ClassCompletionEntry[];
|
|
23
25
|
componentNames: string[];
|
|
24
26
|
utilityNames: string[];
|
|
@@ -34,5 +36,5 @@ export interface CompletionIndex {
|
|
|
34
36
|
pseudoElementSelectors: SelectorVariantCandidate[];
|
|
35
37
|
atRules: [string, AtRule][];
|
|
36
38
|
}
|
|
37
|
-
export declare function createCompletionIndex(css?: MasterCSS): CompletionIndex;
|
|
39
|
+
export declare function createCompletionIndex(css?: MasterCSS, runtime?: CSSLanguageRuntime): CompletionIndex;
|
|
38
40
|
export declare function matchesIndexedName(field: string, name: string): boolean;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CompletionItemKind } from 'vscode-languageserver-protocol';
|
|
2
|
-
import {
|
|
3
|
-
import { UtilityType, getMdnPseudoElementNames, getMdnPseudoClassNames, createDefaultCSS } from '@master/css-language';
|
|
2
|
+
import { defaultCSSLanguageRuntime, getMdnPseudoElementNames, getMdnPseudoClassNames, createDefaultCSS } from '@master/css-language';
|
|
4
3
|
import getUtilityInfo from './get-utility-info.mjs';
|
|
5
4
|
import sortCompletionItems from './sort-completion-items.mjs';
|
|
6
5
|
|
|
@@ -36,7 +35,7 @@ function addMapValue(map, key, value) {
|
|
|
36
35
|
]);
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
function collectClassEntries(css) {
|
|
38
|
+
function collectClassEntries(css, runtime) {
|
|
40
39
|
const completionItems = [];
|
|
41
40
|
const addedKeys = new Set();
|
|
42
41
|
const addedCompletionLabels = new Set();
|
|
@@ -73,7 +72,7 @@ function collectClassEntries(css) {
|
|
|
73
72
|
});
|
|
74
73
|
};
|
|
75
74
|
for (const eachDefinedUtility of css.definedUtilities){
|
|
76
|
-
if (eachDefinedUtility.type === UtilityType.Semantic) {
|
|
75
|
+
if (eachDefinedUtility.type === runtime.UtilityType.Semantic) {
|
|
77
76
|
const isComponent = eachDefinedUtility.layer === 'components';
|
|
78
77
|
const { detail } = getUtilityInfo(eachDefinedUtility);
|
|
79
78
|
for (const matcher of eachDefinedUtility.matchers){
|
|
@@ -106,10 +105,10 @@ function collectClassEntries(css) {
|
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
|
-
for (const [key, canonicalKey] of Object.entries(builtinKeyAliases)){
|
|
108
|
+
for (const [key, canonicalKey] of Object.entries(runtime.builtinKeyAliases)){
|
|
110
109
|
addPropertyCompletionItem(key, canonicalKey);
|
|
111
110
|
}
|
|
112
|
-
for (const namespace of builtinNativeValueNamespaces){
|
|
111
|
+
for (const namespace of runtime.builtinNativeValueNamespaces){
|
|
113
112
|
for (const property of namespace.properties){
|
|
114
113
|
addPropertyCompletionItem(property);
|
|
115
114
|
}
|
|
@@ -159,9 +158,9 @@ function createPseudoElementSelectors(css) {
|
|
|
159
158
|
}
|
|
160
159
|
return selectors;
|
|
161
160
|
}
|
|
162
|
-
function createNativeVariableNamespacesByProperty() {
|
|
161
|
+
function createNativeVariableNamespacesByProperty(runtime) {
|
|
163
162
|
const namespacesByProperty = new Map();
|
|
164
|
-
for (const namespace of builtinNativeValueNamespaces){
|
|
163
|
+
for (const namespace of runtime.builtinNativeValueNamespaces){
|
|
165
164
|
const variableNamespaces = (namespace.variableAliasRefs || []).map((ref)=>ref[0] === '=' || ref[0] === '~' ? ref.slice(1) : '').filter(Boolean);
|
|
166
165
|
if (!variableNamespaces.length) continue;
|
|
167
166
|
for (const property of namespace.properties){
|
|
@@ -177,7 +176,7 @@ function createNativeVariableNamespacesByProperty() {
|
|
|
177
176
|
}
|
|
178
177
|
return namespacesByProperty;
|
|
179
178
|
}
|
|
180
|
-
function createCompletionIndex(css = createDefaultCSS()) {
|
|
179
|
+
function createCompletionIndex(css = createDefaultCSS(), runtime = defaultCSSLanguageRuntime) {
|
|
181
180
|
const componentNames = [];
|
|
182
181
|
const utilityNames = [];
|
|
183
182
|
const nativeUtilityKeys = new Map();
|
|
@@ -185,17 +184,17 @@ function createCompletionIndex(css = createDefaultCSS()) {
|
|
|
185
184
|
const patternValuesByKey = new Map();
|
|
186
185
|
const animationUtilitiesByKey = new Map();
|
|
187
186
|
for (const utility of css.definedUtilities){
|
|
188
|
-
const staticNames = utility.type === UtilityType.Semantic ? utilityNames : undefined;
|
|
187
|
+
const staticNames = utility.type === runtime.UtilityType.Semantic ? utilityNames : undefined;
|
|
189
188
|
for (const matcher of utility.matchers){
|
|
190
189
|
if (matcher.type === 'static') {
|
|
191
190
|
staticNames?.push(matcher.name);
|
|
192
|
-
if (utility.type === UtilityType.Semantic && utility.layer === 'components') {
|
|
191
|
+
if (utility.type === runtime.UtilityType.Semantic && utility.layer === 'components') {
|
|
193
192
|
componentNames.push(matcher.name);
|
|
194
193
|
}
|
|
195
194
|
} else if (matcher.type === 'pattern') {
|
|
196
195
|
const patternNames = matcher.values.map((value)=>matcher.prefix + value);
|
|
197
196
|
utilityNames.push(...patternNames);
|
|
198
|
-
if (utility.type === UtilityType.Semantic && utility.layer === 'components') {
|
|
197
|
+
if (utility.type === runtime.UtilityType.Semantic && utility.layer === 'components') {
|
|
199
198
|
componentNames.push(...patternNames);
|
|
200
199
|
}
|
|
201
200
|
if (matcher.prefix.endsWith(':')) {
|
|
@@ -239,14 +238,16 @@ function createCompletionIndex(css = createDefaultCSS()) {
|
|
|
239
238
|
}
|
|
240
239
|
}
|
|
241
240
|
return {
|
|
242
|
-
|
|
241
|
+
runtime,
|
|
242
|
+
keyAliases: runtime.builtinKeyAliases,
|
|
243
|
+
classEntries: collectClassEntries(css, runtime),
|
|
243
244
|
componentNames,
|
|
244
245
|
utilityNames,
|
|
245
246
|
nativeUtilityKeys,
|
|
246
247
|
scopedVariablesByKey,
|
|
247
248
|
patternValuesByKey,
|
|
248
249
|
animationUtilitiesByKey,
|
|
249
|
-
nativeVariableNamespacesByProperty: createNativeVariableNamespacesByProperty(),
|
|
250
|
+
nativeVariableNamespacesByProperty: createNativeVariableNamespacesByProperty(runtime),
|
|
250
251
|
variables: Array.from(css.variables.values()),
|
|
251
252
|
pseudoClassNames: getMdnPseudoClassNames(),
|
|
252
253
|
pseudoClassSelectors: createPseudoClassSelectors(css),
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generateCSS, createDefaultCSS } from '@master/css-language';
|
|
2
2
|
import createCSSMarkdownDocumentation from './create-css-markdown-documentation.mjs';
|
|
3
3
|
import { createCompletionIndex } from './completion-index.mjs';
|
|
4
4
|
|
|
5
|
-
function createCompletionItem(css, entry) {
|
|
6
|
-
const { documentationClassName, ...completionItem } = entry;
|
|
7
|
-
return {
|
|
8
|
-
...completionItem,
|
|
9
|
-
...documentationClassName ? {
|
|
10
|
-
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
11
|
-
documentationClassName
|
|
12
|
-
], css))
|
|
13
|
-
} : {}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
5
|
function getClassCompletionItems(css = createDefaultCSS(), completionIndex = createCompletionIndex(css)) {
|
|
17
|
-
return completionIndex.classEntries.map((entry)=>
|
|
6
|
+
return completionIndex.classEntries.map((entry)=>{
|
|
7
|
+
const { documentationClassName, ...completionItem } = entry;
|
|
8
|
+
return {
|
|
9
|
+
...completionItem,
|
|
10
|
+
...documentationClassName ? {
|
|
11
|
+
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
12
|
+
documentationClassName
|
|
13
|
+
], css, completionIndex.runtime))
|
|
14
|
+
} : {}
|
|
15
|
+
};
|
|
16
|
+
});
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
export { getClassCompletionItems as default };
|
|
@@ -41,7 +41,7 @@ function getPseudoClassCompletionItems(css = createDefaultCSS(), syntax, complet
|
|
|
41
41
|
sortText,
|
|
42
42
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
43
43
|
syntax + name.slice(1)
|
|
44
|
-
], css)),
|
|
44
|
+
], css, completionIndex.runtime)),
|
|
45
45
|
kind
|
|
46
46
|
};
|
|
47
47
|
});
|
|
@@ -55,7 +55,7 @@ function getPseudoClassCompletionItems(css = createDefaultCSS(), syntax, complet
|
|
|
55
55
|
label,
|
|
56
56
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
57
57
|
syntax + label.slice(1)
|
|
58
|
-
], css)),
|
|
58
|
+
], css, completionIndex.runtime)),
|
|
59
59
|
sortText,
|
|
60
60
|
kind,
|
|
61
61
|
detail: String(value)
|
|
@@ -15,7 +15,7 @@ function getPseudoElementCompletionItems(css = createDefaultCSS(), syntax, compl
|
|
|
15
15
|
sortText,
|
|
16
16
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
17
17
|
syntax + name.slice(2)
|
|
18
|
-
], css)),
|
|
18
|
+
], css, completionIndex.runtime)),
|
|
19
19
|
kind
|
|
20
20
|
};
|
|
21
21
|
});
|
|
@@ -30,7 +30,7 @@ function getPseudoElementCompletionItems(css = createDefaultCSS(), syntax, compl
|
|
|
30
30
|
label: name,
|
|
31
31
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
32
32
|
syntax + name.slice(2)
|
|
33
|
-
], css)),
|
|
33
|
+
], css, completionIndex.runtime)),
|
|
34
34
|
sortText,
|
|
35
35
|
kind,
|
|
36
36
|
detail: String(value)
|
|
@@ -19,7 +19,7 @@ function getQueryCompletionItems(css = createDefaultCSS(), triggerCharacter = AT
|
|
|
19
19
|
sortText: name + '()',
|
|
20
20
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
21
21
|
syntax + name + '()'
|
|
22
|
-
], css))
|
|
22
|
+
], css, completionIndex.runtime))
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -38,7 +38,7 @@ function getQueryCompletionItems(css = createDefaultCSS(), triggerCharacter = AT
|
|
|
38
38
|
kind: CompletionItemKind.Keyword,
|
|
39
39
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
40
40
|
syntax + token
|
|
41
|
-
], css))
|
|
41
|
+
], css, completionIndex.runtime))
|
|
42
42
|
});
|
|
43
43
|
return true;
|
|
44
44
|
}
|
|
@@ -49,7 +49,7 @@ function getQueryCompletionItems(css = createDefaultCSS(), triggerCharacter = AT
|
|
|
49
49
|
insertText: token,
|
|
50
50
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
51
51
|
syntax + token
|
|
52
|
-
], css))
|
|
52
|
+
], css, completionIndex.runtime))
|
|
53
53
|
};
|
|
54
54
|
if ([
|
|
55
55
|
AT_SIGN,
|
|
@@ -65,7 +65,7 @@ function getQueryCompletionItems(css = createDefaultCSS(), triggerCharacter = AT
|
|
|
65
65
|
kind: CompletionItemKind.Keyword,
|
|
66
66
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
67
67
|
syntax + token
|
|
68
|
-
], css))
|
|
68
|
+
], css, completionIndex.runtime))
|
|
69
69
|
});
|
|
70
70
|
} else if (QUERY_COMPARISON_OPERATORS.includes(triggerCharacter)) {
|
|
71
71
|
handleNumberNodes(atRule, token);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CompletionItemKind } from 'vscode-languageserver-protocol';
|
|
2
2
|
import { getMdnPropertySyntax, getMdnPropertyValueNames, generateCSS, createDefaultCSS } from '@master/css-language';
|
|
3
|
-
import { builtinKeyAliases } from '@master/css-engine';
|
|
4
3
|
import createCSSMarkdownDocumentation from './create-css-markdown-documentation.mjs';
|
|
5
4
|
import sortCompletionItems from './sort-completion-items.mjs';
|
|
6
5
|
import { createCompletionIndex } from './completion-index.mjs';
|
|
@@ -35,7 +34,7 @@ function getVariableKeyByNamespace(variableName, namespace) {
|
|
|
35
34
|
function getValueCompletionItems(css = createDefaultCSS(), ruleKey, valuePrefix = '', completionIndex = createCompletionIndex(css)) {
|
|
36
35
|
const completionItems = [];
|
|
37
36
|
const addedLabels = new Set();
|
|
38
|
-
const canonicalRuleKey =
|
|
37
|
+
const canonicalRuleKey = completionIndex.keyAliases[ruleKey] || ruleKey;
|
|
39
38
|
const nativeUtilityKey = completionIndex.nativeUtilityKeys.get(canonicalRuleKey);
|
|
40
39
|
const nativeKey = nativeUtilityKey || (getMdnPropertySyntax(canonicalRuleKey) ? canonicalRuleKey : undefined);
|
|
41
40
|
const nativePropertyValues = getMdnPropertyValueNames(nativeKey);
|
|
@@ -49,7 +48,7 @@ function getValueCompletionItems(css = createDefaultCSS(), ruleKey, valuePrefix
|
|
|
49
48
|
const valueToken = appliedValue ?? (scoped ? variable.key : variable.name);
|
|
50
49
|
const documentation = createCSSMarkdownDocumentation(generateCSS([
|
|
51
50
|
ruleKey + ':' + valueToken
|
|
52
|
-
], css));
|
|
51
|
+
], css, completionIndex.runtime));
|
|
53
52
|
const completionItemLabel = label ?? variable.name;
|
|
54
53
|
const conflicted = addedLabels.has(completionItemLabel);
|
|
55
54
|
const completionItem = {
|
|
@@ -59,11 +58,11 @@ function getValueCompletionItems(css = createDefaultCSS(), ruleKey, valuePrefix
|
|
|
59
58
|
if (conflicted) {
|
|
60
59
|
completionItem.documentation = createCSSMarkdownDocumentation(generateCSS([
|
|
61
60
|
ruleKey + ':' + completionItem.label
|
|
62
|
-
], css));
|
|
61
|
+
], css, completionIndex.runtime));
|
|
63
62
|
} else {
|
|
64
63
|
completionItem.documentation = createCSSMarkdownDocumentation(generateCSS([
|
|
65
64
|
ruleKey + ':' + valueToken
|
|
66
|
-
], css));
|
|
65
|
+
], css, completionIndex.runtime));
|
|
67
66
|
}
|
|
68
67
|
if (variable.namespace?.startsWith('color')) {
|
|
69
68
|
if (Object.keys(variable.modes || {}).length) {
|
|
@@ -132,7 +131,7 @@ function getValueCompletionItems(css = createDefaultCSS(), ruleKey, valuePrefix
|
|
|
132
131
|
kind: CompletionItemKind.Value,
|
|
133
132
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
134
133
|
ruleKey + ':' + value
|
|
135
|
-
], css)),
|
|
134
|
+
], css, completionIndex.runtime)),
|
|
136
135
|
detail: canonicalRuleKey + ': ' + value
|
|
137
136
|
});
|
|
138
137
|
}
|
|
@@ -145,7 +144,7 @@ function getValueCompletionItems(css = createDefaultCSS(), ruleKey, valuePrefix
|
|
|
145
144
|
kind: CompletionItemKind.Value,
|
|
146
145
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
147
146
|
ruleKey + ':' + animationName
|
|
148
|
-
], css)),
|
|
147
|
+
], css, completionIndex.runtime)),
|
|
149
148
|
detail: animationUtility.detailPrefix ? animationUtility.detailPrefix + ': ' + animationName : animationName
|
|
150
149
|
});
|
|
151
150
|
});
|
|
@@ -158,7 +157,7 @@ function getValueCompletionItems(css = createDefaultCSS(), ruleKey, valuePrefix
|
|
|
158
157
|
kind: CompletionItemKind.Value,
|
|
159
158
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
160
159
|
ruleKey + ':' + animationName
|
|
161
|
-
], css)),
|
|
160
|
+
], css, completionIndex.runtime)),
|
|
162
161
|
detail: canonicalRuleKey + ': ' + animationName
|
|
163
162
|
});
|
|
164
163
|
});
|
|
@@ -183,7 +182,7 @@ function getValueCompletionItems(css = createDefaultCSS(), ruleKey, valuePrefix
|
|
|
183
182
|
sortText: NATIVE_PRIORITY + (value.startsWith('-') ? 'zz' + value.slice(1) : value),
|
|
184
183
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
185
184
|
ruleKey + ':' + value
|
|
186
|
-
], css)),
|
|
185
|
+
], css, completionIndex.runtime)),
|
|
187
186
|
detail: nativeKey + ': ' + value
|
|
188
187
|
});
|
|
189
188
|
});
|
|
@@ -82,7 +82,7 @@ function querySyntaxCompletions(q = '', css = createDefaultCSS(), completionInde
|
|
|
82
82
|
insertText: '.',
|
|
83
83
|
documentation: createCSSMarkdownDocumentation(generateCSS([
|
|
84
84
|
field + '.class'
|
|
85
|
-
], css)),
|
|
85
|
+
], css, completionIndex.runtime)),
|
|
86
86
|
kind: CompletionItemKind.Class
|
|
87
87
|
});
|
|
88
88
|
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@master/css-language-service","type":"module","scripts":{"build":"techor build \"src/**/*.ts\" --formats esm","dev":"pnpm build --watch","type-check":"tsc --noEmit","lint":"eslint","test":"vitest"},"description":"Master CSS Language Service","author":"Aoyue Design LLC.","license":"MIT","repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/language-service"},"dependencies":{"@master/css":"^2.0.0-rc.
|
|
1
|
+
{"name":"@master/css-language-service","type":"module","scripts":{"build":"techor build \"src/**/*.ts\" --formats esm","dev":"pnpm build --watch","type-check":"tsc --noEmit","lint":"eslint","test":"vitest"},"description":"Master CSS Language Service","author":"Aoyue Design LLC.","license":"MIT","repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/language-service"},"dependencies":{"@master/css":"^2.0.0-rc.73","@master/css-engine":"^2.0.0-rc.73","@master/css-language":"^2.0.0-rc.73","@techor/extend":"^3.2.5","colorjs.io":"^0.6.1","js-beautify":"^1.15.4","minimatch":"^10.2.5","vscode-languageserver-protocol":"^3.18.0","vscode-languageserver-textdocument":"^1.0.12"},"devDependencies":{"@types/vscode":"^1.125.0","vscode-languageserver":"^10.0.0","@master/css-schema":"^2.0.0-rc.73"},"sideEffects":false,"main":"./dist/index.mjs","module":"./dist/index.mjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","default":"./dist/index.mjs"},"./common":{"types":"./dist/common.d.ts","import":"./dist/common.mjs","default":"./dist/common.mjs"}},"files":["dist"],"publishConfig":{"access":"public","provenance":true},"version":"2.0.0-rc.73"}
|