hardhat-vscode icon indicating copy to clipboard operation
hardhat-vscode copied to clipboard

with emacs lsp-bridge package, textDocument/definition find contract definition not work

Open getong opened this issue 8 months ago • 6 comments

The code file example contracts/BasicERC20.sol from https://github.com/protokol/solidity-typescript-hardhat-template

The code sample:

import { ERC20Pausable } from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol";

find ERC20Pausable definition fail:

--- [10:15:13.605713] Send textDocument/definition request (44080) to 'solidity' for project 
{
   "id": 44080,
   "method": "textDocument/definition",
   "params": {
      "position": {
         "line": 6,
         "character": 9
      },
      "textDocument": {
         "uri": "file:///Users/gerald/test/typescript/solidity-typescript-hardhat-template/contracts/BasicERC20.sol"
      }
   },
   "message_type": "request",
   "jsonrpc": "2.0"
}

--- [10:15:13.606691] Recv textDocument/definition response (44080) from 'solidity' for project 
Eval in Emacs: (lsp-bridge-find-def-fallback '(:line 6 :character 9))
{
   "jsonrpc": "2.0",
   "id": 44080,
   "result": null
}

But find the file definition works, find the "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol", it jump to the right file

--- [10:16:13.605574] Send textDocument/definition request (3315) to 'solidity' for project 
{
   "id": 3315,
   "method": "textDocument/definition",
   "params": {
      "position": {
         "line": 6,
         "character": 95
      },
      "textDocument": {
         "uri": "file:///Users/gerald/test/typescript/solidity-typescript-hardhat-template/contracts/BasicERC20.sol"
      }
   },
   "message_type": "request",
   "jsonrpc": "2.0"
}

--- [10:16:13.606381] Recv textDocument/definition response (3315) from 'solidity' for project 
Eval in Emacs: (lsp-bridge-define--jump '"/Users/gerald/test/typescript/solidity-typescript-hardhat-template/node_modules/@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol" '"" '(:line 6 :character 0))
{
   "jsonrpc": "2.0",
   "id": 3315,
   "result": {
      "uri": "file:///Users/gerald/test/typescript/solidity-typescript-hardhat-template/node_modules/%40openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol",
      "range": {
         "start": {
            "line": 6,
            "character": 0
         },
         "end": {
            "line": 6,
            "character": 96
         }
      }
   }
}

I also test the code with emacs lsp-mode package, same behaviour, same error.

getong avatar May 26 '24 02:05 getong