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

feat(vocabulary): vocab support for map in vocab auto generation #74

Merged

Conversation

sanketshevkar
Copy link
Member

@sanketshevkar sanketshevkar commented Nov 17, 2023

Closes #69

Changes

  • added visitor methods for map-declaration. map-key, map-value

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:branchname

@coveralls
Copy link

Coverage Status

coverage: 98.924% (+0.007%) from 98.917%
when pulling 6ac890d on sanketshevkar:sanketshevkar/i69/vocab-map-codegen
into e22a321 on accordproject:main.

const mapDeclarationName = mapDeclaration.getName();
const mapDeclarationVocabulary = VocabularyManager.englishMissingTermGenerator(null, null, mapDeclarationName);

parameters.fileWriter.writeLine(0, ` - ${mapDeclarationName}: ${mapDeclarationVocabulary}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the whitespaces before these lines standard? i.e., if this is adding to an existing vocab yaml file, will it be at the same indentation level as the one in the yaml file?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we support passing an existing YAML file to this. The purpose of VocabularyVistitor is just to bootstrap a new .voc file.

@@ -54,6 +54,10 @@ class VocabularyVisitor {
return this.visitProperty(thing, parameters);
} else if (thing.isEnumValue?.()) {
return this.visitProperty(thing, parameters);
} else if (thing.isKey?.()) {
return this.visitMapKey(thing, parameters);
} else if (thing.isValue?.()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess, it's a bit late to do anything about it now, but isValue looks a lot more generic than it should be. We could have made it like isMapValue, just as we did for declarations. Just a remark, nothing actionable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe to future-proof this, if possible, we can check if the parent of the thing is a map, os something similar to scope this to map declarations only. The same goes for the keys.

Copy link
Member Author

Choose a reason for hiding this comment

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

For now I believe keys and values are only scoped to Maps as of now.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you are suggesting for readability and interpretation, that's why kept the visitor method names as visitMapKey visitMapValue.
I agree with you the method name is very generic.

@jonathan-casey jonathan-casey self-requested a review November 17, 2023 11:31
@jonathan-casey
Copy link
Member

jonathan-casey commented Nov 17, 2023

@sanketshevkar as an aside, you don't necessarily need to use recursion to visit the Map Key & Value, you could do it all within the VisitMapDeclaration and keep things a bit more compact. LGTM, nice work!

@sanketshevkar
Copy link
Member Author

@sanketshevkar as an aside, you don't necessarily need to use recursion to visit the Map Key & Value, you could do it all within the VisitMapDeclaration and keep things a bit more compact. LGTM, nice work!

Thanks @jonathan-casey! Agreed with your suggestion. But I think we will on have two recursive calls inside a map declaration level. Shouldn't cause a big issue I believe.
Shall I go forward with merging the code?

@mttrbrts mttrbrts merged commit 41428ed into accordproject:main Nov 22, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supporting Map type declaration, key and value for vocabulary codegen
5 participants