Skip to content

Commit c66e2ff

Browse files
committed
chore:⚡ cleanup and fixes
1 parent e574663 commit c66e2ff

File tree

3 files changed

+15
-24
lines changed

3 files changed

+15
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
},
107107
"keybindings": [
108108
{
109-
"command": "vscode-solidity-inspector.pathIntel",
109+
"command": "vscode-solidity-inspector.resetRemappings",
110110
"key": "ctrl+alt+x",
111111
"mac": "cmd+alt+x",
112112
"when": "editorTextFocus"

src/extension.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const { treeFilesCodeActionProvider, treeFilesDiagnosticCollection } = require("
4040

4141
const { scaffoldActiveFile, scaffoldContextMenu } = require("./commands/bulloak-scaffold");
4242

43-
const { provideCompletionItems } = require("./helpers");
43+
const { provideCompletionItems, resetRemappings } = require("./helpers");
4444

4545

4646
/** global vars */
@@ -152,9 +152,13 @@ function onActivate(context) {
152152
context.subscriptions.push(scaffoldActiveFileSubscription);
153153
context.subscriptions.push(scaffoldContextMenuSubscription);
154154

155+
155156
// Import suggestions.
156157
context.subscriptions.push(vscode.languages.registerCompletionItemProvider('solidity', { provideCompletionItems }, ['"', "{"]));
157-
158+
context.subscriptions.push(vscode.commands.registerCommand(EXTENSION_PREFIX + '.resetRemappings', () => {
159+
resetRemappings();
160+
vscode.window.showInformationMessage('Remappings have been refreshed!');
161+
}));
158162

159163
vscode.window.visibleTextEditors.map(editor => {
160164
if (editor && editor.document && editor.document.languageId == "solidity") {

src/helpers.js

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,6 @@ async function provideCompletionItems(document, position) {
5656

5757
const rootPath = workspaceFolders[0].uri.fsPath;
5858

59-
60-
const remappingsPath = path.join(rootPath, 'remappings.txt');
61-
let remappings = {};
62-
63-
if (fs.existsSync(remappingsPath)) {
64-
const remappingsContent = fs.readFileSync(remappingsPath, 'utf8');
65-
remappingsContent.split('\n').forEach(line => {
66-
const [key, val] = line.split('=');
67-
remappings[key.trim()] = val.trim();
68-
});
69-
}
70-
71-
7259
if (remappings === null) { // Load remappings if not already loaded
7360
remappings = await loadRemappings(rootPath);
7461
}
@@ -122,6 +109,13 @@ function findSolidityFiles() {
122109

123110
}
124111

112+
function resetRemappings() {
113+
remappings = null;
114+
}
115+
116+
117+
118+
125119
const networkMap = {
126120
"1": "Ethereum",
127121
"8": "Ubiq",
@@ -220,11 +214,4 @@ const networkMap = {
220214

221215

222216

223-
module.exports = { newWindowBeside, getContractRootDir, LANGID, networkMap, provideCompletionItems, findSolidityFiles };
224-
225-
// Execution time for optimized: 22.145625114440918 milliseconds
226-
// Execution time for optimized: 11.452915668487549 milliseconds
227-
// Execution time for optimized: 8.146999835968018 milliseconds
228-
// Execution time for optimized: 14.010457992553711 milliseconds
229-
// Execution time for optimized: 8.457749843597412 milliseconds
230-
// Execution time for optimized: 12.96274995803833 milliseconds
217+
module.exports = { newWindowBeside, getContractRootDir, LANGID, networkMap, provideCompletionItems, resetRemappings };

0 commit comments

Comments
 (0)