1111using EmmyLua . LanguageServer . Framework . Server . Handler ;
1212using Microsoft . CodeAnalysis ;
1313using Microsoft . CodeAnalysis . FindSymbols ;
14- using SymbolKind = Microsoft . CodeAnalysis . SymbolKind ;
1514
1615namespace DotRush . Roslyn . Server . Handlers . TextDocument ;
1716
@@ -31,55 +30,50 @@ public override void RegisterCapability(ServerCapabilities serverCapabilities, C
3130 if ( documentIds == null )
3231 return null ;
3332
34- var displayStrings = new Dictionary < string , List < string > > ( ) ;
33+ var displayDictionary = new Dictionary < string , List < string > > ( ) ;
3534 var documentation = string . Empty ;
3635 foreach ( var documentId in documentIds ) {
3736 var document = navigationService . Solution ? . GetDocument ( documentId ) ;
3837 if ( document == null )
3938 continue ;
4039
4140 var sourceText = await document . GetTextAsync ( token ) . ConfigureAwait ( false ) ;
42- var semanticModel = await document . GetSemanticModelAsync ( token ) . ConfigureAwait ( false ) ;
4341 var offset = request . Position . ToOffset ( sourceText ) ;
4442 var symbol = await SymbolFinder . FindSymbolAtPositionAsync ( document , offset ) . ConfigureAwait ( false ) ;
45- if ( symbol == null || semanticModel == null )
43+ if ( symbol == null )
4644 continue ;
4745
4846 if ( symbol is IAliasSymbol aliasSymbol )
4947 symbol = aliasSymbol . Target ;
5048
51- var displayString = symbol . Kind == SymbolKind . NamedType || symbol . Kind == SymbolKind . Namespace
52- ? symbol . ToDisplayString ( DisplayFormat . Default )
53- : symbol . ToMinimalDisplayString ( semanticModel , offset , DisplayFormat . Minimal ) ;
49+ var format = symbol . Kind == SymbolKind . NamedType || symbol . Kind == SymbolKind . Namespace ? DisplayFormat . Default : DisplayFormat . Minimal ;
50+ var displayString = symbol . ToDisplayString ( format ) ;
51+ if ( ! displayDictionary . ContainsKey ( displayString ) )
52+ displayDictionary [ displayString ] = new List < string > ( ) ;
5453
55- if ( ! displayStrings . ContainsKey ( displayString ) )
56- displayStrings . Add ( displayString , new List < string > ( ) ) ;
54+ displayDictionary [ displayString ] . Add ( document . Project . GetTargetFramework ( ) ) ;
5755
58- displayStrings [ displayString ] . Add ( document . Project . GetTargetFramework ( ) ) ;
5956 if ( string . IsNullOrEmpty ( documentation ) )
6057 documentation = symbol . GetDocumentationCommentXml ( ) ;
6158 }
6259
63- if ( displayStrings . Count == 1 ) {
60+ if ( displayDictionary . Count == 1 ) {
6461 return new HoverResponse {
6562 Contents = new MarkupContent {
6663 Kind = MarkupKind . Markdown ,
67- Value = MarkdownExtensions . CreateDocumentation ( displayStrings . Keys . First ( ) , documentation , "csharp" )
64+ Value = MarkdownExtensions . CreateDocumentation ( displayDictionary . Keys . First ( ) , documentation , "csharp" )
6865 }
6966 } ;
7067 }
7168
72- if ( displayStrings . Count > 1 ) {
69+ if ( displayDictionary . Count > 1 ) {
7370 var builder = new StringBuilder ( ) ;
74- foreach ( var pair in displayStrings ) {
75- var frameworks = string . Join ( ", " , pair . Value ) ;
76- builder . AppendLine ( MarkdownExtensions . CreateDocumentation ( $ "{ pair . Key } ({ frameworks } )", null , "csharp" ) ) ;
77- }
71+ displayDictionary . ForEach ( kv => builder . AppendLine ( $ "{ kv . Key } ({ string . Join ( ", " , kv . Value ) } )") ) ;
7872
7973 return new HoverResponse {
8074 Contents = new MarkupContent {
8175 Kind = MarkupKind . Markdown ,
82- Value = builder . ToString ( )
76+ Value = MarkdownExtensions . CreateDocumentation ( builder . ToString ( ) , null , "csharp" )
8377 }
8478 } ;
8579 }
0 commit comments