Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: return an ExprSyntaxError for invalid references that end in a dot #692

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

ansgarm
Copy link
Member

@ansgarm ansgarm commented Aug 21, 2024

Return an ExprSyntaxError for invalid references that end in a dot (commonly occurs in editors for completions).

Detect value expressions of the ExprSyntaxError type when parsing object constructor expressions and use them to add an item to the result even though we skip parsing the object due to recovery after the invalid expression.

This allows the Terraform language server to support completions for object attributes after a dot was typed.

@ansgarm ansgarm changed the title feat: return an ExprSyntaxError for invalid references that end in a dot (commonly occurs in editors for completions) feat: return an ExprSyntaxError for invalid references that end in a dot Aug 21, 2024
@ansgarm ansgarm changed the title feat: return an ExprSyntaxError for invalid references that end in a dot feat: return an ExprSyntaxError for invalid references that end in a dot Aug 21, 2024
@ansgarm ansgarm force-pushed the support-incomplete-references-in-object-items branch from 1961bbe to d196382 Compare August 21, 2024 13:35
hclsyntax/parser_test.go Outdated Show resolved Hide resolved
…dot (commonly occurs in editors for completions)

Detect value expressions of the ExprSyntaxError type when parsing object constructor expressions and use them to add an item to the result even though we skip parsing the object due to recovery after the invalid expression.

This allows the Terraform language server to support completions for object attributes after a dot was typed.
@ansgarm ansgarm force-pushed the support-incomplete-references-in-object-items branch from d196382 to 117baa8 Compare August 21, 2024 13:39
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me! 👍🏻

ansgarm added a commit to hashicorp/hcl-lang that referenced this pull request Aug 21, 2024
Previously it was required to type a first character as the hclsyntax parser wouldn't return anything for these invalid references. This requires hashicorp/hcl#692 to work
@ansgarm ansgarm merged commit ae53b93 into main Aug 22, 2024
13 checks passed
@ansgarm ansgarm deleted the support-incomplete-references-in-object-items branch August 22, 2024 08:14
@ansgarm ansgarm mentioned this pull request Aug 22, 2024
ansgarm added a commit to hashicorp/hcl-lang that referenced this pull request Aug 22, 2024
Previously it was required to type a first character as the hclsyntax parser wouldn't return anything for these invalid references. This requires hashicorp/hcl#692 to work
ansgarm added a commit to hashicorp/hcl-lang that referenced this pull request Aug 22, 2024
Previously it was required to type a first character as the hclsyntax parser wouldn't return anything for these invalid references. This requires hashicorp/hcl#692 to work
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.

4 participants