@@ -89,116 +89,4 @@ function pathIntel(context) {
8989
9090module . exports = { pathIntel} ;
9191
92- // class SolidityImportCompletionItemProvider {
93- // constructor() {
94- // this.filesCache = [];
95- // this.lastCacheUpdate = Date.now();
96- // this.remappings = {};
97- // this.loadRemappings();
98- // this.updateFilesCache(); // Initial cache update
99- // }
100- // async provideCompletionItems(document, position, token, context) {
101- // const linePrefix = document.lineAt(position).text.substr(0, position.character);
102- // if (!linePrefix.endsWith('import "') && !linePrefix.endsWith("import '")) {
103- // return undefined;
104- // }
105-
106- // const currentFilePath = document.uri.fsPath;
107- // const cacheAge = Date.now() - this.lastCacheUpdate;
108- // if (this.filesCache.length === 0 || cacheAge > 10000) { // 10 seconds cache timeout
109- // await this.updateFilesCache();
110- // }
111-
112- // return this.filesCache.map(filePath => {
113- // const contractName = path.basename(filePath, '.sol');
114- // console.log("contractName",contractName,filePath);
115- // const relativeOrRemappedPath = this.getCompletionItemPath(filePath, currentFilePath);
116- // console.log("contractName",contractName,filePath);
117-
118- // const insertText = `import {${contractName}} from "${relativeOrRemappedPath}";`;
119-
120- // const completionItem = new vscode.CompletionItem(contractName, vscode.CompletionItemKind.File);
121- // completionItem.insertText = new vscode.SnippetString(insertText);
122- // return completionItem;
123- // });
124- // }
125-
126-
127- // async updateFilesCache() {
128- // // Reset cache
129- // this.filesCache = [];
130-
131- // // Define the glob pattern for Solidity files
132- // const solidityFilesGlob = '**/*.sol';
133- // // Exclude node_modules from the search
134- // const excludePattern = '**/node_modules/**';
135-
136- // try {
137- // const files = await vscode.workspace.findFiles(solidityFilesGlob, excludePattern);
138- // this.filesCache = files.map(fileUri => vscode.workspace.asRelativePath(fileUri.path));
139-
140- // this.lastCacheUpdate = Date.now();
141- // } catch (error) {
142- // console.error('Error updating Solidity files cache:', error);
143- // }
144- // }
145- // loadRemappings() {
146- // const workspaceFolders = vscode.workspace.workspaceFolders;
147- // if (!workspaceFolders) return;
148-
149- // const rootPath = workspaceFolders[0].uri.fsPath;
150- // const remappingsPath = path.join(rootPath, 'remappings.txt');
151- // if (fs.existsSync(remappingsPath)) {
152- // const remappingsContent = fs.readFileSync(remappingsPath, 'utf8');
153- // remappingsContent.split('\n').forEach(line => {
154- // const [key, val] = line.split('=');
155- // if (key && val) {
156- // this.remappings[key.trim()] = val.trim();
157- // }
158- // });
159- // }
160- // }
161-
162- // getCompletionItemPath(fileUri, currentFilePath) {
163- // try {
164- // const relativePath = vscode.workspace.asRelativePath(fileUri);
165- // if (!relativePath) {
166- // throw new Error('File is not within the workspace.');
167- // }
168- // const filePath = relativePath.replace(/\\/g, '/');
169-
170- // // Apply remappings
171- // for (const [remappedPrefix, remappedValue] of Object.entries(this.remappings)) {
172- // if (filePath.startsWith(remappedValue)) {
173- // return filePath.replace(remappedValue, remappedPrefix);
174- // }
175- // }
176-
177- // // Calculate relative path if not remapped
178- // const currentDir = path.dirname(currentFilePath);
179- // let finalPath = path.relative(currentDir, fileUri.fsPath).replace(/\\/g, '/');
180- // if (!finalPath.startsWith('.')) {
181- // finalPath = './' + finalPath;
182- // }
183- // return finalPath;
184- // } catch (error) {
185- // console.error('Error while determining file path:', error.message);
186- // // Return an empty string or handle the error as appropriate for your use case
187- // return '';
188- // }
189- // }
190-
191-
192- // async maybeUpdateCache() {
193- // const cacheAge = Date.now() - this.lastCacheUpdate;
194- // if (this.filesCache.length === 0 || cacheAge > 10000) { // E.g., 10 seconds cache timeout
195- // await this.updateFilesCache();
196- // }
197- // }
198- // }
199-
200-
201-
202- // module.exports = {SolidityImportCompletionItemProvider};
203-
204-
92+
0 commit comments