-
-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
structurizr-dsl: Adds support for
url
, properties
, and `perspecti…
…ves` nested inside `!elements` and `!relationships`.
- Loading branch information
1 parent
b412261
commit b507b5d
Showing
14 changed files
with
219 additions
and
117 deletions.
There are no files selected for viewing
This file contains 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 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 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
22 changes: 0 additions & 22 deletions
22
structurizr-dsl/src/main/java/com/structurizr/dsl/ModelItemPerspectivesDslContext.java
This file was deleted.
Oops, something went wrong.
This file contains 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
35 changes: 35 additions & 0 deletions
35
structurizr-dsl/src/main/java/com/structurizr/dsl/PerspectiveParser.java
This file contains 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,35 @@ | ||
package com.structurizr.dsl; | ||
|
||
import com.structurizr.model.ModelItem; | ||
|
||
final class PerspectiveParser extends AbstractParser { | ||
|
||
private final static int PERSPECTIVE_NAME_INDEX = 0; | ||
private final static int PERSPECTIVE_DESCRIPTION_INDEX = 1; | ||
private final static int PERSPECTIVE_VALUE_INDEX = 2; | ||
|
||
void parse(PerspectivesDslContext context, Tokens tokens) { | ||
// <name> <description> [value] | ||
|
||
if (tokens.hasMoreThan(PERSPECTIVE_VALUE_INDEX)) { | ||
throw new RuntimeException("Too many tokens, expected: <name> <description> [value]"); | ||
} | ||
|
||
if (!tokens.includes(PERSPECTIVE_DESCRIPTION_INDEX)) { | ||
throw new RuntimeException("Expected: <name> <description> [value]"); | ||
} | ||
|
||
String name = tokens.get(PERSPECTIVE_NAME_INDEX); | ||
String description = tokens.get(PERSPECTIVE_DESCRIPTION_INDEX); | ||
String value = ""; | ||
|
||
if (tokens.includes(PERSPECTIVE_VALUE_INDEX)) { | ||
value = tokens.get(PERSPECTIVE_VALUE_INDEX); | ||
} | ||
|
||
for (ModelItem modelItem : context.getModelItems()) { | ||
modelItem.addPerspective(name, description, value); | ||
} | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
structurizr-dsl/src/main/java/com/structurizr/dsl/PerspectivesDslContext.java
This file contains 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,29 @@ | ||
package com.structurizr.dsl; | ||
|
||
import com.structurizr.model.ModelItem; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
final class PerspectivesDslContext extends DslContext { | ||
|
||
private final Collection<ModelItem> modelItems = new ArrayList<>(); | ||
|
||
PerspectivesDslContext(ModelItem modelItem) { | ||
this.modelItems.add(modelItem); | ||
} | ||
|
||
PerspectivesDslContext(Collection<ModelItem> modelItems) { | ||
this.modelItems.addAll(modelItems); | ||
} | ||
|
||
Collection<ModelItem> getModelItems() { | ||
return this.modelItems; | ||
} | ||
|
||
@Override | ||
protected String[] getPermittedTokens() { | ||
return new String[0]; | ||
} | ||
|
||
} |
This file contains 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 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 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 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 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
Oops, something went wrong.