-
Notifications
You must be signed in to change notification settings - Fork 210
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
Generic fontification v3 #410
Open
muirdm
wants to merge
15
commits into
dominikh:master
Choose a base branch
from
muirdm:generic-fontification-v3
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Now at least type param lists don't break the font locking of later param lists in the signature.
This involves a new anchored matcher to iterate over each param in the list.
This uses a cheeky approach where we piggyback off existing type matching. After using the existing matcher to fontify "foo" in make(foo[bar]), we then check if the next char is "[", and if so we know it is a type list, so we fontify it as such. This approach will be used in later commits for all the other simple type matchers.
When fontifying a type list if we see another "[" we presume it is a nested type list and fontify it accordingly.
Now we fontify func names in generic invocations when there are more than one type params (so we can be sure it is a func instantiation). I also tweaked things to avoid fontifying "bar" in (foo)(bar)(baz) (fixes dominikh#385). We also support fontifying method names with type params even though that isn't allowed yet.
For example, we now fontify a, b, c and d as types: map[a[b]]c[d] This required tweaking the map value matcher to allow square brackets to appear in the map key type.
Fix "foo.Bar", "int" and "string" are now fontified as types in "foo.Bar[int, string]{}".
We now fontify "foo" and "bar" as types in: []foo[bar]
We now fontify "baz" as a type: type foo = bar[baz]
"bar" is now fontified as a type in: func _() foo[bar] {} var _ foo[bar]
If there is more than one thing in between "[]", we know it is a type list. Now we fontify "int" and "string" as types in: foo[int, string]()
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Don't ask about v2.
Most things work, but there remain a few issues. A gold star to whomever can find them!