feat(ui): structured editors for script schemas and alarm triggers
Replace raw-JSON text inputs with rich UI: script parameter/return types use a JSON Schema builder (SchemaBuilder + JsonSchemaShapeParser, with a migration to convert existing definitions); alarm trigger config uses a type-aware editor with a flattened attribute picker (AlarmTriggerEditor). AlarmActor gains optional direction (rising/falling/either) on RateOfChange triggers.
This commit is contained in:
@@ -4,7 +4,6 @@ using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Scripting;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Formatting;
|
||||
using Microsoft.CodeAnalysis.Scripting;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
@@ -334,11 +333,13 @@ public class ScriptAnalysisService
|
||||
return new FormatResponse(request.Code);
|
||||
try
|
||||
{
|
||||
using var workspace = new AdhocWorkspace();
|
||||
var tree = CSharpSyntaxTree.ParseText(
|
||||
request.Code,
|
||||
new CSharpParseOptions(LanguageVersion.Latest, kind: SourceCodeKind.Script));
|
||||
var formatted = Formatter.Format(tree.GetRoot(), workspace);
|
||||
// NormalizeWhitespace produces canonical layout (indentation + line
|
||||
// breaks). Formatter.Format alone with an empty workspace only
|
||||
// normalizes inter-token spacing — it won't split crammed lines.
|
||||
var formatted = tree.GetRoot().NormalizeWhitespace(indentation: " ", eol: "\n");
|
||||
return new FormatResponse(formatted.ToFullString());
|
||||
}
|
||||
catch
|
||||
|
||||
Reference in New Issue
Block a user