Forge
csharpd39635e2
1#nullable enable
2
3using CascadeIDE.Features.CasaField.Application;
4using CascadeIDE.ViewModels;
5
6namespace CascadeIDE.Features.CasaField.Application;
7
8/// <summary>Open code target from CASA field query (code_anchors in claims_nav).</summary>
9public static class CasaFieldCodeNavigationOpener
10{
11 public static bool TryOpenCodeTarget(MainWindowViewModel vm, CasaFieldTarget target)
12 {
13 if (target.Kind != "code" || string.IsNullOrWhiteSpace(target.CodeFile))
14 return false;
15
16 var ws = vm.GetWorkspacePath();
17 if (string.IsNullOrWhiteSpace(ws))
18 return false;
19
20 var fullPath = Path.IsPathRooted(target.CodeFile)
21 ? target.CodeFile
22 : Path.GetFullPath(Path.Combine(ws, target.CodeFile.Replace('/', Path.DirectorySeparatorChar)));
23
24 if (!File.Exists(fullPath))
25 return false;
26
27 var line = target.CodeLine ?? 1;
28 vm.IdeMcp.GoToPosition(fullPath, line, 1);
29 return true;
30 }
31}
32
View only · write via MCP/CIDE