Skip to content

Commit 1f855b9

Browse files
author
ci-bot
committed
resolution index
1 parent 4d9c4a0 commit 1f855b9

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

libs/remix-solidity/src/compiler/compiler.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,8 @@ export class Compiler {
232232
} else {
233233
console.log(`[Compiler] ✅ 🎉 Compilation successful for target: "${this.state.target}"`)
234234

235-
// Save resolution index before cleaning up resolver
235+
// Clean up resolver (no longer needed - DependencyResolver handles resolution index)
236236
if (this.currentResolver) {
237-
console.log(`[Compiler] 💾 Saving resolution index...`)
238-
this.currentResolver.saveResolutionsToIndex().catch(err => {
239-
console.log(`[Compiler] ⚠️ Failed to save resolution index:`, err)
240-
})
241237
console.log(`[Compiler] 🧹 Compilation successful, discarding resolver`)
242238
this.currentResolver = null
243239
}

libs/remix-solidity/src/compiler/dependency-resolver.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,13 @@ export class DependencyResolver {
277277

278278
return sources
279279
}
280+
281+
/**
282+
* Save all import resolutions to the resolution index for "Go to Definition" functionality
283+
* This should be called after buildDependencyTree() completes successfully
284+
*/
285+
public async saveResolutionIndex(): Promise<void> {
286+
console.log(`[DependencyResolver] 💾 Saving resolution index...`)
287+
await this.resolver.saveResolutionsToIndex()
288+
}
280289
}

libs/remix-solidity/src/compiler/resolution-index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,22 @@ export class ResolutionIndex {
184184
}
185185

186186
try {
187+
// Ensure the directory exists before writing the file
188+
const directory = '.deps/npm'
189+
try {
190+
const exists = await this.pluginApi.call('fileManager', 'exists', directory)
191+
if (!exists) {
192+
await this.pluginApi.call('fileManager', 'mkdir', directory)
193+
console.log(`[ResolutionIndex] 📁 Created directory: ${directory}`)
194+
}
195+
} catch (dirErr) {
196+
console.log(`[ResolutionIndex] ⚠️ Could not ensure directory exists:`, dirErr)
197+
}
198+
187199
const content = JSON.stringify(this.index, null, 2)
188200
await this.pluginApi.call('fileManager', 'writeFile', this.indexPath, content)
189201
this.isDirty = false
190-
console.log(`[ResolutionIndex] 💾 Saved index with ${Object.keys(this.index).length} source files`)
202+
console.log(`[ResolutionIndex] 💾 Saved index with ${Object.keys(this.index).length} source files to: ${this.indexPath}`)
191203
} catch (err) {
192204
console.log(`[ResolutionIndex] ❌ Failed to save index:`, err)
193205
}

libs/remix-ui/solidity-compiler/src/lib/logic/compileTabLogic.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ export class CompileTabLogic {
163163
console.log(`[CompileTabLogic] ✅ Dependency tree built successfully`)
164164
console.log(`[CompileTabLogic] 📦 Source bundle contains ${sourceBundle.size} files`)
165165

166+
// Save resolution index for "Go to Definition" functionality
167+
await depResolver.saveResolutionIndex()
168+
166169
// Get import graph for debugging/logging
167170
const importGraph = depResolver.getImportGraph()
168171
if (importGraph.size > 0) {

0 commit comments

Comments
 (0)