Skip to content

Ensure correct usage of language IDs - #147

Merged
Yantrio merged 1 commit into
mainfrom
language-id-fixes
Dec 11, 2025
Merged

Ensure correct usage of language IDs#147
Yantrio merged 1 commit into
mainfrom
language-id-fixes

Conversation

@Yantrio

@Yantrio Yantrio commented Dec 11, 2025

Copy link
Copy Markdown
Member

There are currently 5 actions that are not using ilsp.ParseLanguageID which causes a language mismatch ("terraform" != "opentofu") and so some items are thrown away (For example, references).

This patch ensures that all references to the document's language ID also goes through ilsp.ParseLanguageID

Resolves #127

Checklist

  • I have read the contribution guide.
  • I have not used an AI coding assistant to create this PR.
  • I have written all code in this PR myself OR I have marked all code I have not written myself (including modified code, e.g. copied from other places and then modified) with a comment indicating where it came from.
  • I (and other contributors to this PR) have not looked at the Terraform source code while implementing this PR.
  • If I'm releasing, I have read the releasing guide.

Go checklist

  • I have run golangci-lint on my change and receive no errors relevant to my code.
  • I have run existing tests to ensure my code doesn't break anything.
  • I have added tests for all relevant use cases of my code, and those tests are passing.
  • I have only exported functions, variables and structs that should be used from other packages.
  • I have added meaningful comments to all exported functions, variables, and structs.

There are currently 5 actions that are not using `ilsp.ParseLanguageID`
which causes a language mismatch ("terraform" != "opentofu") and so some
items are thrown away (For example, references).

This patch ensures that all references to the document's language ID
also goes through `ilsp.ParseLanguageID`

Resolves #127

Signed-off-by: James Humphries <james@james-humphries.co.uk>
@Yantrio
Yantrio requested a review from a team as a code owner December 11, 2025 12:04

@Gogotchuri Gogotchuri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! It appears to be the correct approach for the time being.
We might want to embed language ID evaluation into hcl-lang to ensure we treat "opentofu" and "terraform" the same.
I have mentioned somewhere before that this need for mapping stems from the fact that most editors have a single mapping for .tf files ("terraform"), and it will take a long time for all of them to also identify those files as "opentofu".

@diofeher diofeher changed the title Ensure correct usage of lanauge IDs Ensure correct usage of language IDs Dec 11, 2025

@diofeher diofeher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

@Yantrio
Yantrio merged commit 5dfedb9 into main Dec 11, 2025
21 checks passed
@Yantrio
Yantrio deleted the language-id-fixes branch December 11, 2025 15:10
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

Successfully merging this pull request may close these issues.

textDocument/references always returns []

3 participants