ballerina-dev-tools icon indicating copy to clipboard operation
ballerina-dev-tools copied to clipboard

Add a new sequence diagram LS extension

Open nipunayf opened this issue 10 months ago • 4 comments

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
  1. Model Generator - generates the sequence diagram for the provided line range information.
  2. 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
  3. 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.
  4. Participant Body Analyzer - acts as the director for building sequence nodes within the body.
  5. 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.
  6. 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

nipunayf avatar Mar 28 '24 09:03 nipunayf

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 28 '24 09:03 CLAassistant

How are we handling the resource method invocations?

json _ = check httpClient->/path1.post(payload);

LakshanWeerasinghe avatar Apr 02 '24 07:04 LakshanWeerasinghe

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

nipunayf avatar Apr 03 '24 03:04 nipunayf

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.

LakshanWeerasinghe avatar Apr 03 '24 04:04 LakshanWeerasinghe