diff --git a/src/fsharp/vs/ServiceLexing.fs b/src/fsharp/vs/ServiceLexing.fs index 295a380af14..39c6ea778f8 100755 --- a/src/fsharp/vs/ServiceLexing.fs +++ b/src/fsharp/vs/ServiceLexing.fs @@ -88,6 +88,8 @@ type FSharpTokenColorKind = | Number = 9 | Operator = 10 | TypeName = 11 + | Pattern = 12 + | Module = 13 /// Categorize an action the editor should take in response to a token, e.g. brace matching /// diff --git a/src/fsharp/vs/ServiceLexing.fsi b/src/fsharp/vs/ServiceLexing.fsi index f372449f410..c300c57d810 100755 --- a/src/fsharp/vs/ServiceLexing.fsi +++ b/src/fsharp/vs/ServiceLexing.fsi @@ -53,6 +53,8 @@ type internal FSharpTokenColorKind = | Number = 9 | Operator = 10 | TypeName = 11 + | Pattern = 12 + | Module = 13 /// Gives an indication of what should happen when the token is typed in an IDE type internal FSharpTokenTriggerClass = diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs index 8945c607213..a5df081c9c4 100755 --- a/src/fsharp/vs/service.fs +++ b/src/fsharp/vs/service.fs @@ -1365,12 +1365,25 @@ type TypeCheckInfo | CNR(_, (Item.Value vref), ItemOccurence.Use, _, _, _, m) when valRefEq g g.seq_vref vref -> yield (m, FSharpTokenColorKind.Keyword) // custom builders, custom operations get colored as keywords - | CNR(_, (Item.CustomBuilder _ | Item.CustomOperation _), ItemOccurence.Use, _, _, _, m) -> + | CNR(_, Item.CustomBuilder(_, valRef), ItemOccurence.Use, _, _, _, _) -> + yield (valRef.Range, FSharpTokenColorKind.Keyword) + | CNR(_, Item.CustomOperation _, ItemOccurence.Use, _, _, _, m) -> yield (m, FSharpTokenColorKind.Keyword) // types get colored as types when they occur in syntactic types or custom attributes // typevariables get colored as types when they occur in syntactic types custom builders, custom operations get colored as keywords - | CNR(_, (Item.TypeVar _ | Item.Types _ | Item.UnqualifiedType _) , (ItemOccurence.UseInType | ItemOccurence.UseInAttribute), _, _, _, m) -> + | CNR(_, (Item.TypeVar _ | Item.Types _ | Item.UnqualifiedType _), + (ItemOccurence.UseInType | ItemOccurence.UseInAttribute | ItemOccurence.Binding _), _, _, _, m) -> + yield (m, FSharpTokenColorKind.TypeName) + | CNR(_, Item.CtorGroup _, ItemOccurence.Use, _, _, _, m) -> yield (m, FSharpTokenColorKind.TypeName) + | CNR(_, Item.ModuleOrNamespaces _, ItemOccurence.Binding, _, _, _, m) -> + yield (m, FSharpTokenColorKind.Module) + | CNR(_, Item.UnionCase (UnionCaseInfo (_, r), _), + (ItemOccurence.Binding | ItemOccurence.Implemented | ItemOccurence.Pattern | ItemOccurence.Use | ItemOccurence.UseInType), _, _, _, _) -> + yield (r.Range, FSharpTokenColorKind.Pattern) + | CNR(_, Item.ActivePatternCase _, + (ItemOccurence.Binding | ItemOccurence.Implemented | ItemOccurence.Pattern | ItemOccurence.Use | ItemOccurence.UseInType), _, _, _, m) -> + yield (m, FSharpTokenColorKind.Pattern) | _ -> () |] member x.ScopeResolutions = sResolutions diff --git a/vsintegration/src/FSharp.Editor/ColorizationService.fs b/vsintegration/src/FSharp.Editor/ColorizationService.fs index e4ae973b2ee..4964075fd10 100644 --- a/vsintegration/src/FSharp.Editor/ColorizationService.fs +++ b/vsintegration/src/FSharp.Editor/ColorizationService.fs @@ -51,7 +51,10 @@ type internal FSharpColorizationService() = | FSharpTokenColorKind.PreprocessorKeyword -> ClassificationTypeNames.PreprocessorKeyword | FSharpTokenColorKind.Operator -> ClassificationTypeNames.Operator | FSharpTokenColorKind.TypeName -> ClassificationTypeNames.ClassName - | FSharpTokenColorKind.Default | _ -> ClassificationTypeNames.Text + | FSharpTokenColorKind.Pattern -> ClassificationTypeNames.EnumName + | FSharpTokenColorKind.Module -> ClassificationTypeNames.ModuleName + | FSharpTokenColorKind.Default + | _ -> ClassificationTypeNames.Text static let scanSourceLine(sourceTokenizer: FSharpSourceTokenizer, textLine: TextLine, lineContents: string, lexState: FSharpTokenizerLexState) : SourceLineData =