2
2
// Licensed under the MIT License.
3
3
4
4
using System . Collections . Generic ;
5
- using System . IO ;
6
5
using System . Threading ;
7
6
using System . Threading . Tasks ;
8
7
using Microsoft . Extensions . Logging ;
9
8
using Microsoft . PowerShell . EditorServices . Services ;
10
9
using Microsoft . PowerShell . EditorServices . Services . Symbols ;
11
10
using Microsoft . PowerShell . EditorServices . Services . TextDocument ;
12
11
using Microsoft . PowerShell . EditorServices . Utility ;
13
- using OmniSharp . Extensions . LanguageServer . Protocol ;
14
12
using OmniSharp . Extensions . LanguageServer . Protocol . Client . Capabilities ;
15
13
using OmniSharp . Extensions . LanguageServer . Protocol . Document ;
16
14
using OmniSharp . Extensions . LanguageServer . Protocol . Models ;
@@ -48,7 +46,6 @@ public override async Task<SymbolInformationOrDocumentSymbolContainer> Handle(Do
48
46
_logger . LogDebug ( $ "Handling document symbols for { request . TextDocument . Uri } ") ;
49
47
50
48
ScriptFile scriptFile = _workspaceService . GetFile ( request . TextDocument . Uri ) ;
51
- string containerName = Path . GetFileNameWithoutExtension ( scriptFile . FilePath ) ;
52
49
List < SymbolInformationOrDocumentSymbol > symbols = new ( ) ;
53
50
54
51
foreach ( SymbolReference r in ProvideDocumentSymbols ( scriptFile ) )
@@ -70,27 +67,15 @@ public override async Task<SymbolInformationOrDocumentSymbolContainer> Handle(Do
70
67
continue ;
71
68
}
72
69
73
- // TODO: This should be a DocumentSymbol now as SymbolInformation is deprecated. But
74
- // this requires figuring out how to populate `children`. Once we do that, the range
75
- // can be NameRegion.
76
- //
77
- // symbols.Add(new SymbolInformationOrDocumentSymbol(new DocumentSymbol
78
- // {
79
- // Name = SymbolTypeUtils.GetDecoratedSymbolName(r),
80
- // Kind = SymbolTypeUtils.GetSymbolKind(r.SymbolType),
81
- // Range = r.ScriptRegion.ToRange(),
82
- // SelectionRange = r.NameRegion.ToRange()
83
- // }));
84
- symbols . Add ( new SymbolInformationOrDocumentSymbol ( new SymbolInformation
70
+ // TODO: This now needs the Children property filled out to support hierarchical
71
+ // symbols, and we don't have the information nor algorithm to do that currently.
72
+ // OmniSharp was previously doing this for us based on the range, perhaps we can
73
+ // find that logic and reuse it.
74
+ symbols . Add ( new SymbolInformationOrDocumentSymbol ( new DocumentSymbol
85
75
{
86
- ContainerName = containerName ,
87
76
Kind = SymbolTypeUtils . GetSymbolKind ( r . Type ) ,
88
- Location = new Location
89
- {
90
- Uri = DocumentUri . From ( r . FilePath ) ,
91
- // Jump to name start, but keep whole range to support symbol tree in outline
92
- Range = new Range ( r . NameRegion . ToRange ( ) . Start , r . ScriptRegion . ToRange ( ) . End )
93
- } ,
77
+ Range = r . ScriptRegion . ToRange ( ) ,
78
+ SelectionRange = r . NameRegion . ToRange ( ) ,
94
79
Name = r . Name
95
80
} ) ) ;
96
81
}
0 commit comments