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

Rename commonly used method to a shorter version. #1627

Closed
wants to merge 7 commits into from

Conversation

AdamSpeight2008
Copy link
Contributor

Rename commonly used method to a shorter version. To aid in source code.readability.

Previously New Name
CanGetCharAtOffset CanGet
PeekAheadChar Peek
PeakChar Peek

No formatting changes.

…de readability.

CanGetCharAtOffset -> CanGet
PeekAheadChar -> Peek
PeakChar -> Peek
PeekAheadChar(6) = "T"c AndAlso
PeekAheadChar(7) = "A"c AndAlso
PeekAheadChar(8) = "["c Then
If CanGet(8) AndAlso
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider using NextAre(3,"CDATA[") as the condition.

@AdamSpeight2008
Copy link
Contributor Author

Note To Self
Look at adding and using NextIs and NextAre

Thought a lot of these were implemented in #1001

@gafter
Copy link
Member

gafter commented Mar 27, 2015

I'm a little overwhelmed with the volume of comments already existing on this PR. It looks like there are enough self-reported issues that you should revise the code before we review it.

@AdamSpeight2008
Copy link
Contributor Author

@gafter Yah I self-reported as I though that I'd already implemented them, but I was think of my personal one. So I fix up those, and post and update. The other PR can be reviewed as that I ain't going go near it, till a yay or a nay. :-).

Modified ScannerXML to use NextAre and NextIs, the remaining candidates are mostly suitable for TryPeek (not yet implemented)
Fixed the failing `Debug.Assert`s that used `AreNext(0, " ")` as the failure was being cause by CanGet looking to far ahead (off by one)
@AdamSpeight2008
Copy link
Contributor Author

@gafter Ready for review.
Also note there will be a small number of merge conflicts that revolve around the methods affected by #1463, irrespective of the order that they apply / merge into master

@gafter
Copy link
Member

gafter commented Mar 27, 2015

@dotnet-bot Test this please.

@AdamSpeight2008
Copy link
Contributor Author

I'm retesting on my machine.

@AdamSpeight2008
Copy link
Contributor Author

@gafter I've fixed the failing test.

If CanGetCharAtOffset(Here + 2) AndAlso _
PeekAheadChar(Here + 1) = "]"c AndAlso _
PeekAheadChar(Here + 2) = ">"c Then
If NextAre(Here + 2,"]>") Then
Copy link
Member

Choose a reason for hiding this comment

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

What is going on here? Why is this Here + 2 instead of Here + 1 ?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see you've already fixed this.

@gafter
Copy link
Member

gafter commented Mar 27, 2015

@AlekseyTs How does this look to you?

@@ -390,21 +390,35 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax

#Region "Buffer helpers"

Private Function NextAre(chars As String) As Boolean
Debug.Assert(Not String.IsNullOrEmpty(chars))
Dim n = chars.Length-1
Copy link
Contributor

Choose a reason for hiding this comment

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

The "-1" doesn't seem right to me. Consider that this should be equivalent to NextAre(0, chars)
The "-1" should be on the upper bound of the For loop on line 397

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pharring I'll retest it with NextAre(0, chars) as this method's implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pharring Result 6 failures, if we use AreNext(0, chars)
So this could suggest that the implementation of AreNext is incorrect.
If it is, it likely to do with this check.
If Not CanGet(offset + n) Then Return False
so I'll try
If Not CanGet(offset + n-1) Then Return False

and retest.

@AdamSpeight2008
Copy link
Contributor Author

@pharring I've modified AreNext to correctly check the CanGet, it was off by one. Strange that it passed the unit tests.

Next
Return True
End Function

Private Function CanGetChar() As Boolean
Private Function NextIs(offset As Integer, c As String) As Boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like parameter 'c' should be a Char rather than a String.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AlekseyTs I'll fix the method signature

@AlekseyTs
Copy link
Contributor

Other than the NextIs signature, LGTM.

@gafter gafter closed this in 9ec063a Mar 31, 2015
@gafter gafter removed the 4 - In Review A fix for the issue is submitted for review. label Mar 31, 2015
@AdamSpeight2008 AdamSpeight2008 mentioned this pull request Dec 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants