diff --git a/package-lock.json b/package-lock.json index b88118f8e..41823826c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,29 +9,29 @@ "version": "1.4.2", "license": "MIT", "dependencies": { - "@solidity-parser/parser": "^0.19.0", - "semver": "^7.6.3" + "@solidity-parser/parser": "^0.20.1", + "semver": "^7.7.1" }, "devDependencies": { "@babel/code-frame": "^7.26.2", "c8": "^10.1.3", "cross-env": "^7.0.3", - "eslint": "^8.47.0", + "eslint": "^8.57.1", "eslint-config-airbnb-base": "^15.0.0", - "eslint-config-prettier": "^10.0.1", + "eslint-config-prettier": "^10.1.2", "eslint-plugin-import": "^2.31.0", "esm-utils": "^4.3.0", - "esmock": "^2.6.9", + "esmock": "^2.7.0", "jest": "^29.7.0", - "jest-light-runner": "^0.7.0", - "jest-snapshot-serializer-ansi": "^2.1.0", + "jest-light-runner": "^0.7.8", + "jest-snapshot-serializer-ansi": "^2.2.1", "jest-snapshot-serializer-raw": "^2.0.0", "jest-watch-typeahead": "^2.2.2", "lines-and-columns": "^2.0.4", - "prettier": "^3.3.3", + "prettier": "^3.5.3", "proxyquire": "^2.1.3", - "solc": "^0.8.28", - "webpack": "^5.97.1", + "solc": "^0.8.29", + "webpack": "^5.99.6", "webpack-cli": "^6.0.1" }, "engines": { @@ -274,10 +274,11 @@ } }, "node_modules/@babel/helper-string-parser": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz", - "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.9.0" } @@ -301,24 +302,28 @@ } }, "node_modules/@babel/helpers": { - "version": "7.22.6", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.22.6.tgz", - "integrity": "sha512-YjDs6y/fVOYFV8hAf1rxd1QvR9wJe1pDBZ2AREKq/SDayfPzgk0PBnVuTCE5X1acEpMMNOVUqoe+OwiZGJ+OaA==", + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.27.0.tgz", + "integrity": "sha512-U5eyP/CTFPuNE3qk+WZMxFkp/4zUzdceQlfzf7DdGdhp+Fezd7HD+i8Y24ZuTMKX3wQBld449jijbGq6OdGNQg==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/template": "^7.22.5", - "@babel/traverse": "^7.22.6", - "@babel/types": "^7.22.5" + "@babel/template": "^7.27.0", + "@babel/types": "^7.27.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", - "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.27.0.tgz", + "integrity": "sha512-iaepho73/2Pz7w2eMS0Q5f83+0RKI7i4xmiYeBmDzfRVbQtTOG7Ts0S4HzJVsTMGI9keU8rNfuZr8DKfSt7Yyg==", "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.27.0" + }, "bin": { "parser": "bin/babel-parser.js" }, @@ -504,14 +509,15 @@ } }, "node_modules/@babel/template": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", - "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.0.tgz", + "integrity": "sha512-2ncevenBqXI6qRMukPlXwHKHchC7RyMuu4xv5JBXRfOGVcTy1mXCD12qrp7Jsoxll1EV3+9sE4GugBVRjT2jFA==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/code-frame": "^7.22.13", - "@babel/parser": "^7.22.15", - "@babel/types": "^7.22.15" + "@babel/code-frame": "^7.26.2", + "@babel/parser": "^7.27.0", + "@babel/types": "^7.27.0" }, "engines": { "node": ">=6.9.0" @@ -548,14 +554,14 @@ } }, "node_modules/@babel/types": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", - "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.0.tgz", + "integrity": "sha512-H45s8fVLYjbhFH62dIJ3WtmJ6RSPt/3DRO0ZcT2SUiYiQyz3BLVb9ADEnLl91m74aQPS3AzzeajZHYOalWe3bg==", "dev": true, + "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.20", - "to-fast-properties": "^2.0.0" + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" }, "engines": { "node": ">=6.9.0" @@ -624,21 +630,24 @@ } }, "node_modules/@eslint/js": { - "version": "8.57.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", - "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", + "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", "dev": true, + "license": "MIT", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.14", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", - "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", + "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", + "deprecated": "Use @eslint/config-array instead", "dev": true, + "license": "Apache-2.0", "dependencies": { - "@humanwhocodes/object-schema": "^2.0.2", + "@humanwhocodes/object-schema": "^2.0.3", "debug": "^4.3.1", "minimatch": "^3.0.5" }, @@ -660,10 +669,12 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", - "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", - "dev": true + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "deprecated": "Use @eslint/object-schema instead", + "dev": true, + "license": "BSD-3-Clause" }, "node_modules/@isaacs/cliui": { "version": "8.0.2", @@ -1324,9 +1335,9 @@ } }, "node_modules/@solidity-parser/parser": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.19.0.tgz", - "integrity": "sha512-RV16k/qIxW/wWc+mLzV3ARyKUaMUTBy9tOLMzFhtNSKYeTAanQ3a5MudJKf/8arIFnA2L27SNjarQKmFg0w/jA==", + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.20.1.tgz", + "integrity": "sha512-58I2sRpzaQUN+jJmWbHfbWf9AKfzqCI8JAdFB0vbyY+u8tBRcuTt9LxzasvR0LGQpcRv97eyV7l61FQ3Ib7zVw==", "license": "MIT" }, "node_modules/@types/babel__core": { @@ -3087,16 +3098,18 @@ } }, "node_modules/eslint": { - "version": "8.57.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", - "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", + "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", + "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", "@eslint/eslintrc": "^2.1.4", - "@eslint/js": "8.57.0", - "@humanwhocodes/config-array": "^0.11.14", + "@eslint/js": "8.57.1", + "@humanwhocodes/config-array": "^0.13.0", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "@ungap/structured-clone": "^1.2.0", @@ -7783,15 +7796,6 @@ "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", "dev": true }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", diff --git a/package.json b/package.json index 68b856757..0c8b938fa 100644 --- a/package.json +++ b/package.json @@ -90,27 +90,27 @@ "@babel/code-frame": "^7.26.2", "c8": "^10.1.3", "cross-env": "^7.0.3", - "eslint": "^8.47.0", + "eslint": "^8.57.1", "eslint-config-airbnb-base": "^15.0.0", - "eslint-config-prettier": "^10.0.1", + "eslint-config-prettier": "^10.1.2", "eslint-plugin-import": "^2.31.0", "esm-utils": "^4.3.0", - "esmock": "^2.6.9", + "esmock": "^2.7.0", "jest": "^29.7.0", - "jest-light-runner": "^0.7.0", - "jest-snapshot-serializer-ansi": "^2.1.0", + "jest-light-runner": "^0.7.8", + "jest-snapshot-serializer-ansi": "^2.2.1", "jest-snapshot-serializer-raw": "^2.0.0", "jest-watch-typeahead": "^2.2.2", "lines-and-columns": "^2.0.4", - "prettier": "^3.3.3", + "prettier": "^3.5.3", "proxyquire": "^2.1.3", - "solc": "^0.8.28", - "webpack": "^5.97.1", + "solc": "^0.8.29", + "webpack": "^5.99.6", "webpack-cli": "^6.0.1" }, "dependencies": { - "@solidity-parser/parser": "^0.19.0", - "semver": "^7.6.3" + "@solidity-parser/parser": "^0.20.1", + "semver": "^7.7.1" }, "peerDependencies": { "prettier": ">=2.3.0" diff --git a/src/comments/handlers/handleContractDefinitionComments.js b/src/comments/handlers/handleContractDefinitionComments.js index 67d5638b9..2a6961692 100644 --- a/src/comments/handlers/handleContractDefinitionComments.js +++ b/src/comments/handlers/handleContractDefinitionComments.js @@ -27,10 +27,19 @@ function handleContractDefinitionComments({ ); // The comment is behind the start of the Block `{}` or behind a base contract - if (followingNode?.type === 'InheritanceSpecifier' || nextCharacter === '{') { + if ( + (followingNode && + (followingNode.type === 'InheritanceSpecifier' || + followingNode === enclosingNode.storageLayout)) || + nextCharacter === '{' + ) { // In this scenario the comment belongs to a base contract. // contract A is B, /* comment for B */ C /* comment for C */ {} - if (precedingNode?.type === 'InheritanceSpecifier') { + if ( + precedingNode && + (precedingNode.type === 'InheritanceSpecifier' || + precedingNode === enclosingNode.storageLayout) + ) { addTrailingComment(precedingNode, comment); return true; } diff --git a/src/nodes/ContractDefinition.js b/src/nodes/ContractDefinition.js index 43e784dda..5eebf5eb3 100644 --- a/src/nodes/ContractDefinition.js +++ b/src/nodes/ContractDefinition.js @@ -6,17 +6,37 @@ import { printSeparatedList } from '../common/printer-helpers.js'; -const { group, line, hardline } = doc.builders; +const { group, hardline, ifBreak, line, softline } = doc.builders; -const inheritance = (node, path, print) => - node.baseContracts.length > 0 - ? [ - ' is', - printSeparatedList(path.map(print, 'baseContracts'), { - firstSeparator: line - }) - ] - : line; +const specifiers = (node, path, print) => { + const document = []; + if (node.baseContracts.length > 0) { + document.push([ + 'is', + printSeparatedList(path.map(print, 'baseContracts'), { + firstSeparator: line + }) + ]); + } + if (node.storageLayout) { + document.push([ + 'layout at', + printSeparatedItem(path.call(print, 'storageLayout'), { + firstSeparator: line + }) + ]); + } + if (document.length === 0) return line; + if (document.length === 1) return [' ', document]; + const groupId = Symbol('ContractSpecifiers.inheritance'); + return printSeparatedList( + [group(document[0], { id: groupId }), document[1]], + { + firstSeparator: line, + separator: ifBreak('', softline, { groupId }) + } + ); +}; const body = (node, path, options, print) => { const comments = printComments(node, path, options); @@ -34,7 +54,7 @@ export const ContractDefinition = { node.kind === 'abstract' ? 'abstract contract' : node.kind, ' ', node.name, - inheritance(node, path, print), + specifiers(node, path, print), '{' ]), body(node, path, options, print), diff --git a/tests/format/Comments/Comments.sol b/tests/format/Comments/Comments.sol index 9cc06b612..cc4c31717 100644 --- a/tests/format/Comments/Comments.sol +++ b/tests/format/Comments/Comments.sol @@ -38,6 +38,18 @@ contract Comments4 is Interface1, Interface2, Interface3, Interface4, Interface5 // solhint-disable-previous-line no-empty-blocks } +contract Comments4a is Interface1, Interface2, Interface3, Interface4, Interface5, Interface6 /*why we used Interface6*/ layout /*where should this go?*/at 123/*why we used this layout*/ { + // solhint-disable-previous-line no-empty-blocks +} + +contract Comments4b is Interface1, Interface2, Interface3, Interface4, Interface5, Interface6 /*why we used Interface6*/ layout /*where should this go?*/at 123 + 456/*why we used this layout*/ { + // solhint-disable-previous-line no-empty-blocks +} + +contract Comments4c is Interface1, Interface2, Interface3, Interface4, Interface5, Interface6 /*why we used Interface6*/ layout /*where should this go?*/at f(123 + 456)/*why we used this layout*/ { + // solhint-disable-previous-line no-empty-blocks +} + contract Comments5 /*nice name*/ { // solhint-disable-previous-line no-empty-blocks } diff --git a/tests/format/Comments/__snapshots__/jsfmt.spec.js.snap b/tests/format/Comments/__snapshots__/jsfmt.spec.js.snap index 097b2df9e..c598b891b 100644 --- a/tests/format/Comments/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/Comments/__snapshots__/jsfmt.spec.js.snap @@ -47,6 +47,18 @@ contract Comments4 is Interface1, Interface2, Interface3, Interface4, Interface5 // solhint-disable-previous-line no-empty-blocks } +contract Comments4a is Interface1, Interface2, Interface3, Interface4, Interface5, Interface6 /*why we used Interface6*/ layout /*where should this go?*/at 123/*why we used this layout*/ { + // solhint-disable-previous-line no-empty-blocks +} + +contract Comments4b is Interface1, Interface2, Interface3, Interface4, Interface5, Interface6 /*why we used Interface6*/ layout /*where should this go?*/at 123 + 456/*why we used this layout*/ { + // solhint-disable-previous-line no-empty-blocks +} + +contract Comments4c is Interface1, Interface2, Interface3, Interface4, Interface5, Interface6 /*why we used Interface6*/ layout /*where should this go?*/at f(123 + 456)/*why we used this layout*/ { + // solhint-disable-previous-line no-empty-blocks +} + contract Comments5 /*nice name*/ { // solhint-disable-previous-line no-empty-blocks } @@ -223,6 +235,45 @@ contract Comments4 is // solhint-disable-previous-line no-empty-blocks } +contract Comments4a + is + Interface1, + Interface2, + Interface3, + Interface4, + Interface5, + Interface6 /*why we used Interface6*/ /*where should this go?*/ + layout at 123 /*why we used this layout*/ +{ + // solhint-disable-previous-line no-empty-blocks +} + +contract Comments4b + is + Interface1, + Interface2, + Interface3, + Interface4, + Interface5, + Interface6 /*why we used Interface6*/ /*where should this go?*/ + layout at 123 + 456 /*why we used this layout*/ +{ + // solhint-disable-previous-line no-empty-blocks +} + +contract Comments4c + is + Interface1, + Interface2, + Interface3, + Interface4, + Interface5, + Interface6 /*why we used Interface6*/ /*where should this go?*/ + layout at f(123 + 456) /*why we used this layout*/ +{ + // solhint-disable-previous-line no-empty-blocks +} + /*nice name*/ contract Comments5 { // solhint-disable-previous-line no-empty-blocks } diff --git a/tests/format/ContractDefinitions/ContractDefinitions.sol b/tests/format/ContractDefinitions/ContractDefinitions.sol index 654354426..5c8ddb4ae 100644 --- a/tests/format/ContractDefinitions/ContractDefinitions.sol +++ b/tests/format/ContractDefinitions/ContractDefinitions.sol @@ -1,2 +1,48 @@ contract ContractDefinition is Contract1, Contract2, Contract3, Contract4, Contract5 { } + +contract StorageLayoutSpecifier layout at 123 { +} + +contract StorageLayoutSpecifier1 layout at 1234567890 * 1234567890 - 1234567890 / 1234567890 { +} + +contract StorageLayoutSpecifier2 layout at veryVeryLongFunction(12345678901234567890 * 12345678901234567890 - 12345678901234567890 / 12345678901234567890 + 12345678901234567890 - 12345678901234567890) { +} + +contract StorageLayoutSpecifier3 is Contract1 layout at 123 { +} + +contract StorageLayoutSpecifier4 is Contract1, Contract2, Contract3, Contract4, Contract5 layout at 123{ +} + +contract StorageLayoutSpecifier5 is Contract1, Contract2, Contract3, Contract4, Contract5 layout at 1234567890 * 1234567890 - 1234567890 / 1234567890{ +} + +contract StorageLayoutSpecifier6 is Contract1, Contract2, Contract3, Contract4, Contract5 layout at veryVeryLongFunction(12345678901234567890 * 12345678901234567890 - 12345678901234567890 / 12345678901234567890 + 12345678901234567890 - 12345678901234567890){ +} + +contract StorageLayoutSpecifier7 is Contract1, Contract2, Contract3, Contract4, Contract5, Contract6, Contract7 layout at 123{ +} + +contract StorageLayoutSpecifier8 is Contract1, Contract2, Contract3, Contract4, Contract5, Contract6, Contract7 layout at 1234567890 * 1234567890 - 1234567890 / 1234567890{ +} + +contract StorageLayoutSpecifier9 is Contract1, Contract2, Contract3, Contract4, Contract5, Contract6, Contract7 layout at veryVeryLongFunction(12345678901234567890 * 12345678901234567890 - 12345678901234567890 / 12345678901234567890 + 12345678901234567890 - 12345678901234567890){ +} + +contract InheritanceSpecifier1 is SomeOtherContract(1234,false) {} + +contract InheritanceSpecifier2 is SomeOtherContract(1234,false) layout at 123 {} + +contract InheritanceSpecifier3 is SomeOtherContract(1234,false) layout at 1234567890 * 1234567890 - 1234567890 / 1234567890 {} + +contract InheritanceSpecifier4 is SomeOtherContract(1234,false) layout at veryVeryLongFunction(12345678901234567890 * 12345678901234567890 - 12345678901234567890 / 12345678901234567890 + 12345678901234567890 - 12345678901234567890) {} + +contract LongInheritanceSpecifier1 is SomeOtherContract(123467890,false,0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c) {} + +contract LongInheritanceSpecifier2 is SomeOtherContract(123467890,false,0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c) layout at 123 {} + +contract LongInheritanceSpecifier3 is SomeOtherContract(123467890,false,0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c) layout at 1234567890 * 1234567890 - 1234567890 / 1234567890 {} + +contract LongInheritanceSpecifier4 is SomeOtherContract(123467890,false,0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c) layout at veryVeryLongFunction(12345678901234567890 * 12345678901234567890 - 12345678901234567890 / 12345678901234567890 + 12345678901234567890 - 12345678901234567890){} diff --git a/tests/format/ContractDefinitions/__snapshots__/jsfmt.spec.js.snap b/tests/format/ContractDefinitions/__snapshots__/jsfmt.spec.js.snap index 1621683a4..e67a4276d 100644 --- a/tests/format/ContractDefinitions/__snapshots__/jsfmt.spec.js.snap +++ b/tests/format/ContractDefinitions/__snapshots__/jsfmt.spec.js.snap @@ -9,6 +9,52 @@ printWidth: 80 contract ContractDefinition is Contract1, Contract2, Contract3, Contract4, Contract5 { } +contract StorageLayoutSpecifier layout at 123 { +} + +contract StorageLayoutSpecifier1 layout at 1234567890 * 1234567890 - 1234567890 / 1234567890 { +} + +contract StorageLayoutSpecifier2 layout at veryVeryLongFunction(12345678901234567890 * 12345678901234567890 - 12345678901234567890 / 12345678901234567890 + 12345678901234567890 - 12345678901234567890) { +} + +contract StorageLayoutSpecifier3 is Contract1 layout at 123 { +} + +contract StorageLayoutSpecifier4 is Contract1, Contract2, Contract3, Contract4, Contract5 layout at 123{ +} + +contract StorageLayoutSpecifier5 is Contract1, Contract2, Contract3, Contract4, Contract5 layout at 1234567890 * 1234567890 - 1234567890 / 1234567890{ +} + +contract StorageLayoutSpecifier6 is Contract1, Contract2, Contract3, Contract4, Contract5 layout at veryVeryLongFunction(12345678901234567890 * 12345678901234567890 - 12345678901234567890 / 12345678901234567890 + 12345678901234567890 - 12345678901234567890){ +} + +contract StorageLayoutSpecifier7 is Contract1, Contract2, Contract3, Contract4, Contract5, Contract6, Contract7 layout at 123{ +} + +contract StorageLayoutSpecifier8 is Contract1, Contract2, Contract3, Contract4, Contract5, Contract6, Contract7 layout at 1234567890 * 1234567890 - 1234567890 / 1234567890{ +} + +contract StorageLayoutSpecifier9 is Contract1, Contract2, Contract3, Contract4, Contract5, Contract6, Contract7 layout at veryVeryLongFunction(12345678901234567890 * 12345678901234567890 - 12345678901234567890 / 12345678901234567890 + 12345678901234567890 - 12345678901234567890){ +} + +contract InheritanceSpecifier1 is SomeOtherContract(1234,false) {} + +contract InheritanceSpecifier2 is SomeOtherContract(1234,false) layout at 123 {} + +contract InheritanceSpecifier3 is SomeOtherContract(1234,false) layout at 1234567890 * 1234567890 - 1234567890 / 1234567890 {} + +contract InheritanceSpecifier4 is SomeOtherContract(1234,false) layout at veryVeryLongFunction(12345678901234567890 * 12345678901234567890 - 12345678901234567890 / 12345678901234567890 + 12345678901234567890 - 12345678901234567890) {} + +contract LongInheritanceSpecifier1 is SomeOtherContract(123467890,false,0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c) {} + +contract LongInheritanceSpecifier2 is SomeOtherContract(123467890,false,0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c) layout at 123 {} + +contract LongInheritanceSpecifier3 is SomeOtherContract(123467890,false,0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c) layout at 1234567890 * 1234567890 - 1234567890 / 1234567890 {} + +contract LongInheritanceSpecifier4 is SomeOtherContract(123467890,false,0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c) layout at veryVeryLongFunction(12345678901234567890 * 12345678901234567890 - 12345678901234567890 / 12345678901234567890 + 12345678901234567890 - 12345678901234567890){} + =====================================output===================================== contract ContractDefinition is Contract1, @@ -18,5 +64,166 @@ contract ContractDefinition is Contract5 {} +contract StorageLayoutSpecifier layout at 123 {} + +contract StorageLayoutSpecifier1 layout at + 1234567890 * 1234567890 - 1234567890 / 1234567890 +{} + +contract StorageLayoutSpecifier2 layout at + veryVeryLongFunction( + 12345678901234567890 * + 12345678901234567890 - + 12345678901234567890 / + 12345678901234567890 + + 12345678901234567890 - + 12345678901234567890 + ) +{} + +contract StorageLayoutSpecifier3 is Contract1 layout at 123 {} + +contract StorageLayoutSpecifier4 + is Contract1, Contract2, Contract3, Contract4, Contract5 + layout at 123 +{} + +contract StorageLayoutSpecifier5 + is Contract1, Contract2, Contract3, Contract4, Contract5 + layout at 1234567890 * 1234567890 - 1234567890 / 1234567890 +{} + +contract StorageLayoutSpecifier6 + is Contract1, Contract2, Contract3, Contract4, Contract5 + layout at + veryVeryLongFunction( + 12345678901234567890 * + 12345678901234567890 - + 12345678901234567890 / + 12345678901234567890 + + 12345678901234567890 - + 12345678901234567890 + ) + +{} + +contract StorageLayoutSpecifier7 + is + Contract1, + Contract2, + Contract3, + Contract4, + Contract5, + Contract6, + Contract7 + layout at 123 +{} + +contract StorageLayoutSpecifier8 + is + Contract1, + Contract2, + Contract3, + Contract4, + Contract5, + Contract6, + Contract7 + layout at 1234567890 * 1234567890 - 1234567890 / 1234567890 +{} + +contract StorageLayoutSpecifier9 + is + Contract1, + Contract2, + Contract3, + Contract4, + Contract5, + Contract6, + Contract7 + layout at + veryVeryLongFunction( + 12345678901234567890 * + 12345678901234567890 - + 12345678901234567890 / + 12345678901234567890 + + 12345678901234567890 - + 12345678901234567890 + ) + +{} + +contract InheritanceSpecifier1 is SomeOtherContract(1234, false) {} + +contract InheritanceSpecifier2 + is SomeOtherContract(1234, false) + layout at 123 +{} + +contract InheritanceSpecifier3 + is SomeOtherContract(1234, false) + layout at 1234567890 * 1234567890 - 1234567890 / 1234567890 +{} + +contract InheritanceSpecifier4 + is SomeOtherContract(1234, false) + layout at + veryVeryLongFunction( + 12345678901234567890 * + 12345678901234567890 - + 12345678901234567890 / + 12345678901234567890 + + 12345678901234567890 - + 12345678901234567890 + ) + +{} + +contract LongInheritanceSpecifier1 is + SomeOtherContract( + 123467890, + false, + 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c + ) +{} + +contract LongInheritanceSpecifier2 + is + SomeOtherContract( + 123467890, + false, + 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c + ) + layout at 123 +{} + +contract LongInheritanceSpecifier3 + is + SomeOtherContract( + 123467890, + false, + 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c + ) + layout at 1234567890 * 1234567890 - 1234567890 / 1234567890 +{} + +contract LongInheritanceSpecifier4 + is + SomeOtherContract( + 123467890, + false, + 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c + ) + layout at + veryVeryLongFunction( + 12345678901234567890 * + 12345678901234567890 - + 12345678901234567890 / + 12345678901234567890 + + 12345678901234567890 - + 12345678901234567890 + ) + +{} + ================================================================================ `; diff --git a/tests/format/InheritanceSpecifier/InheritanceSpecifier.sol b/tests/format/InheritanceSpecifier/InheritanceSpecifier.sol deleted file mode 100644 index 0a30e951b..000000000 --- a/tests/format/InheritanceSpecifier/InheritanceSpecifier.sol +++ /dev/null @@ -1,2 +0,0 @@ -contract InheritanceSpecifier is SomeOtherContract(1234,false) {} -contract LongInheritanceSpecifier is SomeOtherContract(123467890,false,0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c) {} diff --git a/tests/format/InheritanceSpecifier/__snapshots__/jsfmt.spec.js.snap b/tests/format/InheritanceSpecifier/__snapshots__/jsfmt.spec.js.snap deleted file mode 100644 index c95f10839..000000000 --- a/tests/format/InheritanceSpecifier/__snapshots__/jsfmt.spec.js.snap +++ /dev/null @@ -1,23 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`InheritanceSpecifier.sol format 1`] = ` -====================================options===================================== -parsers: ["solidity-parse"] -printWidth: 80 - | printWidth -=====================================input====================================== -contract InheritanceSpecifier is SomeOtherContract(1234,false) {} -contract LongInheritanceSpecifier is SomeOtherContract(123467890,false,0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c) {} - -=====================================output===================================== -contract InheritanceSpecifier is SomeOtherContract(1234, false) {} -contract LongInheritanceSpecifier is - SomeOtherContract( - 123467890, - false, - 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c - ) -{} - -================================================================================ -`; diff --git a/tests/format/InheritanceSpecifier/jsfmt.spec.js b/tests/format/InheritanceSpecifier/jsfmt.spec.js deleted file mode 100644 index 765dd60a6..000000000 --- a/tests/format/InheritanceSpecifier/jsfmt.spec.js +++ /dev/null @@ -1 +0,0 @@ -run_spec(import.meta, ['solidity-parse']);