Repository navigation
Allow annotations on individual topology connections - #1190
Conversation
Parse the connections of a direct connection graph as an annotated element sequence, so each connection can have pre and post annotations. Ast.SpecConnectionGraph.Direct now holds a list of Annotated[Connection], and Connection keeps the annotated AST connection in a new astOpt field, filled in by Connection.fromAst. The AST writer and the FPP writer write the annotations. The analysis JSON output leaves out astOpt, since the AST output already has it. Fixes nasa#664
In Parser, id is the parser for the id token, not the identity function, so the connections parser did not compile.
fpp-syntax and fpp-to-fpp now write the annotations on the first connection of syntax.fpp. In the AST JSON of fpp-to-json, each direct connection is now an annotated triple, like the other annotated elements, and the parser assigns the node IDs that follow it differently, as it does after other annotated element sequences.
bocchino
left a comment
There was a problem hiding this comment.
The implementation looks good! We need to update the language specification and the User's Guide to match. Please make those changes. By coincidence, it looks like the section to update in both documents is 14.2.1.
|
Thanks, Rob! I'll update the language specification and the User's Guide (section 14.2.1 in both) to cover annotations on individual connections, and push the changes shortly. |
List a connection in a direct graph specifier among the annotatable elements in the language specification (section 14.2.1), and show an annotated connection in the User's Guide section on direct graph specifiers.
|
@Shakhtar-Sankur I see the changes, thanks. Is this PR ready for re-review? |
|
Yes, it's ready for re-review. Commit a98042e adds connections in direct graph specifiers to the list of annotatable elements in the spec (14.2.1) and an annotated connection example to the User's Guide (14.2.1). I haven't regenerated the HTML files; happy to do that too if you'd like. |
|
Sounds good! Yes, please regenerate the HTML. That's part of the process for updating the docs. Then I'll re-review. |
|
Done: I've regenerated the HTML for the spec and the User's Guide in 18fcab5. Ready for re-review whenever you are. |
Fixes #664
This follows the design in #664:
Ast.SpecConnectionGraph.Direct.connectionsis now aList[Annotated[SpecConnectionGraph.Connection]], and the parser reads the connections of a direct graph withannotatedElementSequence, as for enum constants and struct members.Connectionhas a new last field,astOpt: Option[Ast.Annotated[Ast.SpecConnectionGraph.Connection]] = None.Connection.fromAsttakes the annotated AST connection and fills inastOpt.The rest follows from the AST change: template expansion keeps the annotations,
BasicUseAnalyzerandTypeExpressionAnalyzervisit the connection inside the annotation, the XML import gives each connection empty annotations, andAstWriterandFppWriterwrite the annotations, sofpp-syntax -aandfpp-to-fppshow them:Two things to check:
AnalysisJsonEncoderderives theConnectionencoder automatically, soastOptwould have put the whole annotated AST of every connection into the analysis output. Since the annotation does not need to go into generated output, I gaveConnectionan explicit encoder that leavesastOptout, and the analysis JSON is unchanged. I can remove that encoder if you would rather haveastOptin the analysis output.fpp-to-json, each direct connection is now[pre, connection, post], like the other annotated elements. The node IDs after a connection list also change:annotatedElementSequencetries an element with a separator, then with a post-annotation, then without a terminator, and each attempt creates new nodes, as it already does for other annotated lists. That is why the fivefpp-to-jsonreference files change so much; most of it is nesting and renumbered IDs.Tests:
syntax.fpp(fpp-syntax) has an annotated connection, with its AST reference outputs updated, andtopology.fpp(fpp-to-fpp) round-trips one. Built with Java 25 as in CI:sbt testpasses (716 tests). Incompiler/test, everything passed except eight reference files (three more outputs ofsyntax.fpp, which now show the annotations, and the fivefpp-to-jsonfiles), which I regenerated with the branch; the fpp-syntax, fpp-to-fpp and fpp-to-json tests pass after that.AI disclosure, per the F´ AI policy: I used Claude as an assistant to work through the parser and the places that use connections, and to draft the code changes, the tests and this description. I've reviewed all of it against the code myself, ran the builds and tests above, and I'll handle the review.