-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Make ReflectiveConfig.Section
implement ValueTreeNode.Section
#49
base: master
Are you sure you want to change the base?
Conversation
This fixes a holdover from the old WrappedConfig system which tried to hide the "internal" representations entirely. Fixes QuiltMC#44
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.
I also think InternalsHelper should be moved to the impl package, but that is nothing new introduced by this pr
@@ -39,6 +41,31 @@ public ReflectiveConfigCreator(Class<C> creatorClass) { | |||
this.creatorClass = creatorClass; | |||
} | |||
|
|||
public static class SectionMarker { |
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.
Im not sure if we should use metadata for pure implementation details. You can get all metadata an elements holds, so it would leak implementation details I think.
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.
Yeah, I'm not a huge fan of it either, but this was a quick fix and trying to keep track of this information in the creator looked like a pain. I could take a look at doing that in the future, but I'm not sure when I'll have the time...
InternalsHelper cannot be moved to the impl package because its whole purpose is to access package private code |
for (ValueTreeNode node : config.nodes()) { | ||
if (node instanceof ValueTreeNode.Section) { | ||
ValueTreeNode.Section section = (ValueTreeNode.Section) node; | ||
ReflectiveConfigCreator.SectionMarker marker = section.metadata(ReflectiveConfigCreator.SectionMarker.TYPE); | ||
if (marker != null) { | ||
marker.self.setWrappedSection(section); | ||
} | ||
} | ||
} |
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.
IMO this should either be put into ReflectiveConfig.setWrappedConfig
, or into the impl package with another setWrappedSection
in here.
This fixes a holdover from the old WrappedConfig system which tried to hide the "internal" representations entirely.
Fixes #44
Passes tests but has not otherwise been tested.