@master/css-language-service 2.0.0-rc.26 → 2.0.0-rc.27
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/common.cjs +57 -0
- package/dist/common.d.ts +9 -0
- package/dist/common.mjs +48 -0
- package/dist/core.cjs +188 -0
- package/dist/core.d.ts +30 -0
- package/dist/core.mjs +186 -0
- package/dist/features/edit-syntax-colors.cjs +19 -0
- package/dist/features/edit-syntax-colors.d.ts +4 -0
- package/dist/features/edit-syntax-colors.mjs +17 -0
- package/dist/features/inspect-syntax.cjs +70 -0
- package/dist/features/inspect-syntax.d.ts +4 -0
- package/dist/features/inspect-syntax.mjs +68 -0
- package/dist/features/render-syntax-colors.cjs +88 -0
- package/dist/features/render-syntax-colors.d.ts +4 -0
- package/dist/features/render-syntax-colors.mjs +86 -0
- package/dist/features/suggest-syntax.cjs +20 -0
- package/dist/features/suggest-syntax.d.ts +4 -0
- package/dist/features/suggest-syntax.mjs +18 -0
- package/dist/index.cjs +23 -15
- package/dist/index.d.ts +7 -5
- package/dist/index.mjs +7 -5
- package/dist/settings.cjs +130 -29
- package/dist/settings.d.ts +16 -8
- package/dist/settings.mjs +130 -29
- package/dist/utils/beautify-css.cjs +13 -0
- package/dist/utils/beautify-css.d.ts +1 -0
- package/dist/utils/beautify-css.mjs +11 -0
- package/dist/utils/convert-color-space.cjs +40 -0
- package/dist/utils/convert-color-space.d.ts +2 -0
- package/dist/utils/convert-color-space.mjs +38 -0
- package/dist/utils/convert-color-token.cjs +28 -0
- package/dist/utils/convert-color-token.d.ts +3 -0
- package/dist/utils/convert-color-token.mjs +26 -0
- package/dist/utils/create-doc.cjs +26 -0
- package/dist/utils/create-doc.d.ts +16 -0
- package/dist/utils/create-doc.mjs +21 -0
- package/dist/utils/css-data-provider.cjs +9 -0
- package/dist/utils/css-data-provider.d.ts +3 -0
- package/dist/utils/css-data-provider.mjs +7 -0
- package/dist/utils/find-matching-brackets.cjs +29 -0
- package/dist/utils/find-matching-brackets.d.ts +1 -0
- package/dist/utils/find-matching-brackets.mjs +27 -0
- package/dist/utils/get-color-completion-items.cjs +30 -0
- package/dist/utils/get-color-completion-items.d.ts +3 -0
- package/dist/utils/get-color-completion-items.mjs +28 -0
- package/dist/utils/get-css-data-documentation.cjs +90 -0
- package/dist/utils/get-css-data-documentation.d.ts +5 -0
- package/dist/utils/get-css-data-documentation.mjs +88 -0
- package/dist/utils/get-main-completion-items.cjs +105 -0
- package/dist/utils/get-main-completion-items.d.ts +3 -0
- package/dist/utils/get-main-completion-items.mjs +103 -0
- package/dist/utils/get-position.cjs +12 -0
- package/dist/utils/get-position.d.ts +1 -0
- package/dist/utils/get-position.mjs +10 -0
- package/dist/utils/get-pseudo-class-completion-items.cjs +65 -0
- package/dist/utils/get-pseudo-class-completion-items.d.ts +3 -0
- package/dist/utils/get-pseudo-class-completion-items.mjs +63 -0
- package/dist/utils/get-pseudo-element-completion-items.cjs +56 -0
- package/dist/utils/get-pseudo-element-completion-items.d.ts +3 -0
- package/dist/utils/get-pseudo-element-completion-items.mjs +54 -0
- package/dist/utils/get-query-completion-items.cjs +102 -0
- package/dist/utils/get-query-completion-items.d.ts +3 -0
- package/dist/utils/get-query-completion-items.mjs +100 -0
- package/dist/utils/get-range.cjs +21 -0
- package/dist/utils/get-range.d.ts +2 -0
- package/dist/utils/get-range.mjs +19 -0
- package/dist/utils/get-utility-info.cjs +32 -0
- package/dist/utils/get-utility-info.d.ts +7 -0
- package/dist/utils/get-utility-info.mjs +30 -0
- package/dist/utils/get-value-completion-items.cjs +185 -0
- package/dist/utils/get-value-completion-items.d.ts +3 -0
- package/dist/utils/get-value-completion-items.mjs +183 -0
- package/dist/utils/query-syntax-completions.cjs +115 -0
- package/dist/utils/query-syntax-completions.d.ts +3 -0
- package/dist/utils/query-syntax-completions.mjs +113 -0
- package/dist/utils/regex.cjs +1 -1
- package/dist/utils/regex.mjs +1 -1
- package/dist/utils/sort-completion-items.cjs +11 -0
- package/dist/utils/sort-completion-items.d.ts +2 -0
- package/dist/utils/sort-completion-items.mjs +9 -0
- package/package.json +1 -1
- package/dist/constant.cjs +0 -3064
- package/dist/constant.d.ts +0 -33
- package/dist/constant.mjs +0 -3055
- package/dist/position-check.cjs +0 -37
- package/dist/position-check.d.ts +0 -7
- package/dist/position-check.mjs +0 -35
- package/dist/providers/color.cjs +0 -319
- package/dist/providers/color.d.ts +0 -5
- package/dist/providers/color.mjs +0 -315
- package/dist/providers/completion.cjs +0 -309
- package/dist/providers/completion.d.ts +0 -14
- package/dist/providers/completion.mjs +0 -303
- package/dist/providers/hover.cjs +0 -65
- package/dist/providers/hover.d.ts +0 -2
- package/dist/providers/hover.mjs +0 -63
- package/dist/utils/get-css-entry-markdown-description.cjs +0 -77
- package/dist/utils/get-css-entry-markdown-description.d.ts +0 -1
- package/dist/utils/get-css-entry-markdown-description.mjs +0 -75
- package/dist/utils/hex-to-rgb.cjs +0 -13
- package/dist/utils/hex-to-rgb.d.ts +0 -2
- package/dist/utils/hex-to-rgb.mjs +0 -11
- package/dist/utils/oklab-to-rgb.cjs +0 -33
- package/dist/utils/oklab-to-rgb.d.ts +0 -1
- package/dist/utils/oklab-to-rgb.mjs +0 -31
- package/dist/utils/oklch-to-oklab.cjs +0 -11
- package/dist/utils/oklch-to-oklab.d.ts +0 -1
- package/dist/utils/oklch-to-oklab.mjs +0 -9
- package/dist/utils/to-two-digit-hex.cjs +0 -8
- package/dist/utils/to-two-digit-hex.d.ts +0 -1
- package/dist/utils/to-two-digit-hex.mjs +0 -6
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import beautifyCSS from './beautify-css.mjs';
|
|
2
|
+
import { OFFICIAL_URL } from '@master/css';
|
|
3
|
+
|
|
4
|
+
function getCSSDataDocumentation(data, additional) {
|
|
5
|
+
const values = [];
|
|
6
|
+
const references = data?.references ? [
|
|
7
|
+
...data.references
|
|
8
|
+
] : [];
|
|
9
|
+
if (data?.status) {
|
|
10
|
+
values.push(getEntryStatus(data.status));
|
|
11
|
+
}
|
|
12
|
+
if (additional?.generatedCSS) {
|
|
13
|
+
values.push('```css\n' + beautifyCSS(additional.generatedCSS) + '\n```');
|
|
14
|
+
}
|
|
15
|
+
if (data?.description) if (typeof data.description === 'string') {
|
|
16
|
+
values.push(textToMarkedString(data.description));
|
|
17
|
+
} else {
|
|
18
|
+
values.push(data.description.kind === 'markdown' ? data.description.value : textToMarkedString(data.description.value));
|
|
19
|
+
}
|
|
20
|
+
const browserLabel = getBrowserLabel(data?.browsers);
|
|
21
|
+
if (browserLabel) {
|
|
22
|
+
values.push('(' + textToMarkedString(browserLabel) + ')');
|
|
23
|
+
}
|
|
24
|
+
if (data && 'syntax' in data && data.syntax) {
|
|
25
|
+
values.push(`Syntax: ${textToMarkedString(data.syntax)}`);
|
|
26
|
+
}
|
|
27
|
+
// todo: can i use
|
|
28
|
+
if (additional?.docs) {
|
|
29
|
+
references.unshift({
|
|
30
|
+
name: 'Master CSS',
|
|
31
|
+
url: new URL(`/docs/${additional.docs}`, OFFICIAL_URL).href
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (references.length) {
|
|
35
|
+
values.push(references.map((r)=>{
|
|
36
|
+
return `[${r.name}](${r.url})`;
|
|
37
|
+
}).join(' | '));
|
|
38
|
+
}
|
|
39
|
+
return values?.length ? {
|
|
40
|
+
kind: 'markdown',
|
|
41
|
+
value: values.join('\n\n')
|
|
42
|
+
} : undefined;
|
|
43
|
+
}
|
|
44
|
+
const browserNames = {
|
|
45
|
+
E: 'Edge',
|
|
46
|
+
FF: 'Firefox',
|
|
47
|
+
S: 'Safari',
|
|
48
|
+
C: 'Chrome',
|
|
49
|
+
IE: 'IE',
|
|
50
|
+
O: 'Opera'
|
|
51
|
+
};
|
|
52
|
+
function getEntryStatus(status) {
|
|
53
|
+
switch(status){
|
|
54
|
+
case 'experimental':
|
|
55
|
+
return '⚠️ Property is experimental. Be cautious when using it.️\n\n';
|
|
56
|
+
case 'nonstandard':
|
|
57
|
+
return '🚨️ Property is nonstandard. Avoid using it.\n\n';
|
|
58
|
+
case 'obsolete':
|
|
59
|
+
return '🚨️️️ Property is obsolete. Avoid using it.\n\n';
|
|
60
|
+
default:
|
|
61
|
+
return '';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function textToMarkedString(text) {
|
|
65
|
+
text = text.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&') // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
|
|
66
|
+
;
|
|
67
|
+
return text.replace(/</g, '<').replace(/>/g, '>');
|
|
68
|
+
}
|
|
69
|
+
function getBrowserLabel(browsers = []) {
|
|
70
|
+
if (browsers.length === 0) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return browsers.map((b)=>{
|
|
74
|
+
let value = '';
|
|
75
|
+
const matches = b.match(/([A-Z]+)(\d+)?/) ?? '';
|
|
76
|
+
const name = matches[1];
|
|
77
|
+
const version = matches[2];
|
|
78
|
+
if (name in browserNames) {
|
|
79
|
+
value += browserNames[name];
|
|
80
|
+
}
|
|
81
|
+
if (version) {
|
|
82
|
+
value += ' ' + version;
|
|
83
|
+
}
|
|
84
|
+
return value;
|
|
85
|
+
}).join(', ');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { getCSSDataDocumentation };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vscodeLanguageserverProtocol = require('vscode-languageserver-protocol');
|
|
4
|
+
var css = require('@master/css');
|
|
5
|
+
var getCssDataDocumentation = require('./get-css-data-documentation.cjs');
|
|
6
|
+
var sortCompletionItems = require('./sort-completion-items.cjs');
|
|
7
|
+
var getUtilityInfo = require('./get-utility-info.cjs');
|
|
8
|
+
var cssDataProvider = require('./css-data-provider.cjs');
|
|
9
|
+
|
|
10
|
+
function getMainCompletionItems(css$1 = new css.MasterCSS()) {
|
|
11
|
+
const completionItems = [];
|
|
12
|
+
const addedKeys = new Set();
|
|
13
|
+
for (const EachRule of css$1.Rules){
|
|
14
|
+
if (EachRule.definition.layer === css.Layer.Utility) {
|
|
15
|
+
const { data, detail, docs } = getUtilityInfo(EachRule, css$1);
|
|
16
|
+
const utilityName = EachRule.id.slice(1);
|
|
17
|
+
completionItems.push({
|
|
18
|
+
label: utilityName,
|
|
19
|
+
kind: vscodeLanguageserverProtocol.CompletionItemKind.Value,
|
|
20
|
+
documentation: getCssDataDocumentation.getCSSDataDocumentation(data, {
|
|
21
|
+
generatedCSS: css.generateCSS([
|
|
22
|
+
utilityName
|
|
23
|
+
], css$1),
|
|
24
|
+
docs
|
|
25
|
+
}),
|
|
26
|
+
detail
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
const nativeProperties = cssDataProvider.provideProperties();
|
|
30
|
+
const nativeCSSPropertyData = nativeProperties.find(({ name })=>name === EachRule.id);
|
|
31
|
+
const eachCompletionItem = {
|
|
32
|
+
kind: vscodeLanguageserverProtocol.CompletionItemKind.Property,
|
|
33
|
+
documentation: getCssDataDocumentation.getCSSDataDocumentation(nativeCSSPropertyData, {
|
|
34
|
+
docs: css.isCoreRule(EachRule.id) && EachRule.id
|
|
35
|
+
}),
|
|
36
|
+
detail: nativeCSSPropertyData?.syntax
|
|
37
|
+
};
|
|
38
|
+
EachRule.keys.forEach((key)=>{
|
|
39
|
+
addedKeys.delete(key);
|
|
40
|
+
completionItems.push({
|
|
41
|
+
...eachCompletionItem,
|
|
42
|
+
label: key + ':',
|
|
43
|
+
sortText: key,
|
|
44
|
+
command: {
|
|
45
|
+
title: 'triggerSuggest',
|
|
46
|
+
command: 'editor.action.triggerSuggest'
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* @example @ animation and ~ transition
|
|
52
|
+
*/ if (EachRule.definition?.sign && EachRule.definition.includeAnimations) {
|
|
53
|
+
for(const animationName in css$1.animations){
|
|
54
|
+
completionItems.push({
|
|
55
|
+
...eachCompletionItem,
|
|
56
|
+
label: EachRule.definition.sign + animationName + '|1s',
|
|
57
|
+
kind: vscodeLanguageserverProtocol.CompletionItemKind.Value
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (EachRule.definition?.ambiguousKeys?.length) {
|
|
62
|
+
for (const ambiguousKey of EachRule.definition.ambiguousKeys){
|
|
63
|
+
if (addedKeys.has(ambiguousKey)) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
addedKeys.add(ambiguousKey);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
addedKeys.forEach((ambiguousKey)=>{
|
|
72
|
+
/**
|
|
73
|
+
* Ambiguous keys are added to the completion list
|
|
74
|
+
* @example text: t:
|
|
75
|
+
*/ completionItems.push({
|
|
76
|
+
kind: vscodeLanguageserverProtocol.CompletionItemKind.Property,
|
|
77
|
+
detail: 'ambiguous key',
|
|
78
|
+
label: ambiguousKey + ':',
|
|
79
|
+
sortText: ambiguousKey,
|
|
80
|
+
command: {
|
|
81
|
+
title: 'triggerSuggest',
|
|
82
|
+
command: 'editor.action.triggerSuggest'
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
if (css$1.config.styles) {
|
|
87
|
+
for(const styleName in css$1.config.styles){
|
|
88
|
+
const styleClasses = css$1.styles[styleName];
|
|
89
|
+
completionItems.push({
|
|
90
|
+
label: styleName,
|
|
91
|
+
kind: vscodeLanguageserverProtocol.CompletionItemKind.Value,
|
|
92
|
+
documentation: getCssDataDocumentation.getCSSDataDocumentation({}, {
|
|
93
|
+
generatedCSS: css.generateCSS([
|
|
94
|
+
styleName
|
|
95
|
+
], css$1),
|
|
96
|
+
docs: 'styles'
|
|
97
|
+
}),
|
|
98
|
+
detail: styleClasses.join(' ') + ' (style)'
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return sortCompletionItems(completionItems);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
module.exports = getMainCompletionItems;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CompletionItemKind } from 'vscode-languageserver-protocol';
|
|
2
|
+
import { Layer, generateCSS, isCoreRule, MasterCSS } from '@master/css';
|
|
3
|
+
import { getCSSDataDocumentation } from './get-css-data-documentation.mjs';
|
|
4
|
+
import sortCompletionItems from './sort-completion-items.mjs';
|
|
5
|
+
import getUtilityInfo from './get-utility-info.mjs';
|
|
6
|
+
import cssDataProvider from './css-data-provider.mjs';
|
|
7
|
+
|
|
8
|
+
function getMainCompletionItems(css = new MasterCSS()) {
|
|
9
|
+
const completionItems = [];
|
|
10
|
+
const addedKeys = new Set();
|
|
11
|
+
for (const EachRule of css.Rules){
|
|
12
|
+
if (EachRule.definition.layer === Layer.Utility) {
|
|
13
|
+
const { data, detail, docs } = getUtilityInfo(EachRule, css);
|
|
14
|
+
const utilityName = EachRule.id.slice(1);
|
|
15
|
+
completionItems.push({
|
|
16
|
+
label: utilityName,
|
|
17
|
+
kind: CompletionItemKind.Value,
|
|
18
|
+
documentation: getCSSDataDocumentation(data, {
|
|
19
|
+
generatedCSS: generateCSS([
|
|
20
|
+
utilityName
|
|
21
|
+
], css),
|
|
22
|
+
docs
|
|
23
|
+
}),
|
|
24
|
+
detail
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
const nativeProperties = cssDataProvider.provideProperties();
|
|
28
|
+
const nativeCSSPropertyData = nativeProperties.find(({ name })=>name === EachRule.id);
|
|
29
|
+
const eachCompletionItem = {
|
|
30
|
+
kind: CompletionItemKind.Property,
|
|
31
|
+
documentation: getCSSDataDocumentation(nativeCSSPropertyData, {
|
|
32
|
+
docs: isCoreRule(EachRule.id) && EachRule.id
|
|
33
|
+
}),
|
|
34
|
+
detail: nativeCSSPropertyData?.syntax
|
|
35
|
+
};
|
|
36
|
+
EachRule.keys.forEach((key)=>{
|
|
37
|
+
addedKeys.delete(key);
|
|
38
|
+
completionItems.push({
|
|
39
|
+
...eachCompletionItem,
|
|
40
|
+
label: key + ':',
|
|
41
|
+
sortText: key,
|
|
42
|
+
command: {
|
|
43
|
+
title: 'triggerSuggest',
|
|
44
|
+
command: 'editor.action.triggerSuggest'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* @example @ animation and ~ transition
|
|
50
|
+
*/ if (EachRule.definition?.sign && EachRule.definition.includeAnimations) {
|
|
51
|
+
for(const animationName in css.animations){
|
|
52
|
+
completionItems.push({
|
|
53
|
+
...eachCompletionItem,
|
|
54
|
+
label: EachRule.definition.sign + animationName + '|1s',
|
|
55
|
+
kind: CompletionItemKind.Value
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (EachRule.definition?.ambiguousKeys?.length) {
|
|
60
|
+
for (const ambiguousKey of EachRule.definition.ambiguousKeys){
|
|
61
|
+
if (addedKeys.has(ambiguousKey)) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
addedKeys.add(ambiguousKey);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
addedKeys.forEach((ambiguousKey)=>{
|
|
70
|
+
/**
|
|
71
|
+
* Ambiguous keys are added to the completion list
|
|
72
|
+
* @example text: t:
|
|
73
|
+
*/ completionItems.push({
|
|
74
|
+
kind: CompletionItemKind.Property,
|
|
75
|
+
detail: 'ambiguous key',
|
|
76
|
+
label: ambiguousKey + ':',
|
|
77
|
+
sortText: ambiguousKey,
|
|
78
|
+
command: {
|
|
79
|
+
title: 'triggerSuggest',
|
|
80
|
+
command: 'editor.action.triggerSuggest'
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
if (css.config.styles) {
|
|
85
|
+
for(const styleName in css.config.styles){
|
|
86
|
+
const styleClasses = css.styles[styleName];
|
|
87
|
+
completionItems.push({
|
|
88
|
+
label: styleName,
|
|
89
|
+
kind: CompletionItemKind.Value,
|
|
90
|
+
documentation: getCSSDataDocumentation({}, {
|
|
91
|
+
generatedCSS: generateCSS([
|
|
92
|
+
styleName
|
|
93
|
+
], css),
|
|
94
|
+
docs: 'styles'
|
|
95
|
+
}),
|
|
96
|
+
detail: styleClasses.join(' ') + ' (style)'
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return sortCompletionItems(completionItems);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { getMainCompletionItems as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vscodeLanguageserverTextdocument = require('vscode-languageserver-textdocument');
|
|
4
|
+
|
|
5
|
+
function getPosition(searchString, text) {
|
|
6
|
+
const document = vscodeLanguageserverTextdocument.TextDocument.create('mockuri://test', 'plaintext', 1, text);
|
|
7
|
+
const offset = text.indexOf(searchString);
|
|
8
|
+
const position = document.positionAt(offset);
|
|
9
|
+
return position;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = getPosition;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getPosition(searchString: string, text: string): import("vscode-languageserver-textdocument").Position;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
+
|
|
3
|
+
function getPosition(searchString, text) {
|
|
4
|
+
const document = TextDocument.create('mockuri://test', 'plaintext', 1, text);
|
|
5
|
+
const offset = text.indexOf(searchString);
|
|
6
|
+
const position = document.positionAt(offset);
|
|
7
|
+
return position;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { getPosition as default };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var css = require('@master/css');
|
|
4
|
+
var cssDataProvider = require('./css-data-provider.cjs');
|
|
5
|
+
var vscodeLanguageserverProtocol = require('vscode-languageserver-protocol');
|
|
6
|
+
var sortCompletionItems = require('./sort-completion-items.cjs');
|
|
7
|
+
var getCssDataDocumentation = require('./get-css-data-documentation.cjs');
|
|
8
|
+
|
|
9
|
+
const kind = vscodeLanguageserverProtocol.CompletionItemKind.Function;
|
|
10
|
+
function getPseudoClassCompletionItems(css$1 = new css.MasterCSS(), syntax) {
|
|
11
|
+
const pseudoClassDataList = cssDataProvider.providePseudoClasses().filter((data)=>{
|
|
12
|
+
// exclude @page pseudo-classes
|
|
13
|
+
if ([
|
|
14
|
+
':first',
|
|
15
|
+
':left',
|
|
16
|
+
':right',
|
|
17
|
+
':blank'
|
|
18
|
+
].includes(data.name)) return false;
|
|
19
|
+
return true;
|
|
20
|
+
});
|
|
21
|
+
const completionItems = pseudoClassDataList.map((data)=>{
|
|
22
|
+
// fix https://github.com/microsoft/vscode-custom-data/issues/78
|
|
23
|
+
const name = /:(?:dir|has|is|nth-col|where)/.test(data.name) ? data.name + '()' : data.name;
|
|
24
|
+
let sortText = name.startsWith(':-') ? 'yyyy' + name.slice(2) : 'yy' + name.replace(/^:/, '');
|
|
25
|
+
if (sortText.endsWith('()')) sortText = 'y' + sortText;
|
|
26
|
+
return {
|
|
27
|
+
label: name,
|
|
28
|
+
sortText,
|
|
29
|
+
documentation: getCssDataDocumentation.getCSSDataDocumentation(data, {
|
|
30
|
+
generatedCSS: css.generateCSS([
|
|
31
|
+
syntax + name.slice(1)
|
|
32
|
+
], css$1),
|
|
33
|
+
docs: 'selectors'
|
|
34
|
+
}),
|
|
35
|
+
kind,
|
|
36
|
+
data
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
for(const selectorName in css$1.config.selectors){
|
|
40
|
+
if (selectorName.startsWith('::')) continue;
|
|
41
|
+
const selectorValue = css$1.config.selectors[selectorName];
|
|
42
|
+
const name = selectorName.endsWith('(') ? selectorName + ')' : selectorName;
|
|
43
|
+
const value = typeof selectorValue === 'string' ? selectorValue.endsWith('(') ? selectorValue + ')' : selectorValue : selectorValue;
|
|
44
|
+
const data = pseudoClassDataList.find((data)=>typeof value === 'string' ? value.startsWith(data.name) : false);
|
|
45
|
+
let sortText = name.startsWith(':-') ? 'yyyy' + name.slice(2) : 'yy' + name.replace(/^:/, '');
|
|
46
|
+
if (sortText.endsWith('()')) sortText = 'y' + sortText;
|
|
47
|
+
const completionItem = {
|
|
48
|
+
label: name,
|
|
49
|
+
documentation: getCssDataDocumentation.getCSSDataDocumentation(data, {
|
|
50
|
+
generatedCSS: css.generateCSS([
|
|
51
|
+
syntax + name.slice(1)
|
|
52
|
+
], css$1),
|
|
53
|
+
docs: 'selectors'
|
|
54
|
+
}),
|
|
55
|
+
sortText,
|
|
56
|
+
kind,
|
|
57
|
+
detail: String(value),
|
|
58
|
+
data
|
|
59
|
+
};
|
|
60
|
+
completionItems.push(completionItem);
|
|
61
|
+
}
|
|
62
|
+
return sortCompletionItems(completionItems);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
module.exports = getPseudoClassCompletionItems;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { generateCSS, MasterCSS } from '@master/css';
|
|
2
|
+
import cssDataProvider from './css-data-provider.mjs';
|
|
3
|
+
import { CompletionItemKind } from 'vscode-languageserver-protocol';
|
|
4
|
+
import sortCompletionItems from './sort-completion-items.mjs';
|
|
5
|
+
import { getCSSDataDocumentation } from './get-css-data-documentation.mjs';
|
|
6
|
+
|
|
7
|
+
const kind = CompletionItemKind.Function;
|
|
8
|
+
function getPseudoClassCompletionItems(css = new MasterCSS(), syntax) {
|
|
9
|
+
const pseudoClassDataList = cssDataProvider.providePseudoClasses().filter((data)=>{
|
|
10
|
+
// exclude @page pseudo-classes
|
|
11
|
+
if ([
|
|
12
|
+
':first',
|
|
13
|
+
':left',
|
|
14
|
+
':right',
|
|
15
|
+
':blank'
|
|
16
|
+
].includes(data.name)) return false;
|
|
17
|
+
return true;
|
|
18
|
+
});
|
|
19
|
+
const completionItems = pseudoClassDataList.map((data)=>{
|
|
20
|
+
// fix https://github.com/microsoft/vscode-custom-data/issues/78
|
|
21
|
+
const name = /:(?:dir|has|is|nth-col|where)/.test(data.name) ? data.name + '()' : data.name;
|
|
22
|
+
let sortText = name.startsWith(':-') ? 'yyyy' + name.slice(2) : 'yy' + name.replace(/^:/, '');
|
|
23
|
+
if (sortText.endsWith('()')) sortText = 'y' + sortText;
|
|
24
|
+
return {
|
|
25
|
+
label: name,
|
|
26
|
+
sortText,
|
|
27
|
+
documentation: getCSSDataDocumentation(data, {
|
|
28
|
+
generatedCSS: generateCSS([
|
|
29
|
+
syntax + name.slice(1)
|
|
30
|
+
], css),
|
|
31
|
+
docs: 'selectors'
|
|
32
|
+
}),
|
|
33
|
+
kind,
|
|
34
|
+
data
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
for(const selectorName in css.config.selectors){
|
|
38
|
+
if (selectorName.startsWith('::')) continue;
|
|
39
|
+
const selectorValue = css.config.selectors[selectorName];
|
|
40
|
+
const name = selectorName.endsWith('(') ? selectorName + ')' : selectorName;
|
|
41
|
+
const value = typeof selectorValue === 'string' ? selectorValue.endsWith('(') ? selectorValue + ')' : selectorValue : selectorValue;
|
|
42
|
+
const data = pseudoClassDataList.find((data)=>typeof value === 'string' ? value.startsWith(data.name) : false);
|
|
43
|
+
let sortText = name.startsWith(':-') ? 'yyyy' + name.slice(2) : 'yy' + name.replace(/^:/, '');
|
|
44
|
+
if (sortText.endsWith('()')) sortText = 'y' + sortText;
|
|
45
|
+
const completionItem = {
|
|
46
|
+
label: name,
|
|
47
|
+
documentation: getCSSDataDocumentation(data, {
|
|
48
|
+
generatedCSS: generateCSS([
|
|
49
|
+
syntax + name.slice(1)
|
|
50
|
+
], css),
|
|
51
|
+
docs: 'selectors'
|
|
52
|
+
}),
|
|
53
|
+
sortText,
|
|
54
|
+
kind,
|
|
55
|
+
detail: String(value),
|
|
56
|
+
data
|
|
57
|
+
};
|
|
58
|
+
completionItems.push(completionItem);
|
|
59
|
+
}
|
|
60
|
+
return sortCompletionItems(completionItems);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { getPseudoClassCompletionItems as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var css = require('@master/css');
|
|
4
|
+
var cssDataProvider = require('./css-data-provider.cjs');
|
|
5
|
+
var vscodeLanguageserverProtocol = require('vscode-languageserver-protocol');
|
|
6
|
+
var sortCompletionItems = require('./sort-completion-items.cjs');
|
|
7
|
+
var getCssDataDocumentation = require('./get-css-data-documentation.cjs');
|
|
8
|
+
|
|
9
|
+
const kind = vscodeLanguageserverProtocol.CompletionItemKind.Function;
|
|
10
|
+
function getPseudoElementCompletionItems(css$1 = new css.MasterCSS(), syntax) {
|
|
11
|
+
const pseudoElementDataList = cssDataProvider.providePseudoElements();
|
|
12
|
+
const completionItems = pseudoElementDataList.map((data)=>{
|
|
13
|
+
// fix https://github.com/microsoft/vscode-custom-data/issues/78
|
|
14
|
+
const name = /::(?:part|slotted)/.test(data.name) ? data.name + '()' : data.name;
|
|
15
|
+
let sortText = name.startsWith('::-') ? 'zzzz' + name.slice(3) : 'zz' + name.replace(/^::/, '');
|
|
16
|
+
if (sortText.endsWith('()')) sortText = 'z' + sortText;
|
|
17
|
+
return {
|
|
18
|
+
label: name,
|
|
19
|
+
sortText,
|
|
20
|
+
documentation: getCssDataDocumentation.getCSSDataDocumentation(data, {
|
|
21
|
+
generatedCSS: css.generateCSS([
|
|
22
|
+
syntax + name.slice(2)
|
|
23
|
+
], css$1),
|
|
24
|
+
docs: 'selectors'
|
|
25
|
+
}),
|
|
26
|
+
kind,
|
|
27
|
+
data
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
for(const selectorName in css$1.config.selectors){
|
|
31
|
+
if (!selectorName.startsWith('::')) continue;
|
|
32
|
+
const selectorValue = css$1.config.selectors[selectorName];
|
|
33
|
+
const name = selectorName.endsWith('(') ? selectorName + ')' : selectorName;
|
|
34
|
+
const value = typeof selectorValue === 'string' ? selectorValue.endsWith('(') ? selectorValue + ')' : selectorValue : selectorValue;
|
|
35
|
+
const data = pseudoElementDataList.find((data)=>typeof value === 'string' ? value.startsWith(data.name) : false);
|
|
36
|
+
let sortText = name.startsWith('::-') ? 'zzzz' + name.slice(3) : 'zz' + name.replace(/^::/, '');
|
|
37
|
+
if (sortText.endsWith('()')) sortText = 'z' + sortText;
|
|
38
|
+
const completionItem = {
|
|
39
|
+
label: name,
|
|
40
|
+
documentation: getCssDataDocumentation.getCSSDataDocumentation(data, {
|
|
41
|
+
generatedCSS: css.generateCSS([
|
|
42
|
+
syntax + name.slice(2)
|
|
43
|
+
], css$1),
|
|
44
|
+
docs: 'selectors'
|
|
45
|
+
}),
|
|
46
|
+
sortText,
|
|
47
|
+
kind,
|
|
48
|
+
detail: String(value),
|
|
49
|
+
data
|
|
50
|
+
};
|
|
51
|
+
completionItems.push(completionItem);
|
|
52
|
+
}
|
|
53
|
+
return sortCompletionItems(completionItems);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = getPseudoElementCompletionItems;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { generateCSS, MasterCSS } from '@master/css';
|
|
2
|
+
import cssDataProvider from './css-data-provider.mjs';
|
|
3
|
+
import { CompletionItemKind } from 'vscode-languageserver-protocol';
|
|
4
|
+
import sortCompletionItems from './sort-completion-items.mjs';
|
|
5
|
+
import { getCSSDataDocumentation } from './get-css-data-documentation.mjs';
|
|
6
|
+
|
|
7
|
+
const kind = CompletionItemKind.Function;
|
|
8
|
+
function getPseudoElementCompletionItems(css = new MasterCSS(), syntax) {
|
|
9
|
+
const pseudoElementDataList = cssDataProvider.providePseudoElements();
|
|
10
|
+
const completionItems = pseudoElementDataList.map((data)=>{
|
|
11
|
+
// fix https://github.com/microsoft/vscode-custom-data/issues/78
|
|
12
|
+
const name = /::(?:part|slotted)/.test(data.name) ? data.name + '()' : data.name;
|
|
13
|
+
let sortText = name.startsWith('::-') ? 'zzzz' + name.slice(3) : 'zz' + name.replace(/^::/, '');
|
|
14
|
+
if (sortText.endsWith('()')) sortText = 'z' + sortText;
|
|
15
|
+
return {
|
|
16
|
+
label: name,
|
|
17
|
+
sortText,
|
|
18
|
+
documentation: getCSSDataDocumentation(data, {
|
|
19
|
+
generatedCSS: generateCSS([
|
|
20
|
+
syntax + name.slice(2)
|
|
21
|
+
], css),
|
|
22
|
+
docs: 'selectors'
|
|
23
|
+
}),
|
|
24
|
+
kind,
|
|
25
|
+
data
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
for(const selectorName in css.config.selectors){
|
|
29
|
+
if (!selectorName.startsWith('::')) continue;
|
|
30
|
+
const selectorValue = css.config.selectors[selectorName];
|
|
31
|
+
const name = selectorName.endsWith('(') ? selectorName + ')' : selectorName;
|
|
32
|
+
const value = typeof selectorValue === 'string' ? selectorValue.endsWith('(') ? selectorValue + ')' : selectorValue : selectorValue;
|
|
33
|
+
const data = pseudoElementDataList.find((data)=>typeof value === 'string' ? value.startsWith(data.name) : false);
|
|
34
|
+
let sortText = name.startsWith('::-') ? 'zzzz' + name.slice(3) : 'zz' + name.replace(/^::/, '');
|
|
35
|
+
if (sortText.endsWith('()')) sortText = 'z' + sortText;
|
|
36
|
+
const completionItem = {
|
|
37
|
+
label: name,
|
|
38
|
+
documentation: getCSSDataDocumentation(data, {
|
|
39
|
+
generatedCSS: generateCSS([
|
|
40
|
+
syntax + name.slice(2)
|
|
41
|
+
], css),
|
|
42
|
+
docs: 'selectors'
|
|
43
|
+
}),
|
|
44
|
+
sortText,
|
|
45
|
+
kind,
|
|
46
|
+
detail: String(value),
|
|
47
|
+
data
|
|
48
|
+
};
|
|
49
|
+
completionItems.push(completionItem);
|
|
50
|
+
}
|
|
51
|
+
return sortCompletionItems(completionItems);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { getPseudoElementCompletionItems as default };
|