Skip to content

Add Parser.find_method()/find_methods() - #98

Open
tabatkins wants to merge 3 commits into
plinss:mainfrom
tabatkins:find-methods-better
Open

tabatkins wants to merge 3 commits into
plinss:mainfrom
tabatkins:find-methods-better

Conversation

@tabatkins

Copy link
Copy Markdown
Contributor

Currently, widlparser has Parser.normalized_method_name(), which will search for a method based on the args (but doesn't understand the Foo/bar path syntax), and Parser.find(), which understands the path syntax but ignores arguments.

I was trying to fix speced/bikeshed#1192, and realized the issue was that I was relying on both of these methods having both of the abilities, meaning I was hitting error cases both times!

This PR fixes three things I ran into while debugging this:

  1. Adds support for path syntax in normalized_method_name, if you don't manually pass the interface name as a separate argument. That is, Foo/bar(arg) will now work, rather than falling down to the final error case because there's no method named Foo/bar.
  2. Makes find() and find_all() use a consistent ordering. Not strictly required for this, but it bugged me that find() gave the last result in the parser while find_all() gave them in order. Generally, foo() should be equivalent to foo_all()[0]. I can snip this commit out if you really want.
  3. Adds a find_method() (and find_methods()) method to Parser, which uses the full parser-normalization and argument usage of normalized_method_name, but returns the actual matching construct.

I'm considering making find() and find_all() dispatch to find_method() if it finds any parentheses, and only doing its current "remove/ignore parens and just look for a name" if that fails to find anything. I haven't added that in yet, tho.

I also haven't run the linter yet, apologies. Just wanted to get the patch up for an eye-over before I left for the day.

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.

Can't find arguments of methods

1 participant