Common: Apply distinct to sql placeholders
This commit is contained in:
@@ -57,45 +57,45 @@ Namespace SQLEditor
|
||||
End Sub
|
||||
|
||||
Private Function ParseTokens() As List(Of SyntaxHighlightToken)
|
||||
Dim tokens As New List(Of SyntaxHighlightToken)()
|
||||
Dim ranges() As DocumentRange = Nothing
|
||||
Dim oTokens As New List(Of SyntaxHighlightToken)()
|
||||
Dim oRanges As IEnumerable(Of DocumentRange) = Nothing
|
||||
|
||||
' search for quoted strings
|
||||
ranges = TryCast(document.FindAll(_quotedString).GetAsFrozen(), DocumentRange())
|
||||
For i As Integer = 0 To ranges.Length - 1
|
||||
tokens.Add(CreateToken(ranges(i).Start.ToInt(), ranges(i).End.ToInt(), Color.Red))
|
||||
Next i
|
||||
oRanges = document.FindAll(_quotedString).GetAsFrozen()
|
||||
For Each oRange In oRanges
|
||||
oTokens.Add(CreateToken(oRange.Start.ToInt, oRange.End.ToInt, Color.Red))
|
||||
Next
|
||||
|
||||
'Extract all keywords
|
||||
ranges = TryCast(document.FindAll(_keywords).GetAsFrozen(), DocumentRange())
|
||||
For j As Integer = 0 To ranges.Length - 1
|
||||
If Not IsRangeInTokens(ranges(j), tokens) Then
|
||||
tokens.Add(CreateToken(ranges(j).Start.ToInt(), ranges(j).End.ToInt(), Color.Blue))
|
||||
oRanges = TryCast(document.FindAll(_keywords).GetAsFrozen(), DocumentRange())
|
||||
For Each oRange In oRanges
|
||||
If Not IsRangeInTokens(oRange, oTokens) Then
|
||||
oTokens.Add(CreateToken(oRange.Start.ToInt(), oRange.End.ToInt(), Color.Blue))
|
||||
End If
|
||||
Next j
|
||||
Next
|
||||
|
||||
'Find all placeholders
|
||||
ranges = TryCast(document.FindAll(_placeholderString).GetAsFrozen(), DocumentRange())
|
||||
For j As Integer = 0 To ranges.Length - 1
|
||||
If Not IsRangeInTokens(ranges(j), tokens) Then
|
||||
tokens.Add(CreateToken(ranges(j).Start.ToInt(), ranges(j).End.ToInt(), Color.DarkTurquoise))
|
||||
oRanges = TryCast(document.FindAll(_placeholderString).GetAsFrozen(), DocumentRange())
|
||||
For Each oRange In oRanges
|
||||
If Not IsRangeInTokens(oRange, oTokens) Then
|
||||
oTokens.Add(CreateToken(oRange.Start.ToInt(), oRange.End.ToInt(), Color.DarkTurquoise))
|
||||
End If
|
||||
Next j
|
||||
Next
|
||||
|
||||
'Find all comments
|
||||
ranges = TryCast(document.FindAll(_commentedString).GetAsFrozen(), DocumentRange())
|
||||
For j As Integer = 0 To ranges.Length - 1
|
||||
If Not IsRangeInTokens(ranges(j), tokens) Then
|
||||
tokens.Add(CreateToken(ranges(j).Start.ToInt(), ranges(j).End.ToInt(), Color.Green))
|
||||
oRanges = TryCast(document.FindAll(_commentedString).GetAsFrozen(), DocumentRange())
|
||||
For Each oRange In oRanges
|
||||
If Not IsRangeInTokens(oRange, oTokens) Then
|
||||
oTokens.Add(CreateToken(oRange.Start.ToInt(), oRange.End.ToInt(), Color.Green))
|
||||
End If
|
||||
Next j
|
||||
Next
|
||||
|
||||
' order tokens by their start position
|
||||
tokens.Sort(New SyntaxHighlightTokenComparer())
|
||||
oTokens.Sort(New SyntaxHighlightTokenComparer())
|
||||
|
||||
' fill in gaps in document coverage
|
||||
tokens = CombineWithPlainTextTokens(tokens)
|
||||
Return tokens
|
||||
oTokens = CombineWithPlainTextTokens(oTokens)
|
||||
Return oTokens
|
||||
End Function
|
||||
|
||||
'Parse the remaining text into tokens:
|
||||
@@ -129,8 +129,9 @@ Namespace SQLEditor
|
||||
|
||||
'Create a token from the retrieved range and specify its forecolor
|
||||
Private Function CreateToken(ByVal start As Integer, ByVal [end] As Integer, ByVal foreColor As Color) As SyntaxHighlightToken
|
||||
Dim properties As New SyntaxHighlightProperties()
|
||||
properties.ForeColor = foreColor
|
||||
Dim properties As New SyntaxHighlightProperties With {
|
||||
.ForeColor = foreColor
|
||||
}
|
||||
Return New SyntaxHighlightToken(start, [end] - start, properties)
|
||||
End Function
|
||||
|
||||
|
||||
Reference in New Issue
Block a user