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 #400

Closed
wants to merge 5 commits into from
Closed

Conversation

muirdm
Copy link
Collaborator

@muirdm muirdm commented Mar 26, 2022

Attempt to fix some fortification issues with type params

#393

Now at least type param lists don't break the font locking of later
param lists in the signature.
Fontify type names in generic instantiation param lists. We look for
index expressions and fontify the elements as types if one of the
following is true:
 - There is more than one element in the list (e.g. "foo[int, string]").
 - The list is followed by "{" (a composite literal)
   (e.g. "foo[int]{}").
 - The list is preceded by space and then an identifer
   (e.g. "var foo bar[int]").

When in doubt, we don't fontify, so expressions like "foo[int]()" will
not have "int" fontified as a type.
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.
Fix "foo.Bar" to be fontified as a type in "foo.Bar[int, string]{}".
@dominikh
Copy link
Owner

dominikh commented Oct 4, 2022

@muirdm is this ready for merging as is?

@muirdm
Copy link
Collaborator Author

muirdm commented Oct 4, 2022

is this ready for merging

No, I'm not really happy with this. We can peel off just the first commit for now for some relief.

I have a different branch with a somewhat better approach - let me try to get that ready for eyes.

@muirdm
Copy link
Collaborator Author

muirdm commented Oct 6, 2022

I opened #410 that has a better approach where we can "piggyback" on top of the existing type fontification in most cases.

@muirdm muirdm closed this 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.

2 participants