Skip to content

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

Closed
kevmoo wants to merge 1 commit into
masterfrom
analyzer_enum_value_access
Closed

DO NOT SUMBIT: Question: is this a better way to get at enum values via pkg:analyzer?#225
kevmoo wants to merge 1 commit into
masterfrom
analyzer_enum_value_access

Conversation

@kevmoo

@kevmoo kevmoo commented Jun 6, 2018

Copy link
Copy Markdown
Collaborator

@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
Copy Markdown

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

kevmoo commented Jun 7, 2018

Copy link
Copy Markdown
Collaborator Author

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