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

Commit2eb9a96

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Use Roslyn's PatternMatcher in Navigate To service (dotnet#2344)
* add PatternMatcher project* use PatternMatcher in NavigateToSearchService* replace Dictionary with ConcurrentDictionary in IncrementalBuild* fix PatternMatcher target framework* add PatternMatcher to OS VSIX* update System.Collections.Immutable to 1.3.1* remove Microsoft.CodeAnalysis.xxx dependencies from PatternMatcher* Revert "update System.Collections.Immutable to 1.3.1"This reverts commit883d462.* remove "solution items" folder* remove Immutable collections dependency from PatternMatcher* sing PatternMatcher* add ProvideCodeBase attribute* move PatternMatcher code to FSharp.LanguageService.Base* Revert "remove Immutable collections dependency from PatternMatcher"This reverts commit23607b1.Conflicts:vsintegration/Vsix/VisualFSharpOpenSource/Source.extension.vsixmanifestvsintegration/src/PatternMatcher/Properties/AssemblyInfo.cs* fix compilation* remove duplicates from navigate to results* remove duplicates from navigate to results by document id* make all types in PatternMatcher internal to make tests happy
1 parent6d55acc commit2eb9a96

File tree

34 files changed

+6183
-10
lines changed

34 files changed

+6183
-10
lines changed

‎src/fsharp/vs/IncrementalBuild.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ module internal IncrementalBuild =
507507
/// Visit each executable action necessary to evaluate the given output (with an optional slot in a
508508
/// vector output). Call actionFunc with the given accumulator.
509509
letForeachAction ctok(Target(output,optSlot))bt(actionFunc:Action->'T->'T)(acc:'T)=
510-
letseen=Dictionary<Id,bool>()
510+
letseen=System.Collections.Concurrent.ConcurrentDictionary<Id,bool>()
511511
letisSeen id=
512512
if seen.ContainsKey idthentrue
513513
else

‎vsintegration/Vsix/VisualFSharpOpenSource/Source.extension.vsixmanifest‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
<ActionType="Ngen"Path="FSharp.ProjectSystem.PropertyPages.dll" />
2828
<ActionType="Ngen"Path="FSharp.VS.FSI.dll" />
2929
</Actions>
30-
- </Installer>
30+
-
31+
</Installer>
3132
<Dependencies>
3233
<DependencyId="Microsoft.Framework.NDP"DisplayName="Microsoft .NET Framework"d:Source="Manual"Version="[4.6,)" />
3334
</Dependencies>
@@ -63,6 +64,6 @@
6364
<AssetType="Microsoft.VisualStudio.MefComponent"d:Source="Project"d:ProjectName="ProjectSystem.Base"Path="|ProjectSystem.Base|" />
6465
</Assets>
6566
<Prerequisites>
66-
<PrerequisiteId="Microsoft.VisualStudio.Component.CoreEditor"Version="[15.0,16.0)"DisplayName="Visual Studio core editor" />
67+
<PrerequisiteId="Microsoft.VisualStudio.Component.CoreEditor"Version="[15.0,16.0)"DisplayName="Visual Studio core editor" />
6768
</Prerequisites>
6869
</PackageManifest>

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ open Microsoft.CodeAnalysis.Options
2020
openMicrosoft.CodeAnalysis.Text
2121
openMicrosoft.CodeAnalysis.NavigateTo
2222
openMicrosoft.CodeAnalysis.Navigation
23+
openMicrosoft.CodeAnalysis.PatternMatching
2324

2425
openMicrosoft.VisualStudio.FSharp.LanguageService
2526
openMicrosoft.VisualStudio.Text
@@ -81,6 +82,7 @@ module private Index =
8182

8283
typeIIndexedNavigableItems=
8384
abstractFind: searchValue:string->INavigateToSearchResult[]
85+
abstractAllItems:NavigableItem[]
8486

8587
letprivatenavigateToSearchResultComparer=
8688
{new IEqualityComparer<INavigateToSearchResult>with
@@ -94,7 +96,7 @@ module private Index =
9496
if isNull xthen0
9597
else23*(17*23+ x.NavigableItem.Document.Id.GetHashCode())+ x.NavigableItem.SourceSpan.GetHashCode()}
9698

97-
letbuild(items:seq<NavigableItem>)=
99+
letbuild(items:NavigableItem[])=
98100
letentries= ResizeArray()
99101

100102
for itemin itemsdo
@@ -139,7 +141,8 @@ module private Index =
139141
while pos< entries.Count&& entries.[pos].StartsWith searchValuedo
140142
handle pos
141143
pos<- pos+1
142-
Seq.toArray result}
144+
Seq.toArray result
145+
member__.AllItems= items}
143146

144147
moduleprivateUtils=
145148
letnavigateToItemKindToRoslynKind=function
@@ -224,6 +227,14 @@ type internal FSharpNavigateToSearchService
224227
return indexedItems
225228
}
226229

230+
letpatternMatchKindToNavigateToMatchKind=function
231+
| PatternMatchKind.Exact-> NavigateToMatchKind.Exact
232+
| PatternMatchKind.Prefix-> NavigateToMatchKind.Prefix
233+
| PatternMatchKind.Substring-> NavigateToMatchKind.Substring
234+
| PatternMatchKind.CamelCase-> NavigateToMatchKind.Regular
235+
| PatternMatchKind.Fuzzy-> NavigateToMatchKind.Regular
236+
|_-> NavigateToMatchKind.Regular
237+
227238
interface INavigateToSearchServicewith
228239
member__.SearchProjectAsync(project,searchPattern,cancellationToken):Task<ImmutableArray<INavigateToSearchResult>>=
229240
asyncMaybe{
@@ -233,7 +244,17 @@ type internal FSharpNavigateToSearchService
233244
|> Seq.map(fun document-> getCachedIndexedNavigableItems(document, options, cancellationToken))
234245
|> Async.Parallel
235246
|> liftAsync
236-
return items|> Array.map(fun items-> items.Find(searchPattern))|> Array.concat
247+
return
248+
[|yield! items|> Array.map(fun items-> items.Find(searchPattern))|> Array.concat
249+
use patternMatcher=new PatternMatcher(searchPattern, allowFuzzyMatching=true)
250+
yield! items
251+
|> Array.collect(fun item-> item.AllItems)
252+
|> Array.Parallel.collect(fun x->
253+
patternMatcher.GetMatches(x.Name)
254+
|> Seq.map(fun pm->
255+
NavigateToSearchResult(x, patternMatchKindToNavigateToMatchKind pm.Kind):> INavigateToSearchResult)
256+
|> Seq.toArray)|]
257+
|> Array.distinctBy(fun x-> x.NavigableItem.Document.Id, x.NavigableItem.SourceSpan)
237258
}
238259
|> Async.map(Option.defaultValue[||])
239260
|> Async.map(fun x-> x.ToImmutableArray())

‎vsintegration/src/FSharp.LanguageService.Base/FSharp.LanguageService.Base.csproj‎

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@
124124
<ReferenceInclude="Microsoft.VisualStudio.ComponentModelHost, Version=$(RoslynVSBinariesVersion).0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
125125
<HintPath>$(FSharpSourcesRoot)\..\packages\Roslyn.Microsoft.VisualStudio.ComponentModelHost.0.0.2\lib\net46\Microsoft.VisualStudio.ComponentModelHost.dll</HintPath>
126126
</Reference>
127+
<ReferenceInclude="System.Collections.Immutable">
128+
<HintPath>$(FSharpSourcesRoot)\..\packages\System.Collections.Immutable.1.2.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
129+
<Private>True</Private>
130+
</Reference>
127131
<ProjectReferenceInclude="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj">
128132
<Project>{DED3BBD7-53F4-428A-8C9F-27968E768605}</Project>
129133
<Name>FSharp.Core</Name>
@@ -141,6 +145,36 @@
141145
<CompileInclude="ExpansionProvider.cs" />
142146
<CompileInclude="ExternDll.cs" />
143147
<CompileInclude="LanguageService.cs" />
148+
<CompileInclude="PatternMatcher\ArrayBuilder.cs" />
149+
<CompileInclude="PatternMatcher\ArrayBuilder.Enumerator.cs" />
150+
<CompileInclude="PatternMatcher\ArraySlice.cs" />
151+
<CompileInclude="PatternMatcher\BKTree.Builder.cs" />
152+
<CompileInclude="PatternMatcher\BKTree.cs" />
153+
<CompileInclude="PatternMatcher\BKTree.Edge.cs" />
154+
<CompileInclude="PatternMatcher\BKTree.Node.cs" />
155+
<CompileInclude="PatternMatcher\CaseSensitiveComparison.cs" />
156+
<CompileInclude="PatternMatcher\EditDistance.cs" />
157+
<CompileInclude="PatternMatcher\Hash.cs" />
158+
<CompileInclude="PatternMatcher\IDictionaryExtensions.cs" />
159+
<CompileInclude="PatternMatcher\ImmutableArrayExtensions.cs" />
160+
<CompileInclude="PatternMatcher\IObjectWritable.cs" />
161+
<CompileInclude="PatternMatcher\NormalizedTextSpanCollection.cs" />
162+
<CompileInclude="PatternMatcher\ObjectPool.cs" />
163+
<CompileInclude="PatternMatcher\ObjectReader.cs" />
164+
<CompileInclude="PatternMatcher\ObjectWriter.cs" />
165+
<CompileInclude="PatternMatcher\PatternMatch.cs" />
166+
<CompileInclude="PatternMatcher\PatternMatcher.cs" />
167+
<CompileInclude="PatternMatcher\PatternMatcher.Segment.cs" />
168+
<CompileInclude="PatternMatcher\PatternMatcher.TextChunk.cs" />
169+
<CompileInclude="PatternMatcher\PatternMatches.cs" />
170+
<CompileInclude="PatternMatcher\PatternMatchKind.cs" />
171+
<CompileInclude="PatternMatcher\PooledHashSet.cs" />
172+
<CompileInclude="PatternMatcher\PooledStringBuilder.cs" />
173+
<CompileInclude="PatternMatcher\SpellChecker.cs" />
174+
<CompileInclude="PatternMatcher\StringBreaker.cs" />
175+
<CompileInclude="PatternMatcher\StringSlice.cs" />
176+
<CompileInclude="PatternMatcher\TextSpan.cs" />
177+
<CompileInclude="PatternMatcher\VersionStamp.cs" />
144178
<CompileInclude="Properties\AssemblyInfo.cs" />
145179
<CompileInclude="Microsoft.VisualStudio.Package.LanguageService.cs">
146180
<AutoGen>True</AutoGen>
@@ -168,18 +202,16 @@
168202
<LogicalName>Resources.completionset.bmp</LogicalName>
169203
</EmbeddedResource>
170204
</ItemGroup>
171-
172205
<ImportProject="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
173206
<ImportProject="$(FSharpSourcesRoot)\Microbuild.Settings.targets" />
174207
<ImportProject="$(VsSDKInstall)\Microsoft.VsSDK.targets" />
175-
176208
<TargetName="GatherBinariesToBeSigned"AfterTargets="Localize"Condition="'$(UseGatherBinaries)' == 'true'">
177209
<ItemGroup>
178210
<BinariesToBeSignedInclude="$(OutDir)$(AssemblyName).dll" />
179211
<BinariesToBeSignedInclude="$(OutDir)localize\**\$(AssemblyName).resources.dll" />
180212
<FilesToSignInclude="@(BinariesToBeSigned)">
181-
<Authenticode>Microsoft</Authenticode>
182-
<StrongName>StrongName</StrongName>
213+
<Authenticode>Microsoft</Authenticode>
214+
<StrongName>StrongName</StrongName>
183215
</FilesToSign>
184216
</ItemGroup>
185217
</Target>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2+
3+
usingSystem.Collections.Generic;
4+
5+
namespaceMicrosoft.CodeAnalysis
6+
{
7+
internalpartialclassArrayBuilder<T>
8+
{
9+
/// <summary>
10+
/// struct enumerator used in foreach.
11+
/// </summary>
12+
internalstructEnumerator:IEnumerator<T>
13+
{
14+
privatereadonlyArrayBuilder<T>_builder;
15+
privateint_index;
16+
17+
publicEnumerator(ArrayBuilder<T>builder)
18+
{
19+
_builder=builder;
20+
_index=-1;
21+
}
22+
23+
publicTCurrent
24+
{
25+
get
26+
{
27+
return_builder[_index];
28+
}
29+
}
30+
31+
publicboolMoveNext()
32+
{
33+
_index++;
34+
return_index<_builder.Count;
35+
}
36+
37+
publicvoidDispose()
38+
{
39+
}
40+
41+
objectSystem.Collections.IEnumerator.Current
42+
{
43+
get
44+
{
45+
returnthis.Current;
46+
}
47+
}
48+
49+
publicvoidReset()
50+
{
51+
_index=-1;
52+
}
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp