ballerina-dev-tools
ballerina-dev-tools copied to clipboard
Add a new sequence diagram LS extension
Purpose
The PR produces a new LS extension for the purpose of revamping the existing sequence diagram model. Currently, it supports the nodes specified in the spec, and the LS API specification can be found here.
Fixes https://github.com/ballerina-platform/ballerina-dev-tools/issues/340
Approach
The high-level design class diagram can be found below:
classDiagram
class E["Expression"]
class SN["Sequence Node"]
class I["Interaction"]
class P["Participant"]
class EF["ExpressionFactory"]
class NB["NodeBuilder"]
class D["Diagram"]
class MG["ModelGenerator"]
class PA["ParticipantAnalyzer"]
class PBA["ParticipantBodyAnalyzer"]
class PM["ParticipantManager"]
SN <|-- I
P o-- "n" SN
SN o-- "n" E
D o-- "n" P
PBA *-- "directs the building" NB
PBA --> "get expression" EF
MG --> "generate root participant" PM
MG ..> "generates" D
PA *-- PBA
PA ..> "generates" P
PBA --> "get target id" PM
PM --> "get participant" PA
EF ..> "generates" E
NB ..> "builds" SN
- Model Generator - generates the sequence diagram for the provided line range information.
- Participant Manager - maintains the information about the participants of the given diagram. It produces a participant on demand if the participant does not exist within the cache
- Participant Analyzer - is a node visitor designed to capture relevant information related to the participant. It calls the Participant Body Analyzer to obtain the sequence nodes of the selected participant.
- Participant Body Analyzer - acts as the director for building sequence nodes within the body.
- Node Builder - has the methods to construct targeted sequence nodes. Each visitor method of the Participant Body Analyzer uses this method to build the respective target node.
- Expression Factory - contains static methods to construct the expression nodes.
Security checks
- Followed secure coding standards in http://wso2.com/technical-reports/wso2-secure-engineering-guidelines? yes
- Ran FindSecurityBugs plugin and verified report? no
- Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? yes
Test environment
Ballerina 2201.8.6 (Swan Lake Update 8) OS: macOS 14.2.1 23C71 JDK: openjdk 17.0.8 2023-07-18
How are we handling the resource method invocations?
json _ = check httpClient->/path1.post(payload);
Shall we add a test with invoking functions define in a separate module?
Currently blocked by https://github.com/ballerina-platform/ballerina-lang/issues/42432
Shall we add a test with invoking functions define in a separate module?
Currently blocked by ballerina-platform/ballerina-lang#42432 This happens only when trying to evaluate the expression of a return statement. Shall we add a test where the invoking function is not returning any value. Once this is fixed we can add more tests.