Skip to content

Commit

Permalink
Merge pull request #15 from accordproject/jonathan/extend_vscode_for_map
Browse files Browse the repository at this point in the history
feat(map): extends for Map Type
  • Loading branch information
jonathan-casey authored Sep 6, 2023
2 parents 7318fed + ad7faf7 commit ad48b80
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The extention adds code snippets for the following elements of the Concerto lang
| Transaction | transaction |
| Concept | concept |
| Enum | enum |
| Map | map |
| Scalar | scalar |
| Event | event |
| Namespace | namespace |
Expand Down
5 changes: 5 additions & 0 deletions client/snippets/concerto.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
"body": ["enum ${1:enumName} {", "\to ${2:ITEM}$0", "}"],
"description": "Concerto enumerations define lists of static values"
},
"Map": {
"prefix": "map",
"body": ["map ${1:mapName} {", "\to ${2:ITEM}$0", "}"],
"description": "Concerto maps define a set of key-value pairs"
},
"Namespace": {
"prefix": "namespace",
"body": ["namespace ${1:[email protected]} "],
Expand Down
85 changes: 81 additions & 4 deletions client/syntaxes/concerto.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"concerto-declaration": {
"name": "keyword.control.flow.concerto",
"match": "\\b(asset|transaction|participant|enum|concept|event|scalar)\\b",
"match": "\\b(asset|transaction|participant|enum|map|concept|event|scalar)\\b",
"patterns": []
},
"concerto-abstract-type": {
Expand Down Expand Up @@ -463,6 +463,9 @@
{
"include": "#enum-declaration"
},
{
"include": "#map-declaration"
},
{
"include": "#namespace-declaration"
},
Expand Down Expand Up @@ -504,7 +507,7 @@
"name": "entity.name.type.js"
}
},
"end": "(?=[};]|\\bvar\\b|\\blet\\b|\\bconst\\b|\\btype\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\bnamespace\\b|\\bmodule\\b|\\bimport\\b|\\benum\\b|\\bdeclare\\b|\\bexport\\b|\\babstract\\b|\\basync\\b)",
"end": "(?=[};]|\\bvar\\b|\\blet\\b|\\bconst\\b|\\btype\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\bnamespace\\b|\\bmodule\\b|\\bimport\\b|\\benum\\b|\\bmap\\b|\\bdeclare\\b|\\bexport\\b|\\babstract\\b|\\basync\\b)",
"patterns": [{
"include": "#comment"
},
Expand Down Expand Up @@ -598,6 +601,80 @@
}
]
},
"map-declaration": {
"name": "meta.map.declaration.js",
"begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?(?:\\b(const)\\s+)?\\b(map)\\s+([_$[:alpha:]][_$[:alnum:]]*)",
"beginCaptures": {
"1": {
"name": "keyword.control.export.js"
},
"2": {
"name": "storage.modifier.js"
},
"3": {
"name": "storage.type.map.js"
},
"4": {
"name": "entity.name.type.map.js"
}
},
"end": "(?<=\\})",
"patterns": [{
"include": "#comment"
},
{
"begin": "\\{",
"beginCaptures": {
"0": {
"name": "punctuation.definition.block.js"
}
},
"end": "\\}",
"endCaptures": {
"0": {
"name": "punctuation.definition.block.js"
}
},
"patterns": [{
"include": "#comment"
},
{
"begin": "([_$[:alpha:]][_$[:alnum:]]*)",
"beginCaptures": {
"0": {
"name": "variable.other.maptype.js"
}
},
"end": "(?=,|\\}|$)",
"patterns": [{
"include": "#comment"
},
{
"include": "#variable-initializer"
}
]
},
{
"begin": "(?=(?:(?:\\'[^']*\\')|(?:\\\"[^\"]*\\\")))",
"end": "(?=,|\\}|$)",
"patterns": [{
"include": "#string"
},
{
"include": "#comment"
},
{
"include": "#variable-initializer"
}
]
},
{
"include": "#punctuation-comma"
}
]
}
]
},
"namespace-declaration": {
"name": "meta.namespace.declaration.js",
"begin": "(?<!\\.|\\$)(?:(\\bexport)\\s+)?\\b(namespace|module)\\s+",
Expand Down Expand Up @@ -752,7 +829,7 @@
"name": "keyword.control.default.js"
}
},
"end": "(?=;|\\bexport\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|\\bimport\\b|\\benum\\b|\\bnamespace\\b|\\bmodule\\b|\\btype\\b|\\babstract\\b|\\bdeclare\\b|\\basync\\b|$)",
"end": "(?=;|\\bexport\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|\\bimport\\b|\\benum\\b|\\bmap\\b|\\bnamespace\\b|\\bmodule\\b|\\btype\\b|\\babstract\\b|\\bdeclare\\b|\\basync\\b|$)",
"patterns": [{
"include": "#expression"
}]
Expand All @@ -765,7 +842,7 @@
"name": "keyword.control.export.js"
}
},
"end": "(?=;|\\bexport\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|\\bimport\\b|\\benum\\b|\\bnamespace\\b|\\bmodule\\b|\\btype\\b|\\babstract\\b|\\bdeclare\\b|\\basync\\b|$)",
"end": "(?=;|\\bexport\\b|\\bfunction\\b|\\bclass\\b|\\binterface\\b|\\blet\\b|\\bvar\\b|\\bconst\\b|\\bimport\\b|\\benum\\b|\\bmap\\b|\\bnamespace\\b|\\bmodule\\b|\\btype\\b|\\babstract\\b|\\bdeclare\\b|\\basync\\b|$)",
"patterns": [{
"include": "#import-export-declaration"
}]
Expand Down
6 changes: 6 additions & 0 deletions test-data/hr/hr.cto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ enum State {
o CA
}

map Rolodex {
o String
o String
}

concept Address {
o String street
o String city
Expand All @@ -20,6 +25,7 @@ concept Address {
concept Company {
o String name
o Address headquarters
o Rolodex rolodex
}

enum Department {
Expand Down

0 comments on commit ad48b80

Please sign in to comment.