@@ -44,6 +44,251 @@ Generated by [AVA](https://avajs.dev).
4444 uint256 a;␊
4545 uint256 b;␊
4646 } SecondaryStorage $SecondaryStorage_random;␊
47+ ␊
48+ /// @custom:storage-location erc7201:example.with.following.comment␊
49+ // some comment␊
50+ struct StorageWithComment {␊
51+ uint256 a;␊
52+ uint256 b;␊
53+ } StorageWithComment $StorageWithComment_random;␊
54+ ␊
55+ ␊
56+ function foo() public {}␊
57+ ␊
58+ ␊
59+ function foo1(uint a) public {}␊
60+ ␊
61+ ␊
62+ function foo2(uint a) internal {}␊
63+ struct MyStruct { uint b; }␊
64+ ␊
65+ // keccak256(abi.encode(uint256(keccak256("example.main")) - 1)) & ~bytes32(uint256(0xff));␊
66+ bytes32 private constant MAIN_STORAGE_LOCATION =␊
67+ 0x183a6125c38840424c4a85fa12bab2ab606c4b6d0e7cc73c0c06ba5300eab500;␊
68+ ␊
69+ function _getMainStorage() private pure returns (bool $) {}␊
70+ ␊
71+ function _getXTimesY() internal view returns (bool) {}␊
72+ ␊
73+ ␊
74+ ␊
75+ ␊
76+ enum $astId_id_random { dummy }␊
77+ ␊
78+ // standalone doc␊
79+ ␊
80+ ␊
81+ ␊
82+ ␊
83+ function foo3() public {}␊
84+ ␊
85+ ␊
86+ function foo4() public {}␊
87+ ␊
88+ ␊
89+ enum $astId_id_random { dummy }␊
90+ ␊
91+ enum $astId_id_random { dummy }␊
92+ enum $astId_id_random { dummy }␊
93+ enum $astId_id_random { dummy }␊
94+ enum $astId_id_random { dummy }␊
95+ enum $astId_id_random { dummy }␊
96+ }␊
97+ ␊
98+ abstract contract HasFunction {␊
99+ ␊
100+ function foo() pure public returns (bool) {}␊
101+ }␊
102+ ␊
103+ abstract contract UsingFunction is HasFunction {␊
104+ enum $astId_id_random { dummy }␊
105+ }␊
106+ ␊
107+ function FreeFunctionUsingSelector() pure returns (bool) {}␊
108+ ␊
109+ bytes4 constant CONSTANT_USING_SELECTOR = HasFunction.foo.selector;␊
110+ ␊
111+ library Lib {␊
112+ function usingSelector() pure public returns (bool) {}␊
113+ ␊
114+ function plusOne(uint x) pure public returns (bool) {}␊
115+ }␊
116+ ␊
117+ abstract contract Consumer {␊
118+ enum $astId_id_random { dummy }␊
119+ ␊
120+ function usingFreeFunction() pure public returns (bool) {}␊
121+ ␊
122+ function usingConstant() pure public returns (bool) {}␊
123+ ␊
124+ function usingLibraryFunction() pure public returns (bool) {}␊
125+ }␊
126+ ␊
127+ abstract contract HasConstantWithSelector {␊
128+ bytes4 constant CONTRACT_CONSTANT_USING_SELECTOR = HasFunction.foo.selector;␊
129+ }␊
130+ ␊
131+ function plusTwo(uint x) pure returns (bool) {}␊
132+ ␊
133+ ␊
134+ ␊
135+ ␊
136+ function plusThree(uint x) pure returns (bool) {}␊
137+ ␊
138+ ␊
139+ ␊
140+ ␊
141+ function plusThree(uint x, uint y) pure returns (bool) {}␊
142+ ␊
143+ function originallyNoDocumentation() pure {}␊
144+ ␊
145+ ␊
146+ enum $astId_id_random { dummy }␊
147+ ␊
148+ abstract contract UsingForDirectives {␊
149+ enum $astId_id_random { dummy }␊
150+ ␊
151+ function usingFor(uint x) pure public returns (bool) {}␊
152+ }␊
153+ ␊
154+ ␊
155+ enum FreeEnum { MyEnum }␊
156+ ␊
157+ ␊
158+ enum CustomErrorOutsideContract { dummy }␊
159+ ␊
160+ int8 constant MAX_SIZE_C = 2;␊
161+ ␊
162+ abstract contract StructArrayUsesConstant {␊
163+ uint16 private constant MAX_SIZE = 10;␊
164+ ␊
165+ struct NotNamespaced {␊
166+ uint16 a;␊
167+ uint256[MAX_SIZE] b;␊
168+ uint256[MAX_SIZE_C] c;␊
169+ }␊
170+ ␊
171+ /// @custom:storage-location erc7201:uses.constant␊
172+ struct MainStorage {␊
173+ uint256 x;␊
174+ uint256[MAX_SIZE] y;␊
175+ uint256[MAX_SIZE_C] c;␊
176+ } MainStorage $MainStorage_random;␊
177+ }␊
178+ ␊
179+ address constant MY_ADDRESS = address(0);␊
180+ uint constant CONVERTED_ADDRESS = uint160(MY_ADDRESS);␊
181+ ␊
182+ interface IDummy {␊
183+ }␊
184+ ␊
185+ abstract contract UsesAddress {␊
186+ IDummy public constant MY_CONTRACT = IDummy(MY_ADDRESS);␊
187+ }␊
188+ ␊
189+ abstract contract HasFunctionWithRequiredReturn {␊
190+ struct S { uint x; }␊
191+ function foo(S calldata s) internal pure returns (bool) {}␊
192+ }␊
193+ ␊
194+ ␊
195+ function hasMultipleReturns() pure returns (bool, bool) {}␊
196+ ␊
197+ ␊
198+ function hasMultipleNamedReturns() pure returns (bool a, bool b) {}␊
199+ ␊
200+ ␊
201+ function hasReturnsDocumentedAsParams() pure returns (bool a, bool b) {}␊
202+ ␊
203+ abstract contract HasNatSpecWithMultipleReturns {␊
204+ ␊
205+ function hasMultipleReturnsInContract() public pure returns (bool, bool) {}␊
206+ ␊
207+ ␊
208+ function hasMultipleNamedReturnsInContract() public pure returns (bool a, bool b) {}␊
209+ ␊
210+ ␊
211+ function hasReturnsDocumentedAsParamsInContract() public pure returns (bool a, bool b) {}␊
212+ }␊
213+ ␊
214+ interface IHasExternalViewFunction {␊
215+ function foo() external view returns (bool);␊
216+ }␊
217+ ␊
218+ abstract contract HasExternalViewFunction is IHasExternalViewFunction {␊
219+ // This generates a getter function that conforms to the interface␊
220+ enum $astId_id_random { dummy }␊
221+ ␊
222+ // References a selector in an interface␊
223+ bytes4 constant USING_INTERFACE_FUNCTION_SELECTOR = IHasExternalViewFunction.foo.selector;␊
224+ ␊
225+ // References a getter generated for a public variable␊
226+ enum $astId_id_random { dummy }␊
227+ }␊
228+ ␊
229+ abstract contract DeploysContractToImmutable {␊
230+ enum $astId_id_random { dummy }␊
231+ }`,
232+ },
233+ 'contracts/test/NamespacedToModifyImported.sol': {
234+ content: `// SPDX-License-Identifier: MIT␊
235+ pragma solidity ^0.8.20;␊
236+ ␊
237+ import {CONSTANT_USING_SELECTOR, plusTwo, plusThree, CustomErrorOutsideContract} from "./NamespacedToModify.sol";␊
238+ ␊
239+ abstract contract Example {}␊
240+ `,
241+ },
242+ },
243+ }
244+
245+ ## make namespaced input - keep all natspec
246+
247+ > Snapshot 1
248+
249+ {
250+ language: 'Solidity',
251+ settings: {
252+ evmVersion: 'paris',
253+ optimizer: {
254+ enabled: true,
255+ runs: 200,
256+ },
257+ outputSelection: {
258+ '*': {
259+ '': [
260+ 'ast',
261+ ],
262+ '*': [
263+ 'storageLayout',
264+ ],
265+ },
266+ },
267+ },
268+ sources: {
269+ 'contracts/test/NamespacedToModify.sol': {
270+ content: `// SPDX-License-Identifier: MIT␊
271+ pragma solidity ^0.8.20;␊
272+ ␊
273+ abstract contract Example {␊
274+ /// @custom:storage-location erc7201:example.main␊
275+ struct MainStorage {␊
276+ uint256 x;␊
277+ uint256 y;␊
278+ } MainStorage $MainStorage_random;␊
279+ ␊
280+ /// @custom:storage-location erc7201:example.secondary␊
281+ struct SecondaryStorage {␊
282+ uint256 a;␊
283+ uint256 b;␊
284+ } SecondaryStorage $SecondaryStorage_random;␊
285+ ␊
286+ /// @custom:storage-location erc7201:example.with.following.comment␊
287+ // some comment␊
288+ struct StorageWithComment {␊
289+ uint256 a;␊
290+ uint256 b;␊
291+ } StorageWithComment $StorageWithComment_random;␊
47292 ␊
48293 /// @notice some natspec␊
49294 function foo() public {}␊
0 commit comments