Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/fsharp/vs/ServiceLexing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
2 changes: 2 additions & 0 deletions src/fsharp/vs/ServiceLexing.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
17 changes: 15 additions & 2 deletions src/fsharp/vs/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion vsintegration/src/FSharp.Editor/ColorizationService.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =

Expand Down