Skip to content
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
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

muirdm
Copy link
Collaborator

@muirdm muirdm commented Oct 6, 2022

Don't ask about v2.

Most things work, but there remain a few issues. A gold star to whomever can find them!

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]()
@muirdm muirdm mentioned this pull request Oct 6, 2022
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.

1 participant