MCPcopy
hub / github.com/MadAppGang/dingo / calculateDmapPathWithConfig

Function calculateDmapPathWithConfig

pkg/lsp/sourcemap_cache.go:167–194  ·  view source on GitHub ↗

calculateDmapPathWithConfig calculates the .dmap file path using config settings. The dmap directory is always ".dmap" at the workspace root.

(dingoPath string, cfg *config.Config)

Source from the content-addressed store, hash-verified

165// calculateDmapPathWithConfig calculates the .dmap file path using config settings.
166// The dmap directory is always ".dmap" at the workspace root.
167func calculateDmapPathWithConfig(dingoPath string, cfg *config.Config) (string, error) {
168 // Convert to absolute path
169 absPath, err := filepath.Abs(dingoPath)
170 if err != nil {
171 return "", fmt.Errorf("failed to get absolute path: %w", err)
172 }
173
174 // Find workspace root (go.mod, go.work, or dingo.toml)
175 inputDir := filepath.Dir(absPath)
176 workspaceRoot, err := detectWorkspaceRoot(inputDir)
177 if err != nil {
178 // Fall back to parent directory traversal
179 workspaceRoot = inputDir
180 }
181
182 // Calculate relative path from workspace root
183 relPath, err := filepath.Rel(workspaceRoot, absPath)
184 if err != nil {
185 return "", fmt.Errorf("failed to calculate relative path: %w", err)
186 }
187
188 // Replace .dingo extension with .dmap
189 relDmap := strings.TrimSuffix(relPath, ".dingo") + ".dmap"
190
191 // Build final path: workspaceRoot/.dmap/relPath
192 // Note: dmap directory is always ".dmap" (not configurable)
193 return filepath.Join(workspaceRoot, ".dmap", relDmap), nil
194}
195
196// detectWorkspaceRoot finds the workspace root by looking for dingo.toml, go.work, or go.mod
197func detectWorkspaceRoot(startPath string) (string, error) {

Callers 2

GetMethod · 0.85
calculateDmapPathFunction · 0.85

Calls 2

detectWorkspaceRootFunction · 0.70
ErrorfMethod · 0.65

Tested by

no test coverage detected