Be a bit more restrictive in the negative lookahead for properties#117
Merged
DustinCampbell merged 1 commit intodotnet:masterfrom May 14, 2018
Merged
Be a bit more restrictive in the negative lookahead for properties#117DustinCampbell merged 1 commit intodotnet:masterfrom
DustinCampbell merged 1 commit intodotnet:masterfrom
Conversation
Fixes dotnet#75 and dotnet#115 There is a bit of negative lookahead for properties to avoid matching nested types as property declarations. Consider the following code: ```C# class Outer { class Inner { } } ``` When the line "class Inner" is matched it really looks like a property declaration where the type is "class" and the name is "Inner". So, there's negative lookahead to ensure that properties can't start with "class" or other keywords. Before this change, the lookahead was matching `.*(class|event|etc...)`, which was too permissive and allowed it to eat up comments. This change adjusts the lookahead to `[[:word:][:space:]]*(class|event|etc...)` to make it a little less restrictive. In addition, there was a spurious `\s*` after the negative lookahead that seems like it was only there to help distinguish field and property declarations. This is more properly handled by just ordering the rules differently (putting properties first) and removing the `\s*`.
DustinCampbell
added a commit
to DustinCampbell/vscode
that referenced
this pull request
May 14, 2018
This grammar update fixes an issue with comments after property declarations solved by dotnet/csharp-tmLanguage#117.
This file contains hidden or 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
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.
Fixes #75 and #115
There is a bit of negative lookahead for properties to avoid matching nested types as property declarations. Consider the following code:
When the line "class Inner" is matched it really looks like a property declaration where the type is "class" and the name is "Inner". So, there's negative lookahead to ensure that properties can't start with "class" or other keywords.
Before this change, the lookahead was matching
.*(class|event|etc...), which was too permissive and allowed it to eat up comments. This change adjusts the lookahead to[[:word:][:space:]]*(class|event|etc...)to make it a little less restrictive.In addition, there was a spurious
\s*after the negative lookahead that seems like it was only there to help distinguish field and property declarations. This is more properly handled by just ordering the rules differently (putting properties first) and removing the\s*.