提交 1eae2829 编写于 作者: V Vasily Kirichenko 提交者: Kevin Ransom (msft)

fix range with step operator coloring (#2826)

上级 d0be5fc5
......@@ -1579,7 +1579,8 @@ type TypeCheckInfo
| CNR(_, Item.Value KeywordIntrinsicValue, ItemOccurence.Use, _, _, _, m) ->
Some (m, SemanticClassificationType.IntrinsicFunction)
| CNR(_, (Item.Value vref), _, _, _, _, m) when isFunction g vref.Type ->
if vref.DisplayName = "( .. )" then None // the range operator
if valRefEq g g.range_op_vref vref || valRefEq g g.range_step_op_vref vref then
None
elif vref.IsPropertyGetterMethod || vref.IsPropertySetterMethod then
Some (m, SemanticClassificationType.Property)
elif IsOperatorName vref.DisplayName then
......
......@@ -288,21 +288,48 @@ module internal Tokenizer =
let colorMap = Array.create textLine.Span.Length ClassificationTypeNames.Text
let lineTokenizer = sourceTokenizer.CreateLineTokenizer(lineContents)
let tokens = ResizeArray()
let mutable tokenInfoOption = None
let previousLexState = ref lexState
let scanAndColorNextToken(lineTokenizer: FSharpLineTokenizer, lexState: Ref<FSharpTokenizerLexState>) : Option<FSharpTokenInfo> =
let tokenInfoOption, nextLexState = lineTokenizer.ScanToken(lexState.Value)
lexState.Value <- nextLexState
if tokenInfoOption.IsSome then
let classificationType = compilerTokenToRoslynToken(tokenInfoOption.Value.ColorClass)
for i = tokenInfoOption.Value.LeftColumn to tokenInfoOption.Value.RightColumn do
Array.set colorMap i classificationType
tokens.Add tokenInfoOption.Value
tokenInfoOption
let processToken() =
let classificationType = compilerTokenToRoslynToken(tokenInfoOption.Value.ColorClass)
for i = tokenInfoOption.Value.LeftColumn to tokenInfoOption.Value.RightColumn do
Array.set colorMap i classificationType
tokens.Add tokenInfoOption.Value
let previousLexState = ref lexState
let mutable tokenInfoOption = scanAndColorNextToken(lineTokenizer, previousLexState)
while tokenInfoOption.IsSome do
tokenInfoOption <- scanAndColorNextToken(lineTokenizer, previousLexState)
let scanAndColorNextToken() =
let info, nextLexState = lineTokenizer.ScanToken(!previousLexState)
tokenInfoOption <- info
previousLexState := nextLexState
match info with
| Some info when info.Tag = FSharpTokenTag.INT32_DOT_DOT ->
tokenInfoOption <-
Some { LeftColumn = info.LeftColumn
RightColumn = info.RightColumn - 2
ColorClass = FSharpTokenColorKind.Number
CharClass = FSharpTokenCharKind.Literal
FSharpTokenTriggerClass = info.FSharpTokenTriggerClass
Tag = info.Tag
TokenName = "INT32"
FullMatchedLength = info.FullMatchedLength - 2 }
processToken()
tokenInfoOption <-
Some { LeftColumn = info.RightColumn - 1
RightColumn = info.RightColumn
ColorClass = FSharpTokenColorKind.Operator
CharClass = FSharpTokenCharKind.Operator
FSharpTokenTriggerClass = info.FSharpTokenTriggerClass
Tag = FSharpTokenTag.DOT_DOT
TokenName = "DOT_DOT"
FullMatchedLength = 2 }
processToken()
| Some _ -> processToken()
| _ -> ()
scanAndColorNextToken()
while tokenInfoOption.IsSome do scanAndColorNextToken()
let mutable startPosition = 0
let mutable endPosition = startPosition
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册