More accurate token group for the right side of the scoped expression #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is a suggestion to add a designated token group for the right side of the ScopedExpression.
The goal is to be able to distinguish between the left and right sides of a scoped expression when describing the
styleTagsrules. This is needed to colorize properties and method calls in both objects and class uniformly. For example, take this code:If I want to colorize the "property", I may use the following rules in
styleTags(https://github.com/codemirror/lang-php/blob/main/src/php.ts#L48):The side effect of this solution is that the
Namemay be in both the left and right parts of the expression. And while in 99% of cases ofMemberExpressionthis can be mitigated by styling VariableName (that is very likely inside the left part), there's no workaround for ScopedExpression. Most of ScopedExpressions are justScopedExpression(Name, Name).The proposed solution changes that to
ScopedExpression(Name, ClassMemberName(Name)). This way you can describestyleTagsas:...and reach the desired effect.
If you think there's a better way, please suggest it and I'll send the updated code.
Seems like a good idea, thanks.
Do you want me to send a pull request to update the lang-php
styleTagsaccordingly?That'd be wonderful, yes.
There you go: https://github.com/codemirror/lang-php/pull/1