Skip to content
Merged
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
88 changes: 31 additions & 57 deletions src/fsharp/vs/ServiceConstants.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,38 @@ namespace Microsoft.FSharp.Compiler.SourceCodeServices

module internal ItemDescriptionIcons =

// Hardwired constants from older versions of Visual Studio. These constants were used with Babel and VS internals.
let iIconGroupClass = 0x0000
let iIconGroupConstant = 0x0001
let iIconGroupDelegate = 0x0002
let iIconGroupEnum = 0x0003
let iIconGroupEnumMember = 0x0004
let iIconGroupEvent = 0x0005
let iIconGroupException = 0x0006
let iIconGroupFieldBlue = 0x0007
let iIconGroupInterface = 0x0008 // Absolute = 48
let iIconGroupTextLine = 0x0009
let iIconGroupScript = 0x000a
let iIconGroupScript2 = 0x000b
let iIconGroupMethod = 0x000c
let iIconGroupMethod2 = 0x000d
let iIconGroupModule = 0x000e
let iIconGroupNameSpace = 0x000f // Absolute = 90
let iIconGroupFormula = 0x0010
let iIconGroupProperty = 0x00011
let iIconGroupStruct = 0x00012
let iIconGroupTemplate = 0x00013
let iIconGroupTypedef = 0x00014
let iIconGroupType = 0x00015
let iIconGroupUnion = 0x00016
let iIconGroupVariable = 0x00017
let iIconGroupValueType = 0x00018 // Absolute = 144
let iIconGroupIntrinsic = 0x00019
let iIconGroupError = 0x0001f
let iIconGroupFieldYellow = 0x0020
let iIconGroupMisc1 = 0x00021
let iIconGroupMisc2 = 0x0022
let iIconGroupMisc3 = 0x00023
type GlyphMajor =
| Class = 0x0000
| Constant = 0x0001
| Delegate = 0x0002
| Enum = 0x0003
| EnumMember = 0x0004
| Event = 0x0005
| Exception = 0x0006
| FieldBlue = 0x0007
| Interface = 0x0008 // Absolute = 48
| Method = 0x000c
| Method2 = 0x000d
| Module = 0x000e
| NameSpace = 0x000f // Absolute = 90
| Property = 0x00011
| Struct = 0x00012
| Typedef = 0x00014
| Type = 0x00015
| Union = 0x00016
| Variable = 0x00017
| ValueType = 0x00018 // Absolute = 144
| Error = 0x0001f


type GlyphMinor =
| Special = 0x0002
| Normal = 0x0000





let iIconItemPublic = 0x0000
let iIconItemInternal = 0x0001
let iIconItemSpecial = 0x0002
let iIconItemProtected = 0x0003
let iIconItemPrivate = 0x0004
let iIconItemShortCut = 0x0005
let iIconItemNormal = iIconItemPublic

let iIconBlackBox = 162
let iIconLibrary = 163
let iIconProgram = 164
let iIconWebProgram = 165
let iIconProgramEmpty = 166
let iIconWebProgramEmpty = 167

let iIconComponents = 168
let iIconEnvironment = 169
let iIconWindow = 170
let iIconFolderOpen = 171
let iIconFolder = 172
let iIconArrowRight = 173

