diff --git a/src/fsharp/TastOps.fs b/src/fsharp/TastOps.fs index 9f784027f9d..cc4d04b6c5f 100644 --- a/src/fsharp/TastOps.fs +++ b/src/fsharp/TastOps.fs @@ -2517,7 +2517,8 @@ let fullNameOfEntityRef nmF xref = | Some pathText -> pathText +.+ nmF xref let tagEntityRefName (xref: EntityRef) name = - if xref.IsNamespace then tagNamespace name + if Set.contains name Lexhelp.Keywords.keywordTypes then tagKeyword name + else if xref.IsNamespace then tagNamespace name else if xref.IsModule then tagModule name else if xref.IsTypeAbbrev then tagAlias name else if xref.IsFSharpDelegateTycon then tagDelegate name diff --git a/src/fsharp/lexhelp.fs b/src/fsharp/lexhelp.fs index f441549997d..503a82e1a80 100644 --- a/src/fsharp/lexhelp.fs +++ b/src/fsharp/lexhelp.fs @@ -298,6 +298,8 @@ module Keywords = let keywordNames = keywordList |> List.map (fun (_, w, _) -> w) + let keywordTypes = StructuredFormat.TaggedTextOps.keywordTypes + let keywordTable = let tab = System.Collections.Generic.Dictionary(100) for _,keyword,token in keywordList do diff --git a/src/fsharp/lexhelp.fsi b/src/fsharp/lexhelp.fsi index 2d427760799..1bf078e64b7 100644 --- a/src/fsharp/lexhelp.fsi +++ b/src/fsharp/lexhelp.fsi @@ -68,3 +68,4 @@ module Keywords = val IdentifierToken : lexargs -> UnicodeLexing.Lexbuf -> string -> Parser.token val QuoteIdentifierIfNeeded : string -> string val keywordNames : string list + val keywordTypes : Set diff --git a/src/fsharp/vs/service.fs b/src/fsharp/vs/service.fs index 2aa7f37d09d..d3b80ac6458 100644 --- a/src/fsharp/vs/service.fs +++ b/src/fsharp/vs/service.fs @@ -1112,36 +1112,7 @@ type TypeCheckInfo else items - let keywordTypes = - [ - "array"; - "bigint"; - "bool"; - "byref"; - "byte"; - "char"; - "decimal"; - "double"; - "float"; - "float32"; - "int"; - "int16"; - "int32"; - "int64"; - "list"; - "nativeint"; - "obj"; - "sbyte"; - "seq"; - "single"; - "string"; - "unit"; - "uint"; - "uint16"; - "uint32"; - "uint64"; - "unativeint" - ] |> Set.ofSeq + static let keywordTypes = Lexhelp.Keywords.keywordTypes /// Get the auto-complete items at a location member x.GetDeclarations (parseResultsOpt, line, lineStr, colAtEndOfNamesAndResidue, qualifyingNames, partialName, hasTextChangedSinceLastTypecheck) = diff --git a/src/utils/sformat.fs b/src/utils/sformat.fs index 5b3fec15df3..b841e5b5b92 100644 --- a/src/utils/sformat.fs +++ b/src/utils/sformat.fs @@ -194,7 +194,37 @@ namespace Microsoft.FSharp.Text.StructuredFormat module TaggedTextOps = #endif let tagAlias = TaggedText.Alias - let tagClass = TaggedText.Class + let keywordTypes = + [ + "array"; + "bigint"; + "bool"; + "byref"; + "byte"; + "char"; + "decimal"; + "double"; + "float"; + "float32"; + "int"; + "int16"; + "int32"; + "int64"; + "list"; + "nativeint"; + "obj"; + "sbyte"; + "seq"; + "single"; + "string"; + "unit"; + "uint"; + "uint16"; + "uint32"; + "uint64"; + "unativeint"; + ] |> Set.ofList + let tagClass name = if Set.contains name keywordTypes then TaggedText.Keyword name else TaggedText.Class name let tagUnionCase = TaggedText.UnionCase let tagDelegate = TaggedText.Delegate let tagEnum = TaggedText.Enum @@ -216,7 +246,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat let tagProperty = TaggedText.Property let tagSpace = TaggedText.Space let tagStringLiteral = TaggedText.StringLiteral - let tagStruct = TaggedText.Struct + let tagStruct name = if Set.contains name keywordTypes then TaggedText.Keyword name else TaggedText.Struct name let tagTypeParameter = TaggedText.TypeParameter let tagText = TaggedText.Text let tagPunctuation = TaggedText.Punctuation @@ -1390,5 +1420,5 @@ namespace Microsoft.FSharp.Text.StructuredFormat #if COMPILER /// Called - let fsi_any_to_layout opts x = anyL ShowTopLevelBinding BindingFlags.Public opts x + let fsi_any_to_layout opts x = anyL ShowTopLevelBinding BindingFlags.Public opts x #endif diff --git a/src/utils/sformat.fsi b/src/utils/sformat.fsi index 789c98aedc8..67eda68473a 100644 --- a/src/utils/sformat.fsi +++ b/src/utils/sformat.fsi @@ -126,6 +126,7 @@ namespace Microsoft.FSharp.Text.StructuredFormat #else #endif TaggedTextOps = + val keywordTypes : Set val tagAlias : string -> TaggedText val tagClass : string -> TaggedText val tagUnionCase : string -> TaggedText