Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd719c97

Browse files
cartermpKevinRansom
authored andcommitted
Implement new NavigateToSearchService interface (dotnet#5573)
* Implement new NavigateToSearchService interface* Fully implement interface* Move hashset to let binding
1 parentf4c00d1 commitd719c97

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

‎vsintegration/src/FSharp.Editor/Navigation/NavigateToSearchService.fs‎

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,24 +182,31 @@ module private Utils =
182182

183183
typePerDocumentSavedData={ Hash:int; Items:Index.IIndexedNavigableItems}
184184

185-
[<ExportLanguageService(typeof<INavigateToSearchService>, FSharpConstants.FSharpLanguageName); Shared>]
185+
[<ExportLanguageService(typeof<INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate>, FSharpConstants.FSharpLanguageName); Shared>]
186186
typeinternalFSharpNavigateToSearchService
187187
[<ImportingConstructor>]
188188
(
189189
checkerProvider: FSharpCheckerProvider,
190190
projectInfoManager: FSharpProjectOptionsManager
191191
)=
192192

193+
letkindsProvided= ImmutableHashSet.Create(NavigateToItemKind.Module, NavigateToItemKind.Class, NavigateToItemKind.Field, NavigateToItemKind.Property, NavigateToItemKind.Method, NavigateToItemKind.Enum, NavigateToItemKind.EnumItem):> IImmutableSet<string>
194+
193195
// Save the backing navigation data in a memory cache held in a sliding window
194196
letitemsByDocumentId=new MemoryCache("FSharp.Editor.FSharpNavigateToSearchService")
195197

196-
letgetNavigableItems(document:Document,parsingOptions:FSharpParsingOptions)=
198+
letgetNavigableItems(document:Document,parsingOptions:FSharpParsingOptions,kinds:IImmutableSet<string>)=
197199
async{
198200
let!cancellationToken= Async.CancellationToken
199201
let!sourceText= document.GetTextAsync(cancellationToken)|> Async.AwaitTask
200202
let!parseResults= checkerProvider.Checker.ParseFile(document.FilePath, sourceText.ToString(), parsingOptions)
203+
204+
letnavItems parsedInput=
205+
NavigateTo.getNavigableItems parsedInput
206+
|> Array.filter(fun i-> kinds.Contains(navigateToItemKindToRoslynKind i.Kind))
207+
201208
return
202-
match parseResults.ParseTree|> Option.mapNavigateTo.getNavigableItemswith
209+
match parseResults.ParseTree|> Option.mapnavItemswith
203210
| Some items->
204211
[|for itemin itemsdo
205212
match RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, item.Range)with
@@ -212,7 +219,7 @@ type internal FSharpNavigateToSearchService
212219
| None->[||]
213220
}
214221

215-
letgetCachedIndexedNavigableItems(document:Document,parsingOptions:FSharpParsingOptions)=
222+
letgetCachedIndexedNavigableItems(document:Document,parsingOptions:FSharpParsingOptions,kinds:IImmutableSet<string>)=
216223
async{
217224
let!cancellationToken= Async.CancellationToken
218225
let!textVersion= document.GetTextVersionAsync(cancellationToken)|> Async.AwaitTask
@@ -221,7 +228,7 @@ type internal FSharpNavigateToSearchService
221228
match itemsByDocumentId.Get(key)with
222229
|:? PerDocumentSavedData as data when data.Hash= textVersionHash-> return data.Items
223230
|_->
224-
let!items= getNavigableItems(document, parsingOptions)
231+
let!items= getNavigableItems(document, parsingOptions, kinds)
225232
letindexedItems= Index.build items
226233
letdata={ Hash= textVersionHash; Items= indexedItems}
227234
letcacheItem= CacheItem(key, data)
@@ -237,20 +244,20 @@ type internal FSharpNavigateToSearchService
237244
| PatternMatchKind.Fuzzy-> NavigateToMatchKind.Regular
238245
|_-> NavigateToMatchKind.Regular
239246

240-
interfaceINavigateToSearchServicewith
241-
member__.SearchProjectAsync(project,searchPattern,cancellationToken):Task<ImmutableArray<INavigateToSearchResult>>=
247+
interfaceINavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdatewith
248+
member__.SearchProjectAsync(project,searchPattern,kinds,cancellationToken):Task<ImmutableArray<INavigateToSearchResult>>=
242249
asyncMaybe{
243250
let!parsingOptions,_site,_options= projectInfoManager.TryGetOptionsForProject(project.Id)
244251
let!items=
245252
project.Documents
246-
|> Seq.map(fun document-> getCachedIndexedNavigableItems(document, parsingOptions))
253+
|> Seq.map(fun document-> getCachedIndexedNavigableItems(document, parsingOptions, kinds))
247254
|> Async.Parallel
248255
|> liftAsync
249256

250257
letitems=
251258
if searchPattern.Length=1then
252259
items
253-
|> Array.map(fun items-> items.Find(searchPattern))
260+
|> Array.map(fun items-> items.Find(searchPattern))
254261
|> Array.concat
255262
|> Array.filter(fun x-> x.Name.Length=1&& String.Equals(x.Name, searchPattern, StringComparison.InvariantCultureIgnoreCase))
256263
else
@@ -270,12 +277,16 @@ type internal FSharpNavigateToSearchService
270277
|> Async.map Seq.toImmutableArray
271278
|> RoslynHelpers.StartAsyncAsTask(cancellationToken)
272279

273-
member__.SearchDocumentAsync(document,searchPattern,cancellationToken):Task<ImmutableArray<INavigateToSearchResult>>=
280+
member__.SearchDocumentAsync(document,searchPattern,kinds,cancellationToken):Task<ImmutableArray<INavigateToSearchResult>>=
274281
asyncMaybe{
275282
let!parsingOptions,_,_= projectInfoManager.TryGetOptionsForDocumentOrProject(document)
276-
let!items= getCachedIndexedNavigableItems(document, parsingOptions)|> liftAsync
283+
let!items= getCachedIndexedNavigableItems(document, parsingOptions, kinds)|> liftAsync
277284
return items.Find(searchPattern)
278285
}
279286
|> Async.map(Option.defaultValue[||])
280287
|> Async.map Seq.toImmutableArray
281-
|> RoslynHelpers.StartAsyncAsTask(cancellationToken)
288+
|> RoslynHelpers.StartAsyncAsTask(cancellationToken)
289+
290+
member__.KindsProvided= kindsProvided
291+
292+
member__.CanFilter=true

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp