-
Notifications
You must be signed in to change notification settings - Fork 24
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
Conversation
schema/signature.go
Outdated
// 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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 🤷🏻
schema/signature.go
Outdated
"github.com/zclconf/go-cty/cty/function" | ||
) | ||
|
||
type FuncSignature struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
decoder/path_context.go
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functions map[string]schema.FuncSignature | |
Functions map[string]schema.FunctionSignature |
lang/signature.go
Outdated
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 | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
e30b6ba
to
7f34f2a
Compare
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.