hashicorp / hcl-lang

Schema and decoder to be used as building blocks for an HCL2-based language server.
https://pkg.go.dev/github.com/hashicorp/hcl-lang
Mozilla Public License 2.0
84 stars 24 forks source link

decoder: refactor `SelfRefs` use context #394

Open giautm opened 5 months ago

giautm commented 5 months ago

This PR refactors a mess in the codebase with allowSelfRefs passing around until it reaches the place it was used for.

The helper schema.WithActiveSelfRefs(ctx) is already defined by the author, so I just use it for this suppose; and remove the allowSelfRefs variable from the method.

Before:

type ReferenceOriginsExpression interface {
    ReferenceOrigins(ctx context.Context, allowSelfRefs bool) reference.Origins
}

After:

type ReferenceOriginsExpression interface {
    ReferenceOrigins(ctx context.Context) reference.Origins
}
giautm commented 5 months ago

@dbanck: please help to review

jpogran commented 5 months ago

Hi @giautm, thank you for offering a contribution to this repo. Can you please put a description of your change in the PR, along with the reasoning for your change? Right now the PR description is empty and the commit message just points to https://github.com/giautm/hcl-lang/pull/2, which I did not find helpful either.

In general it is a good practice to open an issue describing the change you want so there is a chance for us to discuss the design before work is put into a PR that may not be accepted as is. Apologies, this repo does not have a CONTRIBUTING.md to have set that expectation, I will fix that.

Once we have an understanding of the intent of the change, we can review this PR.

giautm commented 5 months ago

@jpogran updated its description, thank you.