let iIconAmbigious = 174
let iIconShadowClass = 175
let iIconShadowMethodPrivate = 176
let iIconShadowMethodProtected = 177
let iIconShadowMethod = 178
let iIconInCompleteSource = 179
95 changes: 49 additions & 46 deletions src/fsharp/vs/ServiceDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,89 +1132,89 @@ module internal ItemDescriptionsImpl =
match repr with
| TFSharpObjectRepr om ->
match om.fsobjmodel_kind with
| TTyconClass -> iIconGroupClass
| TTyconInterface -> iIconGroupInterface
| TTyconStruct -> iIconGroupStruct
| TTyconDelegate _ -> iIconGroupDelegate
| TTyconEnum _ -> iIconGroupEnum
| TRecdRepr _ -> iIconGroupType
| TUnionRepr _ -> iIconGroupUnion
| TTyconClass -> GlyphMajor.Class
| TTyconInterface -> GlyphMajor.Interface
| TTyconStruct -> GlyphMajor.Struct
| TTyconDelegate _ -> GlyphMajor.Delegate
| TTyconEnum _ -> GlyphMajor.Enum
| TRecdRepr _ -> GlyphMajor.Type
| TUnionRepr _ -> GlyphMajor.Union
| TILObjectRepr(_,_,td) ->
match td.tdKind with
| ILTypeDefKind.Class -> iIconGroupClass
| ILTypeDefKind.ValueType -> iIconGroupStruct
| ILTypeDefKind.Interface -> iIconGroupInterface
| ILTypeDefKind.Enum -> iIconGroupEnum
| ILTypeDefKind.Delegate -> iIconGroupDelegate
| TAsmRepr _ -> iIconGroupTypedef
| TMeasureableRepr _-> iIconGroupTypedef
| ILTypeDefKind.Class -> GlyphMajor.Class
| ILTypeDefKind.ValueType -> GlyphMajor.Struct
| ILTypeDefKind.Interface -> GlyphMajor.Interface
| ILTypeDefKind.Enum -> GlyphMajor.Enum
| ILTypeDefKind.Delegate -> GlyphMajor.Delegate
| TAsmRepr _ -> GlyphMajor.Typedef
| TMeasureableRepr _-> GlyphMajor.Typedef
#if EXTENSIONTYPING
| TProvidedTypeExtensionPoint _-> iIconGroupTypedef
| TProvidedNamespaceExtensionPoint _-> iIconGroupTypedef
| TProvidedTypeExtensionPoint _-> GlyphMajor.Typedef
| TProvidedNamespaceExtensionPoint _-> GlyphMajor.Typedef
#endif
| TNoRepr -> iIconGroupClass
| TNoRepr -> GlyphMajor.Class

/// Find the glyph for the given type representation.
let typeToGlyph typ =
if isAppTy denv.g typ then
let tcref = tcrefOfAppTy denv.g typ
tcref.TypeReprInfo |> reprToGlyph
elif isAnyTupleTy denv.g typ then iIconGroupStruct
elif isFunction denv.g typ then iIconGroupDelegate
elif isTyparTy denv.g typ then iIconGroupStruct
else iIconGroupTypedef
elif isAnyTupleTy denv.g typ then GlyphMajor.Struct
elif isFunction denv.g typ then GlyphMajor.Delegate
elif isTyparTy denv.g typ then GlyphMajor.Struct
else GlyphMajor.Typedef


/// Find the glyph for the given value representation.
let ValueToGlyph typ =
if isFunction denv.g typ then iIconGroupMethod
else iIconGroupConstant
if isFunction denv.g typ then GlyphMajor.Method
else GlyphMajor.Constant

/// Find the major glyph of the given named item.
let namedItemToMajorGlyph item =
// This may explore assemblies that are not in the reference set,
// e.g. for type abbreviations to types not in the reference set.
// In this case just use iIconGroupClass.
protectAssemblyExploration iIconGroupClass (fun () ->
// In this case just use GlyphMajor.Class.
protectAssemblyExploration GlyphMajor.Class (fun () ->
match item with
| Item.Value(vref) | Item.CustomBuilder (_,vref) -> ValueToGlyph(vref.Type)
| Item.Types(_,typ::_) -> typeToGlyph (stripTyEqns denv.g typ)
| Item.UnionCase _
| Item.ActivePatternCase _ -> iIconGroupEnumMember
| Item.ExnCase _ -> iIconGroupException
| Item.RecdField _ -> iIconGroupFieldBlue
| Item.ILField _ -> iIconGroupFieldBlue
| Item.Event _ -> iIconGroupEvent
| Item.Property _ -> iIconGroupProperty
| Item.ActivePatternCase _ -> GlyphMajor.EnumMember
| Item.ExnCase _ -> GlyphMajor.Exception
| Item.RecdField _ -> GlyphMajor.FieldBlue
| Item.ILField _ -> GlyphMajor.FieldBlue
| Item.Event _ -> GlyphMajor.Event
| Item.Property _ -> GlyphMajor.Property
| Item.CtorGroup _
| Item.DelegateCtor _
| Item.FakeInterfaceCtor _
| Item.CustomOperation _
| Item.MethodGroup _ -> iIconGroupMethod
| Item.MethodGroup _ -> GlyphMajor.Method
| Item.TypeVar _
| Item.Types _ -> iIconGroupClass
| Item.Types _ -> GlyphMajor.Class
| Item.ModuleOrNamespaces(modref::_) ->
if modref.IsNamespace then iIconGroupNameSpace else iIconGroupModule
| Item.ArgName _ -> iIconGroupVariable
| Item.SetterArg _ -> iIconGroupVariable
| _ -> iIconGroupError)
if modref.IsNamespace then GlyphMajor.NameSpace else GlyphMajor.Module
| Item.ArgName _ -> GlyphMajor.Variable
| Item.SetterArg _ -> GlyphMajor.Variable
| _ -> GlyphMajor.Error)

