feat(adminui): script document formatting (NormalizeWhitespace)

This commit is contained in:
Joseph Doherty
2026-06-09 15:06:40 -04:00
parent 9104b6c614
commit 4a2f7e37e5
2 changed files with 46 additions and 1 deletions
@@ -325,6 +325,21 @@ public sealed class ScriptAnalysisService
}
catch (Exception ex) { _logger?.LogWarning(ex, "Script signature help failed."); return empty; }
}
public FormatResponse Format(FormatRequest req) => new(req.Code); // Task 8
public FormatResponse Format(FormatRequest req) // Task 8
{
if (string.IsNullOrEmpty(req.Code)) return new FormatResponse(req.Code);
try
{
var code = Normalize(req.Code);
var tree = CSharpSyntaxTree.ParseText(code,
new CSharpParseOptions(LanguageVersion.Latest, kind: SourceCodeKind.Script));
var formatted = tree.GetRoot().NormalizeWhitespace(indentation: " ", eol: "\n").ToFullString();
return new FormatResponse(formatted);
}
catch
{
return new FormatResponse(req.Code);
}
}
public InlayHintsResponse InlayHints(InlayHintsRequest req) => new(Array.Empty<InlayHint>()); // Task 8 (stays empty)
}