Skip to content

Commit

Permalink
added examples and fixed stackoverflow error on recursive include
Browse files Browse the repository at this point in the history
  • Loading branch information
kiebor81 committed Apr 23, 2018
1 parent c63e5c0 commit 2b62222
Show file tree
Hide file tree
Showing 17 changed files with 256 additions and 30 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
PlantUml Language Service provides editor features for the [PlantUml Language](http://plantuml.com/) to Visual Studio (2017). These features are listed and elaborated on below.

##### Credit
+ [PlantUml](https://github.com/plantuml/plantuml) by [arnaudroques](https://github.com/arnaudroques)
+ Built and adapted from [TextMate starter project](https://github.com/madskristensen/TextmateSample) by [Mads Kristensen](https://github.com/madskristensen)
+ Modelled on [Ruby Language Service](https://github.com/madskristensen/RubyLanguageService)
+ Inspired by [Visual Studio Code plugin](https://github.com/qjebbs/vscode-plantuml) by [qjebbs](https://github.com/qjebbs)
Expand Down Expand Up @@ -119,7 +120,7 @@ Several macros have been embedded for simplicity. They can be imported into your

<sub> -- Happy to receive/include more -- </sub>

- SysML (`!import SysML`)
##### - SysML (`!import SysML`)

Provides short hand commands to create and associate requirements, tests, and expectations:

Expand All @@ -145,6 +146,20 @@ Provides short hand commands to create and associate requirements, tests, and ex
|` Criticality(requirement, detail)`| describes the criticality of a requirement |
|`Describe(requirement, detail)` | provides a simple description of a requirement |

![requirements](http://www.plantuml.com/plantuml/svg/hLRRRXCn47qcKlx1P5yIAQs4n0EgcgWte4XG95h12n9oTYU9oQwzs5xIKFNBUE2J-0N6tekzkxcr9QhQr3DpvdXcVEo_l_-SA4sbpfAus-bsr8Bnb4gQ42uqaBjkX-3dZ8QBcHGPZyv5B2HPpfa6bOW557OX8v2vJSLKmqp2gjkvhoEcY49dSArNCH09eQPy5eFluUD4L2uyBESKmPHciPuAhXNx1UJ5Izyg9jyHsHbVhM5GRMilsgTIYcNBgPrp1-gQEXuV4ooZ9kDnkw8jJma_CYOX0Mu3R7c08ZRmJI6JJ34EIXrmWCW4bGkR0cR0GRBGkCPiDjVRc8jKCy6DQogMkE59d45Hk-VO8in3hc3v7l_sDTpg0VdAWy1yS_ORt7oVqmG6PGdDFmJ1R_AoEDVh43YLJFHDmORc5vt466VhTqH6vbCvaT6Oz2iV1_8PDpTTzRrAUaX-VOyF3-z8QK9uPFJJnjOudIebGeODxa-PLDg7LH0A7dah0zBq8S5XG5f-UJ9Q8Zywtp1YveHXXzPchgmFvN21PVZvC0AZNjJRGMAyYKHaqzKOlBvDZNIOk5edqLTJ5jSRQIR32r17rKm6GU5V7ySFeESYsWaS1DzktEJbSrNuERnpoJGBQSpqQZ-cxv9KI5J54BRol00LIZQ1_K17kRizhTjWOy5dX7noqVPa3gsHvOEKIq7ZgDPrANUnjkt9ArGa03no71g4pWh9ka89svDHgN9jEazcypONo3s9E3dztppCy7rXUbx9eYNan6mjdKfKwotQ9fpREEHJRrXO7T-Gl5mkJqoJHwMoDSrrvwiXlOyWv4lXOwavgNeQnstJFAHHPB_Gs54c8zBBUeFY4cv5DsR6DjQystf1uD1wgEMstyZOMDq050la_g1AU32sbXsb_fYsz3VVJLtqQ-MkosSGb6DPFIIwdMV5zL8JjdLnNa_RJBiT_F65x8qGGvQgB27uT844GsgLFADoQ0tCl2q5cijZpZ3IM3doWuXDQJWmyEuYDiZeWAi5SvigZxAkHQ7CChdKIMmN_IlCM5IM6k5NP9vx-1U7IKykyJ66wuq1z_ESO0tm2VyF)

##### - Entities (`!import Entities`)

Provides stereotypes for Entity Relationship Mapping (see examples)

![data_tables](http://www.plantuml.com/plantuml/svg/pLN1Rjf043q7oVymTG-0QWxaM4Ke16Y4WYWYpg4dQsjlO8LPq_MY2Y6-h8T-Kd-XixF6sCP4YT93ETZUcJVlpSpEBdz-_RvDDLDwkuwTXjFu4F5d8JaC-tu_yFjtan7St43Bzo1HuL94RV3PzvX3htV2pkPV1wFXqzn2Pnwm7rjM1voCfmy5qea76o5NRPZWKyX5JSHewe_zRuGUUR3ZSPpyRCD8Qg5t16mUaOdaWKw2DPEx5dvxOBwIvxPnG6UVBGi1nf17TCtJWslpQWEju81HP3XNmLUhIohN-CG04jbsQ8bTtB1mnHOSt27Jp9QLkh1t6e2_C6Pf2WyYIejTpfpczsaSmMUuVneF2xOfMtEqfbfXfwpzKEIRCSMb_gUKWoNEnPiOiLm-Pt9XQCrt3QdFqjLxixHQF0sLs6YHo3htOvWe4oUavWkkIfdasrCQlDCELRiQ39OYZWA3vgeunGKyYH9k75Lh89-bggdmK1MrVG-eKwyGDRWBciHqxlj_5CqfU6TVNrR4ry4fdSXapOIqLuZ8zlpgc1EgP5TERhJRLhMIQDLesfBRq6hvtAvhheOzkDArfnvT6Ml9bvrW2ZJi9QVj5_f8fEIYNQkM-QXn_2FOg2JaqLQL2xtdcd93lRjTFfUdQzmWh_A1nGLndu99yKkYicqvYypiUM3TAVfehilQH32WMPzX9yAIoPxrzso6ZgoL34_WqeXVHZThgYHrOpJYL5WT9w9w-MvT16HxvZJgMaC8KzKBxdnOSf5Y6meCbxp759t6BPSH_ll_1G00)

##### - UseCase (`!import UseCase`)

Provides stereotypes for UseCase diagrams (see examples)

![usecase](http://www.plantuml.com/plantuml/svg/ZPN1Zjem48RlaV8EqniSEEmkXnvMQDCigf2s2mhiIZsQP0WkZeri1qIhFbaFVQI-GiSa46S9so8kp7ppptXcRFxy-lrWBDEsB4GOX87PSBbbcXKWbKNu4GP0dqyitUHQbJABbL0QzcjkqHHgWxLVwGnrvJE2MSmr7iBWPrjnIoeinxaz20IDgMKo5-WJlax6zCRJQg0CLwmKTgMaDVmxmitGzwhbDr9kd1yxAZWVwx_AZhHM-ml89qg3AJDNkyK4Jt4fIknqtzz3WWRr3ZCOZS2kkR7YAXehcN7BbMJ2qLkrfnCuROTV2vffNZ1zS04Naxk0vvXIZXeNR8UICbo35wWjhzcjA0klYkxUEbTtGzzsFRLAlxTtxwF7hkRKIjHLNxqX_3CooWekNL3d_bL1rpSr33xGYdA9a8pdu-Hr_0Zj6JT0F7r-d2mcq-Ve2Iw6ss2pPF8bIhv2QvIDUpvsEZNWZwz15kDaCQa9RsPUiKB972AfvF5uFSaAxDVZSWPm1XVzkKHZAstQZ2QMb2em5XobfIteFQaSNkZKC95zO0Pwz2EcUtBJFvt8XwQbRL6tFXMlwQt02fmnO_RK_XPzrs_QGFpBDgDvLFmZMiQ5QU735Xu6TT63mM04foexhRUTrhjEwz0f7vzHpVEr1RMgcrFrTK4t7UXhrtMXrTC5Mwrs_7pdcCmWAecHbgVCBGVGW4rPE20CQ0R7b_gSQgciLONBrPp3wPmMXwpWpBLwtnT78FLZUkFoa4Rfwahf2Zc22VCsvGFze7-Elm00)

&nbsp;

## Embedded Skins
Expand Down
13 changes: 13 additions & 0 deletions example/activity.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@startuml

start

if (Condition) then (true)
:do when true;
else (false)
:do when false;
endif

stop

@enduml
63 changes: 63 additions & 0 deletions example/archimate.iuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@startuml

sprite $bProcess jar:archimate/business-process
sprite $aService jar:archimate/application-service
sprite $aComponent jar:archimate/application-component

archimate #Business "Handle claim" as HC <<business-process>>
archimate #Business "Capture Information" as CI <<business-process>>
archimate #Business "Notify\nAdditional Stakeholders" as NAS <<business-process>>
archimate #Business "Validate" as V <<business-process>>
archimate #Business "Investigate" as I <<business-process>>
archimate #Business "Pay" as P <<business-process>>

HC *-down- CI
HC *-down- NAS
HC *-down- V
HC *-down- I
HC *-down- P

CI -right->> NAS
NAS -right->> V
V -right->> I
I -right->> P

archimate #APPLICATION "Scanning" as scanning <<application-service>>
archimate #APPLICATION "Customer admnistration" as customerAdministration <<application-service>>
archimate #APPLICATION "Claims admnistration" as claimsAdministration <<application-service>>
archimate #APPLICATION Printing <<application-service>>
archimate #APPLICATION Payment <<application-service>>

scanning -up-> CI
customerAdministration -up-> CI
claimsAdministration -up-> NAS
claimsAdministration -up-> V
claimsAdministration -up-> I
Payment -up-> P

Printing -up-> V
Printing -up-> P

archimate #APPLICATION "Document\nManagement\nSystem" as DMS <<application-component>>
archimate #APPLICATION "General\nCRM\nSystem" as CRM <<application-component>>
archimate #APPLICATION "Home & Away\nPolicy\nAdministration" as HAPA <<application-component>>
archimate #APPLICATION "Home & Away\nFinancial\nAdministration" as HFPA <<application-component>>

DMS .up.|> scanning
DMS .up.|> Printing
CRM .up.|> customerAdministration
HAPA .up.|> claimsAdministration
HFPA .up.|> Payment

legend left
Example from the "Archisurance case study" (OpenGroup).
See
==
<$bProcess> :business process
==
<$aService> : application service
==
<$aComponent> : appplication component
endlegend

@enduml
6 changes: 6 additions & 0 deletions example/blue_foo.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@startuml

!include foo.puml
!theme blue

@enduml
40 changes: 34 additions & 6 deletions example/data_tables.puml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,43 @@ package "Data Tables" {
}
}

package "Domain Entities" {
class Child ENTITY
class Parent ENTITY
class Chart ENTITY
class Task ENTITY

Child "1" -u-{ "n" Kids
Parent "1" -u-{ "n" Parents
Chart "1" -u-{ "n" Charts
Task "1" -u-{ "n" Tasks
}

package "Stored procedures" {
class GetChildrenByParentId PROCEDURE {
+ParentId
}

class GetTasksForChildId PROCEDURE {
+ChildId
}

Parent_Child_Linker #-u- GetChildrenByParentId
'GetChildrenByParentId -d-{ Child

Charts_Kids_Linker #-u- GetTasksForChildId
Charts_Tasks_Linker #-u- GetTasksForChildId
'GetTasksForChildId -d-{ Task

}

Charts_Tasks_Linker -down-> Charts
Charts_Tasks_Linker -down-> Tasks
Parent_Child_Linker -up-> Kids
Parent_Child_Linker -up-> Parents
Charts_Kids_Linker -up-> Kids
Charts_Kids_Linker -down-> Charts
Charts_Tasks_Linker -d-> Charts
Charts_Tasks_Linker -d-> Tasks

Parent_Child_Linker -d-> Kids
Parent_Child_Linker -d-> Parents

Charts_Kids_Linker -d-> Kids
Charts_Kids_Linker -d-> Charts

@enduml
8 changes: 8 additions & 0 deletions example/example.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ VisualStudioVersion = 15.0.26430.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{57A6073C-AEFE-48EB-8640-7781D074098F}"
ProjectSection(SolutionItems) = preProject
activity.puml = activity.puml
archimate.iuml = archimate.iuml
blue_foo.puml = blue_foo.puml
data_tables.puml = data_tables.puml
foo.puml = foo.puml
requirements.puml = requirements.puml
usecase.puml = usecase.puml
EndProjectSection
EndProject
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D7F12EAE-EE5B-490B-AC66-7CEE76975A6A}
EndGlobalSection
EndGlobal
5 changes: 5 additions & 0 deletions example/nap_foo.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@startuml
!include activity.puml
!theme drive

@enduml
18 changes: 18 additions & 0 deletions example/requirements.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@startuml

!import SysML

Requirement(Foo,ipsum lorem)
BusinessNeed(Bar,loremi defo)
Generic(iFooBar,non edifac)

Associate(Foo,Bar)
Derive(Foo,iFooBar)

Option(Foo, Html)

Expectation(Foo,supports html)
Criticality(Bar, High)
VerifyWithTest(iFooBar)

@enduml
28 changes: 28 additions & 0 deletions example/usecase.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@startuml

!import UseCase

Actor Client
(Log User In) as (UseCase1) PRIMARY
(Log User Out) as (UseCase2) PRIMARY
(Change User Password) as (UseCase3) SECONDARY
(Update User Details) as (UseCase4) SECONDARY

Client ---> UseCase1
Client ---> UseCase2
Client ---> UseCase3
Client ---> UseCase4

note right of Client
This is the User object provider
and Authentication consumer

end note

note bottom of UseCase1
Primary Use Case
a) Authenticate on provision of user credentials

end note

@enduml
7 changes: 5 additions & 2 deletions src/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public static class Global

internal static string CurrentFile = string.Empty;

internal static string CurrentFilePath = string.Empty;

private static Validator validator = new Validator();

internal static List<string> Warnings = new List<string>();
Expand Down Expand Up @@ -45,12 +47,13 @@ internal static void PreviewFileContent(this IServiceProvider serviceprovider, s
if (Constants.FileTypes.Contains($".{path.Split('.').Last()}"))
{
Warnings.Clear();
CurrentFilePath = path;
CurrentFile = Path.GetFileNameWithoutExtension(path);
DiagramUrl =
DiagramService.GetImageUrlForSource(
MacroService.CheckImports(File.ReadAllLines(path).IncludeFiles()),
"svg"
);
CurrentFile = Path.GetFileNameWithoutExtension(path);
OpenDiagramPreviewer();
}
else
Expand Down Expand Up @@ -86,7 +89,7 @@ static internal void WriteOutput()
if (DiagramUrl != Constants.NoImageBase64)
{
string output =
$"\nMarkdown:\r{string.Format(Constants.UrlFormatMd, DiagramUrl,CurrentFile)}" +
$"\nMarkdown:\r{string.Format(Constants.UrlFormatMd,CurrentFile, DiagramUrl)}" +
$"\n\rHtml:\r{string.Format(Constants.UrlFormatSrc, DiagramUrl, CurrentFile)}";

customPane.OutputString(output);
Expand Down
28 changes: 22 additions & 6 deletions src/Grammars/plantuml.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@
"include": "#Keywords"
},
{
"include": "#Gerneral"
"include": "#General"
},
{
"include": "#StereoType"
}
]
},
Expand Down Expand Up @@ -97,7 +100,10 @@
"include": "#Keywords"
},
{
"include": "#Gerneral"
"include": "#General"
},
{
"include": "#StereoType"
}
],
"repository": {
Expand Down Expand Up @@ -202,7 +208,7 @@
{
"comment": "line begin keywords",
"name": "keyword.other.linebegin.source.wsd",
"match": "(?i)^\\s*(usecase|actor|object|participant|boundary|control|entity|database|create|component|interface|package|node|folder|frame|cloud|annotation|enum|abstract|class|abstract\\s+class|state|autonumber(\\s+stop|resume)?|activate|deactivate|destroy|newpage|alt|else|opt|loop|par|break|critical|group|box|rectangle|namespace|partition)\\b"
"match": "(?i)^\\s*(usecase|actor|object|participant|boundary|control|entity|database|create|component|interface|package|node|folder|frame|cloud|annotation|enum|abstract|class|abstract\\s+class|state|autonumber(\\s+stop|resume)?|activate|deactivate|destroy|newpage|alt|else|opt|loop|par|break|critical|group|box|rectangle|namespace|partition|archimate|sprite)\\b"
},
{
"comment": "whole line keywords",
Expand All @@ -216,7 +222,7 @@
}
]
},
"Gerneral": {
"General": {
"patterns": [
{
"comment": "multi-line title, enables ctrl+r jump list.",
Expand Down Expand Up @@ -429,7 +435,7 @@
"name": "keyword.other.header_legend_footer.source.wsd"
}
},
"end": "(?i)^\\s*(end\\s?(header|legend|footer))",
"end": "(?i)^\\s*(end\\s?(header|legend|footer|endlegend))",
"endCaptures": {
"1": {
"name": "keyword.other.header_legend_footer.source.wsd"
Expand Down Expand Up @@ -479,7 +485,7 @@
"end": "$",
"patterns": [
{
"include": "#Gerneral"
"include": "#General"
},
{
"comment": "actor and link message",
Expand Down Expand Up @@ -832,6 +838,16 @@
}
}
]
},
"StereoType": {
"patterns": [
{
"comment": "stereotype definitions",
"name": "stereotype.definitions.source.wsd",
"begin": "<<",
"end": ">>"
}
]
}
}
}
5 changes: 1 addition & 4 deletions src/Macros/Entities.macro
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
!define DATA_TABLE << (T, orchid) Table >>
!define PROCEDURE << (P, aqua) Table >>
!define LINK_TABLE << (L, pink) Linking Table >>
!define ENTITY << (E, yellow) Entity >>
!define one_to_many(one, manyof) one -{ manyof
!define many_to_many(1many, 2many) 1many }-{ 2many
!define one_to_one(1one,2one) 1one -u- 2one
!define ENTITY << (E, yellow) Entity >>
2 changes: 2 additions & 0 deletions src/Macros/Junctions.macro
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
!define Junction_Or circle #black
!define Junction_And circle #whitesmoke
6 changes: 6 additions & 0 deletions src/Macros/UseCase.macro
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ skinparam ActorBackgroundColor<< Registered >> aliceblue
skinparam ActorBackgroundColor<< Admin >> slategrey
skinparam ActorBorderColor darkslategrey

!define RESERVED << Reserved >>
!define CONDITIONAL << Conditional >>
!define PRIMARY << Primary >>
!define SECONDARY << Secondary >>
!define TERTIARY << Tertiary >>

!definelong AnonActor(name)
Actor name << Guest >>
!enddefinelong
Loading

0 comments on commit 2b62222

Please sign in to comment.