Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit f5af861

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Remove duplicated navigation bar items for properties with getters and setters (dotnet#2146)
* remove duplicated navigation bar items for properties with getters and setters * fix glyphs for class let bindings * better navigation bar glyphs * fix accessibility for members and let bindings
1 parent 9d4e537 commit f5af861

File tree

2 files changed

+74
-36
lines changed

2 files changed

+74
-36
lines changed

Common/CommonHelpers.fs

Lines changed: 72 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -377,30 +377,6 @@ module internal CommonHelpers =
377377
| -1 | 0 -> span
378378
| index -> TextSpan(span.Start + index + 1, text.Length - index - 1)
379379

380-
let glyphMajorToRoslynGlyph = function
381-
| GlyphMajor.Class
382-
| GlyphMajor.Typedef
383-
| GlyphMajor.Type
384-
| GlyphMajor.Exception -> Glyph.ClassPublic
385-
| GlyphMajor.Constant -> Glyph.ConstantPublic
386-
| GlyphMajor.Delegate -> Glyph.DelegatePublic
387-
| GlyphMajor.Union
388-
| GlyphMajor.Enum -> Glyph.EnumPublic
389-
| GlyphMajor.EnumMember
390-
| GlyphMajor.Variable
391-
| GlyphMajor.FieldBlue -> Glyph.FieldPublic
392-
| GlyphMajor.Event -> Glyph.EventPublic
393-
| GlyphMajor.Interface -> Glyph.InterfacePublic
394-
| GlyphMajor.Method
395-
| GlyphMajor.Method2 -> Glyph.MethodPublic
396-
| GlyphMajor.Module -> Glyph.ModulePublic
397-
| GlyphMajor.NameSpace -> Glyph.Namespace
398-
| GlyphMajor.Property -> Glyph.PropertyPublic
399-
| GlyphMajor.Struct
400-
| GlyphMajor.ValueType -> Glyph.StructurePublic
401-
| GlyphMajor.Error -> Glyph.Error
402-
| _ -> Glyph.None
403-
404380
[<RequireQualifiedAccess; NoComparison>]
405381
type internal SymbolDeclarationLocation =
406382
| CurrentDocument
@@ -410,6 +386,7 @@ type internal SymbolDeclarationLocation =
410386
module internal Extensions =
411387
open System
412388
open System.IO
389+
open Microsoft.FSharp.Compiler.Ast
413390

414391
type System.IServiceProvider with
415392
member x.GetService<'T>() = x.GetService(typeof<'T>) :?> 'T
@@ -526,4 +503,74 @@ module internal Extensions =
526503
| Some declRange -> declRange.FileName = this.RangeAlternate.FileName
527504
| _ -> false
528505

529-
isPrivate && declaredInTheFile
506+
isPrivate && declaredInTheFile
507+
508+
type FSharpNavigationDeclarationItem with
509+
member x.RoslynGlyph : Glyph =
510+
match x.GlyphMajor with
511+
| GlyphMajor.Class
512+
| GlyphMajor.Typedef
513+
| GlyphMajor.Type
514+
| GlyphMajor.Exception ->
515+
match x.Access with
516+
| Some SynAccess.Private -> Glyph.ClassPrivate
517+
| Some SynAccess.Internal -> Glyph.ClassInternal
518+
| _ -> Glyph.ClassPublic
519+
| GlyphMajor.Constant ->
520+
match x.Access with
521+
| Some SynAccess.Private -> Glyph.ConstantPrivate
522+
| Some SynAccess.Internal -> Glyph.ConstantInternal
523+
| _ -> Glyph.ConstantPublic
524+
| GlyphMajor.Delegate ->
525+
match x.Access with
526+
| Some SynAccess.Private -> Glyph.DelegatePrivate
527+
| Some SynAccess.Internal -> Glyph.DelegateInternal
528+
| _ -> Glyph.DelegatePublic
529+
| GlyphMajor.Union
530+
| GlyphMajor.Enum ->
531+
match x.Access with
532+
| Some SynAccess.Private -> Glyph.EnumPrivate
533+
| Some SynAccess.Internal -> Glyph.EnumInternal
534+
| _ -> Glyph.EnumPublic
535+
| GlyphMajor.EnumMember
536+
| GlyphMajor.Variable
537+
| GlyphMajor.FieldBlue ->
538+
match x.Access with
539+
| Some SynAccess.Private -> Glyph.FieldPrivate
540+
| Some SynAccess.Internal -> Glyph.FieldInternal
541+
| _ -> Glyph.FieldPublic
542+
| GlyphMajor.Event ->
543+
match x.Access with
544+
| Some SynAccess.Private -> Glyph.EventPrivate
545+
| Some SynAccess.Internal -> Glyph.EventInternal
546+
| _ -> Glyph.EventPublic
547+
| GlyphMajor.Interface ->
548+
match x.Access with
549+
| Some SynAccess.Private -> Glyph.InterfacePrivate
550+
| Some SynAccess.Internal -> Glyph.InterfaceInternal
551+
| _ -> Glyph.InterfacePublic
552+
| GlyphMajor.Method
553+
| GlyphMajor.Method2 ->
554+
match x.Access with
555+
| Some SynAccess.Private -> Glyph.MethodPrivate
556+
| Some SynAccess.Internal -> Glyph.MethodInternal
557+
| _ -> Glyph.MethodPublic
558+
| GlyphMajor.Module ->
559+
match x.Access with
560+
| Some SynAccess.Private -> Glyph.ModulePrivate
561+
| Some SynAccess.Internal -> Glyph.ModuleInternal
562+
| _ -> Glyph.ModulePublic
563+
| GlyphMajor.NameSpace -> Glyph.Namespace
564+
| GlyphMajor.Property ->
565+
match x.Access with
566+
| Some SynAccess.Private -> Glyph.PropertyPrivate
567+
| Some SynAccess.Internal -> Glyph.PropertyInternal
568+
| _ -> Glyph.PropertyPublic
569+
| GlyphMajor.Struct
570+
| GlyphMajor.ValueType ->
571+
match x.Access with
572+
| Some SynAccess.Private -> Glyph.StructurePrivate
573+
| Some SynAccess.Internal -> Glyph.StructureInternal
574+
| _ -> Glyph.StructurePublic
575+
| GlyphMajor.Error -> Glyph.Error
576+
| _ -> Glyph.None

Navigation/NavigationBarItemService.fs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,9 @@ type internal FSharpNavigationBarItemService
6161
|> Array.choose (fun decl ->
6262
rangeToTextSpan(decl.Range)
6363
|> Option.map(fun textSpan ->
64-
NavigationBarSymbolItem(
65-
decl.Name,
66-
CommonHelpers.glyphMajorToRoslynGlyph(decl.GlyphMajor),
67-
[| textSpan |],
68-
null)
69-
:> NavigationBarItem))
64+
NavigationBarSymbolItem(decl.Name, decl.RoslynGlyph, [| textSpan |], null) :> NavigationBarItem))
7065

71-
NavigationBarSymbolItem(
72-
topLevelDecl.Declaration.Name,
73-
CommonHelpers.glyphMajorToRoslynGlyph(topLevelDecl.Declaration.GlyphMajor),
74-
[| topLevelTextSpan |],
75-
childItems)
66+
NavigationBarSymbolItem(topLevelDecl.Declaration.Name, topLevelDecl.Declaration.RoslynGlyph, [| topLevelTextSpan |], childItems)
7667
:> NavigationBarItem)) :> IList<_>
7768
}
7869
|> Async.map (Option.defaultValue emptyResult)

0 commit comments

Comments
 (0)