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

Add function signature types #207

Merged
merged 1 commit into from
Feb 15, 2023
Merged

Add function signature types #207

merged 1 commit into from
Feb 15, 2023

Conversation

dbanck
Copy link
Member

@dbanck dbanck commented Feb 15, 2023

This PR extracts the function signature types from #135 to enable us to implement upstream changes in terraform-schema before completing the function signatures features as a whole.

We can use the new signature types to embed function signatures in terraform-schema.


@dbanck dbanck requested a review from a team as a code owner February 15, 2023 11:05
@dbanck dbanck self-assigned this Feb 15, 2023
@dbanck dbanck added the enhancement New feature or request label Feb 15, 2023
Comment on lines 18 to 23
// Parameters describes the function's fixed positional parameters.
Params []function.Parameter

// VariadicParameter describes the function's variadic
// parameter if it is supported.
VarParam *function.Parameter
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Parameters describes the function's fixed positional parameters.
Params []function.Parameter
// VariadicParameter describes the function's variadic
// parameter if it is supported.
VarParam *function.Parameter
// Params describes the function's fixed positional parameters.
Params []function.Parameter
// VarParam describes the function's variadic
// parameter if it is supported.
VarParam *function.Parameter

I'm not sure if the short names are better here, but I guess they align with the relevant function names in go-cty, so at least we're consistent 🤷🏻

"github.com/zclconf/go-cty/cty/function"
)

type FuncSignature struct {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
type FuncSignature struct {
type FunctionSignature struct {

This would IMO better align with function.Function in go-cty: https://pkg.go.dev/github.com/zclconf/[email protected]/cty/function#Function

@@ -16,8 +16,7 @@ type PathContext struct {
ReferenceOrigins reference.Origins
ReferenceTargets reference.Targets
Files map[string]*hcl.File

// TODO: Functions
Functions map[string]schema.FuncSignature
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Functions map[string]schema.FuncSignature
Functions map[string]schema.FunctionSignature

Comment on lines 3 to 24
type FuncSignature struct {
Name string

// Description is an optional human-readable description
// of the function.
Description MarkupContent

// Parameters is an ordered list of the function's parameters.
Parameters []FuncParameter

// ActiveParameter is an index marking the parameter a user is currently
// editing. It should lie inside the range of Parameters.
ActiveParameter uint
}

type FuncParameter struct {
Name string

// Description is an optional human-readable description
// of the parameter.
Description MarkupContent
}
Copy link
Member

Choose a reason for hiding this comment

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

None of the lang.* types seem currently required for hashicorp/terraform-schema#145 AFAICT, so shall we leave it for a separate PR which introduces the code that needs it? e.g. signatureHelp method?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we can do that.

@dbanck dbanck force-pushed the f-function-signature-types branch from e30b6ba to 7f34f2a Compare February 15, 2023 16:35
@dbanck dbanck requested a review from radeksimko February 15, 2023 16:39
@dbanck dbanck merged commit 7a48063 into main Feb 15, 2023
@dbanck dbanck deleted the f-function-signature-types branch February 15, 2023 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants