Repository navigation
Add the failing call's context to StateMachineErrorContext - #9
Merged
Merged
Conversation
StateMachineErrorContext now also carries the receiver of the failing call, the states accepted by the Expected condition, the Expected and Found conditions as readable text (receiver shown by its source name), and the single state Found establishes for the receiver, if any. The called method is resolved by checking which method, constructor or static factory declaration contains the verifier's declaration position (the position of the state refinement annotation value), instead of exact position equality, which never matched real verifier errors. Tests run the verifier on new fixtures, including the DefaultMutableTreeNode example, a multi-state precondition and a Found condition that does not establish a single state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #7.
Summary
StateMachineErrorContextkeepscalledMethodandactualStatesand addsreceiver,expectedStates,expectedCondition,foundConditionanddefiniteFoundState. The VS Code State Machine view uses them to focus on a rejected call (Focus the state machine on the rejected call and relevant states vscode-liquidjava#117) and to list state errors (Show state machine errors in the State Machine view vscode-liquidjava#155).calledMethodwas alwaysnullfor real verifier errors. The verifier reports the position of the@StateRefinementvalue, not the method, so the exact position comparison never matched. It now selects the smallest method, constructor or static factory whose source range contains that position. Constructors are named after the class.receiveris the source name of the call's receiver (root, not the verifier's instance name).expectedStateslists the states Expected accepts, in state set order:a || bgives[a, b];!lockedgives the other states.expectedConditionandfoundConditionare formatted with the verifier'sExpressionFormatter. Found is restricted to premises about the receiver. It istruewhen nothing is known about the receiver.definiteFoundStateis set only when Found has exactly one state call on the receiver as a top-level conjunct and does not negate it. Disjunctions, conditionals, contradictions and negations alone givenull.parse(uri)is unchanged. Only callers that constructStateMachineErrorContextdirectly must pass the new arguments.Tests
Seven new tests, four of which run the real verifier on new fixtures:
DefaultMutableTreeNode: FoundchildrenAllowed(root), required[maybeHasChildren],calledMethodgetFirstChild;flag ? open(unknown) : closed(unknown)).The other three construct Expected and Found directly to check the single-Found-state rules and restricting Found to the receiver. They also check method, constructor, static factory and interface-constructor resolution by position. The verifier does not yet report state errors on constructors or factories, so those cases are not exercised through it.
mvn test: 30 tests, all pass.🤖 Generated with Claude Code