juanfranblanco / vscode-solidity

Visual Studio Code language support extension for Solidity smart contracts in Ethereum https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity
MIT License
904 stars 194 forks source link

Extension produces inline import error when using root-relative-paths #441

Open Keinberger opened 10 months ago

Keinberger commented 10 months ago

Problem statement

I unfortunately have an issue trying trying to use the extension on Foundry projects using root-relative-paths. The extension seems to not process these paths correctly and produces an inline error statement.

This is one of the contracts of the project that I'm facing problems with:

This contract can be found in the Sablier-v2 repository: https://github.com/sablier-labs/v2-core/blob/main/test/unit/concrete/adminable/transfer-admin/transferAdmin.t.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.19 <0.9.0;

import { Errors } from "src/libraries/Errors.sol";

import { Adminable_Unit_Shared_Test } from "../../../shared/Adminable.t.sol";

contract TransferAdmin_Unit_Concrete_Test is Adminable_Unit_Shared_Test {
    /// ...code of the contract
}

This contract is located inside of the test/unit/concrete/adminable/transferAdmin.t.sol file. As you can see, this file uses the root-relative-path "src/libraries/Errors.sol".

Failure

Unfortunately this path does not get resolved correctly from the VSCode extension and the following in-line error at the line of the import statemens:

Source "src/libraries/Errors.sol" not found: File import callback not supported(6275)

Does anyone have experience with root-relative-path in regards to the Solidity extension or any possible solutions off the top of their head? Any help is much appreciated🙏

juanfranblanco commented 9 months ago

@Keinberger you need to set "./" in front of "src" as it will be confused with a library, and yes it has to be relative.