Skip to content

Editor can't create enums, fields, namespaces, source files, aliases, assertions, constructions or float/long literals, though the schema accepts them #383

Open

Description

@matt-edmondson

What's wrong

The graph editor creates new nodes from exactly two sources:

  • AstNodeCatalog.Templates (Coder.Graph/AstNodeCatalog.cs L57-L96). This feeds the palette, the link-drop menu (CreatableFrom) and "Convert to" (ConversionsFor) in AstGraphEditor.
  • AstSchema.CreateDefaultChild (AstSchema.cs L648-L660). This backs the "one more child" action and only ever produces a Parameter, a ReturnStatement, a FunctionDeclaration, an EnumMember or an unfilled string literal.

The catalog's nodes are Class, Function, Parameter, Property, Variable, Constant, Entry point, Return, Expression statement, the assignment, binary and unary operators, Variable reference, Call and Conditional. Its only literals are string, int, double and bool.

AstSchema was deliberately widened to accept and wire more node kinds. A loaded document displays and connects them, but nothing in the editor can create one:

  • AstSchema.Accepts lets a Members slot take FieldDeclaration, EnumDeclaration, NamespaceDeclaration, UsingAlias and CompileTimeAssertion (L702-L705). None of them is in the catalog, and the default Member child is always a FunctionDeclaration.
  • SlotsOf gives SourceFile and NamespaceDeclaration Members slots, and gives ConstructionExpression an element slot that takes MemberInitialiser. None of those node types can be created either.
  • LiteralExpression.StorageTypes includes long and float, and every generator emits them (f, LL and so on). The palette can only make int and double literals.

Concrete failure

  • A user starting from an empty document can't add a field to a class, an enum, or a namespace. "Add member" gives a function, and the palette and link-drop menu have no template for any of these kinds. The same goes for building a header-style document (SourceFile → NamespaceDeclaration → …).
  • Writing new Point { x = 1 } is impossible because neither ConstructionExpression nor MemberInitialiser can be created.
  • A float local can't be given a literal of its own type. In Rust, for example, a Decimal (double) literal assigned to an f32 is a type error.

These features only work today in documents that were hand-written in YAML.

Suggested fix / acceptance criteria

  • Add catalog templates for EnumDeclaration, FieldDeclaration, NamespaceDeclaration, SourceFile, UsingAlias, CompileTimeAssertion, ConstructionExpression and MemberInitialiser. Each should be valid on its own, as the existing templates are, using AstSchema.Unfilled() for operands.

  • Add Long and Single literal templates, or let the Number and Decimal templates choose a width.

  • Add a coverage test next to AstNodeCoverageTests that checks:

    • every AstSlotKind that SlotsOf exposes is satisfiable by at least one catalog template or by CreateDefaultChild;
    • every type named in Accepts(Member) can be built by some template, apart from an explicit exemption list.

    A slot that no menu can fill would then fail the build instead of going unnoticed.

Activity

  1. added
    enhancement
    on Oct 30, 2026
  2. matt-edmondson commented on Oct 30, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    • Category: Feature Request. The editor can't create node kinds the schema already accepts.
    • Priority: Medium. Enums, fields, namespaces, construction expressions and long/float literals can only be added by hand-writing YAML. Generation is unaffected.
    • Area: Coder.Graph (AstNodeCatalog.Templates, AstSchema.CreateDefaultChild), AstGraphEditor, plus a coverage test next to AstNodeCoverageTests.
    • Related: Editor ships no example documents, though plan Task 6.2 ("Add demo commands and examples") is checked off #377 (no example documents) is adjacent editor-onboarding work.
    • Duplicates / in progress: None found. No open PR.

    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions