Skip to content

Commit

Permalink
Remove old PatternMatcher copy in favor of built-in one (#14746)
Browse files Browse the repository at this point in the history
* remove PatternMatcher project

* clean up remnants

* some formatting

* restore Array.Parallel

---------

Co-authored-by: Petr <psfinaki@users.noreply.github.com>
  • Loading branch information
majocha and psfinaki authored Feb 28, 2023
1 parent 20e4d14 commit 310358f
Show file tree
Hide file tree
Showing 35 changed files with 19 additions and 5,617 deletions.
2 changes: 0 additions & 2 deletions FSharp.Editor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.DependencyManager.Nu
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Editor", "vsintegration\src\FSharp.Editor\FSharp.Editor.fsproj", "{86E148BE-92C8-47CC-A070-11D769C6D898}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.PatternMatcher", "vsintegration\src\FSharp.PatternMatcher\FSharp.PatternMatcher.csproj", "{4FFA5E03-4128-48C9-8FCD-D7C60729ED74}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.UIResources", "vsintegration\src\FSharp.UIResources\FSharp.UIResources.csproj", "{DA9495E6-BEAA-42A4-AD3B-170D2005AF4B}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.VS.FSI", "vsintegration\src\FSharp.VS.FSI\FSharp.VS.FSI.fsproj", "{EAC029EB-4A8F-4966-9B38-60D73D8E20D1}"
Expand Down
15 changes: 0 additions & 15 deletions VisualFSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ResourceFile", "vsintegrati
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Build.UnitTests", "tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj", "{400FAB03-786E-40CC-85A8-04B0C2869B14}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FSharp.PatternMatcher", "vsintegration\src\FSharp.PatternMatcher\FSharp.PatternMatcher.csproj", "{18227628-DF90-4C47-AF3D-CC72D2EDD986}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Setup", "Setup", "{6235B3AF-774D-4EA1-8F37-789E767F6368}"
EndProject
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}"
Expand Down Expand Up @@ -699,18 +697,6 @@ Global
{400FAB03-786E-40CC-85A8-04B0C2869B14}.Release|Any CPU.Build.0 = Release|Any CPU
{400FAB03-786E-40CC-85A8-04B0C2869B14}.Release|x86.ActiveCfg = Release|Any CPU
{400FAB03-786E-40CC-85A8-04B0C2869B14}.Release|x86.Build.0 = Release|Any CPU
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Debug|x86.ActiveCfg = Debug|Any CPU
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Debug|x86.Build.0 = Debug|Any CPU
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Proto|Any CPU.ActiveCfg = Release|Any CPU
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Proto|Any CPU.Build.0 = Release|Any CPU
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Proto|x86.ActiveCfg = Release|Any CPU
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Proto|x86.Build.0 = Release|Any CPU
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Release|Any CPU.ActiveCfg = Release|Any CPU
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Release|Any CPU.Build.0 = Release|Any CPU
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Release|x86.ActiveCfg = Release|Any CPU
{18227628-DF90-4C47-AF3D-CC72D2EDD986}.Release|x86.Build.0 = Release|Any CPU
{4CBEE353-EB7F-4A47-988B-0070AEB4EE7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4CBEE353-EB7F-4A47-988B-0070AEB4EE7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CBEE353-EB7F-4A47-988B-0070AEB4EE7A}.Debug|x86.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -1098,7 +1084,6 @@ Global
{FF76BD3C-5E0A-4752-B6C3-044F6E15719B} = {35636A82-401A-4C3A-B2AB-EB7DC5E9C268}
{0385564F-07B4-4264-AB8A-17C393E9140C} = {F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA}
{400FAB03-786E-40CC-85A8-04B0C2869B14} = {CFE3259A-2D30-4EB0-80D5-E8B5F3D01449}
{18227628-DF90-4C47-AF3D-CC72D2EDD986} = {4C7B48D7-19AF-4AE7-9D1D-3BB289D5480D}
{4CBEE353-EB7F-4A47-988B-0070AEB4EE7A} = {6235B3AF-774D-4EA1-8F37-789E767F6368}
{6BCFED7A-3F67-4180-B307-C7D69D191D8C} = {6235B3AF-774D-4EA1-8F37-789E767F6368}
{E93E7D28-1C6B-4E04-BE83-68428CF7E039} = {6235B3AF-774D-4EA1-8F37-789E767F6368}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<_Dependency Include="FSharp.Editor" Version="$(VSAssemblyVersion)" />
<_Dependency Include="FSharp.LanguageService.Base" Version="$(VSAssemblyVersion)" />
<_Dependency Include="FSharp.LanguageService" Version="$(VSAssemblyVersion)" />
<_Dependency Include="FSharp.PatternMatcher" Version="$(VSAssemblyVersion)" />
<_Dependency Include="FSharp.ProjectSystem.Base" Version="$(VSAssemblyVersion)" />
<_Dependency Include="FSharp.ProjectSystem.FSharp" Version="$(VSAssemblyVersion)" />
<_Dependency Include="FSharp.ProjectSystem.PropertyPages" Version="$(VSAssemblyVersion)" />
Expand Down
1 change: 0 additions & 1 deletion vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
<ItemGroup>
<ProjectReference Include="$(FSharpSourcesRoot)\FSharp.Core\FSharp.Core.fsproj" />
<ProjectReference Include="$(FSharpSourcesRoot)\Compiler\FSharp.Compiler.Service.fsproj" />
<ProjectReference Include="..\FSharp.PatternMatcher\FSharp.PatternMatcher.csproj" />
<ProjectReference Include="..\FSharp.UIResources\FSharp.UIResources.csproj" />
<ProjectReference Include="..\FSharp.VS.FSI\FSharp.VS.FSI.fsproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ open System.Globalization

open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.Text
open Microsoft.CodeAnalysis.PatternMatching
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.Navigation
open Microsoft.CodeAnalysis.ExternalAccess.FSharp.NavigateTo
open Microsoft.VisualStudio.Text.PatternMatching

open FSharp.Compiler.CodeAnalysis
open FSharp.Compiler.EditorServices
open FSharp.Compiler.Syntax

Expand Down Expand Up @@ -172,6 +171,7 @@ module private Utils =
type internal FSharpNavigateToSearchService
[<ImportingConstructor>]
(
patternMatcherFactory: IPatternMatcherFactory
) =

let kindsProvided = ImmutableHashSet.Create(FSharpNavigateToItemKind.Module, FSharpNavigateToItemKind.Class, FSharpNavigateToItemKind.Field, FSharpNavigateToItemKind.Property, FSharpNavigateToItemKind.Method, FSharpNavigateToItemKind.Enum, FSharpNavigateToItemKind.EnumItem) :> IImmutableSet<string>
Expand Down Expand Up @@ -229,9 +229,13 @@ type internal FSharpNavigateToSearchService
| PatternMatchKind.Exact -> FSharpNavigateToMatchKind.Exact
| PatternMatchKind.Prefix -> FSharpNavigateToMatchKind.Prefix
| PatternMatchKind.Substring -> FSharpNavigateToMatchKind.Substring
| PatternMatchKind.CamelCase -> FSharpNavigateToMatchKind.Regular
| PatternMatchKind.Fuzzy -> FSharpNavigateToMatchKind.Regular
| _ -> FSharpNavigateToMatchKind.Regular
| PatternMatchKind.CamelCaseExact -> FSharpNavigateToMatchKind.CamelCaseExact
| PatternMatchKind.CamelCasePrefix -> FSharpNavigateToMatchKind.CamelCasePrefix
| PatternMatchKind.CamelCaseNonContiguousPrefix -> FSharpNavigateToMatchKind.CamelCaseNonContiguousPrefix
| PatternMatchKind.CamelCaseSubstring -> FSharpNavigateToMatchKind.CamelCaseSubstring
| PatternMatchKind.CamelCaseNonContiguousSubstring -> FSharpNavigateToMatchKind.CamelCaseNonContiguousSubstring
| PatternMatchKind.Fuzzy -> FSharpNavigateToMatchKind.Fuzzy
| _ -> FSharpNavigateToMatchKind.Fuzzy

interface IFSharpNavigateToSearchService with
member _.SearchProjectAsync(project, _priorityDocuments, searchPattern, kinds, cancellationToken) : Task<ImmutableArray<FSharpNavigateToSearchResult>> =
Expand All @@ -250,14 +254,18 @@ type internal FSharpNavigateToSearchService
|> Array.filter (fun x -> x.Name.Length = 1 && String.Equals(x.Name, searchPattern, StringComparison.InvariantCultureIgnoreCase))
else
[| yield! items |> Array.map (fun items -> items.Find(searchPattern)) |> Array.concat
use patternMatcher = new PatternMatcher(searchPattern, allowFuzzyMatching = true)
let patternMatcherOptions = PatternMatcherCreationOptions(
cultureInfo = CultureInfo.CurrentUICulture,
flags = PatternMatcherCreationFlags.AllowFuzzyMatching
)
let patternMatcher = patternMatcherFactory.CreatePatternMatcher(searchPattern, patternMatcherOptions)
yield! items
|> Array.collect (fun item -> item.AllItems)
|> Array.Parallel.collect (fun x ->
patternMatcher.GetMatches(x.LogicalName)
|> Seq.map (fun pm ->
NavigateToSearchResult(x, patternMatchKindToNavigateToMatchKind pm.Kind) :> FSharpNavigateToSearchResult)
|> Seq.toArray) |]
|> Array.Parallel.choose (fun x ->
patternMatcher.TryMatch(x.LogicalName)
|> Option.ofNullable
|> Option.map (fun pm ->
NavigateToSearchResult(x, patternMatchKindToNavigateToMatchKind pm.Kind) :> FSharpNavigateToSearchResult)) |]

return items |> Array.distinctBy (fun x -> x.NavigableItem.Document.Id, x.NavigableItem.SourceSpan)
}
Expand Down
55 changes: 0 additions & 55 deletions vsintegration/src/FSharp.PatternMatcher/ArrayBuilder.Enumerator.cs

This file was deleted.

Loading

0 comments on commit 310358f

Please sign in to comment.