Skip to content

Commit 142ca02

Browse files
authored
feat(natspec): support for @Custom and updates to grammar (#7)
1 parent cb5af4c commit 142ca02

9 files changed

+152
-99
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ node_modules
77
*.tgz
88
*.zip
99
*.tar
10-
dist/
1110
build/
1211
cache
1312
.cache/
1413
*.log
1514
*-error.
1615
solidity-lang-*.zip
17-
16+
*.vsix
17+
!dist/*.vsix

.vscode/extensions.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"recommendations": [
3-
"leodevbro.blockman"
4-
]
2+
"recommendations": ["leodevbro.blockman"]
53
}

.vscodeignore

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
.vscode/**
2-
.vscode-test/**
1+
.github/**
32
.gitignore
4-
vsc-extension-quickstart.md
3+
.prettierignore
4+
.vscode-test/**
5+
.vscode/**
6+
.yarnrc
7+
**/.eslintrc.json
8+
**/*.map
9+
**/*.ts
10+
**/test/*
11+
**/tsconfig.json
12+
node_modules
13+

CHANGELOG.md

Lines changed: 0 additions & 51 deletions
This file was deleted.

LICENSE.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
SPDX-License-Identifier: BSD 3-Clause License
2+
SPDX-FileCopyrightText: Copyright (c) 2021, Sam Bacha, <@sambacha> All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
3. Neither the name of the copyright holder nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
29+
30+
CopyrightNotice
31+
SPDX-License-Identifier: CC-BY-4.0
32+
SPDX-FileCopyrightText: © 2020 The Solidity Language Authors
33+
34+
The Solidity logo is distributed and licensed under a Creative Commons Attribution 4.0 International License.
35+
<https://docs.soliditylang.org/en/latest/brand-guide.html#solidity-logo-license>
36+
<https://creativecommons.org/licenses/by/4.0/legalcode>
37+
38+

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@
1111

1212
<span align="center">
1313

14-
15-
[![vscode marketplace](https://badgen.net/vs-marketplace/v/contractshark.solidity-lang)](https://marketplace.visualstudio.com/items?itemName=ContractShark.solidity-lang) ![Open VSX Version](https://img.shields.io/open-vsx/v/contractshark/solidity-lang?logo=eclipse) [![solidity - <0.9.0](https://img.shields.io/badge/solidity-v0.9.0-2ea44f?logo=solidity)](https://github.com/manifoldfinance)
14+
[![vscode marketplace](https://badgen.net/vs-marketplace/v/contractshark.solidity-lang)](https://marketplace.visualstudio.com/items?itemName=ContractShark.solidity-lang)
15+
![Open VSX Version](https://img.shields.io/open-vsx/v/contractshark/solidity-lang?logo=eclipse)
16+
[![solidity - <0.9.0](https://img.shields.io/badge/solidity-v0.9.0-2ea44f?logo=solidity)](https://github.com/manifoldfinance)
1617

1718
</span>
1819

19-
2020
## Motivation
2121

22-
Every Solidity extension on Visual Studio Code's Marketplace contain multiple plugins. This can
23-
lead to an inconsistent developer environment, or worse create conflicting configurations that,
24-
under the pretense of `helping` you, do things in the background to your files without your explicit
22+
Every Solidity extension on Visual Studio Code's Marketplace contain multiple plugins. This can lead
23+
to an inconsistent developer environment, or worse create conflicting configurations that, under the
24+
pretense of `helping` you, do things in the background to your files without your explicit
2525
knowledge.
2626

27-
Hence why this extension exists: only to provide syntax highlighting so that you can decided what
28-
to add without having to give up basic functionality.
27+
Hence why this extension exists: only to provide syntax highlighting so that you can decided what to
28+
add without having to give up basic functionality.
2929

3030
## Features
3131

@@ -47,7 +47,6 @@ to add without having to give up basic functionality.
4747

4848
- [Eclipse Open VSX Registry Marketplace](https://open-vsx.org/extension/contractshark/solidity-lang)
4949

50-
5150
## Extension Settings
5251

5352
This extension contributes the following settings:

dist/LICENSE.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
SPDX-License-Identifier: BSD 3-Clause License
2+
SPDX-FileCopyrightText: Copyright (c) 2021, Sam Bacha, <@sambacha> All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
3. Neither the name of the copyright holder nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
29+
30+
CopyrightNotice
31+
SPDX-License-Identifier: CC-BY-4.0
32+
SPDX-FileCopyrightText: © 2020 The Solidity Language Authors
33+
34+
The Solidity logo is distributed and licensed under a Creative Commons Attribution 4.0 International License.
35+
<https://docs.soliditylang.org/en/latest/brand-guide.html#solidity-logo-license>
36+
<https://creativecommons.org/licenses/by/4.0/legalcode>
37+
38+

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"publisher": "ContractShark",
66
"icon": "assets/icon.png",
77
"license": "MIT",
8-
"version": "1.3.0",
8+
"version": "1.4.0",
99
"engines": {
10-
"vscode": "^1.55.0"
10+
"vscode": "^1.65.0"
1111
},
1212
"keywords": [
1313
"solidity",
@@ -28,7 +28,7 @@
2828
],
2929
"scripts": {
3030
"ci": "npm i -g vsce && npm run build",
31-
"build": "npx vsce package",
31+
"build": "npx vsce package -o dist/",
3232
"test": "npx ajv-cli test -s tests/tmLanguage.schema.json -d syntaxes/solidity.tmLanguage.json --valid"
3333
},
3434
"bugs": {

syntaxes/solidity.tmLanguage.json

Lines changed: 50 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"fileTypes": [
33
"sol"
44
],
5-
"name": "solidity",
6-
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
5+
"name": "Solidity",
6+
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
77
"patterns": [
88
{
99
"include": "#natspec"
@@ -92,6 +92,9 @@
9292
},
9393
{
9494
"include": "#natspec-tag-return"
95+
},
96+
{
97+
"include": "#natspec-tag-custom"
9598
}
9699
]
97100
},
@@ -111,6 +114,10 @@
111114
"match": "(@dev)\\b",
112115
"name": "storage.type.dev.natspec"
113116
},
117+
"natspec-tag-custom": {
118+
"match": "(@custom:)\\b",
119+
"name": "storage.type.custom.natspec"
120+
},
114121
"natspec-tag-param": {
115122
"match": "(@param)(\\s+([A-Za-z_]\\w*))?\\b",
116123
"captures": {
@@ -123,8 +130,15 @@
123130
}
124131
},
125132
"natspec-tag-return": {
126-
"match": "(@return)\\b",
127-
"name": "storage.type.return.natspec"
133+
"match": "(@return)(\\s+([A-Za-z_]\\w*))?\\b",
134+
"captures": {
135+
"1": {
136+
"name": "storage.type.return.natspec"
137+
},
138+
"3": {
139+
"name": "variable.other.natspec"
140+
}
141+
}
128142
},
129143
"comment": {
130144
"patterns": [
@@ -358,7 +372,7 @@
358372
"name": "constant.language.time"
359373
},
360374
"constant-currency": {
361-
"match": "\\b(ether|wei|finney|szabo)\\b",
375+
"match": "\\b(ether|wei|gwei|nanoeth|finney|szabo)\\b",
362376
"name": "constant.language.currency"
363377
},
364378
"number": {
@@ -655,17 +669,6 @@
655669
},
656670
"declaration-contract": {
657671
"patterns": [
658-
{
659-
"match": "\\b(contract)\\b\\s+(\\w+)\\b\\s*(?=\\{)",
660-
"captures": {
661-
"1": {
662-
"name": "storage.type.contract"
663-
},
664-
"2": {
665-
"name": "entity.name.type.contract"
666-
}
667-
}
668-
},
669672
{
670673
"begin": "\\b(contract)\\b\\s+(\\w+)\\b\\s+\\b(is)\\b\\s+",
671674
"end": "(?=\\{)",
@@ -686,22 +689,23 @@
686689
"name": "entity.name.type.contract.extend"
687690
}
688691
]
689-
}
690-
]
691-
},
692-
"declaration-interface": {
693-
"patterns": [
692+
},
694693
{
695-
"match": "\\b(interface)\\b\\s+(\\w+)\\b\\s*(?=\\{)",
694+
"match": "\\b(contract)(\\s+([A-Za-z_]\\w*))?\\b",
696695
"captures": {
697696
"1": {
698-
"name": "storage.type.interface"
697+
"name": "storage.type.contract"
699698
},
700699
"2": {
701-
"name": "entity.name.type.interface"
700+
"name": "entity.name.type.contract"
702701
}
703702
}
704-
},
703+
}
704+
705+
]
706+
},
707+
"declaration-interface": {
708+
"patterns": [
705709
{
706710
"begin": "\\b(interface)\\b\\s+(\\w+)\\b\\s+\\b(is)\\b\\s+",
707711
"end": "(?=\\{)",
@@ -722,7 +726,19 @@
722726
"name": "entity.name.type.interface.extend"
723727
}
724728
]
729+
},
730+
{
731+
"match": "\\b(interface)(\\s+([A-Za-z_]\\w*))?\\b",
732+
"captures": {
733+
"1": {
734+
"name": "storage.type.interface"
735+
},
736+
"2": {
737+
"name": "entity.name.type.interface"
738+
}
739+
}
725740
}
741+
726742
]
727743
},
728744
"declaration-library": {
@@ -975,6 +991,9 @@
975991
},
976992
{
977993
"include": "#modifier-call"
994+
},
995+
{
996+
"include": "#punctuation"
978997
}
979998
]
980999
},
@@ -1096,10 +1115,13 @@
10961115
}
10971116
},
10981117
"function-call": {
1099-
"match": "\\b([A-Za-z_]\\w*)\\s*\\(",
1118+
"match": "\\b([A-Za-z_]\\w*)\\s*(\\()",
11001119
"captures": {
11011120
"1": {
11021121
"name": "entity.name.function"
1122+
},
1123+
"2": {
1124+
"name": "punctuation.parameters.begin"
11031125
}
11041126
}
11051127
},
@@ -1157,5 +1179,5 @@
11571179
}
11581180
},
11591181
"scopeName": "source.solidity",
1160-
"uuid": "25f5cd46-fd8e-4a88-986a-239ae90c9877"
1161-
}
1182+
"uuid": "18e064f3-32b1-44de-ac9e-10f0607d7b84"
1183+
}

0 commit comments

Comments
 (0)