-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Scanner(unification) + TryPeek #1463
Scanner(unification) + TryPeek #1463
Conversation
@AlekseyTs Could you please look at this and decide if it is worth moving forward with it? |
@dotnet-bot test this please |
Resubmit within PR #1727 as that PR merge is simpler. |
e2db2e2
to
23a5f87
Compare
Friend Module CharExts | ||
|
||
<Runtime.CompilerServices.Extension> | ||
Friend Function IsAnyOf(c As Char, c0 As Char, c1 As Char) As Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider changing the name to something more descriptive. For example, IsEqualToAny.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about if I add XML documentation to them instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, XML documentation doesn't help at a call site unless you are reading the code in VS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering that LNQ provides the extension method .Any
, I don't the contextual meaning isn't that far of a leap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am simply suggesting to name the methods in such a way so that no leap would be necessary.
@dotnet-bot test this please |
' TODO: do we allow widechars in keywords? | ||
Dim spelling = "As" | ||
AdvanceChar(2) | ||
If fullWidth Then spelling = GetText(2) Else AdvanceChar(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using multi-line If
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've had the feeling that this could be simplified to
AdvanceChar(2)
Return MakeKeyword(SyntaxKind.AsKeyword, "If", precedingTrivia)
or (currently testing)
Return MakeKeyword(SyntaxKind.AsKeyword, GetText(2), precedingTrivia)
but never entirely sure.
Private Function GetText(length As Integer) As String
Debug.Assert(length > 0)
Debug.Assert(CanGet(length - 1))
If length = 1 Then
Return GetNextChar()
End If
Dim str = GetText(_lineBufferOffset, length)
AdvanceChar(length)
Return str
End Function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlekseyTs I've tried both alternatives and both pass the unit test.
So I'm going with the first alternative.
AdvanceChar(2)
Return MakeKeyword(SyntaxKind.AsKeyword, "If", precedingTrivia)
As it calls less code.
This will then apply to the other cases, as well with the appropriate changes.
343a889
to
cc616ed
Compare
@jasonwilliams200OK Done and Thank you for the notes on the rebase. |
👍 |
It makes the vb parser / scanner code a lot nicer to work with. Some section are little more efficient, some occur minor costs for the sake of clarity of code. I've had to resolve merge conflict twice already. |
ch = MakeHalfWidth(ch) | ||
Return ScanTokenFullWidth(precedingTrivia, ch) | ||
If fullWidth Then | ||
Debug.Assert(Not IsDoubleQuote(ch)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debating whether it is worth making this as debug only? It be an empty branch (true) body in release mode..
I think the concerns about overuse of AggressiveInlining should be addressed. I agree with Jared that we should avoid contractions in method names. I am concerned that this PR combines too many changes to be effectively reviewed. |
I agree with @gafter |
@gafter Strange I thought I'd already addressed those, unless the squash zapped them. |
…Exception. Use of string interpolation.
Rename method so it does't use contraction. Remove Inlining Attribute. Restructured and IF statement in ScanTokenCommon
179bf0d
to
711246e
Compare
@dotnet-bot test this please |
@gafter @jaredpar @AlekseyTs @jasonwilliams200OK @ljw1004 Hasn't this been slowly reviewed? over the course of its inception to now, through it varied incarnations. A little tweak there another tweak here, since it involve a delicate part of the VB.net compiler. Even if if doesn't make it into current release, it is worth looking at a future one. I think that progression has had side benefits, of us discovering other issues, gotchas and problems in the language specification. |
@AdamSpeight2008 Because this pull request is so large, and has been presented in numerous revisions, I have no idea which parts have been reviewed and which not, and which parts have outstanding issues. It is too large for us to reasonably scan through it to answer such questions. I'd prefer to see such changes presented in a series of separate PRs each focused on a particular set of issues. |
@AdamSpeight2008 I do not have any idea why @jasonwilliams200OK was giving you instructions of what to do with this PR. |
@gafter They were helping me reduce the number of commits ( I think it was in the region of 20) in PR, since I seem to break thing when I do git commands. |
Quick overview of concern and issues
@gafter wrote:
|
@AlekseyTs Can you please make an executive decision as to whether we want to move forward with this PR, or instead close it and request that the submitter re-submit smaller more focused PRs for the elements of it? |
Again?! True it's a big PR. The |
@AdamSpeight2008 Not again. Still. One reason for the decreasing number of review comments and changes is that some reviewers have grown tired of re-reviewing thousands of lines of code multiple times as you revise the PR. This code has not been reviewed since any of the last 10 revisions (perhaps more), and I am not motivated to review it again because it is so large and keeps changing out from under me. In any case, my question was for @AlekseyTs. |
@gafter Oh don't treat me like a doormat, to be walked all over. It's not like the
See it from me side.
Merge conflict as the 2nd contains the older methods. Thus I have rebase if
Merge conflict as the unified method doesn't contain the use of TryParse. Thus require addition commit / rebase. Either way I'm screwed i terms merge conflicts Alternative this
Wouldn't it be simpler for everyone to have one PR (this one)? |
The issue with this PR is that it's a collection of changes rather than a single change to the scanner:
Combining all of these changes into a single PR, and a large one at that, makes it significantly costlier for the Roslyn team to review and verify. The ask from @gafter, which I completely agree with, is for the PR to be broken into smaller focused PRs. In its current form I don't see any way we could merge this PR into the source tree:
There is a general question as to whether we would take the refactoring of the Scanner even if it was separated out from the rest of the change. Some of the pattern changes, like I do want to thank you for pushing on this change. We are interested in adding value to our code bases and cleaning up parts of our code base which have gone stale. I appreciate that you've put a good deal of effort into this PR and are trying to add value to our code base. But in its current form it's not possible for us to accept it for the reasons listed above. Given all of this I'm closing this PR. |
This pull request unifies the contents of
TryScanToken
andScanTokenFullWidth
.I retain those methods so not the break existing calls to them. The internals now call a common implementation method
ScanTokenCommon
.This reduces the size of the sourcecode and the resulting IL (Debug)