/// Find the minor glyph of the given named item.
let namedItemToMinorGlyph item =
// This may explore assemblies that are not in the reference set,
// e.g. for type abbreviations to types not in the reference set.
// In this case just use iIconItemNormal.
protectAssemblyExploration iIconItemNormal (fun () ->
// In this case just use GlyphMinor.Normal.
protectAssemblyExploration GlyphMinor.Normal (fun () ->
match item with
| Item.Value(vref) when isFunction denv.g vref.Type -> iIconItemSpecial
| _ -> iIconItemNormal)
| Item.Value(vref) when isFunction denv.g vref.Type -> GlyphMinor.Special
| _ -> GlyphMinor.Normal)

(6 * namedItemToMajorGlyph d) + namedItemToMinorGlyph d
(namedItemToMajorGlyph d, namedItemToMinorGlyph d)


/// An intellisense declaration
[<Sealed>]
type FSharpDeclarationListItem(name, glyph:int, info) =
type FSharpDeclarationListItem(name, glyphMajor:GlyphMajor, glyphMinor:GlyphMinor, info) =
let mutable descriptionTextHolder:FSharpToolTipText option = None
let mutable task = null

Expand Down Expand Up @@ -1259,7 +1259,9 @@ type FSharpDeclarationListItem(name, glyph:int, info) =
| Choice2Of2 result ->
result

member decl.Glyph = glyph
member decl.Glyph = 6 * int glyphMajor + int glyphMinor
member decl.GlyphMajor = glyphMajor
member decl.GlyphMinor = glyphMinor

/// A table of declarations for Intellisense completion
[<Sealed>]
Expand Down Expand Up @@ -1319,11 +1321,12 @@ type FSharpDeclarationListInfo(declarations: FSharpDeclarationListItem[]) =
match itemsWithSameName with
| [] -> failwith "Unexpected empty bag"
| items ->
new FSharpDeclarationListItem(nm, GlyphOfItem(denv,items.Head), Choice1Of2 (items, infoReader, m, denv, reactor, checkAlive)))
let glyphMajor, glyphMinor = GlyphOfItem(denv,items.Head)
new FSharpDeclarationListItem(nm, glyphMajor, glyphMinor, Choice1Of2 (items, infoReader, m, denv, reactor, checkAlive)))

new FSharpDeclarationListInfo(Array.ofList decls)


static member Error msg = new FSharpDeclarationListInfo([| new FSharpDeclarationListItem("<Note>", 0, Choice2Of2 (FSharpToolTipText [FSharpToolTipElement.CompositionError msg])) |] )
static member Error msg = new FSharpDeclarationListInfo([| new FSharpDeclarationListItem("<Note>", GlyphMajor.Error, GlyphMinor.Normal, Choice2Of2 (FSharpToolTipText [FSharpToolTipElement.CompositionError msg])) |] )
static member Empty = new FSharpDeclarationListInfo([| |])

2 changes: 2 additions & 0 deletions src/fsharp/vs/ServiceDeclarations.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ type internal FSharpDeclarationListItem =
member DescriptionTextAsync : Async<FSharpToolTipText>
/// Get the glyph integer for the declaration as used by Visual Studio.
member Glyph : int
member GlyphMajor : ItemDescriptionIcons.GlyphMajor
member GlyphMinor : ItemDescriptionIcons.GlyphMinor

[<Sealed>]
/// Represents a set of declarations in F# source code, with information attached ready for display by an editor.
Expand Down
Loading