Skip to content

DO NOT SUMBIT: Question: is this a better way to get at enum values via pkg:analyzer? #225

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

Closed
wants to merge 1 commit into from

Conversation

kevmoo
Copy link
Collaborator

@kevmoo kevmoo commented Jun 6, 2018

@scheglov @bwilkerson as you can likely tell be recent issues ( dart-lang/sdk#33373 dart-lang/sdk#33375 ) I'm looking at some code that details with enums.

Look at the diff here. Both before and after have their own code smell – is one preferred? Is there something I'm missing?

Thanks!

@bwilkerson
Copy link

Neither solution is great, but there isn't anything better that I can think of. The element model doesn't differentiate between classes and enums, so there isn't any nice way to get all of the enum constants.

When analyzer moves to the CFE we might not be able to move as easily from the element model back to the AST, so the current code might be slightly better in terms of future-proofing.

One alternative I can think of would be to ask for fields rather than accessors, and then ask whether the field is synthetic. (Everything except the explicitly defined enum constants will be synthetic.) It might be a little more performant because we don't have to test the equality of types, but is fairly equivalent in other ways.

@kevmoo
Copy link
Collaborator Author

kevmoo commented Jun 7, 2018

Thanks, @bwilkerson – opened #227

Would love comments on the other issues I opened.

@kevmoo kevmoo closed this Jun 7, 2018
@kevmoo kevmoo deleted the analyzer_enum_value_access branch June 7, 2018 17:14
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.

2 participants