From 68c2ea38c913e99c9b1b8ace18232e6df0071d41 Mon Sep 17 00:00:00 2001 From: Justin Greywolf Date: Tue, 19 Nov 2019 12:18:41 -0800 Subject: [PATCH] Bug1061-CannotMarkMembersAsProtectedInClassDiagram Using # to indicate protected status of a member or method causing parser error when not used inside class declaration brackets {}. Removed '#' from `LABEL` regex --- .../integration/rendering/classDiagram.spec.js | 3 +++ dist/index.html | 6 +++--- src/diagrams/class/classDiagram.spec.js | 15 +++++++++++++++ src/diagrams/class/parser/classDiagram.jison | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cypress/integration/rendering/classDiagram.spec.js b/cypress/integration/rendering/classDiagram.spec.js index 1e45851499..4b0efc85c4 100644 --- a/cypress/integration/rendering/classDiagram.spec.js +++ b/cypress/integration/rendering/classDiagram.spec.js @@ -19,6 +19,9 @@ describe('Class diagram', () => { Class01 : size() Class01 : int chimp Class01 : int gorilla + Class01 : -int privateChimp + Class01 : +int publicGorilla + Class01 : #int protectedMarmoset Class08 <--> C2: Cool label class Class10 { <<service>> diff --git a/dist/index.html b/dist/index.html index 73f6ff1543..2fb6f2ab62 100644 --- a/dist/index.html +++ b/dist/index.html @@ -408,9 +408,9 @@ Class09 --|> Class07 Class07 : equals() Class07 : Object[] elementData -Class01 : size() -Class01 : int chimp -Class01 : int gorilla +Class01 : #size() +Class01 : -int chimp +Class01 : +int gorilla Class08 <--> C2: Cool label class Class10 { <<service>> diff --git a/src/diagrams/class/classDiagram.spec.js b/src/diagrams/class/classDiagram.spec.js index a24a01a882..4ed51c1dbb 100644 --- a/src/diagrams/class/classDiagram.spec.js +++ b/src/diagrams/class/classDiagram.spec.js @@ -40,6 +40,21 @@ describe('class diagram, ', function() { parser.parse(str); }); + + it('should handle visibility for methods and members', function() { + const str = + 'classDiagram\n' + + 'class TestClass\n' + + 'TestClass : -int privateMember\n' + + 'TestClass : +int publicMember\n' + + 'TestClass : #int protectedMember\n' + + 'TestClass : -privateMethod()\n' + + 'TestClass : +publicMethod()\n' + + 'TestClass : #protectedMethod()\n' + + + parser.parse(str); + }); + it('should handle class definitions', function() { const str = 'classDiagram\n' + diff --git a/src/diagrams/class/parser/classDiagram.jison b/src/diagrams/class/parser/classDiagram.jison index 4b0fe97c24..f9e1d22af7 100644 --- a/src/diagrams/class/parser/classDiagram.jison +++ b/src/diagrams/class/parser/classDiagram.jison @@ -36,7 +36,7 @@ \s*o return 'AGGREGATION'; \-\- return 'LINE'; \.\. return 'DOTTED_LINE'; -":"[^#\n;]+ return 'LABEL'; +":"[^\n;]+ return 'LABEL'; \- return 'MINUS'; "." return 'DOT'; \+ return 'PLUS';