-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support nested file imports in LSP #616
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you for fixing the local file resolution, I hadn't realized it wasn't handling relative paths properly 👍
Just one concern, and there seem to be build errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! Thank you for fixing this 🙏
2a1e1e0
to
5f8226f
Compare
Description
I noticed a small bug that occurs when using nested imports in the VS Code extension (e.g. import a file that imports another file).
Here's an example:
In this case, when resolving the import of
MyContractB
, themainPath
value is stilltransactions/myTransaction.cdc
, so the computed absolute file path (I call this path normalization) istransactions/MyContractB.cdc
, which fails.This PR updates the import logic to normalize paths before setting the location on the sub-checker for the imported program. This way, each value of
checker.Location
points to the absolute path for that file. Then, any further nested imports are normalized againstchecker.Location
, allowing for arbitrary depth of imports.Disclaimer: I have only tested this code with file imports and have not yet tested extensively enough to ensure I didn't introduce a regression with address-based imports. I'll try to find time for that today.
For contributor use:
master
branchFiles changed
in the Github PR explorer