55using System ;
66using System . Collections . Generic ;
77using System . Collections . Immutable ;
8- using System . Diagnostics . CodeAnalysis ;
98using System . IO ;
109using System . Runtime . Serialization ;
1110using System . Threading ;
1615using Microsoft . CodeAnalysis . PooledObjects ;
1716using Microsoft . CodeAnalysis . Shared . Extensions ;
1817using Microsoft . CodeAnalysis . Text ;
19- using Roslyn . Utilities ;
2018
2119namespace Microsoft . CodeAnalysis . NavigateTo
2220{
@@ -108,7 +106,7 @@ private class NavigateToSearchResult : INavigateToSearchResult, INavigableItem
108106 /// <summary>
109107 /// The <see cref="Document"/> that <see cref="_item"/> is contained within.
110108 /// </summary>
111- private readonly Document _itemDocument ;
109+ private readonly INavigableItem . NavigableDocument _itemDocument ;
112110
113111 /// <summary>
114112 /// The document the user was editing when they invoked the navigate-to operation.
@@ -124,35 +122,35 @@ public NavigateToSearchResult(
124122 Document ? activeDocument )
125123 {
126124 _item = item ;
127- _itemDocument = itemDocument ;
125+ _itemDocument = INavigableItem . NavigableDocument . FromDocument ( itemDocument ) ;
128126 if ( activeDocument is not null )
129127 _activeDocument = ( activeDocument . Id , activeDocument . Folders ) ;
130128
131- _additionalInformation = ComputeAdditionalInformation ( ) ;
129+ _additionalInformation = ComputeAdditionalInformation ( in item , itemDocument ) ;
132130 _secondarySort = new Lazy < string > ( ComputeSecondarySort ) ;
133131 }
134132
135- private string ComputeAdditionalInformation ( )
133+ private static string ComputeAdditionalInformation ( in RoslynNavigateToItem item , Document itemDocument )
136134 {
137135 // For partial types, state what file they're in so the user can disambiguate the results.
138- var combinedProjectName = ComputeCombinedProjectName ( ) ;
139- return ( _item . DeclaredSymbolInfo . IsPartial , IsNonNestedNamedType ( ) ) switch
136+ var combinedProjectName = ComputeCombinedProjectName ( in item , itemDocument ) ;
137+ return ( item . DeclaredSymbolInfo . IsPartial , IsNonNestedNamedType ( in item ) ) switch
140138 {
141- ( true , true ) => string . Format ( FeaturesResources . _0_dash_1 , _itemDocument . Name , combinedProjectName ) ,
142- ( true , false ) => string . Format ( FeaturesResources . in_0_1_2 , _item . DeclaredSymbolInfo . ContainerDisplayName , _itemDocument . Name , combinedProjectName ) ,
139+ ( true , true ) => string . Format ( FeaturesResources . _0_dash_1 , itemDocument . Name , combinedProjectName ) ,
140+ ( true , false ) => string . Format ( FeaturesResources . in_0_1_2 , item . DeclaredSymbolInfo . ContainerDisplayName , itemDocument . Name , combinedProjectName ) ,
143141 ( false , true ) => string . Format ( FeaturesResources . project_0 , combinedProjectName ) ,
144- ( false , false ) => string . Format ( FeaturesResources . in_0_project_1 , _item . DeclaredSymbolInfo . ContainerDisplayName , combinedProjectName ) ,
142+ ( false , false ) => string . Format ( FeaturesResources . in_0_project_1 , item . DeclaredSymbolInfo . ContainerDisplayName , combinedProjectName ) ,
145143 } ;
146144 }
147145
148- private string ComputeCombinedProjectName ( )
146+ private static string ComputeCombinedProjectName ( in RoslynNavigateToItem item , Document itemDocument )
149147 {
150148 // If there aren't any additional matches in other projects, we don't need to merge anything.
151- if ( _item . AdditionalMatchingProjects . Length > 0 )
149+ if ( item . AdditionalMatchingProjects . Length > 0 )
152150 {
153151 // First get the simple project name and flavor for the actual project we got a hit in. If we can't
154152 // figure this out, we can't create a merged name.
155- var firstProject = _itemDocument . Project ;
153+ var firstProject = itemDocument . Project ;
156154 var ( firstProjectName , firstProjectFlavor ) = firstProject . State . NameAndFlavor ;
157155
158156 if ( firstProjectName != null )
@@ -165,7 +163,7 @@ private string ComputeCombinedProjectName()
165163 // Now, do the same for the other projects where we had a match. As above, if we can't figure out the
166164 // simple name/flavor, or if the simple project name doesn't match the simple project name we started
167165 // with then we can't merge these.
168- foreach ( var additionalProjectId in _item . AdditionalMatchingProjects )
166+ foreach ( var additionalProjectId in item . AdditionalMatchingProjects )
169167 {
170168 var additionalProject = solution . GetRequiredProject ( additionalProjectId ) ;
171169 var ( projectName , projectFlavor ) = additionalProject . State . NameAndFlavor ;
@@ -181,17 +179,17 @@ private string ComputeCombinedProjectName()
181179 }
182180
183181 // Couldn't compute a merged project name (or only had one project). Just return the name of hte project itself.
184- return _itemDocument . Project . Name ;
182+ return itemDocument . Project . Name ;
185183 }
186184
187185 string INavigateToSearchResult . AdditionalInformation => _additionalInformation ;
188186
189- private bool IsNonNestedNamedType ( )
190- => ! _item . DeclaredSymbolInfo . IsNestedType && IsNamedType ( ) ;
187+ private static bool IsNonNestedNamedType ( in RoslynNavigateToItem item )
188+ => ! item . DeclaredSymbolInfo . IsNestedType && IsNamedType ( in item ) ;
191189
192- private bool IsNamedType ( )
190+ private static bool IsNamedType ( in RoslynNavigateToItem item )
193191 {
194- switch ( _item . DeclaredSymbolInfo . Kind )
192+ switch ( item . DeclaredSymbolInfo . Kind )
195193 {
196194 case DeclaredSymbolInfoKind . Class :
197195 case DeclaredSymbolInfoKind . Record :
@@ -356,7 +354,7 @@ ImmutableArray<TaggedText> INavigableItem.DisplayTaggedParts
356354 /// </summary>
357355 bool INavigableItem . IsImplicitlyDeclared => false ;
358356
359- Document INavigableItem . Document => _itemDocument ;
357+ INavigableItem . NavigableDocument INavigableItem . Document => _itemDocument ;
360358
361359 TextSpan INavigableItem . SourceSpan => _item . DeclaredSymbolInfo . Span ;
362360
0 commit comments