-
Notifications
You must be signed in to change notification settings - Fork 591
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
[Python] Decorator refactoring #743
Conversation
Also called "qualified names", just like the context is called now. Additionally, add meta scopes for qualified names and generic names for more precise testing.
... and use it to match function calls less explicitly and more magically. Usually you would think this is bad, but it's not because it's not really less explicit. It just avoids repetition when scoping the last (non-special) part of a qualified name with a name other than "meta.generic-name". This change triggers the bug described in sublimehq/sublime_text#1190, where the most-inner context in a multi-push operation *must* match at least one character before it can be popped. Due this, the tests are currently *not* passing.
Adheres to conventions discussed in sublimehq#709 and sublimehq#737.
- match: (?=\.?\s*{{path}}\s*\() # now we do | ||
set: [decorator-function-call-wrapper, qualified-name-until-leaf] | ||
- match: (?=\.?\s*{{path}}) | ||
push: [decorator-wrapper, qualified-name-until-leaf] |
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.
So this (and two lines above) is where you are pushing two contexts, the later of which does not consume anything?
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.
Exactly. The latter may or may not consume something, but due to the bug it always consumes the first character.
Note that after this is merged, https://github.com/FichteForks/Packages/tree/python_unpacking-operators can probably be merged too. It's been a while since I looked into this and I obviously can't test it myself. |
…opes [Python] Decorator refactoring
Requires sublimehq/sublime_text#1190 to be fixed before merging!
When trying to implement proper scoping according to #709 and #737, I noticed that I would have to rebuild almost the entire
function-calls
scope for decorators only with different scope names. Since I religiously hate duplicated code (especially considering I would have to duplicate it twice), I worked on refactoring how qualified names are matched instead andqualified-name-until-leaf
was born.Unfortunately, it is affected by the bug described in sublimehq/sublime_text#1190 and thus is not ready to be merged yet. The following 17 failing tests should be fixed when this bug is fixed:
Note: I am unsure if I split the commits correctly (and tests are passing after each of them).