diff --git a/src/fsharp/service/SemanticClassification.fs b/src/fsharp/service/SemanticClassification.fs index 0fb348c3e86..a00ac34d90f 100644 --- a/src/fsharp/service/SemanticClassification.fs +++ b/src/fsharp/service/SemanticClassification.fs @@ -28,7 +28,7 @@ type SemanticClassificationType = | Property | MutableVar | Module - | NameSpace + | Namespace | Printf | ComputationExpression | IntrinsicFunction @@ -55,6 +55,7 @@ type SemanticClassificationType = | LocalValue | Type | TypeDef + | Plaintext [] module TcResolutionsExtensions = @@ -164,8 +165,10 @@ module TcResolutionsExtensions = add m SemanticClassificationType.IntrinsicFunction | (Item.Value vref), _, _, _, _, m when isFunction g vref.Type -> - if valRefEq g g.range_op_vref vref || valRefEq g g.range_step_op_vref vref then - () + if isDiscard vref.DisplayName then + add m SemanticClassificationType.Plaintext + elif valRefEq g g.range_op_vref vref || valRefEq g g.range_step_op_vref vref then + add m SemanticClassificationType.Operator elif vref.IsPropertyGetterMethod || vref.IsPropertySetterMethod then add m SemanticClassificationType.Property elif vref.IsMember then @@ -213,21 +216,29 @@ module TcResolutionsExtensions = add m SemanticClassificationType.Property | Item.CtorGroup (_, minfos), _, _, _, _, m -> - if minfos |> List.forall (fun minfo -> isDisposableTy minfo.ApparentEnclosingType) then - add m SemanticClassificationType.DisposableType - elif minfos |> List.forall (fun minfo -> isStructTy g minfo.ApparentEnclosingType) then - add m SemanticClassificationType.ConstructorForValueType - else + match minfos with + | [] -> add m SemanticClassificationType.ConstructorForReferenceType + | _ -> + if minfos |> List.forall (fun minfo -> isDisposableTy minfo.ApparentEnclosingType) then + add m SemanticClassificationType.DisposableType + elif minfos |> List.forall (fun minfo -> isStructTy g minfo.ApparentEnclosingType) then + add m SemanticClassificationType.ConstructorForValueType + else + add m SemanticClassificationType.ConstructorForReferenceType | (Item.DelegateCtor _ | Item.FakeInterfaceCtor _), _, _, _, _, m -> add m SemanticClassificationType.ConstructorForReferenceType | Item.MethodGroup (_, minfos, _), _, _, _, _, m -> - if minfos |> List.forall (fun minfo -> minfo.IsExtensionMember || minfo.IsCSharpStyleExtensionMember) then - add m SemanticClassificationType.ExtensionMethod - else + match minfos with + | [] -> add m SemanticClassificationType.Method + | _ -> + if minfos |> List.forall (fun minfo -> minfo.IsExtensionMember || minfo.IsCSharpStyleExtensionMember) then + add m SemanticClassificationType.ExtensionMethod + else + add m SemanticClassificationType.Method // Special case measures for struct types | Item.Types(_, TType_app(tyconRef, TType_measure _ :: _) :: _), LegitTypeOccurence, _, _, _, m when isStructTyconRef tyconRef -> @@ -295,7 +306,7 @@ module TcResolutionsExtensions = | Item.ModuleOrNamespaces (modref :: _), LegitTypeOccurence, _, _, _, m -> if modref.IsNamespace then - add m SemanticClassificationType.NameSpace + add m SemanticClassificationType.Namespace else add m SemanticClassificationType.Module @@ -331,7 +342,7 @@ module TcResolutionsExtensions = elif tcref.IsModule then add m SemanticClassificationType.Module elif tcref.IsNamespace then - add m SemanticClassificationType.NameSpace + add m SemanticClassificationType.Namespace elif tcref.IsUnionTycon || tcref.IsRecordTycon then if isStructTyconRef tcref then add m SemanticClassificationType.ValueType @@ -351,8 +362,8 @@ module TcResolutionsExtensions = else add m SemanticClassificationType.ReferenceType - | _ -> - ()) + | _, _, _, _, _, m -> + add m SemanticClassificationType.Plaintext) results.AddRange(formatSpecifierLocations |> Array.map (fun (m, _) -> struct(m, SemanticClassificationType.Printf))) results.ToArray() ) diff --git a/src/fsharp/service/SemanticClassification.fsi b/src/fsharp/service/SemanticClassification.fsi index f2447219bd6..13819bfd03d 100644 --- a/src/fsharp/service/SemanticClassification.fsi +++ b/src/fsharp/service/SemanticClassification.fsi @@ -20,7 +20,7 @@ type SemanticClassificationType = | Property | MutableVar | Module - | NameSpace + | Namespace | Printf | ComputationExpression | IntrinsicFunction @@ -47,6 +47,7 @@ type SemanticClassificationType = | LocalValue | Type | TypeDef + | Plaintext /// Extension methods for the TcResolutions type. [] diff --git a/vsintegration/src/FSharp.Editor/Classification/ClassificationDefinitions.fs b/vsintegration/src/FSharp.Editor/Classification/ClassificationDefinitions.fs index 23b265e8f5c..7d4bf7d497d 100644 --- a/vsintegration/src/FSharp.Editor/Classification/ClassificationDefinitions.fs +++ b/vsintegration/src/FSharp.Editor/Classification/ClassificationDefinitions.fs @@ -32,7 +32,7 @@ module internal FSharpClassificationTypes = | SemanticClassificationType.MutableVar -> MutableVar | SemanticClassificationType.DisposableValue -> DisposableValue | SemanticClassificationType.DisposableType -> DisposableType - | SemanticClassificationType.NameSpace -> ClassificationTypeNames.NamespaceName + | SemanticClassificationType.Namespace -> ClassificationTypeNames.NamespaceName | SemanticClassificationType.Printf -> Printf | SemanticClassificationType.Exception | SemanticClassificationType.Module @@ -63,6 +63,7 @@ module internal FSharpClassificationTypes = | SemanticClassificationType.Delegate -> ClassificationTypeNames.DelegateName | SemanticClassificationType.Value -> ClassificationTypeNames.Identifier | SemanticClassificationType.LocalValue -> ClassificationTypeNames.LocalName + | SemanticClassificationType.Plaintext -> ClassificationTypeNames.Text module internal ClassificationDefinitions =