Skip to content

Commit

Permalink
feat(natspec): support for @Custom and updates to grammar (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
sambacha authored Mar 20, 2022
1 parent cb5af4c commit 142ca02
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 99 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ node_modules
*.tgz
*.zip
*.tar
dist/
build/
cache
.cache/
*.log
*-error.
solidity-lang-*.zip

*.vsix
!dist/*.vsix
4 changes: 1 addition & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"recommendations": [
"leodevbro.blockman"
]
"recommendations": ["leodevbro.blockman"]
}
15 changes: 12 additions & 3 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
.vscode/**
.vscode-test/**
.github/**
.gitignore
vsc-extension-quickstart.md
.prettierignore
.vscode-test/**
.vscode/**
.yarnrc
**/.eslintrc.json
**/*.map
**/*.ts
**/test/*
**/tsconfig.json
node_modules

51 changes: 0 additions & 51 deletions CHANGELOG.md

This file was deleted.

38 changes: 38 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
SPDX-License-Identifier: BSD 3-Clause License
SPDX-FileCopyrightText: Copyright (c) 2021, Sam Bacha, <@sambacha> All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


CopyrightNotice
SPDX-License-Identifier: CC-BY-4.0
SPDX-FileCopyrightText: © 2020 The Solidity Language Authors

The Solidity logo is distributed and licensed under a Creative Commons Attribution 4.0 International License.
<https://docs.soliditylang.org/en/latest/brand-guide.html#solidity-logo-license>
<https://creativecommons.org/licenses/by/4.0/legalcode>


17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@

<span align="center">


[![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)
[![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)

</span>


## Motivation

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

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

## Features

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

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

## Extension Settings

This extension contributes the following settings:
Expand Down
38 changes: 38 additions & 0 deletions dist/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
SPDX-License-Identifier: BSD 3-Clause License
SPDX-FileCopyrightText: Copyright (c) 2021, Sam Bacha, <@sambacha> All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


CopyrightNotice
SPDX-License-Identifier: CC-BY-4.0
SPDX-FileCopyrightText: © 2020 The Solidity Language Authors

The Solidity logo is distributed and licensed under a Creative Commons Attribution 4.0 International License.
<https://docs.soliditylang.org/en/latest/brand-guide.html#solidity-logo-license>
<https://creativecommons.org/licenses/by/4.0/legalcode>


6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"publisher": "ContractShark",
"icon": "assets/icon.png",
"license": "MIT",
"version": "1.3.0",
"version": "1.4.0",
"engines": {
"vscode": "^1.55.0"
"vscode": "^1.65.0"
},
"keywords": [
"solidity",
Expand All @@ -28,7 +28,7 @@
],
"scripts": {
"ci": "npm i -g vsce && npm run build",
"build": "npx vsce package",
"build": "npx vsce package -o dist/",
"test": "npx ajv-cli test -s tests/tmLanguage.schema.json -d syntaxes/solidity.tmLanguage.json --valid"
},
"bugs": {
Expand Down
78 changes: 50 additions & 28 deletions syntaxes/solidity.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"fileTypes": [
"sol"
],
"name": "solidity",
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Solidity",
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"patterns": [
{
"include": "#natspec"
Expand Down Expand Up @@ -92,6 +92,9 @@
},
{
"include": "#natspec-tag-return"
},
{
"include": "#natspec-tag-custom"
}
]
},
Expand All @@ -111,6 +114,10 @@
"match": "(@dev)\\b",
"name": "storage.type.dev.natspec"
},
"natspec-tag-custom": {
"match": "(@custom:)\\b",
"name": "storage.type.custom.natspec"
},
"natspec-tag-param": {
"match": "(@param)(\\s+([A-Za-z_]\\w*))?\\b",
"captures": {
Expand All @@ -123,8 +130,15 @@
}
},
"natspec-tag-return": {
"match": "(@return)\\b",
"name": "storage.type.return.natspec"
"match": "(@return)(\\s+([A-Za-z_]\\w*))?\\b",
"captures": {
"1": {
"name": "storage.type.return.natspec"
},
"3": {
"name": "variable.other.natspec"
}
}
},
"comment": {
"patterns": [
Expand Down Expand Up @@ -358,7 +372,7 @@
"name": "constant.language.time"
},
"constant-currency": {
"match": "\\b(ether|wei|finney|szabo)\\b",
"match": "\\b(ether|wei|gwei|nanoeth|finney|szabo)\\b",
"name": "constant.language.currency"
},
"number": {
Expand Down Expand Up @@ -655,17 +669,6 @@
},
"declaration-contract": {
"patterns": [
{
"match": "\\b(contract)\\b\\s+(\\w+)\\b\\s*(?=\\{)",
"captures": {
"1": {
"name": "storage.type.contract"
},
"2": {
"name": "entity.name.type.contract"
}
}
},
{
"begin": "\\b(contract)\\b\\s+(\\w+)\\b\\s+\\b(is)\\b\\s+",
"end": "(?=\\{)",
Expand All @@ -686,22 +689,23 @@
"name": "entity.name.type.contract.extend"
}
]
}
]
},
"declaration-interface": {
"patterns": [
},
{
"match": "\\b(interface)\\b\\s+(\\w+)\\b\\s*(?=\\{)",
"match": "\\b(contract)(\\s+([A-Za-z_]\\w*))?\\b",
"captures": {
"1": {
"name": "storage.type.interface"
"name": "storage.type.contract"
},
"2": {
"name": "entity.name.type.interface"
"name": "entity.name.type.contract"
}
}
},
}

]
},
"declaration-interface": {
"patterns": [
{
"begin": "\\b(interface)\\b\\s+(\\w+)\\b\\s+\\b(is)\\b\\s+",
"end": "(?=\\{)",
Expand All @@ -722,7 +726,19 @@
"name": "entity.name.type.interface.extend"
}
]
},
{
"match": "\\b(interface)(\\s+([A-Za-z_]\\w*))?\\b",
"captures": {
"1": {
"name": "storage.type.interface"
},
"2": {
"name": "entity.name.type.interface"
}
}
}

]
},
"declaration-library": {
Expand Down Expand Up @@ -975,6 +991,9 @@
},
{
"include": "#modifier-call"
},
{
"include": "#punctuation"
}
]
},
Expand Down Expand Up @@ -1096,10 +1115,13 @@
}
},
"function-call": {
"match": "\\b([A-Za-z_]\\w*)\\s*\\(",
"match": "\\b([A-Za-z_]\\w*)\\s*(\\()",
"captures": {
"1": {
"name": "entity.name.function"
},
"2": {
"name": "punctuation.parameters.begin"
}
}
},
Expand Down Expand Up @@ -1157,5 +1179,5 @@
}
},
"scopeName": "source.solidity",
"uuid": "25f5cd46-fd8e-4a88-986a-239ae90c9877"
}
"uuid": "18e064f3-32b1-44de-ac9e-10f0607d7b84"
}

0 comments on commit 142ca02

Please sign in to comment.