-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
3944 extend the properties api to better support nested configuration #3952
3944 extend the properties api to better support nested configuration #3952
Conversation
This reverts commit 28165cc.
…upport-nested-configuration
I think this is done. It provide serveral new functions to deal with nested properties(new functions and the use example at the first comment ). Also I've added test for this new api as prof of correctness. |
…upport-nested-configuration
…upport-nested-configuration
…upport-nested-configuration
…upport-nested-configuration
…upport-nested-configuration
…upport-nested-configuration
…upport-nested-configuration
…upport-nested-configuration
…upport-nested-configuration
…upport-nested-configuration
…upport-nested-configuration
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.
First, sorry for taking forever to get this reviewed! It is rather difficult code to review :)
Second, thanks for taking care of the Properties module!
I mostly have some small nitpicks, especially regarding the formatting. Could you make sure to add a newline between instance declarations and normalise the formatting a little bit? E.g. ,HasProperty
vs , ParsePropertyPath
.
Also, a little bit more documentation in the code would be nice, to explain what problem TProperties
is supposed to solve.
Otherwise, looks good to go to me!
@@ -57,6 +66,7 @@ data PropertyType | |||
| TObject Type | |||
| TArray Type | |||
| TEnum Type | |||
| TProperties [PropertyKey] |
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.
This doesn't map naturally the JSON type any more, could you add a comment why we want/need this?
propertyTest = testGroup "property api tests" [ | ||
testCase "property toVSCodeExtensionSchema" $ do | ||
let expect = "[(\"top.baz\",Object (fromList [(\"default\",String \"baz\"),(\"markdownDescription\",String \"baz\"),(\"scope\",String \"resource\"),(\"type\",String \"string\")])),(\"top.parent.foo\",Object (fromList [(\"default\",String \"foo\"),(\"markdownDescription\",String \"foo\"),(\"scope\",String \"resource\"),(\"type\",String \"string\")]))]" | ||
let result = toVSCodeExtensionSchema "top." nestedPropertiesExample | ||
show result @?= expect |
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.
Could we perhaps turn tests like these into golden tests? It is difficult to review what's going on here.
Co-authored-by: fendor <[email protected]>
Co-authored-by: fendor <[email protected]>
Co-authored-by: fendor <[email protected]>
…upport-nested-configuration
Thanks for the review @fendor. This indeed is hard to review with all the type level fiddling. I've adjusted the test and add a comment, see if it is better? |
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.
LGTM, thanks!
…upport-nested-configuration
The implementation closely aligns with the original design, extensively incorporating existing code to minimize workload costs. The new API maintains a consistent style with the old API, which remains unchanged.
Features
With new expose stuff:
KeyNamePath
-- path to search for propertiesdefinePropertiesProperty
-- define nested propertyusePropertyByPath
-- extract property by pathusePropertyByPathEither
-- same as aboveusePropertyByPathAction
-- action api forusePropertyByPath
HasPropertyByPath
-- constraint for usingusePropertyByPath
like theHasProperty
We can now define properties upon properties to create nested one. And use KeyNamePath to retrieve the property
To retrieve we can have
Todo list:
This should close #3944, old api would remains the same.