question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to find definitions or declarations in many cases

See original GitHub issue

Issue Description

Unable to find definition or declaration

Environment Information

Terraform Information

Version: 1.1.5 Platform: darwin_amd64 Outdated: true

.vscode/extensions/hashicorp.terraform-2.20.0/bin/terraform-ls version: 0.25.2 platform: darwin/amd64 go: go1.17.5 compiler: gc

Visual Studio Code

Name Version
Operating System Darwin x64 21.3.0
VSCode 1.65.2

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
aws-toolkit-vscode amazonwebservices 1.36.0
better-cpp-syntax jeff-hykin 1.15.13
cmake twxs 0.0.17
cmake-tools ms-vscode 1.9.2
code-groovy marlon407 0.1.2
cpptools ms-vscode 1.8.4
cpptools-extension-pack ms-vscode 1.1.0
cpptools-themes ms-vscode 1.0.0
csharp ms-dotnettools 1.24.1
doxdocgen cschlosser 1.4.0
go golang 0.32.0
gradle-language naco-siren 0.2.3
java redhat 1.4.0
jupyter ms-toolsai 2022.2.1030672458
jupyter-keymap ms-toolsai 1.0.0
jupyter-renderers ms-toolsai 1.0.6
opa tsandall 0.10.0
plantuml jebbs 2.17.2
python ms-python 2022.2.1924087327
remote-containers ms-vscode-remote 0.224.2
remote-ssh ms-vscode-remote 0.76.1
remote-ssh-edit ms-vscode-remote 0.76.1
remote-wsl ms-vscode-remote 0.64.2
saltstack korekontrol 0.0.9
shell-format foxundermoon 7.2.2
synthwave-vscode RobbOwen 0.1.11
terraform hashicorp 2.20.0
vscode-docker ms-azuretools 1.20.0
vscode-jetbrains-keybindings isudox 0.1.9
vscode-power-mode hoovercj 3.0.1
vscode-pylance ms-python 2022.3.1
vscode-yaml redhat 1.5.1
xml DotJoshJohnson 2.5.1

Extension Logs

Find this from the first few lines of the relevant Output pane: View -> Output -> ‘HashiCorp Terraform’

2022/03/13 23:32:59 hover.go:37: Looking for hover data at "vpc_peering.tf" -> hcl.Pos{Line:17, Column:70, Byte:499}
2022/03/13 23:32:59 hover.go:39: received hover data: (*lang.HoverData)(nil)
2022/03/13 23:32:59 rpc_logger.go:45: Error for "textDocument/hover" (ID 90): [-32098] vpc_peering.tf (17,70): unsupported expression (*hclsyntax.FunctionCallExpr)
2022/03/13 23:32:59 opts.go:254: Completed 1 requests [14.805875ms elapsed]
[Error - 11:32:59 PM] Request textDocument/hover failed.
  Message: vpc_peering.tf (17,70): unsupported expression (*hclsyntax.FunctionCallExpr)
  Code: -32098 
2022/03/13 23:32:59 hover.go:37: Looking for hover data at "vpc_peering.tf" -> hcl.Pos{Line:17, Column:70, Byte:499}
2022/03/13 23:32:59 hover.go:39: received hover data: (*lang.HoverData)(nil)
2022/03/13 23:32:59 rpc_logger.go:45: Error for "textDocument/hover" (ID 97): [-32098] vpc_peering.tf (17,70): unsupported expression (*hclsyntax.FunctionCallExpr)
2022/03/13 23:32:59 opts.go:254: Completed 1 requests [17.461433ms elapsed]
[Error - 11:32:59 PM] Request textDocument/hover failed.
  Message: vpc_peering.tf (17,70): unsupported expression (*hclsyntax.FunctionCallExpr)
  Code: -32098 

The HCL looks like this:

data "aws_availability_zones" "available" {
}

data "aws_subnet" "private" {
  count             = var.subnet_count
  availability_zone = element(data.aws_availability_zones.available.names, count.index)

  tags = {
    Type = "private"
  }

  vpc_id = var.vpc_id
}

Hovering or navigating to usage/definition/declaration doesn’t work in most cases and simply reports that it cannot be found. It can find Data Source Type aws_availability_zones but hovering data.aws_availability_zones.available.names doesn’t do anything, neither does navigating to the declaration of data.aws_availability_zones.available.

Typing data.aws_availability_zones.av doesn’t yield autocompletion for data.aws_availability_zones.available either. It can do data.aws_avail and complete data.aws_availability_zones but beyond that it’s no use.

Other things it can’t find:

  • symlinked HCL
  • cross-module declarations
  • submodule declarations
  • Variables in TFVars

I’ve tried to find out if there is a list of known issues for finding usages/definitions but there doesn’t seem to be a detailed “it does not cross this type of boundary” list of things it tries to resolve.

Example of a variable that is filled by tfvars:

variables.tf

variable "namespace" {
  description = "The group this environment belongs to. Not optional."
}

environment.auto.tfvars

namespace = "hyperion"

Can’t navigate in either direction via references/declaration.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
radeksimkocommented, Jul 25, 2022
0reactions
github-actions[bot]commented, Aug 25, 2022

I’m going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - Unable to find definitions or declarations in many cases -
Hovering or navigating to usage/definition/declaration doesn't work in most cases and simply reports that it cannot be found. It can find Data Source...
Read more >
Code::Blocks cannot find function declarations or definitions
First, let me give a couple of ways to help C::B find your declarations/definitions. Although somewhat obvious, you should make sure the ...
Read more >
Fix: VS Code Go to Definition Not Working - YouTube
Visual Studio Code (VS Code) is a very popular code editor among the developers of the world. This is due to it's awesome...
Read more >
VS2017 C++ function definition not found
I was searching for a function definition in a source file, and clicked on the dropdown list for the functions available in the...
Read more >
"Go to Declaration or Usages" unable to find a function ...
Do the same for function definition in pytest_selenium.py, it is unable to find usages like test_login either. It's PyCharm 2019.3.1, and have ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found