Open on a class that does something, and fix loading an assignment - #24
Merged
Conversation
The editor opened on a function with one parameter and an empty body. That
shows neither what the node kinds are nor how they connect, which on a
graph canvas is most of what a starting document is for.
It now opens on a small Counter class: two initialised fields, and two
methods that use them - one assigning the result of a binary expression
back to a field and returning it, one declaring a local from an expression
and returning that. A field, a parameter, an assignment, a binary
expression, a local and a return are all on screen at once.
Generated C#:
public class Counter
{
int count = 0;
int step = 1;
public int Add(int amount)
{
count = (count + amount);
return count;
}
public int Next()
{
int result = (count + step);
return result;
}
}
Doing this surfaced a bug that made the new document unopenable, and would
have hit any document with an assignment in it. AssignmentStatement's
parameterless constructor - the one its own comment says is for
deserialization - built its placeholder target with
`new VariableReference("")`, and that overload throws on an empty name. So
YamlDeserializer threw before it could overwrite the placeholder, and the
load failed. It now uses the parameterless VariableReference, whose whole
job is to leave the name empty.
NewClassDocument is left alone: "New class" still gives a bare class to
start from, which is a different thing from a worked example.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D2KNUKr1xJPTEdDmeF2tQN
…ture The fixture's `root` is the temporary directory the store writes into, so a local of the same name holding the reopened document's root node read as the same thing twice over. Now `reopenedRoot`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01D2KNUKr1xJPTEdDmeF2tQN
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Default document
The editor opened on a function with one parameter and an empty body. That shows neither what the node kinds are nor how they connect, which on a graph canvas is most of what a starting document is for.
NewDocument()now returns a smallCounterclass: two initialised fields, and two methods that use them — one assigning the result of a binary expression back to a field and returning it, one declaring a local from an expression and returning that. A field, a parameter, an assignment, a binary expression, a local and a return are all on screen at once.Generated C#:
Python comes out equivalently (
class Counter:,def Add(self, amount: int) -> int:), so the preview pane has something worth switching languages on.NewClassDocument()is left alone — "New class" still gives a bare class to start from, which is a different thing from a worked example.A bug this surfaced
The new document could not be reopened, and neither could any document containing an assignment.
AssignmentStatement's parameterless constructor — the one its own comment says is "Used for deserialization" — built its placeholder target withnew VariableReference(""). That overload throws on an empty name:So
YamlDeserializerthrew before it could overwrite the placeholder and the load failed. It now uses the parameterlessVariableReference, whose whole job is to leave the name empty. One line, and the only instance of the pattern in the codebase — I grepped.This is pre-existing on
main; it was simply never exercised, because nothing the editor produced by default had an assignment in it.Testing
NewDocument_IsAClassWithFieldsAndMethodsThatDoSomething— replaces the old test that asserted a function with one parameter. Checks both fields are initialised, both methods have bodies, and that a method assigns an expression result and another declares a local from one.Document_WithAnAssignment_RoundTripsThroughTheFileSystem— new, and fails without the constructor fix. This is the path a user takes by saving and reopening what the editor handed them.newFunction) updated to the new one: the round-trip, the language preview, and the export.Coder.Test330/330, full solution builds clean in Release.Not verified visually — this environment is headless, so how the new document lays out on the canvas is worth a glance.
🤖 Generated with Claude Code
https://claude.ai/code/session_01D2KNUKr1xJPTEdDmeF2tQN
Generated by Claude Code