Skip to content
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

cmd/ctrl-click on import identifier doesn't work on npm packages #402

Open
shirotech opened this issue Jul 31, 2023 · 6 comments
Open

cmd/ctrl-click on import identifier doesn't work on npm packages #402

shirotech opened this issue Jul 31, 2023 · 6 comments

Comments

@shirotech
Copy link

shirotech commented Jul 31, 2023

For example:

import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Ownable} from "./Ownable.sol";

cmd-click doesn't work when clicking on {Initializable} or {IERC20}, but it works for local files in the example {Ownable}. cmd-click on the filePath is fine though, to make sure that the file actually exists.

@shirotech shirotech changed the title cmd/ctrl-click on import identifier doesn't work on npm packages like @openzeppelin/contracts cmd/ctrl-click on import identifier doesn't work on npm packages Aug 2, 2023
@jonahcui
Copy link
Contributor

Are you sure that the "import x from x" statement is correct? Does the solidity support the grammar?

The Solidity Doc

@shirotech
Copy link
Author

Are you sure that the "import x from x" statement is correct? Does the solidity support the grammar?

The Solidity Doc

Yes, I'm 100% sure it is supported, otherwise it would complain about compilation errors. Not sure why you referenced a 3rd party docs that may not have the complete set of rules. Please see https://docs.soliditylang.org/en/latest/layout-of-source-files.html for the official reference, thank you 🙏

@jonahcui
Copy link
Contributor

CleanShot 2023-09-15 at 16 37 03@2x

Can you share your project structure? I found the reference is work correctly.

@shirotech
Copy link
Author

@jonahcui That looks like just the docs for that file, what happens when you cmd+click on the text between the {} ? The expected behaviour is that it should jump to the file with scrollbar targeted at the class name.

@jonahcui
Copy link
Contributor

jonahcui commented Sep 15, 2023 via email

@XAudit174176
Copy link

For example:

import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {Ownable} from "./Ownable.sol";

cmd-click doesn't work when clicking on {Initializable} or {IERC20}, but it works for local files in the example {Ownable}. cmd-click on the filePath is fine though, to make sure that the file actually exists.

Hi there,

Looks like you have a problem with the external imports, please consider these 2 things:

  1. The external contracts files may not be downloaded or maybe corrupt, check if the file exists in the exact path, or even try reinstalling the dependencies
  2. If the file exists, you need to check if you have defined appropriate remappings in order, so that the compiler and extension could understand for example @openzeppelin/contracts/ should be replaced by lib/openzeppelin-contracts/contracts/

Btw if the compiler is doing well, the extension also should work

Also the problem doesn't seem to be general, as it is Ok now on my system (current new version by the time of submitting this response) !

Good Luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants