-
Notifications
You must be signed in to change notification settings - Fork 10
Better function call matching (also decorators) #17
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
Conversation
Essentially reverts #8, but this is in scope of a bigger change. Also clearly separate built-in functions and built-in types because some used to be duplicated.
The previous attempt just didn't work because of two reasons: 1. The "dotted_name" was already consumed in function-call's "begin" match. 2. All "special" identifiers were essentially matched before the function call which meant that the actual call would never be matched since the function to be called (the identifier) was already consumed. Simplify #dotted_name a bit in the process.
The print statement can now only be matched if it's not used in a function previously since otherwise it would've been consumed.
Forgot about decorators but for some reason I can't get them to work properly right now. Maybe I'll see it after some sleep. Edit: got it in the end |
Although it looked okay-ish with background color it was not intended.
Otherwise, color schemes defining a background color for `entitiy.name.function` would make decorators span the remainder of the line.
Fixed a few regressions, mostly regarding decorators. Test snippet: @normal.decorator
class Class():
@indented(method)#comment
def wrapper(self):
pass |
Sorry about my slow feedback, but I'm really taking my time with this, trying to understand all the changes you're making and if they are in the direction I want to go. Feel free to keep pushing more commits, I'm trying to go through them in order, but alas real work is also interfering 😩 so it may be some time before I accept anything. Thanks for your help, though! |
Sure thing. It's not like I depend on an upstream merge here since I can use my local version just fine, so take your time. I only noticed the regressions as I happend to view a file with lots of decorators that happend to be open while I was testing sublimehq/sublime_text#464. Other than that I think everything's fine. Furthermore, since I now have a feeling of how the syntax is structured I can make other changes more quickly, such as splitting the syntax def into statements and expressions, should I ever feel bored enough to do that. |
Previously, `self.CONSTANT` was not matched.
Or well, it's only valid syntax in Python 3.
Even though we can't really match that correctly, at least match the leading dot on a new line or after a function call. That's more correct. Example: ident = (value.dotted .__init__)
It could be of use for regression testing later, or whatever. In any case it should illustrate most of the changes of my pull request and can easily be extended.
Fixed highlighting of ALL_CAPS constants in dotted names which really annoyed me and addressed a few other issues that just crossed my mind. I also added my personal test file for future reference. It uses the |
poke |
Fixed an annoying regression with It's likely harder to merge this now because you made changes on your own and they are now conflicting. |
@FichteFoll sorry for the huge delay, but I'm finally getting around to thinking about releasing PythonImproved 2.0, and I've incorporated a lot of your changes from this PR into |
Well, pretty much everything in Python is a "dotted name" (because I made the dotted part before the last 'undotted' part just optional). This part would look a lot simpler with contexts from sublime-syntax btw. |
I have the feeling that there are quite a few parts missing which I will look into tomorrow. I'll probably prepare a syntax-test file from my fork and compare that to your unicode branch. |
OK, thanks. I'm hoping to release 2.0 by Sunday at the latest (probably quickly followed by 2.0.1, etc.) to coincide with the release of Python 3.5. After that we can talk about making a |
I prepared a syntax test file from my previously used test file and pushed it to the branch. Notable issues with your unicode branch (visible in testfile):
So yeah, it's probably 80% of my work that's still missing. I honestly do not feel like revisiting this again. You just took too long to merge the changes I made and made too many changes on the main and unicode branch in the meantime so that merging will be a hassle. Instead, I will most likely work on a new |
I'm going to close this, mainly for the reasons you mentioned above - it's no longer mergeable, and things have just moved on. I think working on a I've started #54 to track |
None that I know of, sadly. I made a pretty nice YAML syntax definition and submitted it to the packages repo 4 months ago (sublimehq/Packages#90), but no word since. My end goal would be to have a neutral, comprehensive and accurate Python.sublime-syntax that was bundled with Sublime Text by default, but so far I'm hesitant due to the lack of updates. Yet, I think of how I would structure it at least twice a week. |
Definitely understandable. I'll work on it now and again just to learn how the format works, but I'm certainly not expecting a rush effort on PI to push it out the door. |
Nice, I didn't know about this. I will have to try it out. |
As discussed in #16, I finally worked on the function call matching that I already thought of in #8.
Following is a snippet that I used for testing:
Closes #16.
PS: This is unrelated, but there are a couple of
include: $self
occurences that are technically incorrect because in most of these cases only an expression is allowed. However, the snytax def itself is not grouped into statement vs expression, so the grouping would be a required step for this (and would also add more structure).