django-cotton-lsp 1.0.0

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/out/server.js ADDED
@@ -0,0 +1,274 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const node_1 = require("vscode-languageserver/node");
40
+ const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
41
+ const vscode_uri_1 = require("vscode-uri");
42
+ const cottonParser_1 = require("./cottonParser");
43
+ const componentIndex_1 = require("./utils/componentIndex");
44
+ const usageIndex_1 = require("./utils/usageIndex");
45
+ const completion_1 = require("./handlers/completion");
46
+ const definition_1 = require("./handlers/definition");
47
+ const diagnostics_1 = require("./handlers/diagnostics");
48
+ const hover_1 = require("./handlers/hover");
49
+ const references_1 = require("./handlers/references");
50
+ const CONFIG_FILE_NAME = 'cotton.config.json';
51
+ const connection = (0, node_1.createConnection)(node_1.ProposedFeatures.all);
52
+ const documents = new node_1.TextDocuments(vscode_languageserver_textdocument_1.TextDocument);
53
+ let workspaceRoot;
54
+ let parser;
55
+ let componentIndex;
56
+ let usageIndex;
57
+ let completionHandler;
58
+ let definitionHandler;
59
+ let diagnosticsHandler;
60
+ let hoverHandler;
61
+ let referencesHandler;
62
+ const defaultSettings = {
63
+ templatePaths: ['templates/cotton']
64
+ };
65
+ let globalSettings = defaultSettings;
66
+ let hasConfigurationCapability = false;
67
+ let initOptions = {};
68
+ connection.onInitialize((params) => {
69
+ hasConfigurationCapability = !!(params.capabilities.workspace?.configuration);
70
+ // Store initialization options from LSP client (Neovim, Sublime, etc.)
71
+ initOptions = params.initializationOptions || {};
72
+ workspaceRoot = params.workspaceFolders?.[0]?.uri
73
+ ? vscode_uri_1.URI.parse(params.workspaceFolders[0].uri).fsPath
74
+ : params.rootUri
75
+ ? vscode_uri_1.URI.parse(params.rootUri).fsPath
76
+ : process.cwd();
77
+ parser = new cottonParser_1.CottonParser();
78
+ componentIndex = new componentIndex_1.ComponentIndex(workspaceRoot, defaultSettings.templatePaths);
79
+ usageIndex = new usageIndex_1.UsageIndex(workspaceRoot);
80
+ completionHandler = new completion_1.CompletionHandler(parser, componentIndex);
81
+ definitionHandler = new definition_1.DefinitionHandler(parser, componentIndex);
82
+ diagnosticsHandler = new diagnostics_1.DiagnosticsHandler(parser, componentIndex);
83
+ hoverHandler = new hover_1.HoverHandler(parser, componentIndex);
84
+ referencesHandler = new references_1.ReferencesHandler(parser, componentIndex, usageIndex);
85
+ usageIndex.onChange(() => { notifyUnusedComponents(); });
86
+ return {
87
+ capabilities: {
88
+ textDocumentSync: node_1.TextDocumentSyncKind.Incremental,
89
+ completionProvider: {
90
+ resolveProvider: false,
91
+ triggerCharacters: ['<', ' ', ':', '=', '"']
92
+ },
93
+ definitionProvider: true,
94
+ hoverProvider: true,
95
+ referencesProvider: true
96
+ }
97
+ };
98
+ });
99
+ connection.onInitialized(() => {
100
+ if (hasConfigurationCapability) {
101
+ connection.client.register(node_1.DidChangeConfigurationNotification.type, undefined);
102
+ }
103
+ updateConfiguration();
104
+ // Kick off the one-time full workspace usage scan in the background - it's not
105
+ // needed to answer completion/definition/hover requests, only references and the
106
+ // unused-component decorations, so there's no reason to block startup on it.
107
+ usageIndex.ensureBuilt();
108
+ });
109
+ /**
110
+ * Push the current list of unused component file paths to the client, which renders
111
+ * them as file-explorer decorations. Called after the initial scan and after every
112
+ * incremental update, but each call is cheap (see UsageIndex benchmarks).
113
+ */
114
+ async function notifyUnusedComponents() {
115
+ const allComponents = await componentIndex.getAllComponents();
116
+ const unusedPaths = usageIndex.getUnusedComponentPaths(allComponents);
117
+ connection.sendNotification('cotton/unusedComponents', {
118
+ uris: unusedPaths.map(p => vscode_uri_1.URI.file(p).toString())
119
+ });
120
+ }
121
+ /**
122
+ * Load settings with priority:
123
+ * 1. Editor configuration (VS Code settings.json)
124
+ * 2. LSP initialization options (Neovim, Sublime, etc.)
125
+ * 3. Project config file (cotton.config.json)
126
+ * 4. Default settings
127
+ */
128
+ async function updateConfiguration() {
129
+ let settings = { ...defaultSettings };
130
+ // Try project config file first (lowest priority that overrides defaults)
131
+ const fileConfig = await loadProjectConfig();
132
+ if (fileConfig?.templatePaths) {
133
+ settings.templatePaths = fileConfig.templatePaths;
134
+ }
135
+ // LSP initialization options override file config
136
+ if (initOptions.templatePaths) {
137
+ settings.templatePaths = initOptions.templatePaths;
138
+ }
139
+ // Editor configuration has highest priority
140
+ if (hasConfigurationCapability) {
141
+ const editorConfig = await connection.workspace.getConfiguration('djangoCotton');
142
+ if (editorConfig?.templatePaths) {
143
+ settings.templatePaths = editorConfig.templatePaths;
144
+ }
145
+ }
146
+ globalSettings = settings;
147
+ componentIndex.updateSettings(globalSettings.templatePaths);
148
+ }
149
+ /**
150
+ * Load configuration from cotton.config.json in the workspace root
151
+ */
152
+ async function loadProjectConfig() {
153
+ const configPath = path.join(workspaceRoot, CONFIG_FILE_NAME);
154
+ try {
155
+ const content = await fs.promises.readFile(configPath, 'utf-8');
156
+ const config = JSON.parse(content);
157
+ // Validate the config
158
+ if (config && typeof config === 'object') {
159
+ const result = {};
160
+ if (Array.isArray(config.templatePaths)) {
161
+ result.templatePaths = config.templatePaths.filter((p) => typeof p === 'string');
162
+ }
163
+ return result;
164
+ }
165
+ }
166
+ catch {
167
+ // Config file doesn't exist or is invalid - that's fine
168
+ }
169
+ return null;
170
+ }
171
+ connection.onDidChangeConfiguration(async () => {
172
+ await updateConfiguration();
173
+ documents.all().forEach(validateDocument);
174
+ });
175
+ connection.onCompletion(async (params) => {
176
+ const document = documents.get(params.textDocument.uri);
177
+ if (!document)
178
+ return [];
179
+ return completionHandler.handleCompletion(document, params.position);
180
+ });
181
+ connection.onDefinition(async (params) => {
182
+ const document = documents.get(params.textDocument.uri);
183
+ if (!document)
184
+ return null;
185
+ return definitionHandler.handleDefinition(document, params.position);
186
+ });
187
+ connection.onHover(async (params) => {
188
+ const document = documents.get(params.textDocument.uri);
189
+ if (!document)
190
+ return null;
191
+ return hoverHandler.handleHover(document, params.position);
192
+ });
193
+ connection.onReferences(async (params) => {
194
+ const document = documents.get(params.textDocument.uri);
195
+ if (!document)
196
+ return null;
197
+ return referencesHandler.handleReferences(document, params.position, params.context.includeDeclaration);
198
+ });
199
+ /**
200
+ * Custom request (not part of the LSP spec) backing the Explorer "Find All References"
201
+ * context-menu command: given a component *file*, rather than a cursor position inside a
202
+ * usage, return every place that component is used across the workspace.
203
+ */
204
+ connection.onRequest('cotton/referencesForFile', async ({ uri }) => {
205
+ const filePath = path.normalize(vscode_uri_1.URI.parse(uri).fsPath);
206
+ const allComponents = await componentIndex.getAllComponents();
207
+ const match = allComponents.find(c => path.normalize(c.filePath) === filePath);
208
+ if (!match)
209
+ return [];
210
+ await usageIndex.ensureBuilt();
211
+ return usageIndex.getReferences(match.name);
212
+ });
213
+ connection.onRequest('cotton/getUnusedComponents', async () => {
214
+ const allComponents = await componentIndex.getAllComponents();
215
+ const unusedPaths = usageIndex.getUnusedComponentPaths(allComponents);
216
+ return { uris: unusedPaths.map(p => vscode_uri_1.URI.file(p).toString()) };
217
+ });
218
+ async function validateDocument(document) {
219
+ const diagnostics = await diagnosticsHandler.getDiagnostics(document);
220
+ connection.sendDiagnostics({ uri: document.uri, diagnostics });
221
+ }
222
+ documents.onDidOpen(event => validateDocument(event.document));
223
+ documents.onDidChangeContent(event => {
224
+ // Keep the usage index in sync as the user types - this only rescans the one
225
+ // changed document (cheap), not the whole workspace.
226
+ usageIndex.updateFile(event.document.uri, event.document.getText());
227
+ validateDocument(event.document);
228
+ });
229
+ documents.onDidSave(async (event) => {
230
+ // Check if the config file was saved
231
+ const savedPath = vscode_uri_1.URI.parse(event.document.uri).fsPath;
232
+ if (path.basename(savedPath) === CONFIG_FILE_NAME) {
233
+ await updateConfiguration();
234
+ }
235
+ componentIndex.invalidateCache();
236
+ validateDocument(event.document);
237
+ });
238
+ documents.onDidClose(event => {
239
+ connection.sendDiagnostics({ uri: event.document.uri, diagnostics: [] });
240
+ });
241
+ /**
242
+ * The client watches every .html file in the workspace via a FileSystemWatcher (see
243
+ * src/client/extension.ts) and forwards changes here even for files that were never opened
244
+ * in an editor - e.g. created, edited, or deleted via git, a terminal, or another tool.
245
+ * Without this, both the component index and the usage index (and therefore unused-component
246
+ * detection) would silently drift out of sync with the filesystem until something happened
247
+ * to be opened/saved in the editor.
248
+ */
249
+ connection.onDidChangeWatchedFiles(async (params) => {
250
+ let changed = false;
251
+ for (const change of params.changes) {
252
+ if (change.type === node_1.FileChangeType.Deleted) {
253
+ usageIndex.removeFile(change.uri);
254
+ changed = true;
255
+ continue;
256
+ }
257
+ try {
258
+ const filePath = vscode_uri_1.URI.parse(change.uri).fsPath;
259
+ const content = await fs.promises.readFile(filePath, 'utf-8');
260
+ usageIndex.updateFile(change.uri, content);
261
+ changed = true;
262
+ }
263
+ catch {
264
+ // File may have been removed/renamed between the event and this read - skip it.
265
+ }
266
+ }
267
+ if (changed) {
268
+ componentIndex.invalidateCache();
269
+ documents.all().forEach(validateDocument);
270
+ }
271
+ });
272
+ documents.listen(connection);
273
+ connection.listen();
274
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,uCAAyB;AACzB,2CAA6B;AAC7B,qDAaoC;AACpC,2FAAkE;AAClE,2CAAiC;AAEjC,iDAA8C;AAC9C,2DAAwD;AACxD,mDAAgD;AAChD,sDAA0D;AAC1D,sDAA0D;AAC1D,wDAA4D;AAC5D,4CAAgD;AAChD,sDAA0D;AAE1D,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAE9C,MAAM,UAAU,GAAG,IAAA,uBAAgB,EAAC,uBAAgB,CAAC,GAAG,CAAC,CAAC;AAC1D,MAAM,SAAS,GAAG,IAAI,oBAAa,CAAC,iDAAY,CAAC,CAAC;AAElD,IAAI,aAAqB,CAAC;AAC1B,IAAI,MAAoB,CAAC;AACzB,IAAI,cAA8B,CAAC;AACnC,IAAI,UAAsB,CAAC;AAC3B,IAAI,iBAAoC,CAAC;AACzC,IAAI,iBAAoC,CAAC;AACzC,IAAI,kBAAsC,CAAC;AAC3C,IAAI,YAA0B,CAAC;AAC/B,IAAI,iBAAoC,CAAC;AAMzC,MAAM,eAAe,GAAmB;IACpC,aAAa,EAAE,CAAC,kBAAkB,CAAC;CACtC,CAAC;AAEF,IAAI,cAAc,GAAmB,eAAe,CAAC;AACrD,IAAI,0BAA0B,GAAG,KAA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E,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,UAAU,CAAC,uBAAuB,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE;IAC9C,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QAClC,IAAI,MAAM,CAAC,IAAI,KAAK,qBAAc,CAAC,OAAO,EAAE,CAAC;YACzC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClC,OAAO,GAAG,IAAI,CAAC;YACf,SAAS;QACb,CAAC;QAED,IAAI,CAAC;YACD,MAAM,QAAQ,GAAG,gBAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;YAC9C,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC9D,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAC3C,OAAO,GAAG,IAAI,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACL,gFAAgF;QACpF,CAAC;IACL,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACV,cAAc,CAAC,eAAe,EAAE,CAAC;QACjC,SAAS,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC9C,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC7B,UAAU,CAAC,MAAM,EAAE,CAAC"}
@@ -0,0 +1,325 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ComponentIndex = void 0;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const fast_glob_1 = __importDefault(require("fast-glob"));
43
+ const COTTON_BUILTIN_DIRECTIVES = ['vars', 'slot', 'component'];
44
+ class ComponentIndex {
45
+ constructor(workspaceRoot, templatePatterns = ['templates/cotton']) {
46
+ this.resolvedPathsCache = null;
47
+ this.cache = new Map();
48
+ this.allComponentsCache = null;
49
+ this.workspaceRoot = workspaceRoot;
50
+ this.templatePatterns = templatePatterns;
51
+ }
52
+ updateSettings(templatePatterns) {
53
+ if (JSON.stringify(this.templatePatterns) !== JSON.stringify(templatePatterns)) {
54
+ this.templatePatterns = templatePatterns;
55
+ this.invalidateCache();
56
+ }
57
+ }
58
+ invalidateCache() {
59
+ this.cache.clear();
60
+ this.allComponentsCache = null;
61
+ this.resolvedPathsCache = null;
62
+ }
63
+ isBuiltinDirective(name) {
64
+ return COTTON_BUILTIN_DIRECTIVES.includes(name);
65
+ }
66
+ /**
67
+ * Resolve glob patterns to actual directory paths
68
+ */
69
+ async resolveTemplatePaths() {
70
+ if (this.resolvedPathsCache) {
71
+ return this.resolvedPathsCache;
72
+ }
73
+ const resolvedPaths = [];
74
+ for (const pattern of this.templatePatterns) {
75
+ // Check if pattern contains glob characters
76
+ if (this.isGlobPattern(pattern)) {
77
+ // Use fast-glob to find matching directories
78
+ const matches = await (0, fast_glob_1.default)(pattern, {
79
+ cwd: this.workspaceRoot,
80
+ onlyDirectories: true,
81
+ absolute: false
82
+ });
83
+ resolvedPaths.push(...matches);
84
+ }
85
+ else {
86
+ // Plain path - just use as-is
87
+ resolvedPaths.push(pattern);
88
+ }
89
+ }
90
+ // Remove duplicates
91
+ this.resolvedPathsCache = [...new Set(resolvedPaths)];
92
+ return this.resolvedPathsCache;
93
+ }
94
+ isGlobPattern(pattern) {
95
+ return /[*?{}[\]]/.test(pattern);
96
+ }
97
+ async findComponent(componentName) {
98
+ if (this.cache.has(componentName)) {
99
+ return this.cache.get(componentName) || null;
100
+ }
101
+ const filePath = await this.findComponentFile(componentName);
102
+ if (!filePath) {
103
+ this.cache.set(componentName, null);
104
+ return null;
105
+ }
106
+ const cVars = await this.parseCVars(filePath);
107
+ const info = {
108
+ name: componentName,
109
+ filePath,
110
+ cVars
111
+ };
112
+ this.cache.set(componentName, info);
113
+ return info;
114
+ }
115
+ async getAllComponents() {
116
+ if (this.allComponentsCache) {
117
+ return this.allComponentsCache;
118
+ }
119
+ const components = [];
120
+ const templatePaths = await this.resolveTemplatePaths();
121
+ for (const templateBasePath of templatePaths) {
122
+ const fullTemplatePath = path.join(this.workspaceRoot, templateBasePath);
123
+ try {
124
+ await this.collectTemplateFiles(fullTemplatePath, '', components);
125
+ }
126
+ catch {
127
+ // Directory doesn't exist, skip
128
+ }
129
+ }
130
+ this.allComponentsCache = components;
131
+ return components;
132
+ }
133
+ async findComponentFile(componentName) {
134
+ const tagPath = componentName.replace(/\./g, '/');
135
+ const pathVariations = [
136
+ tagPath,
137
+ tagPath.replace(/-/g, '_'),
138
+ tagPath.replace(/_/g, '-')
139
+ ];
140
+ const templatePaths = await this.resolveTemplatePaths();
141
+ for (const templateBasePath of templatePaths) {
142
+ for (const pathVariation of pathVariations) {
143
+ const templatePath = path.join(this.workspaceRoot, templateBasePath, pathVariation + '.html');
144
+ try {
145
+ await fs.promises.access(templatePath);
146
+ return templatePath;
147
+ }
148
+ catch {
149
+ const indexPath = path.join(this.workspaceRoot, templateBasePath, pathVariation, 'index.html');
150
+ try {
151
+ await fs.promises.access(indexPath);
152
+ return indexPath;
153
+ }
154
+ catch {
155
+ continue;
156
+ }
157
+ }
158
+ }
159
+ }
160
+ return undefined;
161
+ }
162
+ async collectTemplateFiles(basePath, relativePath, items) {
163
+ try {
164
+ const entries = await fs.promises.readdir(path.join(basePath, relativePath), { withFileTypes: true });
165
+ for (const entry of entries) {
166
+ const currentRelativePath = path.join(relativePath, entry.name);
167
+ if (entry.isDirectory()) {
168
+ const indexPath = path.join(basePath, currentRelativePath, 'index.html');
169
+ try {
170
+ await fs.promises.access(indexPath);
171
+ const componentName = currentRelativePath.replace(/[\\/]/g, '.').replace(/_/g, '-');
172
+ const cVars = await this.parseCVars(indexPath);
173
+ items.push({
174
+ name: componentName,
175
+ filePath: indexPath,
176
+ cVars
177
+ });
178
+ }
179
+ catch {
180
+ // No index.html
181
+ }
182
+ await this.collectTemplateFiles(basePath, currentRelativePath, items);
183
+ }
184
+ else if (entry.isFile() && entry.name.endsWith('.html') && entry.name !== 'index.html') {
185
+ const componentName = currentRelativePath.slice(0, -5).replace(/[\\/]/g, '.').replace(/_/g, '-');
186
+ const filePath = path.join(basePath, currentRelativePath);
187
+ const cVars = await this.parseCVars(filePath);
188
+ items.push({
189
+ name: componentName,
190
+ filePath,
191
+ cVars
192
+ });
193
+ }
194
+ }
195
+ }
196
+ catch {
197
+ // Directory not readable
198
+ }
199
+ }
200
+ async parseCVars(filePath) {
201
+ try {
202
+ const content = await fs.promises.readFile(filePath, 'utf-8');
203
+ const cVarsMatch = content.match(/<c-vars\s+([^>]+)>/);
204
+ if (!cVarsMatch)
205
+ return [];
206
+ const cVars = [];
207
+ const attributeRegex = /(:?)(\w(?:[\w-]*\w)?)(?:=["']([^"']*)["'])?/g;
208
+ let match;
209
+ while ((match = attributeRegex.exec(cVarsMatch[1])) !== null) {
210
+ cVars.push({
211
+ name: match[2],
212
+ defaultValue: match[3] || '',
213
+ isDjangoExpression: match[1] === ':'
214
+ });
215
+ }
216
+ return cVars;
217
+ }
218
+ catch {
219
+ return [];
220
+ }
221
+ }
222
+ async getComponentFileContent(filePath) {
223
+ try {
224
+ return await fs.promises.readFile(filePath, 'utf-8');
225
+ }
226
+ catch {
227
+ return null;
228
+ }
229
+ }
230
+ /**
231
+ * Locate where a prop is best "defined" within a component file, for go-to-definition
232
+ * on an attribute name at a usage site:
233
+ * 1. The prop's declaration inside <c-vars ...>, if present.
234
+ * 2. Otherwise, the first place the prop is referenced in the file (e.g. {{ prop }}).
235
+ * 3. Otherwise, null (caller should fall back to the top of the file).
236
+ *
237
+ * Cotton exposes kebab-cased attributes as their snake_case equivalent inside the
238
+ * template (e.g. `icon-name` -> `{{ icon_name }}`), since `{{ }}` expressions can't
239
+ * contain hyphens. We match against both forms so navigation works either way.
240
+ */
241
+ findPropTargetOffset(content, propName) {
242
+ const nameVariants = [...new Set([propName, propName.replace(/-/g, '_'), propName.replace(/_/g, '-')])];
243
+ const cVarsMatch = content.match(/<c-vars\s+([^>]+)>/);
244
+ if (cVarsMatch) {
245
+ const groupOffset = cVarsMatch.index + cVarsMatch[0].indexOf(cVarsMatch[1]);
246
+ const attributeRegex = /(:?)(\w(?:[\w-]*\w)?)(?:=["']([^"']*)["'])?/g;
247
+ let match;
248
+ while ((match = attributeRegex.exec(cVarsMatch[1])) !== null) {
249
+ if (nameVariants.includes(match[2])) {
250
+ const nameStart = groupOffset + match.index + match[1].length;
251
+ return { start: nameStart, end: nameStart + match[2].length };
252
+ }
253
+ }
254
+ }
255
+ const searchFrom = cVarsMatch ? cVarsMatch.index + cVarsMatch[0].length : 0;
256
+ const usageRegex = new RegExp(`\\b(?:${nameVariants.map(v => this.escapeRegex(v)).join('|')})\\b`, 'g');
257
+ usageRegex.lastIndex = searchFrom;
258
+ const usageMatch = usageRegex.exec(content);
259
+ if (usageMatch) {
260
+ return { start: usageMatch.index, end: usageMatch.index + usageMatch[0].length };
261
+ }
262
+ return null;
263
+ }
264
+ /**
265
+ * Heuristically collect every variable name a component's body references via
266
+ * `{{ name }}` or `{% if name %}` (the two patterns Cotton slots are actually rendered
267
+ * through). Shared by slot-name completion and slot-name validation.
268
+ */
269
+ async getReferencedVariableNames(filePath) {
270
+ const content = await this.getComponentFileContent(filePath);
271
+ if (!content)
272
+ return new Set();
273
+ const bodyContent = content.replace(/<c-vars\s+[^>]+>/, '');
274
+ const names = new Set();
275
+ const patterns = [/\{\{\s*([a-zA-Z_]\w*)/g, /\{%\s*if\s+([a-zA-Z_]\w*)/g];
276
+ for (const pattern of patterns) {
277
+ let match;
278
+ while ((match = pattern.exec(bodyContent)) !== null) {
279
+ names.add(match[1]);
280
+ }
281
+ }
282
+ return names;
283
+ }
284
+ /**
285
+ * Heuristically find candidate named-slot identifiers for a component: variables it
286
+ * references in its body ({{ name }}, {% if name %}) that aren't declared c-vars, the
287
+ * default slot, or common template globals. Used to power completion inside <c-slot name="">.
288
+ */
289
+ async getSlotCandidates(filePath, excludeNames) {
290
+ const referenced = await this.getReferencedVariableNames(filePath);
291
+ return [...referenced].filter(name => !ComponentIndex.RESERVED_TEMPLATE_NAMES.has(name) && !excludeNames.has(name));
292
+ }
293
+ /**
294
+ * Whether `<c-slot name="slotName">` actually does something for this component, i.e.
295
+ * whether its body references that name via `{{ slotName }}` or `{% if slotName %}`
296
+ * anywhere. Used to flag likely-typo'd slot names as a diagnostic. This is a heuristic
297
+ * (same patterns as getSlotCandidates) so it won't catch every possible usage (e.g. a name
298
+ * only referenced through `{% with %}` or `{% for %}`), but keeps false positives low.
299
+ */
300
+ async hasSlotReference(filePath, slotName) {
301
+ const referenced = await this.getReferencedVariableNames(filePath);
302
+ return referenced.has(slotName);
303
+ }
304
+ escapeRegex(str) {
305
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
306
+ }
307
+ async getComponentDocumentation(filePath) {
308
+ try {
309
+ const content = await fs.promises.readFile(filePath, 'utf-8');
310
+ const firstLine = content.split('\n')[0].trim();
311
+ if (firstLine.startsWith('<!--') && firstLine.endsWith('-->')) {
312
+ return firstLine.slice(4, -3).trim();
313
+ }
314
+ return undefined;
315
+ }
316
+ catch {
317
+ return undefined;
318
+ }
319
+ }
320
+ }
321
+ exports.ComponentIndex = ComponentIndex;
322
+ ComponentIndex.RESERVED_TEMPLATE_NAMES = new Set([
323
+ 'slot', 'attrs', 'forloop', 'True', 'False', 'None', 'request', 'user', 'perms', 'messages'
324
+ ]);
325
+ //# sourceMappingURL=componentIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentIndex.js","sourceRoot":"","sources":["../../src/utils/componentIndex.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,0DAA2B;AAE3B,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AAchE,MAAa,cAAc;IAOvB,YAAY,aAAqB,EAAE,mBAA6B,CAAC,kBAAkB,CAAC;QAJ5E,uBAAkB,GAAoB,IAAI,CAAC;QAC3C,UAAK,GAAsC,IAAI,GAAG,EAAE,CAAC;QACrD,uBAAkB,GAA2B,IAAI,CAAC;QAGtD,IAAI,CAAC,aA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