You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will make VSCode always complain about the !!python/object tag simply because its not an exact match. I have tried several values for yaml.customTags including:
but none work due to the CommonTagImpl not utilizing the test field that ScalarTag provides in the yaml module used by this module. Unfortunately CollectionTag doesnt support test, but if we had a custom Composer class that overrides the next generator to look at the token that is passed in and add the value of the tag to our options.customTags if it matches then that would be sufficient I think. A crude and incomplete example being:
classCustomComposerextendsComposer{regexTags: RegexTag[]schema: Schema// yaml.Schema, should be the same schema used in the private option options.schema*next(token: Token){// check token tag and if it matches our internal list of regexTags// if it matches add it to schema.tagssuper.next(token);}}
Describe the solution you would like
Some way to allow a user to specify that a custom tag is using a prefix/regex. I have looked briefly at the code and it seems that most cases just do simple tag parsing like:
which given the use of .split(' ') could mean that there could be code that checks for options after [1] and does some additional parsing for it. A simple example being:
// assuming a tag of "!!python/object:.* mapping regex"consttypeInfo=tag.split(' ');consttagName=typeInfo[0];consttagType=(typeInfo[1]&&typeInfo[1].toLowerCase())||'scalar';constoptions=typeInfo.slice(2);if(options.includes("regex")){// some code to handle regex tags here}
Im not saying this is 100% the best solution, but it is backwards compatible with how custom tags have been working. Some alternatives might involve changing the structure of yaml.customTags entirely to accept mappings or similar which is also valid, albeit more work.
The text was updated successfully, but these errors were encountered:
Is your enhancement related to a problem? Please describe.
Currently there is no way to provide support for matching tags based on a prefix or regex pattern.
A trivial example being straight from pyyaml:
This will make VSCode always complain about the
!!python/object
tag simply because its not an exact match. I have tried several values foryaml.customTags
including:but none work due to the CommonTagImpl not utilizing the
test
field that ScalarTag provides in theyaml
module used by this module. UnfortunatelyCollectionTag
doesnt supporttest
, but if we had a customComposer
class that overrides thenext
generator to look at thetoken
that is passed in and add the value of the tag to ouroptions.customTags
if it matches then that would be sufficient I think. A crude and incomplete example being:Describe the solution you would like
Some way to allow a user to specify that a custom tag is using a prefix/regex. I have looked briefly at the code and it seems that most cases just do simple tag parsing like:
which given the use of
.split(' ')
could mean that there could be code that checks for options after[1]
and does some additional parsing for it. A simple example being:Im not saying this is 100% the best solution, but it is backwards compatible with how custom tags have been working. Some alternatives might involve changing the structure of
yaml.customTags
entirely to accept mappings or similar which is also valid, albeit more work.The text was updated successfully, but these errors were encountered: