intellij-solidity / intellij-solidity

Solidity plugin for IntelliJ

Home Page:https://plugins.jetbrains.com/plugin/9475-intellij-solidity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

shirotech opened this issue · comments

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.

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

The Solidity Doc

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 🙏

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

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

@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.

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