-
Notifications
You must be signed in to change notification settings - Fork 21
(GH-141) Modify the Puppet Function loading to use all of the new Puppet 4 API features #142
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
Conversation
69ec36e to
67e317e
Compare
Previously the Sidecar Protocol had the serialisation methods on the BasePuppetObject however this meant anything that wanted to use the serialisation methods also inherited the parameters like key and calling_source. This commit: * Moves the serialisation methods (to_json, from_json!) to BaseClass which BasePuppetObject now inherits from * Adds equality methods on the BaseClass to make it possible to compare Sidecar objects correctly. This is mainly required in spec tests to test for equality (either == or eql?) * Adds a hash method to generate the hash number required when Sidecar objects are put into hashtables There are no test changes as this is a refactor only.
…upport V4 API Previously the Puppet Function information retrieved over the Sidecar Protocol only supported the older V3 Function API. This commit updates the Protocol to now be able to transmit V4 function information. V3 information is expected to be adapted into its equivalent in V4. This commit: * Removes the deprecated arity and type methods and adds function_version and signatures. Where signatures are the function method signatures expressed as a PuppetFunctionSignatureList object * Adds a PuppetFunctionSignature and PuppetFunctionSignatureList object which captures all of the properties of Puppet Function V4 API method signature. The PuppetFunctionSignatureList object is a "typed" array of PuppetFunctionSignature objects * Adds a PuppetFunctionSignatureParameter and PuppetFunctionSignatureParameterList object which captures all of the properties of Puppet Function V4 API method signature parameter. The PuppetFunctionSignatureParameterList object is a "typed" array of PuppetFunctionSignatureParameter objects * Updates the spec_helper to be able to create mock objects for functions, function signatures and function signature parameters * Updates the sidecar protocol tests for the modified parameters and newly added classes * Updates the in-memory cache object tests for the modified parameters of a Function. At this point the protocol now only accepts V4 Function API information. Later commits will modify the Sidecar and Language Server to generate and consume the new information respectively.
8cbc51d to
674cbe0
Compare
|
Found some bugs. Back to WIP |
Previously the Sidecar could only emit information in function V3 API format. Now that the Sidecar Protocol has been changed to emit V4 information, this commit updates the Sidecar to extact the V4 information. This commit: * Updates the sidecar_protocol_extensions for the Puppet Function object to adapt the V3 function information into the V4 version * Updates the tests for the sidecar_protocol_extensions for the new parameters for the V4 API functions * Updates the Puppet Strings Helper to extract the required information from YARN in order to populate the V4 API function metadata. In particular the concepts of function type and arity no longer apply, and have been replaced using Function Signatures.
Previously the function loader was modified for V4 Function API however there were no tests for the Puppet based Functions, as opposed to Ruby. This commit adds the test fixtures and tests to ensure that Puppet based Functions are loaded correctly.
674cbe0 to
a87fd92
Compare
Previously a Puppet Strings Helper was added however there no tests for the metadata extraction. This commit: * Adds tests to ensure that YARD/Puppet Strings extracts the metadata correctly * Converts the Strings Helper module into a class to make it easier to test * Updates the Puppet 4 function fixture to be a more complete example
When Puppet Strings extracts the parameter name it differs from how it appears in the signature key. This makes it hard for clients to determine where in the signature, the parameter actually is. This commit: * Updates the Sidecar Protocol and adds two new methods for the PuppetFunctionSignatureParameter class; signature_key_offset and signature_key_length. These values will store where in the signature key a parameter exists * Updates the protocol tests and spec helper for the new methods * Updates the Puppet Strings Helper to detect and populate the offset and length values for each parameter in a signature * Updates the Puppet Strings Helper tests to assert these values are correct for bare parameter names, blocks and splattable arguments.
…unctions Now that the Sidecar and the Sidecar Protocol have been modified to emit V4 API function metadata the completion and hover providers need to be modified to use it. This commit: * Because the concept of Function Type no longer exists (rvalue vs statement) all functions need to be returned when in the root of a document. Therefore the all_statement_functions method is changed into all_functions * The completion resolver is modified to only emit completion information if the function actually has a signature (all functions should have at least one sig). The resulting resolution now returns the function documentation and function signatures in separate fields in the response * The insertion text for the completion item now just emits the function with empty parentheses. This should trigger the Signature Helper, which will be implemented in later commits * The hover provider is modified to remove a todo item because arity no longer exists
a87fd92 to
04178c5
Compare
There is a state problem when running different combinations of integration tests whereby the Puppet mode still has tasks enabled, which then breaks node graph generation. This commit safely modifies the Puppet[:tasks] state prior to testing and reverts once complete.
04178c5 to
c2aaa5f
Compare
|
I'm good to merge this, but feel like I haven't really 'used' it as I don't have examples of these advanced functions and stuff you've exposed. Do you have some examples to use? |
|
Stdlib is my goto module as it basically has everything and it's used a lot 4.x 3.x |
jpogran
left a comment
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.

Builds on #140Fixes #141
Previously the Sidecar Protocol had the serialisation methods on the
BasePuppetObject however this meant anything that wanted to use the
serialisation methods also inherited the parameters like key and calling_source.
This commit:
BasePuppetObject now inherits from
Sidecar objects correctly. This is mainly required in spec tests to test for
equality (either == or eql?)
are put into hashtables
Previously the Puppet Function information retrieved over the Sidecar Protocol
only supported the older V3 Function API. This commit updates the Protocol to
now be able to transmit V4 function information. V3 information is expected to
be adapted into its equivalent in V4.
This commit:
signatures. Where signatures are the function method signatures expressed as
a PuppetFunctionSignatureList object
captures all of the properties of Puppet Function V4 API method signature.
The PuppetFunctionSignatureList object is a "typed" array of
PuppetFunctionSignature objects
PuppetFunctionSignatureParameterList object which captures all of the
properties of Puppet Function V4 API method signature parameter. The
PuppetFunctionSignatureParameterList object is a "typed" array of
PuppetFunctionSignatureParameter objects
function signatures and function signature parameters
classes
Function.
Previously a Puppet Strings Helper was added however there no tests for the
metadata extraction. This commit:
When Puppet Strings extracts the parameter name it differs from how it appears
in the signature key. This makes it hard for clients to determine where in the
signature, the parameter actually is. This commit:
PuppetFunctionSignatureParameter class; signature_key_offset and
signature_key_length. These values will store where in the signature key
a parameter exists
values for each parameter in a signature
bare parameter names, blocks and splattable arguments.
Previously the Sidecar could only emit information in function V3 API format.
Now that the Sidecar Protocol has been changed to emit V4 information, this
commit updates the Sidecar to extact the V4 information.
This commit:
adapt the V3 function information into the V4 version
for the V4 API functions
YARN in order to populate the V4 API function metadata. In particular the
concepts of function type and arity no longer apply, and have been replaced
using Function Signatures.
Now that the Sidecar and the Sidecar Protocol have been modified to emit V4
API function metadata the completion and hover providers need to be modified
to use it. This commit:
all functions need to be returned when in the root of a document. Therefore
the all_statement_functions method is changed into all_functions
function actually has a signature (all functions should have at least one
sig). The resulting resolution now returns the function documentation and
function signatures in separate fields in the response
empty parentheses. This should trigger the Signature Helper, which will be
implemented in later commits
exists