[Feature]: Refactor How motsu
Modifies Test Functions to Improve IDE's Ability to Resolve References
#24
Labels
bug
Something isn't working
enhancement
New feature or request
question
Further information is requested
What is the feature you would like to see?
In VS Code with
rust-analyzer
extension, code reference behavior is inconsistent within functions annotated with#[motsu::test]
. This makes it difficult to navigate from our tests to the actual contract functions being tests (e.g. to verify the function logic).For example, see in the attached video showing how "go to" commands behave in
error_when_minting_token_id_twice
:motsu::test
,Erc721Consecutive
,msg
, andmatches!
macro - all works fine._mint
,random_token_id
,contract
- no definitions/references are found.Since a large number of developers use VS Code, it might be prudent to make their experience with using
motsu
as smooth as possible.Possible explanation (needs to be verified!)
The macro is creating a new context where the contract parameter is introduced, but this happens at compilation time. Before macro expansion, the IDE only sees the raw
TokenStream
and can't properly resolve the references within it.VS Code (through
rust-analyzer
) tries to resolve symbols before macro expansion, which is why it can't find the definition. The actual binding of contract and its methods only exists after the macro is expanded.Screencast.from.13-01-25.10.46.47.webm
Contribution Guidelines
The text was updated successfully, but these errors were encountered: