Skip to content

Fix #140: Identify nameless given declarations #144

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

Merged
merged 1 commit into from
Sep 9, 2020

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@@ -708,7 +708,7 @@ export const scalaTmLanguage: TmLanguage = {
name: 'meta.package.scala'
},
{
match: `\\b(given)\\b\\s*(?:\\b(as)\\b|(${idUpper})|(${backQuotedId}|(?!//|/\\*)${plainid})?)`,
match: `\\b(given)\\b\\s*(?:\\b(as)\\b|(${idUpper})(?=.+\\bas\\b)|(${backQuotedId}(?=.+\\bas\\b)|(?!//|/\\*)${plainid}(?=.+\\bas\\b))?)`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.+ can be too greedy, and make the regex match just because there is an as later on the line (e.g. given foo = ???; given Bar as bar, where foo is highlighted incorrectly).

I dont think we need \b\s*, we can just use \s+, which also allows us to remove the \b before the first (as).

Copy link
Contributor Author

@nicolasstucki nicolasstucki Sep 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored it and added support for multiple given definitions in a single line.

Copy link
Contributor

@MaximeKjaer MaximeKjaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@MaximeKjaer MaximeKjaer merged commit 858627f into scala:master Sep 9, 2020
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.

Class name not highlighted in given
2 participants