Repository navigation
fix(view): render directed calc parameters as parameter pins in tree views - #1584
Merged
Merged
Conversation
…t parameters Directed parameters of calc, action and constraint definitions and usages render as attribute children of their owner, and an anonymous result parameter as a bare attribute. The fixture pins the rendering as it stands before the fix. Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
…views A tree drew the directed parameters of a calculation, action or constraint definition or usage as attribute members with membership edges, and an anonymous return as a bare attribute: treeNode appended every non-pinned member as a child and labelled it by its default kind, never reading its direction. They are now parameter pins of their owner's node, as §8.2.3.17, §8.2.3.19 and §8.2.3.20 set them, the anonymous result named result, a usage typed by a definition showing each parameter once. The text form lists the pins direction first, DOT and D2 draw them, Mermaid and PlantUML list them in a parameters compartment; a tree keeps them whatever parameter-symbols says, as it keeps its members. Co-Authored-By: jason.han <hanhuijun@gmail.com>
…its on A parameter drawn as a pin has no node of its own, so its Note annotations were dropped; they are now anchored to the owner's node, as narrowing anchors a note at a pin the display leaves out. Co-Authored-By: jason.han <hanhuijun@gmail.com>
…er's member A note about one usage's inherited parameter (about a::x) reached every usage inheriting it: the pin looked notes up by the declaring symbol. It now resolves them as the member the owner has under the name, through MemberLayoutOf and MemberNotesOf, as inherited start and done nodes do. Co-Authored-By: jason.han <hanhuijun@gmail.com>
…e, not its notation localName quotes a name the notation cannot write bare, and LookupMember reads the name itself, so a parameter named 'input value' lost its Layout and Notes. Co-Authored-By: jason.han <hanhuijun@gmail.com>
5 of 6 tasks
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.
What and why
Refs #1576 (the rendering half; the default-kind half — calcs defaulting to the action rendering — is a sibling change in
default_kind.go).A tree rendering (
sysml -render '#tree:A::add', REPL and Jupyter%viz A::add, anyrender asTreeDiagramview) drew the directed parameters of a calculation as ordinary attribute members with membership (diamond) edges, and the anonymousreturnas a bareattribute:Root cause (
internal/ir/view):treeNodeappends every member thatpinnedAtdoes not pin as a child node, andpinnedAtpins only port usages, case pins and constraint parameters;treeNodeShallowlabels a child bydeclKind→Symbol.Notation(), which for a keyword-less directed usage is the parser's default kindattribute, so the direction was never read. The same held for action and constraint definitions and usages in a tree (#tree:Pins::Heatprintedattribute b,attribute t).What changed (view layer only; no parser or semantic change):
tree_parameters.go:treeParameter(owner, member)— a directed usage (in/out/inout/return, by the existingpinDirection) of a calc, action or constraint definition or usage — is drawn bypinParameteras aPort{Parameter: true, Direction, Name, Type, Inherited}of its owner's node instead of a child.treeNodeandtreeDescendantspin it at every depth (as ports and case pins already were at the depth bound or under a collapsed Layout).return : Integeris the pinresult:parameterNametakes the declared name, elseModel.EffectiveNameOf, elseresultfor a result parameter — the name of theFunction::resultit redefines (§7.19.2). A namedreturn ris the out pinr.calc sum : Add { in x = a; }) pinsin x,in ^y,out ^result— each once, the redefining one as its own, the def's others inherited (effectiveMembersalready dedupes the redefinition; the pin carriesInherited). A calc nested in a part keeps its tree containment under the part.textlists the pins under the node direction first (in x,in x : Integerundertypings, mirroring how action pins print),dotdraws them as pin cells (inputs above the head, outputs below, as action pins),d2as nestedpinshapes,mermaid(flowchart) andplantuml(class diagram), which have no pin on a tree node, list them in aparameterscompartment of the label (labeller.parameterLines, the §8.2.3.17/19parameters-compartment). The JSON/LSP data carries them asPortsof the node.narrow.go: a tree keeps its parameter pins whateverparameter-symbolssays (default off), the way it keeps a case's parameters as members and a port as a member — otherwise the default display would have hidden the parameters altogether.Decision on action and constraint trees: §8.2.3.17 (
action-def,action), §8.2.3.19 (calc-def,calc) and §8.2.3.20 (constraint-def,constraint) give all three node forms the sameparam-l* … param-r* … param-b*border pins, so a tree forced over an action or constraint def/usage pins its directed parameters the same way as a calc. Case parameters (subject,actor, …) are untouched: a tree still lists them as members (existing, documented behaviour); interconnection, action and mixed renderings are untouched.Before / after on the reporter's model (
-render '#tree:A::add', text;-render-show typingsadds: Integer):Mermaid before / after:
REPL
%viz A::add texton this branch prints the samein x / in y / out resulttree; the Jupyter kernel's default rendering goes throughsession.Render, the same path.Specification basis
SysML v2.1 §7.19.2 (directed usages in a calc body are its parameters;
returndeclares the result parameter; every calc has one), §8.2.3.17, §8.2.3.19 and §8.2.3.20 (action, calc and constraint nodes carryparam-l*/param-r*/param-b*pins, optionally aparameterscompartment ofFeatureDirection UsageDeclarationentries), KerML §7.4.6 (an unnamed result parameter redefinesFunction::result). No row ofdocs/project/spec-compliance.mdmoves (rendering is not a compliance row).Golden movements
internal/ir/view/testdata/calc-parameters.sysmlwithcalc-parameters.{text,mermaid,dot,plantuml,d2}.goldenandcalc-parameter-definitions.{text,mermaid,dot,plantuml,d2}.golden(anonymousreturn, namedreturn r,in/out/inout, calc def vs calc usage typed by it, a calc nested in a part def, an action def and a constraint def in a tree). The first commit records them on unmodified develop (attribute children); the second re-records them with the fix, so the diff between the two commits is the before/after.go test ./internal/ir/view/...,./internal/doc/...,./internal/frontend/...,./cmd/...,./tests/...all green without any other re-record).How it was verified
go test ./internal/ir/view/...(newtree_parameters_test.go: pins and no edges for#tree:over the reporter's calc, text with and withouttypings, defaultDatakeeps the pins, typed usage shows each parameter once withInherited, action/constraint defs, collapsed Layout keeps the pins),./internal/frontend/...,./internal/doc/...,./cmd/...,./tests/...: green.go build ./...,go vet ./...,gofmt -l .empty;python3 scripts/changelog.py check;python3 scripts/check-doc-links.py.go test -timeout 40m ./...: green (noFAIL);make lint(staticcheck + gosec):✓ Lint passed.developat e7506f7 (the earliertools/referee/apijsonbaseline failure was develop's own, restated by docs(project): restate the api-json differential figures from the re-recorded baseline #1580). Dry-merged against fix(view): render calculations with the behaviour view and parameter pins by default #1583 (fix/calc-default-behaviour-view, 92d50ad): clean, view suite green on the merged tree.bin/sysml -render '#tree:A::add'(text,-render-form mermaid,-render-show typings) and the REPL%viz A::addon this branch vs develop, output above.Checklist
make testandmake lintpass locally (see above)docs/project/view-rendering-forms.md,docs/reference/cli.md)changes/unreleased/calc-parameter-pins.fixed.mdmake docs-countsrun if a gate count moved — none moved