css-variable-lsp 1.0.16 → 1.0.17
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/README.md +1 -1
- package/docs/SCSS_SASS_SUPPORT_RESEARCH.md +96 -0
- package/out/completionContext.js +244 -0
- package/out/completionContext.js.map +1 -0
- package/out/cssVariableManager.js +5 -5
- package/out/cssVariableManager.js.map +1 -1
- package/out/handlers/callHierarchy.js +128 -0
- package/out/handlers/callHierarchy.js.map +1 -0
- package/out/handlers/codeAction.js +142 -0
- package/out/handlers/codeAction.js.map +1 -0
- package/out/handlers/codeLens.js +41 -0
- package/out/handlers/codeLens.js.map +1 -0
- package/out/handlers/declaration.js +34 -0
- package/out/handlers/declaration.js.map +1 -0
- package/out/handlers/documentHighlight.js +45 -0
- package/out/handlers/documentHighlight.js.map +1 -0
- package/out/handlers/documentLink.js +61 -0
- package/out/handlers/documentLink.js.map +1 -0
- package/out/handlers/documentSync.js +15 -0
- package/out/handlers/documentSync.js.map +1 -0
- package/out/handlers/foldingRange.js +77 -0
- package/out/handlers/foldingRange.js.map +1 -0
- package/out/handlers/formatting.js +99 -0
- package/out/handlers/formatting.js.map +1 -0
- package/out/handlers/implementation.js +35 -0
- package/out/handlers/implementation.js.map +1 -0
- package/out/handlers/inlayHint.js +46 -0
- package/out/handlers/inlayHint.js.map +1 -0
- package/out/handlers/linkedEditingRange.js +45 -0
- package/out/handlers/linkedEditingRange.js.map +1 -0
- package/out/handlers/prepareRename.js +44 -0
- package/out/handlers/prepareRename.js.map +1 -0
- package/out/handlers/selectionRange.js +100 -0
- package/out/handlers/selectionRange.js.map +1 -0
- package/out/handlers/semanticTokens.js +57 -0
- package/out/handlers/semanticTokens.js.map +1 -0
- package/out/handlers/signatureHelp.js +54 -0
- package/out/handlers/signatureHelp.js.map +1 -0
- package/out/handlers/typeDefinition.js +35 -0
- package/out/handlers/typeDefinition.js.map +1 -0
- package/out/hierarchy/callHierarchy.js +119 -0
- package/out/hierarchy/callHierarchy.js.map +1 -0
- package/out/hierarchy/shared/hierarchyTypes.js +45 -0
- package/out/hierarchy/shared/hierarchyTypes.js.map +1 -0
- package/out/hierarchy/shared/variableAnalyzer.js +43 -0
- package/out/hierarchy/shared/variableAnalyzer.js.map +1 -0
- package/out/server.js +5 -130
- package/out/server.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlayHint.js","sourceRoot":"","sources":["../../src/handlers/inlayHint.ts"],"names":[],"mappings":";;AAYA,4CAmDC;AA/DD,qDAIoC;AAIpC;;;GAGG;AACH,SAAgB,gBAAgB,CAC9B,MAAuB,EACvB,SAAyD,EACzD,kBAAsC;IAEtC,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;IAChC,MAAM,KAAK,GAAgB,EAAE,CAAC;IAE9B,8BAA8B;IAC9B,MAAM,QAAQ,GAAG,qCAAqC,CAAC;IACvD,IAAI,KAAK,CAAC;IAEV,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAE/C,oDAAoD;QACpD,MAAM,MAAM,GAAG,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC7C,IACE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI;YACrC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EACnC,CAAC;YACD,SAAS;QACX,CAAC;QAED,yBAAyB;QACzB,MAAM,SAAS,GAAG,kBAAkB,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAChE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,SAAS;QACX,CAAC;QAED,8CAA8C;QAC9C,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAEjC,uBAAuB;QACvB,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QAE5E,KAAK,CAAC,IAAI,CAAC;YACT,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,MAAM,YAAY,EAAE;YAC3B,IAAI,EAAE,oBAAa,CAAC,IAAI;YACxB,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleLinkedEditingRange = handleLinkedEditingRange;
|
|
4
|
+
/**
|
|
5
|
+
* Handle linked editing range requests for CSS variables.
|
|
6
|
+
* Returns ranges that should be edited simultaneously (variable name in definition and usages).
|
|
7
|
+
*/
|
|
8
|
+
function handleLinkedEditingRange(params, documents, cssVariableManager) {
|
|
9
|
+
const document = documents.get(params.textDocument.uri);
|
|
10
|
+
if (!document) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const text = document.getText();
|
|
14
|
+
const offset = document.offsetAt(params.position);
|
|
15
|
+
// Find the word at the cursor position
|
|
16
|
+
const left = text.slice(0, offset).match(/[\w-]*$/);
|
|
17
|
+
const right = text.slice(offset).match(/^[\w-]*/);
|
|
18
|
+
if (!left || !right) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const word = left[0] + right[0];
|
|
22
|
+
// Only for CSS variables
|
|
23
|
+
if (!word.startsWith("--")) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
// Get all references to this variable in the current document
|
|
27
|
+
const references = cssVariableManager.getReferences(word);
|
|
28
|
+
const documentRefs = references.filter((ref) => ref.uri === document.uri);
|
|
29
|
+
if (documentRefs.length === 0) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
// Return all ranges that contain just the variable name
|
|
33
|
+
const ranges = documentRefs
|
|
34
|
+
.map((ref) => ref.nameRange || ref.range)
|
|
35
|
+
.filter((range) => range !== undefined);
|
|
36
|
+
if (ranges.length === 0) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
ranges,
|
|
41
|
+
// CSS variable names follow this pattern
|
|
42
|
+
wordPattern: "--[\\w-]+",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=linkedEditingRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkedEditingRange.js","sourceRoot":"","sources":["../../src/handlers/linkedEditingRange.ts"],"names":[],"mappings":";;AAYA,4DAkDC;AAtDD;;;GAGG;AACH,SAAgB,wBAAwB,CACtC,MAAgC,EAChC,SAAyD,EACzD,kBAAsC;IAEtC,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAElD,uCAAuC;IACvC,MAAM,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|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handlePrepareRename = handlePrepareRename;
|
|
4
|
+
/**
|
|
5
|
+
* Handle prepare rename requests for CSS variables.
|
|
6
|
+
* Validates that the rename target is a valid CSS variable and returns its range.
|
|
7
|
+
*/
|
|
8
|
+
function handlePrepareRename(params, documents, cssVariableManager) {
|
|
9
|
+
const document = documents.get(params.textDocument.uri);
|
|
10
|
+
if (!document) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const text = document.getText();
|
|
14
|
+
const offset = document.offsetAt(params.position);
|
|
15
|
+
// Find the word at the cursor position
|
|
16
|
+
const left = text.slice(0, offset).match(/[\w-]*$/);
|
|
17
|
+
const right = text.slice(offset).match(/^[\w-]*/);
|
|
18
|
+
if (!left || !right) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const word = left[0] + right[0];
|
|
22
|
+
// Only allow renaming CSS variables
|
|
23
|
+
if (!word.startsWith("--")) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
// Check if this variable exists (either as definition or usage)
|
|
27
|
+
const definitions = cssVariableManager.getVariables(word);
|
|
28
|
+
const usages = cssVariableManager.getVariableUsages(word);
|
|
29
|
+
if (definitions.length === 0 && usages.length === 0) {
|
|
30
|
+
// Variable doesn't exist in the workspace
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
// Calculate the range of the variable name
|
|
34
|
+
const startOffset = offset - left[0].length;
|
|
35
|
+
const endOffset = offset + right[0].length;
|
|
36
|
+
return {
|
|
37
|
+
range: {
|
|
38
|
+
start: document.positionAt(startOffset),
|
|
39
|
+
end: document.positionAt(endOffset),
|
|
40
|
+
},
|
|
41
|
+
placeholder: word,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=prepareRename.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareRename.js","sourceRoot":"","sources":["../../src/handl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AA2C;IAC3C,MAAM,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAE3C,OAAO;QACL,KAAK,EAAE;YACL,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC;YACvC,GAAG,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;SACpC;QACD,WAAW,EAAE,IAAI;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleSelectionRanges = handleSelectionRanges;
|
|
4
|
+
const csstree = require("css-tree");
|
|
5
|
+
/**
|
|
6
|
+
* Handle selection range requests for CSS documents.
|
|
7
|
+
* Returns nested selection ranges for smart "expand selection" functionality.
|
|
8
|
+
* Selection hierarchy: value → declaration → rule block → at-rule → stylesheet
|
|
9
|
+
*/
|
|
10
|
+
function handleSelectionRanges(params, documents) {
|
|
11
|
+
const document = documents.get(params.textDocument.uri);
|
|
12
|
+
if (!document) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const text = document.getText();
|
|
16
|
+
const results = [];
|
|
17
|
+
// Parse CSS once
|
|
18
|
+
let ast = null;
|
|
19
|
+
try {
|
|
20
|
+
ast = csstree.parse(text, {
|
|
21
|
+
positions: true,
|
|
22
|
+
parseCustomProperty: true,
|
|
23
|
+
onParseError: () => { },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// If parsing fails, return null
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
for (const position of params.positions) {
|
|
31
|
+
const offset = document.offsetAt(position);
|
|
32
|
+
const ranges = findContainingRanges(ast, offset, document);
|
|
33
|
+
if (ranges.length === 0) {
|
|
34
|
+
// Fallback: return the whole document
|
|
35
|
+
results.push({
|
|
36
|
+
range: {
|
|
37
|
+
start: { line: 0, character: 0 },
|
|
38
|
+
end: document.positionAt(text.length),
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// Build nested SelectionRange from innermost to outermost
|
|
44
|
+
let selectionRange;
|
|
45
|
+
for (let i = ranges.length - 1; i >= 0; i--) {
|
|
46
|
+
selectionRange = {
|
|
47
|
+
range: ranges[i],
|
|
48
|
+
parent: selectionRange,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
results.push(selectionRange);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return results;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Find all AST nodes that contain the given offset, from innermost to outermost.
|
|
58
|
+
*/
|
|
59
|
+
function findContainingRanges(ast, offset, document) {
|
|
60
|
+
const containers = [];
|
|
61
|
+
csstree.walk(ast, {
|
|
62
|
+
enter(node) {
|
|
63
|
+
if (!node.loc)
|
|
64
|
+
return;
|
|
65
|
+
const startOffset = document.offsetAt({
|
|
66
|
+
line: node.loc.start.line - 1,
|
|
67
|
+
character: node.loc.start.column - 1,
|
|
68
|
+
});
|
|
69
|
+
const endOffset = document.offsetAt({
|
|
70
|
+
line: node.loc.end.line - 1,
|
|
71
|
+
character: node.loc.end.column - 1,
|
|
72
|
+
});
|
|
73
|
+
if (offset >= startOffset && offset <= endOffset) {
|
|
74
|
+
// Include useful node types for selection
|
|
75
|
+
if (node.type === "StyleSheet" ||
|
|
76
|
+
node.type === "Rule" ||
|
|
77
|
+
node.type === "Atrule" ||
|
|
78
|
+
node.type === "Block" ||
|
|
79
|
+
node.type === "Declaration" ||
|
|
80
|
+
node.type === "Value" ||
|
|
81
|
+
node.type === "SelectorList" ||
|
|
82
|
+
node.type === "Selector") {
|
|
83
|
+
containers.push({ type: node.type, loc: node.loc });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
// Convert to Range objects, outermost first (StyleSheet → ... → Value)
|
|
89
|
+
return containers.map((c) => ({
|
|
90
|
+
start: {
|
|
91
|
+
line: c.loc.start.line - 1,
|
|
92
|
+
character: c.loc.start.column - 1,
|
|
93
|
+
},
|
|
94
|
+
end: {
|
|
95
|
+
line: c.loc.end.line - 1,
|
|
96
|
+
character: c.loc.end.column - 1,
|
|
97
|
+
},
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=selectionRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionRange.js","sourceRoot":"","sources":["../../src/handlers/selectionRange.ts"],"names":[],"mappings":";;AAaA,sDAmDC;AA3DD,oCAAoC;AAGpC;;;;GAIG;AACH,SAAgB,qBAAqB,CACnC,MAA4B,EAC5B,SAAyD;IAEzD,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;IAChC,MAAM,OAAO,GAAqB,EAAE,CAAC;IAErC,iBAAiB;IACjB,IAAI,GAAG,GAA2B,IAAI,CAAC;IACvC,IAAI,CAAC;QACH,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE;YACxB,SAAS,EAAE,IAAI;YACf,mBAAmB,EAAE,IAAI;YACzB,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;SACvB,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,gCAAgC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.semanticTokensLegend = exports.tokenModifiers = exports.tokenTypes = void 0;
|
|
4
|
+
exports.handleSemanticTokens = handleSemanticTokens;
|
|
5
|
+
const node_1 = require("vscode-languageserver/node");
|
|
6
|
+
// Define token types and modifiers
|
|
7
|
+
exports.tokenTypes = [
|
|
8
|
+
"variable",
|
|
9
|
+
"property",
|
|
10
|
+
"value",
|
|
11
|
+
"string",
|
|
12
|
+
"comment",
|
|
13
|
+
];
|
|
14
|
+
exports.tokenModifiers = ["declaration", "readonly", "static"];
|
|
15
|
+
exports.semanticTokensLegend = {
|
|
16
|
+
tokenTypes: exports.tokenTypes,
|
|
17
|
+
tokenModifiers: exports.tokenModifiers,
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Handle semantic tokens requests.
|
|
21
|
+
* Provides syntax highlighting for CSS variables and properties.
|
|
22
|
+
*/
|
|
23
|
+
function handleSemanticTokens(params, documents, cssVariableManager) {
|
|
24
|
+
const document = documents.get(params.textDocument.uri);
|
|
25
|
+
if (!document) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const text = document.getText();
|
|
29
|
+
const builder = new node_1.SemanticTokensBuilder();
|
|
30
|
+
// Highlight CSS variables --var-name
|
|
31
|
+
const variableRegex = /--[\w-]+/g;
|
|
32
|
+
let match;
|
|
33
|
+
while ((match = variableRegex.exec(text)) !== null) {
|
|
34
|
+
const startPos = document.positionAt(match.index);
|
|
35
|
+
const length = match[0].length;
|
|
36
|
+
// Determine if it's a declaration or usage
|
|
37
|
+
// Heuristic: check if followed by ":"
|
|
38
|
+
const afterMatch = text.slice(match.index + length);
|
|
39
|
+
const isDeclaration = /^\s*:/.test(afterMatch);
|
|
40
|
+
let variableType = 0; // "variable"
|
|
41
|
+
let modifiers = 0;
|
|
42
|
+
if (isDeclaration) {
|
|
43
|
+
modifiers |= 1 << 0; // "declaration"
|
|
44
|
+
}
|
|
45
|
+
builder.push(startPos.line, startPos.character, length, variableType, modifiers);
|
|
46
|
+
}
|
|
47
|
+
// Highlight var() functions
|
|
48
|
+
const varFuncRegex = /var\(/g;
|
|
49
|
+
while ((match = varFuncRegex.exec(text)) !== null) {
|
|
50
|
+
const startPos = document.positionAt(match.index);
|
|
51
|
+
// Highlight "var"
|
|
52
|
+
builder.push(startPos.line, startPos.character, 3, 1, // "property" (misusing property for function keyword here for distinction)
|
|
53
|
+
0);
|
|
54
|
+
}
|
|
55
|
+
return builder.build();
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=semanticTokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semanticTokens.js","sourceRoot":"","sources":["../../src/handlers/semanticTokens.ts"],"names":[],"mappings":";;;AA2BA,oDAyDC;AApFD,qDAIoC;AAIpC,mCAAmC;AACtB,QAAA,UAAU,GAAG;IACxB,UAAU;IACV,UAAU;IACV,OAAO;IACP,QAAQ;IACR,SAAS;CACV,CAAC;AACW,QAAA,cAAc,GAAG,CAAC,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAEvD,QAAA,oBAAoB,GAAG;IAClC,UAAU,EAAV,kBAAU;IACV,cAAc,EAAd,sBAAc;CACf,CAAC;AAEF;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,MAA4B,EAC5B,SAAyD,EACzD,kBAAsC;IAEtC,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;IAChC,MAAM,OAAO,GAAG,IAAI,4BAAqB,EAAE,CAAC;IAE5C,qCAAqC;IACrC,MAAM,aAAa,GAAG,WAAW,CAAC;IAClC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|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleSignatureHelp = handleSignatureHelp;
|
|
4
|
+
/**
|
|
5
|
+
* Handle signature help requests for CSS documents.
|
|
6
|
+
* Provides parameter hints for var(--name, fallback) syntax.
|
|
7
|
+
*/
|
|
8
|
+
function handleSignatureHelp(params, documents, cssVariableManager) {
|
|
9
|
+
const document = documents.get(params.textDocument.uri);
|
|
10
|
+
if (!document) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const text = document.getText();
|
|
14
|
+
const offset = document.offsetAt(params.position);
|
|
15
|
+
// Look backwards for "var(" to see if we're inside a var() call
|
|
16
|
+
const textBefore = text.slice(0, offset);
|
|
17
|
+
const varMatch = textBefore.match(/var\(\s*(--[\w-]*)?(?:\s*,\s*)?$/);
|
|
18
|
+
if (!varMatch) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
// Determine which parameter we're in
|
|
22
|
+
const afterVar = textBefore.slice(textBefore.lastIndexOf("var("));
|
|
23
|
+
const hasComma = afterVar.includes(",");
|
|
24
|
+
const activeParameter = hasComma ? 1 : 0;
|
|
25
|
+
// Get variable info if we have a name
|
|
26
|
+
const varName = varMatch[1];
|
|
27
|
+
let variableInfo = "";
|
|
28
|
+
if (varName) {
|
|
29
|
+
const variables = cssVariableManager.getVariables(varName);
|
|
30
|
+
if (variables.length > 0) {
|
|
31
|
+
variableInfo = ` (current value: ${variables[0].value})`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const signature = {
|
|
35
|
+
label: "var(--custom-property, fallback-value)",
|
|
36
|
+
documentation: `CSS custom property (variable) function.${variableInfo}\n\nThe var() function substitutes the value of a custom property.`,
|
|
37
|
+
parameters: [
|
|
38
|
+
{
|
|
39
|
+
label: "--custom-property",
|
|
40
|
+
documentation: "The name of the custom property to use, starting with --",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: "fallback-value",
|
|
44
|
+
documentation: "Optional fallback value used if the property is not defined",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
signatures: [signature],
|
|
50
|
+
activeSignature: 0,
|
|
51
|
+
activeParameter,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=signatureHelp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signatureHelp.js","sourceRoot":"","sources":["../../src/handlers/signatureHelp.ts"],"names":[],"mappings":";;AAaA,kDA0DC;AA9DD;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,MAA2B,EAC3B,SAAyD,EACzD,kBAAsC;IAEtC,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAElD,gEAAgE;IAChE,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAEtE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qCAAqC;IACrC,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,eAAe,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzC,sCAAsC;IACtC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,SAAS,GAAG,kBAAkB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,YAAY,GAAG,oBAAoB,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAyB;QACtC,KAAK,EAAE,wCAAwC;QAC/C,aAAa,EAAE,2CAA2C,YAAY,oEAAoE;QAC1I,UAAU,EAAE;YACV;gBACE,KAAK,EAAE,mBAAmB;gBAC1B,aAAa,EACX,0DAA0D;aACrC;YACzB;gBACE,KAAK,EAAE,gBAAgB;gBACvB,aAAa,EACX,6DAA6D;aACxC;SAC1B;KACF,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,CAAC,SAAS,CAAC;QACvB,eAAe,EAAE,CAAC;QAClB,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleTypeDefinition = handleTypeDefinition;
|
|
4
|
+
const node_1 = require("vscode-languageserver/node");
|
|
5
|
+
/**
|
|
6
|
+
* Handle type definition requests for CSS variables.
|
|
7
|
+
* For CSS variables, type definition is similar to definition -
|
|
8
|
+
* it refers to where the variable type/value is defined.
|
|
9
|
+
*/
|
|
10
|
+
function handleTypeDefinition(params, documents, cssVariableManager) {
|
|
11
|
+
const document = documents.get(params.textDocument.uri);
|
|
12
|
+
if (!document) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const text = document.getText();
|
|
16
|
+
const offset = document.offsetAt(params.position);
|
|
17
|
+
// Find the word at the cursor position
|
|
18
|
+
const left = text.slice(0, offset).match(/[\w-]*$/);
|
|
19
|
+
const right = text.slice(offset).match(/^[\w-]*/);
|
|
20
|
+
if (!left || !right) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const word = left[0] + right[0];
|
|
24
|
+
// Check if it's a CSS variable
|
|
25
|
+
if (word.startsWith("--")) {
|
|
26
|
+
const variables = cssVariableManager.getVariables(word);
|
|
27
|
+
if (variables.length > 0) {
|
|
28
|
+
// For CSS variables, type definition points to where the variable is defined
|
|
29
|
+
// This could be enhanced to include type information (color, size, etc.)
|
|
30
|
+
return node_1.Location.create(variables[0].uri, variables[0].range);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=typeDefinition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeDefinition.js","sourceRoot":"","sources":["../../src/handlers/typeDefinition.ts"],"names":[],"mappings":";;AAcA,oDAkCC;AAzCD,qDAAsD;AAEtD;;;;GAIG;AACH,SAAgB,oBAAoB,CAClC,MAAkC,EAClC,SAAyD,EACzD,kBAAsC;IAEtC,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAElD,uCAAuC;IACvC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAElD,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAEhC,+BAA+B;IAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,SAAS,GAAG,kBAAkB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACxD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,6EAA6E;YAC7E,yEAAyE;YACzE,OAAO,eAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handlePrepareCallHierarchy = handlePrepareCallHierarchy;
|
|
4
|
+
exports.handleIncomingCalls = handleIncomingCalls;
|
|
5
|
+
exports.handleOutgoingCalls = handleOutgoingCalls;
|
|
6
|
+
const node_1 = require("vscode-languageserver/node");
|
|
7
|
+
const variableAnalyzer_1 = require("./shared/variableAnalyzer");
|
|
8
|
+
/**
|
|
9
|
+
* Implements textDocument/prepareCallHierarchy for CSS variables.
|
|
10
|
+
* Returns a call hierarchy item for a variable at the given position.
|
|
11
|
+
*/
|
|
12
|
+
function handlePrepareCallHierarchy(params, cssVariableManager) {
|
|
13
|
+
const variables = cssVariableManager.getVariables(params.textDocument.uri);
|
|
14
|
+
// Find the variable at the cursor position
|
|
15
|
+
const targetVariable = findVariableAtPosition(variables, params.textDocument.uri, params.position);
|
|
16
|
+
if (!targetVariable) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
// Create call hierarchy item for the target variable
|
|
20
|
+
const item = {
|
|
21
|
+
name: targetVariable.name,
|
|
22
|
+
kind: node_1.SymbolKind.Variable,
|
|
23
|
+
uri: targetVariable.uri,
|
|
24
|
+
range: targetVariable.range,
|
|
25
|
+
detail: `CSS variable defined with ${targetVariable.value}`,
|
|
26
|
+
selectionRange: targetVariable.range,
|
|
27
|
+
};
|
|
28
|
+
return item;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Implements textDocument/callHierarchy/incomingCalls for CSS variables.
|
|
32
|
+
* Returns all items that call the given variable.
|
|
33
|
+
*/
|
|
34
|
+
function handleIncomingCalls(params, cssVariableManager) {
|
|
35
|
+
const targetVariable = params.item;
|
|
36
|
+
if (targetVariable.kind !== node_1.SymbolKind.Variable) {
|
|
37
|
+
return { item: [] };
|
|
38
|
+
}
|
|
39
|
+
// Get all variables and analyze dependencies
|
|
40
|
+
const allVariables = cssVariableManager.getAllVariables();
|
|
41
|
+
const dependencies = (0, variableAnalyzer_1.analyzeVariableDependencies)(allVariables);
|
|
42
|
+
// Find which variables reference the target variable
|
|
43
|
+
const callers = dependencies.get(targetVariable.name);
|
|
44
|
+
if (callers.size === 0) {
|
|
45
|
+
return { item: [] };
|
|
46
|
+
}
|
|
47
|
+
// Find definition locations for each caller
|
|
48
|
+
const incomingItems = [];
|
|
49
|
+
for (const callerName of callers) {
|
|
50
|
+
const callerVars = allVariables.filter(v => v.name === callerName);
|
|
51
|
+
for (const callerVar of callerVars) {
|
|
52
|
+
const item = {
|
|
53
|
+
name: callerName,
|
|
54
|
+
kind: node_1.SymbolKind.Variable,
|
|
55
|
+
uri: callerVar.uri,
|
|
56
|
+
range: callerVar.range,
|
|
57
|
+
detail: `CSS variable that uses --${targetVariable.name}`,
|
|
58
|
+
selectionRange: callerVar.range,
|
|
59
|
+
};
|
|
60
|
+
incomingItems.push(item);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return { item: incomingItems };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Implements textDocument/callHierarchy/outgoingCalls for CSS variables.
|
|
67
|
+
* Returns all items that the given variable calls.
|
|
68
|
+
*/
|
|
69
|
+
function handleOutgoingCalls(params, cssVariableManager) {
|
|
70
|
+
const targetVariable = params.item;
|
|
71
|
+
if (targetVariable.kind !== node_1.SymbolKind.Variable) {
|
|
72
|
+
return { item: [] };
|
|
73
|
+
}
|
|
74
|
+
// Get the target variable and find its dependencies
|
|
75
|
+
const targetVariables = allVariables.filter(v => v.name === targetVariable.name);
|
|
76
|
+
if (targetVariables.length === 0) {
|
|
77
|
+
return { item: [] };
|
|
78
|
+
}
|
|
79
|
+
const targetVariable = targetVariables[0];
|
|
80
|
+
const dependencies = (0, variableAnalyzer_1.analyzeVariableDependencies)(allVariables);
|
|
81
|
+
const callerVariables = dependencies.get(targetVariable.name) || [];
|
|
82
|
+
// Find definition locations for each called variable
|
|
83
|
+
const outgoingItems = [];
|
|
84
|
+
for (const calledVarName of callerVariables) {
|
|
85
|
+
const calledVarDefs = allVariables.filter(v => v.name === calledVarName);
|
|
86
|
+
for (const calledVar of calledVarDefs) {
|
|
87
|
+
const item = {
|
|
88
|
+
name: calledVarName,
|
|
89
|
+
kind: node_1.SymbolKind.Variable,
|
|
90
|
+
uri: calledVar.uri,
|
|
91
|
+
range: calledVar.range,
|
|
92
|
+
detail: `CSS variable referenced by --${targetVariable.name}`,
|
|
93
|
+
selectionRange: calledVar.range,
|
|
94
|
+
};
|
|
95
|
+
outgoingItems.push(item);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return { item: outgoingItems };
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Finds a variable at the given cursor position in a list of variables.
|
|
102
|
+
*/
|
|
103
|
+
function findVariableAtPosition(variables, uri, position) {
|
|
104
|
+
// For simplicity, find the first variable that contains the cursor position
|
|
105
|
+
for (const variable of variables) {
|
|
106
|
+
const startOffset = (position.line * 1000) + position.character;
|
|
107
|
+
const endOffset = (position.line * 1000) + position.character;
|
|
108
|
+
// Check if cursor is within variable range
|
|
109
|
+
if (variable.range.start.character <= position.character &&
|
|
110
|
+
position.character <= variable.range.end.character &&
|
|
111
|
+
startOffset >= variable.range.start.character &&
|
|
112
|
+
endOffset <= variable.range.end.character &&
|
|
113
|
+
variable.uri === uri) {
|
|
114
|
+
return variable;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=callHierarchy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callHierarchy.js","sourceRoot":"","sources":["../../src/hierarchy/callHierarchy.ts"],"names":[],"mappings":";;AAeA,gEA2BC;AAMD,kDAqCC;AAMD,kDAoCC;AAzHD,qDAAwD;AAExD,gEAAwE;AAGxE;;;GAGG;AACH,SAAgB,0BAA0B,CACxC,MAAkC,EAClC,kBAAsC;IAEtC,MAAM,SAAS,GAAG,kBAAkB,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC3E,2CAA2C;IAC3C,MAAM,cAAc,GAAG,sBAAsB,CAC3C,SAAS,EACT,MAAM,CAAC,YAAY,CAAC,GAAG,EACvB,MAAM,CAAC,QAAQ,CAChB,CAAC;IAEF,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qDAAqD;IACrD,MAAM,IAAI,GAAyB;QACjC,IAAI,EAAE,cAAc,CAAC,IAAI;QACzB,IAAI,EAAE,iBAAU,CAAC,QAAQ;QACzB,GAAG,EAAE,cAAc,CAAC,GAAG;QACvB,KAAK,EAAE,cAAc,CAAC,KAAK;QAC3B,MAAM,EAAE,6BAA6B,cAAc,CAAC,KAAK,EAAE;QAC3D,cAAc,EAAE,cAAc,CAAC,KAAK;KACrC,CAAC;IAEF,OAAO,IAAI,CAAC;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AS,CAAC,KAAK;aAChC,CAAC;YACF,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAS,sBAAsB,CAC7B,SAAwB,EACxB,GAAW,EACX,QAA6C;IAE7C,4EAA4E;IAC5E,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,WAAW,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC;QAChE,MAAM,SAAS,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC;QAE9D,2CAA2C;QAC3C,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS;YACpD,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS;YAClD,WAAW,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS;YAC7C,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS;YACzC,QAAQ,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;YACzB,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PropertyCategory = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Categories of CSS properties for type hierarchy organization.
|
|
6
|
+
*/
|
|
7
|
+
var PropertyCategory;
|
|
8
|
+
(function (PropertyCategory) {
|
|
9
|
+
PropertyCategory["Color"] = "color";
|
|
10
|
+
PropertyCategory["Font"] = "font";
|
|
11
|
+
PropertyCategory["Size"] = "size";
|
|
12
|
+
PropertyCategory["Position"] = "position";
|
|
13
|
+
PropertyCategory["Layout"] = "layout";
|
|
14
|
+
PropertyCategory["Animation"] = "animation";
|
|
15
|
+
PropertyCategory["Border"] = "border";
|
|
16
|
+
PropertyCategory["Background"] = "background";
|
|
17
|
+
PropertyCategory["Text"] = "text";
|
|
18
|
+
PropertyCategory["Visual"] = "visual";
|
|
19
|
+
PropertyCategory["Box"] = "box";
|
|
20
|
+
PropertyCategory["Effect"] = "effect";
|
|
21
|
+
PropertyCategory["Transform"] = "transform";
|
|
22
|
+
PropertyCategory["Grid"] = "grid";
|
|
23
|
+
PropertyCategory["Flex"] = "flex";
|
|
24
|
+
})(PropertyCategory || (exports.PropertyCategory = PropertyCategory = {}));
|
|
25
|
+
/**
|
|
26
|
+
* Categories of CSS properties for type hierarchy organization.
|
|
27
|
+
*/
|
|
28
|
+
(function (PropertyCategory) {
|
|
29
|
+
PropertyCategory["Color"] = "color";
|
|
30
|
+
PropertyCategory["Font"] = "font";
|
|
31
|
+
PropertyCategory["Size"] = "size";
|
|
32
|
+
PropertyCategory["Position"] = "position";
|
|
33
|
+
PropertyCategory["Layout"] = "layout";
|
|
34
|
+
PropertyCategory["Animation"] = "animation";
|
|
35
|
+
PropertyCategory["Border"] = "border";
|
|
36
|
+
PropertyCategory["Background"] = "background";
|
|
37
|
+
PropertyCategory["Text"] = "text";
|
|
38
|
+
PropertyCategory["Visual"] = "visual";
|
|
39
|
+
PropertyCategory["Box"] = "box";
|
|
40
|
+
PropertyCategory["Effect"] = "effect";
|
|
41
|
+
PropertyCategory["Transform"] = "transform";
|
|
42
|
+
PropertyCategory["Grid"] = "grid";
|
|
43
|
+
PropertyCategory["Flex"] = "flex";
|
|
44
|
+
})(PropertyCategory || (exports.PropertyCategory = PropertyCategory = {}));
|
|
45
|
+
//# sourceMappingURL=hierarchyTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hierarchyTypes.js","sourceRoot":"","sources":["../../../src/hierarchy/shared/hierarchyTypes.ts"],"names":[],"mappings":";;;AA8CA;;GAEG;AACH,IAAY,gBAgBX;AAhBD,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,iCAAa,CAAA;IACb,iCAAa,CAAA;IACb,yCAAqB,CAAA;IACrB,qCAAiB,CAAA;IACjB,2CAAuB,CAAA;IACvB,qCAAiB,CAAA;IACjB,6CAAyB,CAAA;IACzB,iCAAa,CAAA;IACb,qCAAiB,CAAA;IACjB,+BAAW,CAAA;IACX,qCAAiB,CAAA;IACjB,2CAAuB,CAAA;IACvB,iCAAa,CAAA;IACb,iCAAa,CAAA;AACf,CAAC,EAhBW,gBAAgB,gCAAhB,gBAAgB,QAgB3B;AAuBD;;GAEG;AACH,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,iCAAa,CAAA;IACb,iCAAa,CAAA;IACb,yCAAqB,CAAA;IACrB,qCAAiB,CAAA;IACjB,2CAAuB,CAAA;IACvB,qCAAiB,CAAA;IACjB,6CAAyB,CAAA;IACzB,iCAAa,CAAA;IACb,qCAAiB,CAAA;IACjB,+BAAW,CAAA;IACX,qCAAiB,CAAA;IACjB,2CAAuB,CAAA;IACvB,iCAAa,CAAA;IACb,iCAAa,CAAA;AACf,CAAC,EAhBW,gBAAgB,gCAAhB,gBAAgB,QAgB3B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.analyzeVariableDependencies = analyzeVariableDependencies;
|
|
4
|
+
exports.extractVariableUsages = extractVariableUsages;
|
|
5
|
+
/**
|
|
6
|
+
* Analyzes CSS variable dependencies to build call hierarchy.
|
|
7
|
+
* Tracks which variables reference other variables in their values.
|
|
8
|
+
*/
|
|
9
|
+
function analyzeVariableDependencies(variables) {
|
|
10
|
+
const dependencies = new Map();
|
|
11
|
+
for (const variable of variables) {
|
|
12
|
+
const referencedVars = new Set();
|
|
13
|
+
// Extract variable references from the variable value
|
|
14
|
+
const varRegex = /var\((--[\w-]+)\)/g;
|
|
15
|
+
let match;
|
|
16
|
+
while ((match = varRegex.exec(variable.value)) !== null) {
|
|
17
|
+
referencedVars.add(match[1]);
|
|
18
|
+
}
|
|
19
|
+
dependencies.set(variable.name, referencedVars);
|
|
20
|
+
}
|
|
21
|
+
return dependencies;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Extracts CSS variable usages from a document's content.
|
|
25
|
+
*/
|
|
26
|
+
function extractVariableUsages(content, uri) {
|
|
27
|
+
const usages = [];
|
|
28
|
+
const varRegex = /var\((--[\w-]+)\)/g;
|
|
29
|
+
let match;
|
|
30
|
+
while ((match = varRegex.exec(content)) !== null) {
|
|
31
|
+
const startPos = match.index;
|
|
32
|
+
const endPos = startPos + match[0].length;
|
|
33
|
+
usages.push({
|
|
34
|
+
variable: match[1],
|
|
35
|
+
range: {
|
|
36
|
+
start: { line: 0, character: startPos },
|
|
37
|
+
end: { line: 0, character: endPos },
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return usages;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=variableAnalyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variableAnalyzer.js","sourceRoot":"","sources":["../../../src/hierarchy/shared/variableAnalyzer.ts"],"names":[],"mappings":";;AAOA,kEAmBC;AAKD,sDAsBC;AAlDD;;;GAGG;AACH,SAAgB,2BAA2B,CACzC,SAAwB;IAExB,MAAM,YAAY,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEpD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;QAEzC,sDAAsD;QACtD,MAAM,QAAQ,GAAG,oBAAoB,CAAC;QACtC,IAAI,KAAK,CAAC;QACV,OAAO,CAAC,KAAK,GAAG,QAAQ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