forked from gsdlab/chocosolver
-
Notifications
You must be signed in to change notification settings - Fork 0
Add PlantUML Compiler / Pretty Printer for Model Visualization #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
EthanJamesLew
wants to merge
13
commits into
feature/sysml
Choose a base branch
from
feature/plantuml
base: feature/sysml
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3c70b75
add plantuml package and start adding the ast classes / interfaces
EthanJamesLew 1044332
add plantuml to cli inputs and check for conflicting options
EthanJamesLew 9205f45
flesh out compile and pprinter interfaces
EthanJamesLew 204c102
add fields to the plantuml ast
EthanJamesLew 3ff20d6
pretty print objects
EthanJamesLew 25138b5
add basic connections compilation
EthanJamesLew b912367
add labels, support or and xor
EthanJamesLew ffe9904
close dataStream to properly handle dynamic allocation
EthanJamesLew 1eaae94
make or arrowhead a filled shape
EthanJamesLew c4193df
make mandatory arrowhead for multiplicity one features
EthanJamesLew 1c8438a
fold refs into object attributes
EthanJamesLew ab5bea8
remove Optimizing message for plantuml (which does not optimize)
EthanJamesLew 71e9e85
fix confusing renaming assignment
EthanJamesLew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.plantuml.ast; | ||
|
||
import java.io.IOException; | ||
|
||
public class PlantumlConnection implements PlantumlExpr { | ||
private final String fromObj; | ||
private final String toObj; | ||
private final char fromConn; | ||
private final char toConn; | ||
|
||
private final char lineChar; | ||
|
||
private final String label; | ||
|
||
public PlantumlConnection(String fromObj, String toObj, char fromConn, char toConn, String label){ | ||
this.fromObj = fromObj; | ||
this.toObj = toObj; | ||
this.fromConn = fromConn; | ||
this.toConn = toConn; | ||
this.label = label; | ||
this.lineChar = '-'; | ||
} | ||
|
||
public PlantumlConnection(String fromObj, String toObj, char fromConn, char toConn, String label, char lineChar){ | ||
this.fromObj = fromObj; | ||
this.toObj = toObj; | ||
this.fromConn = fromConn; | ||
this.toConn = toConn; | ||
this.label = label; | ||
this.lineChar = lineChar; | ||
} | ||
|
||
public String getFromObj(){ | ||
return fromObj; | ||
} | ||
|
||
public String getToObj(){ | ||
return toObj; | ||
} | ||
|
||
public char getToConn(){ | ||
return toConn; | ||
} | ||
|
||
public char getFromConn(){ | ||
return fromConn; | ||
} | ||
|
||
public String getLabel(){ | ||
return label; | ||
} | ||
|
||
public char getLineChar(){ | ||
return lineChar; | ||
} | ||
|
||
@Override | ||
public <A, B> B accept(PlantumlExprVisitor<A, B> visitor, A a) throws IOException { | ||
return visitor.visit(this, a); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.plantuml.ast; | ||
|
||
import java.io.IOException; | ||
|
||
public interface PlantumlExpr { | ||
/** | ||
* Dynamic dispatch on the visitor. | ||
* | ||
* @param <A> the parameter type | ||
* @param <B> the return type | ||
* @param visitor the visitor | ||
* @param a the parameter | ||
* @return the return value | ||
*/ | ||
<A, B> B accept(PlantumlExprVisitor<A, B> visitor, A a) throws IOException; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.plantuml.ast; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* AST Visitor | ||
* | ||
* We make AST visitors capable of throwing IOExecptions as it's convenient for pretty printers | ||
* However, we could likely get rid of this throw some type of interface conversion. | ||
*/ | ||
public interface PlantumlExprVisitor<A, B> { | ||
B visit(PlantumlProgram plantumlProgram, A a) throws IOException; | ||
|
||
B visit(PlantumlObject plantumlObject, A a) throws IOException; | ||
|
||
B visit(PlantumlPropertyGroup plantumlPropertyGroup, A a) throws IOException; | ||
|
||
B visit(PlantumlProperty plantumlProperty, A a) throws IOException; | ||
|
||
B visit(PlantumlConnection plantumlConnection, A a) throws IOException; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.plantuml.ast; | ||
|
||
public interface PlantumlId { | ||
/** | ||
* PlantUML <language-identifier> | ||
* | ||
* @return the name of the identifier | ||
*/ | ||
String getName(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.plantuml.ast; | ||
|
||
import java.io.IOException; | ||
|
||
public class PlantumlObject implements PlantumlExpr, PlantumlId { | ||
private final String name; | ||
private final PlantumlPropertyGroup[] propertyGroups; | ||
|
||
public PlantumlObject(String name, PlantumlPropertyGroup[] propertyGroups) { | ||
this.name = name; | ||
this.propertyGroups = propertyGroups; | ||
} | ||
|
||
public PlantumlPropertyGroup[] getPropertyGroups() { | ||
return propertyGroups; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public <A, B> B accept(PlantumlExprVisitor<A, B> visitor, A a) throws IOException { | ||
return visitor.visit(this, a); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.plantuml.ast; | ||
|
||
import org.sysml.ast.SysmlExpr; | ||
import org.sysml.ast.SysmlExprVisitor; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Main PlantUML Program Element | ||
* | ||
* This is likely quite wrong. For our use case, we consider a PlantUML program as a collection | ||
* of objects and connections. | ||
*/ | ||
public class PlantumlProgram implements PlantumlExpr { | ||
private PlantumlObject[] objects; | ||
private PlantumlConnection[] connections; | ||
|
||
public PlantumlProgram() { | ||
this.objects = new PlantumlObject[0]; | ||
this.connections = new PlantumlConnection[0]; | ||
} | ||
|
||
public PlantumlProgram(PlantumlObject[] objects, PlantumlConnection[] connections) { | ||
this.objects = objects; | ||
this.connections = connections; | ||
|
||
} | ||
|
||
public PlantumlObject[] getObjects(){ | ||
return objects; | ||
} | ||
|
||
public PlantumlConnection[] getConnections(){ | ||
return connections; | ||
} | ||
|
||
@Override | ||
public <A, B> B accept(PlantumlExprVisitor<A, B> visitor, A a) throws IOException { | ||
return visitor.visit(this, a); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.plantuml.ast; | ||
|
||
import java.io.IOException; | ||
|
||
public class PlantumlProperty implements PlantumlExpr { | ||
private final String prop; | ||
|
||
public PlantumlProperty(String prop) { | ||
this.prop = prop; | ||
} | ||
|
||
public String getProp(){ | ||
return prop; | ||
} | ||
|
||
@Override | ||
public <A, B> B accept(PlantumlExprVisitor<A, B> visitor, A a) throws IOException { | ||
return visitor.visit(this, a); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.plantuml.ast; | ||
|
||
import java.io.IOException; | ||
|
||
public class PlantumlPropertyGroup implements PlantumlId, PlantumlExpr { | ||
|
||
private final String name; | ||
private PlantumlProperty[] properties; | ||
|
||
public PlantumlPropertyGroup(String name, PlantumlProperty[] properties) { | ||
this.properties = properties; | ||
this.name = name; | ||
} | ||
|
||
public PlantumlProperty[] getProperties() { | ||
return this.properties; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public <A, B> B accept(PlantumlExprVisitor<A, B> visitor, A a) throws IOException { | ||
return visitor.visit(this, a); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.