From 673e7bfcde2f9fe1fb2ccef287df012b2ae2d058 Mon Sep 17 00:00:00 2001 From: tintin Date: Mon, 10 Oct 2022 17:27:05 +0200 Subject: [PATCH] handle supercall and modifier args for semantic decoration (#117) * handle supercall and modifier args for semantic deco * update changelog --- CHANGELOG.md | 1 + package-lock.json | 61 ++++++++++++++++--------------- package.json | 2 +- src/extension.js | 1 + src/features/deco.js | 8 +++- src/features/whatsnew/whatsNew.js | 1 + 6 files changed, 42 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4858542..24e14a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Note: Don't forget to check out `preferences → Settings → Solidity Visual De - clicking on a function name highlights the first line of the function instead of the full function block in the editor - clicking on an external call/modifier highlights the invocation in the editor +- fix: semantic highlighting for supercall and modifier arguments - #112 #117 ## v0.1.3 - new: customize semantic highlighting mode #105 #108 diff --git a/package-lock.json b/package-lock.json index 10618fc..812774a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "dependencies": { "c3-linearization": "^0.3.0", "keccak": "^3.0.2", - "solidity-workspace": "^0.1.6", + "solidity-workspace": "^0.1.7", "surya": "^0.4.6" }, "engines": { @@ -66,13 +66,16 @@ } }, "node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", "dependencies": { "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", + "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" } }, "node_modules/code-point-at": { @@ -540,9 +543,9 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" }, "node_modules/solidity-workspace": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/solidity-workspace/-/solidity-workspace-0.1.6.tgz", - "integrity": "sha512-QEhKVLWhwWzpNTVWzr8rFyuD6S9S1YGFXn50zbYPaUW6kMhBtBQEMN1+E53f8o3Hm9W/L/oyLHE2KlkC6Dy8AA==", + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/solidity-workspace/-/solidity-workspace-0.1.7.tgz", + "integrity": "sha512-m+9cKL6ZBb2gMTFgTg/LiMsqUC7adB6oWcDnSAwEJAiC7BHVijzLU6SOK1eEXqrHuhF/1wymypM7Dvvoo+MyKQ==", "dependencies": { "@solidity-parser/parser": "^0.14.3", "c3-linearization": "^0.3.0", @@ -818,11 +821,11 @@ } }, "node_modules/yargs": { - "version": "17.5.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz", - "integrity": "sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==", + "version": "17.6.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.0.tgz", + "integrity": "sha512-8H/wTDqlSwoSnScvV2N/JHfLWOKuh5MVla9hqLjK3nsfyy6Y4kDSYSvkU5YCUEPOSnRXfIyx3Sq+B/IWudTo4g==", "dependencies": { - "cliui": "^7.0.2", + "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", @@ -835,9 +838,9 @@ } }, "node_modules/yargs-parser": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz", - "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==", + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "engines": { "node": ">=12" } @@ -881,12 +884,12 @@ "integrity": "sha512-FxAv7HpHrXbh3aPo4o2qxHay2lkLY3x5Mw3KeE4KQE8ysVfziWeRZDwcjauvwBSGEC/nXUPzZy8zeh4HokqOnw==" }, "cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", "requires": { "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", + "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" } }, @@ -1226,9 +1229,9 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" }, "solidity-workspace": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/solidity-workspace/-/solidity-workspace-0.1.6.tgz", - "integrity": "sha512-QEhKVLWhwWzpNTVWzr8rFyuD6S9S1YGFXn50zbYPaUW6kMhBtBQEMN1+E53f8o3Hm9W/L/oyLHE2KlkC6Dy8AA==", + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/solidity-workspace/-/solidity-workspace-0.1.7.tgz", + "integrity": "sha512-m+9cKL6ZBb2gMTFgTg/LiMsqUC7adB6oWcDnSAwEJAiC7BHVijzLU6SOK1eEXqrHuhF/1wymypM7Dvvoo+MyKQ==", "requires": { "@solidity-parser/parser": "^0.14.3", "c3-linearization": "^0.3.0", @@ -1448,11 +1451,11 @@ "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==" }, "yargs": { - "version": "17.5.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.5.1.tgz", - "integrity": "sha512-t6YAJcxDkNX7NFYiVtKvWUz8l+PaKTLiL63mJYWR2GnHq2gjEWISzsLp9wg3aY36dY1j+gfIEL3pIF+XlJJfbA==", + "version": "17.6.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.0.tgz", + "integrity": "sha512-8H/wTDqlSwoSnScvV2N/JHfLWOKuh5MVla9hqLjK3nsfyy6Y4kDSYSvkU5YCUEPOSnRXfIyx3Sq+B/IWudTo4g==", "requires": { - "cliui": "^7.0.2", + "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", @@ -1462,9 +1465,9 @@ } }, "yargs-parser": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz", - "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==" + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==" } } } diff --git a/package.json b/package.json index 8c46393..534e548 100644 --- a/package.json +++ b/package.json @@ -541,7 +541,7 @@ "dependencies": { "c3-linearization": "^0.3.0", "keccak": "^3.0.2", - "solidity-workspace": "^0.1.6", + "solidity-workspace": "^0.1.7", "surya": "^0.4.6" } } diff --git a/src/extension.js b/src/extension.js index e705338..51ae9fe 100644 --- a/src/extension.js +++ b/src/extension.js @@ -259,6 +259,7 @@ function analyzeSourceUnit(cancellationToken, document, editor) { // local declaration switch (ident.extra.scope) { case "argument": + case "super": highlightIdentifiers.push(ident); break; case "returns": diff --git a/src/features/deco.js b/src/features/deco.js index 94d6e55..d01d272 100644 --- a/src/features/deco.js +++ b/src/features/deco.js @@ -194,14 +194,18 @@ var gutterIcons = {}; function varDecIsArray(node) { - return node.typeName.type == "ArrayTypeName"; + return node && node.typeName && node.typeName.type == "ArrayTypeName"; } function varDecIsUserDefined(node) { - return node.typeName.type == "UserDefinedTypeName"; + return node && node.typeName && node.typeName.type == "UserDefinedTypeName"; } function getVariableDeclarationType(node) { + if(!node){ + return null; + } + if (typeof node.typeName != "undefined" && node.typeName != null) { if (varDecIsArray(node)) { node = node.typeName.baseTypeName; diff --git a/src/features/whatsnew/whatsNew.js b/src/features/whatsnew/whatsNew.js index d3fb004..30ab039 100644 --- a/src/features/whatsnew/whatsNew.js +++ b/src/features/whatsnew/whatsNew.js @@ -49,6 +49,7 @@ The complete changelog can be found [here](https://github.com/ConsenSys/vscode-s - clicking on a function name highlights the first line of the function instead of the full function block in the editor - clicking on an external call/modifier highlights the invocation in the editor +- fix: semantic highlighting for supercall and modifier arguments - #112 #117 ## v0.1.3 - 🧸