Skip to content

Commit 310358f

Browse files
majochapsfinaki
andauthored
Remove old PatternMatcher copy in favor of built-in one (#14746)
* remove PatternMatcher project * clean up remnants * some formatting * restore Array.Parallel --------- Co-authored-by: Petr <[email protected]>
1 parent 20e4d14 commit 310358f

35 files changed

+19
-5617
lines changed

FSharp.Editor.sln

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.DependencyManager.Nu
1313
EndProject
1414
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Editor", "vsintegration\src\FSharp.Editor\FSharp.Editor.fsproj", "{86E148BE-92C8-47CC-A070-11D769C6D898}"
1515
EndProject
16-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.PatternMatcher", "vsintegration\src\FSharp.PatternMatcher\FSharp.PatternMatcher.csproj", "{4FFA5E03-4128-48C9-8FCD-D7C60729ED74}"
17-
EndProject
1816
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.UIResources", "vsintegration\src\FSharp.UIResources\FSharp.UIResources.csproj", "{DA9495E6-BEAA-42A4-AD3B-170D2005AF4B}"
1917
EndProject
2018
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.VS.FSI", "vsintegration\src\FSharp.VS.FSI\FSharp.VS.FSI.fsproj", "{EAC029EB-4A8F-4966-9B38-60D73D8E20D1}"

VisualFSharp.sln

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResourceFile", "vsintegrati
119119
EndProject
120120
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Build.UnitTests", "tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj", "{400FAB03-786E-40CC-85A8-04B0C2869B14}"
121121
EndProject
122-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.PatternMatcher", "vsintegration\src\FSharp.PatternMatcher\FSharp.PatternMatcher.csproj", "{18227628-DF90-4C47-AF3D-CC72D2EDD986}"
123-
EndProject
124122
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Setup", "Setup", "{6235B3AF-774D-4EA1-8F37-789E767F6368}"
125123
EndProject
126124
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.FSharp.Compiler.MSBuild", "setup\Swix\Microsoft.FSharp.Compiler.MSBuild\Microsoft.FSharp.Compiler.MSBuild.csproj", "{4CBEE353-EB7F-4A47-988B-0070AEB4EE7A}"
@@ -699,18 +697,6 @@ Global
699697
{400FAB03-786E-40CC-85A8-04B0C2869B14}.Release|Any CPU.Build.0 = Release|Any CPU
700698
{400FAB03-786E-40CC-85A8-04B0C2869B14}.Release|x86.ActiveCfg = Release|Any CPU
701699
{400FAB03-786E-40CC-85A8-04B0C2869B14}.Release|x86.Build.0 = Release|Any CPU
702-
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
703-
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Debug|Any CPU.Build.0 = Debug|Any CPU
704-
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Debug|x86.ActiveCfg = Debug|Any CPU
705-
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Debug|x86.Build.0 = Debug|Any CPU
706-
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Proto|Any CPU.ActiveCfg = Release|Any CPU
707-
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Proto|Any CPU.Build.0 = Release|Any CPU
708-
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Proto|x86.ActiveCfg = Release|Any CPU
709-
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Proto|x86.Build.0 = Release|Any CPU
710-
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Release|Any CPU.ActiveCfg = Release|Any CPU
711-
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Release|Any CPU.Build.0 = Release|Any CPU
712-
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Release|x86.ActiveCfg = Release|Any CPU
713-
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Release|x86.Build.0 = Release|Any CPU
714700
{4CBEE353-EB7F-4A47-988B-0070AEB4EE7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
715701
{4CBEE353-EB7F-4A47-988B-0070AEB4EE7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
716702
{4CBEE353-EB7F-4A47-988B-0070AEB4EE7A}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -1098,7 +1084,6 @@ Global
10981084
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B} = {35636A82-401A-4C3A-B2AB-EB7DC5E9C268}
10991085
{0385564F-07B4-4264-AB8A-17C393E9140C} = {F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA}
11001086
{400FAB03-786E-40CC-85A8-04B0C2869B14} = {CFE3259A-2D30-4EB0-80D5-E8B5F3D01449}
1101-
{18227628-DF90-4C47-AF3D-CC72D2EDD986} = {4C7B48D7-19AF-4AE7-9D1D-3BB289D5480D}
11021087
{4CBEE353-EB7F-4A47-988B-0070AEB4EE7A} = {6235B3AF-774D-4EA1-8F37-789E767F6368}
11031088
{6BCFED7A-3F67-4180-B307-C7D69D191D8C} = {6235B3AF-774D-4EA1-8F37-789E767F6368}
11041089
{E93E7D28-1C6B-4E04-BE83-68428CF7E039} = {6235B3AF-774D-4EA1-8F37-789E767F6368}

setup/Swix/Microsoft.FSharp.IDE/Microsoft.FSharp.IDE.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
<_Dependency Include="FSharp.Editor" Version="$(VSAssemblyVersion)" />
2323
<_Dependency Include="FSharp.LanguageService.Base" Version="$(VSAssemblyVersion)" />
2424
<_Dependency Include="FSharp.LanguageService" Version="$(VSAssemblyVersion)" />
25-
<_Dependency Include="FSharp.PatternMatcher" Version="$(VSAssemblyVersion)" />
2625
<_Dependency Include="FSharp.ProjectSystem.Base" Version="$(VSAssemblyVersion)" />
2726
<_Dependency Include="FSharp.ProjectSystem.FSharp" Version="$(VSAssemblyVersion)" />
2827
<_Dependency Include="FSharp.ProjectSystem.PropertyPages" Version="$(VSAssemblyVersion)" />

vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@
146146
<ItemGroup>
147147
<ProjectReference Include="$(FSharpSourcesRoot)\FSharp.Core\FSharp.Core.fsproj" />
148148
<ProjectReference Include="$(FSharpSourcesRoot)\Compiler\FSharp.Compiler.Service.fsproj" />
149-
<ProjectReference Include="..\FSharp.PatternMatcher\FSharp.PatternMatcher.csproj" />
150149
<ProjectReference Include="..\FSharp.UIResources\FSharp.UIResources.csproj" />
151150
<ProjectReference Include="..\FSharp.VS.FSI\FSharp.VS.FSI.fsproj" />
152151
</ItemGroup>

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ open System.Globalization
1313

1414
open Microsoft.CodeAnalysis
1515
open Microsoft.CodeAnalysis.Text
16-
open Microsoft.CodeAnalysis.PatternMatching
1716
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation
1817
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo
18+
open Microsoft.VisualStudio.Text.PatternMatching
1919

20-
open FSharp.Compiler.CodeAnalysis
2120
open FSharp.Compiler.EditorServices
2221
open FSharp.Compiler.Syntax
2322

@@ -172,6 +171,7 @@ module private Utils =
172171
type internal FSharpNavigateToSearchService
173172
[<ImportingConstructor>]
174173
(
174+
patternMatcherFactory: IPatternMatcherFactory
175175
) =
176176

177177
let kindsProvided = ImmutableHashSet.Create(FSharpNavigateToItemKind.Module, FSharpNavigateToItemKind.Class, FSharpNavigateToItemKind.Field, FSharpNavigateToItemKind.Property, FSharpNavigateToItemKind.Method, FSharpNavigateToItemKind.Enum, FSharpNavigateToItemKind.EnumItem) :> IImmutableSet<string>
@@ -229,9 +229,13 @@ type internal FSharpNavigateToSearchService
229229
| PatternMatchKind.Exact -> FSharpNavigateToMatchKind.Exact
230230
| PatternMatchKind.Prefix -> FSharpNavigateToMatchKind.Prefix
231231
| PatternMatchKind.Substring -> FSharpNavigateToMatchKind.Substring
232-
| PatternMatchKind.CamelCase -> FSharpNavigateToMatchKind.Regular
233-
| PatternMatchKind.Fuzzy -> FSharpNavigateToMatchKind.Regular
234-
| _ -> FSharpNavigateToMatchKind.Regular
232+
| PatternMatchKind.CamelCaseExact -> FSharpNavigateToMatchKind.CamelCaseExact
233+
| PatternMatchKind.CamelCasePrefix -> FSharpNavigateToMatchKind.CamelCasePrefix
234+
| PatternMatchKind.CamelCaseNonContiguousPrefix -> FSharpNavigateToMatchKind.CamelCaseNonContiguousPrefix
235+
| PatternMatchKind.CamelCaseSubstring -> FSharpNavigateToMatchKind.CamelCaseSubstring
236+
| PatternMatchKind.CamelCaseNonContiguousSubstring -> FSharpNavigateToMatchKind.CamelCaseNonContiguousSubstring
237+
| PatternMatchKind.Fuzzy -> FSharpNavigateToMatchKind.Fuzzy
238+
| _ -> FSharpNavigateToMatchKind.Fuzzy
235239

236240
interface IFSharpNavigateToSearchService with
237241
member _.SearchProjectAsync(project, _priorityDocuments, searchPattern, kinds, cancellationToken) : Task<ImmutableArray<FSharpNavigateToSearchResult>> =
@@ -250,14 +254,18 @@ type internal FSharpNavigateToSearchService
250254
|> Array.filter (fun x -> x.Name.Length = 1 && String.Equals(x.Name, searchPattern, StringComparison.InvariantCultureIgnoreCase))
251255
else
252256
[| yield! items |> Array.map (fun items -> items.Find(searchPattern)) |> Array.concat
253-
use patternMatcher = new PatternMatcher(searchPattern, allowFuzzyMatching = true)
257+
let patternMatcherOptions = PatternMatcherCreationOptions(
258+
cultureInfo = CultureInfo.CurrentUICulture,
259+
flags = PatternMatcherCreationFlags.AllowFuzzyMatching
260+
)
261+
let patternMatcher = patternMatcherFactory.CreatePatternMatcher(searchPattern, patternMatcherOptions)
254262
yield! items
255263
|> Array.collect (fun item -> item.AllItems)
256-
|> Array.Parallel.collect (fun x ->
257-
patternMatcher.GetMatches(x.LogicalName)
258-
|> Seq.map (fun pm ->
259-
NavigateToSearchResult(x, patternMatchKindToNavigateToMatchKind pm.Kind) :> FSharpNavigateToSearchResult)
260-
|> Seq.toArray) |]
264+
|> Array.Parallel.choose (fun x ->
265+
patternMatcher.TryMatch(x.LogicalName)
266+
|> Option.ofNullable
267+
|> Option.map (fun pm ->
268+
NavigateToSearchResult(x, patternMatchKindToNavigateToMatchKind pm.Kind) :> FSharpNavigateToSearchResult)) |]
261269

262270
return items |> Array.distinctBy (fun x -> x.NavigableItem.Document.Id, x.NavigableItem.SourceSpan)
263271
}

vsintegration/src/FSharp.PatternMatcher/ArrayBuilder.Enumerator.cs

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)