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

Commit2335589

Browse files
Vasily KirichenkoVasily Kirichenko
Vasily Kirichenko
authored and
Vasily Kirichenko
committed
move Unused Opens analyzer core logic to FCS
1 parentbf88499 commit2335589

File tree

12 files changed

+516
-403
lines changed

12 files changed

+516
-403
lines changed

‎fcs/FSharp.Compiler.Service.netstandard/FSharp.Compiler.Service.netstandard.fsproj‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,12 @@
536536
<CompileInclude="$(FSharpSourcesRoot)\fsharp\symbols\Exprs.fs">
537537
<Link>Symbols/Exprs.fs</Link>
538538
</Compile>
539+
<CompileInclude="$(FSharpSourcesRoot)\fsharp\symbols\SymbolPatterns.fsi">
540+
<Link>Symbols/SymbolPatterns.fsi</Link>
541+
</Compile>
542+
<CompileInclude="$(FSharpSourcesRoot)\fsharp\symbols\SymbolPatterns.fs">
543+
<Link>Symbols/SymbolPatterns.fs</Link>
544+
</Compile>
539545
<CompileInclude="$(FSharpSourcesRoot)\fsharp\vs\IncrementalBuild.fsi">
540546
<Link>Service/IncrementalBuild.fsi</Link>
541547
</Compile>
@@ -632,6 +638,12 @@
632638
<CompileInclude="$(FSharpSourcesRoot)\fsharp\vs\ServiceStructure.fs">
633639
<Link>Service/ServiceStructure.fs</Link>
634640
</Compile>
641+
<CompileInclude="$(FSharpSourcesRoot)\fsharp\vs\ServiceAnalysis.fsi">
642+
<Link>Service/ServiceAnalysis.fsi</Link>
643+
</Compile>
644+
<CompileInclude="$(FSharpSourcesRoot)\fsharp\vs\ServiceAnalysis.fs">
645+
<Link>Service/ServiceAnalysis.fs</Link>
646+
</Compile>
635647
<CompileInclude="$(FSharpSourcesRoot)\fsharp\fsi\fsi.fsi">
636648
<Link>Service/fsi.fsi</Link>
637649
</Compile>

‎fcs/FSharp.Compiler.Service/FSharp.Compiler.Service.fsproj‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,12 @@
512512
<CompileInclude="$(FSharpSourcesRoot)\fsharp\symbols\Exprs.fs">
513513
<Link>Symbols/Exprs.fs</Link>
514514
</Compile>
515+
<CompileInclude="$(FSharpSourcesRoot)\fsharp\symbols\SymbolPatterns.fsi">
516+
<Link>Symbols/SymbolPatterns.fsi</Link>
517+
</Compile>
518+
<CompileInclude="$(FSharpSourcesRoot)\fsharp\symbols\SymbolPatterns.fs">
519+
<Link>Symbols/SymbolPatterns.fs</Link>
520+
</Compile>
515521
<CompileInclude="$(FSharpSourcesRoot)\fsharp\vs\IncrementalBuild.fsi">
516522
<Link>Service/IncrementalBuild.fsi</Link>
517523
</Compile>
@@ -608,6 +614,12 @@
608614
<CompileInclude="$(FSharpSourcesRoot)\fsharp\vs\ServiceStructure.fs">
609615
<Link>Service/ServiceStructure.fs</Link>
610616
</Compile>
617+
<CompileInclude="$(FSharpSourcesRoot)\fsharp\vs\ServiceAnalysis.fsi">
618+
<Link>Service/ServiceAnalysis.fsi</Link>
619+
</Compile>
620+
<CompileInclude="$(FSharpSourcesRoot)\fsharp\vs\ServiceAnalysis.fs">
621+
<Link>Service/ServiceAnalysis.fs</Link>
622+
</Compile>
611623
<CompileInclude="$(FSharpSourcesRoot)\fsharp\fsi\fsi.fsi">
612624
<Link>Service/fsi.fsi</Link>
613625
</Compile>

‎src/buildfromsource/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,12 @@
492492
<CompileInclude="$(FSharpSourcesRoot)\fsharp\symbols\Exprs.fs">
493493
<Link>Symbols/Exprs.fs</Link>
494494
</Compile>
495+
<CompileInclude="$(FSharpSourcesRoot)\fsharp\symbols\SymbolPatterns.fsi">
496+
<Link>Symbols/SymbolPatterns.fsi</Link>
497+
</Compile>
498+
<CompileInclude="$(FSharpSourcesRoot)\fsharp\symbols\SymbolPatterns.fs">
499+
<Link>Symbols/SymbolPatterns.fs</Link>
500+
</Compile>
495501

496502
<!-- the incremental builder and service .-->
497503
<CompileInclude="$(FSharpSourcesRoot)\fsharp\vs\IncrementalBuild.fsi">
@@ -590,6 +596,12 @@
590596
<CompileInclude="$(FSharpSourcesRoot)\fsharp\vs\ServiceStructure.fs">
591597
<Link>Service/ServiceStructure.fs</Link>
592598
</Compile>
599+
<CompileInclude="$(FSharpSourcesRoot)\fsharp\vs\ServiceAnalysis.fsi">
600+
<Link>Service/ServiceAnalysis.fsi</Link>
601+
</Compile>
602+
<CompileInclude="$(FSharpSourcesRoot)\fsharp\vs\ServiceAnalysis.fs">
603+
<Link>Service/ServiceAnalysis.fs</Link>
604+
</Compile>
593605

594606
<!-- the core of the F# Interactive fsi.exe implementation-->
595607
<FsSrGenInclude="$(FSharpSourcesRoot)\fsharp\fsi\FSIstrings.txt">

‎src/fsharp/FSharp.Compiler.Private/FSharp.Compiler.Private.fsproj‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,12 @@
546546
<CompileInclude="..\symbols\Exprs.fs">
547547
<Link>Symbols/Exprs.fs</Link>
548548
</Compile>
549+
<CompileInclude="..\symbols\SymbolPatterns.fsi">
550+
<Link>Symbols/SymbolPatterns.fsi</Link>
551+
</Compile>
552+
<CompileInclude="..\symbols\SymbolPatterns.fs">
553+
<Link>Symbols/SymbolPatterns.fs</Link>
554+
</Compile>
549555

550556
<!-- the incremental builder and service .-->
551557
<CompileInclude="..\vs\IncrementalBuild.fsi">
@@ -644,7 +650,13 @@
644650
<CompileInclude="..\vs\ServiceStructure.fs">
645651
<Link>Service/ServiceStructure.fs</Link>
646652
</Compile>
647-
653+
<CompileInclude="..\vs\ServiceAnalysis.fsi">
654+
<Link>Service/ServiceAnalysis.fsi</Link>
655+
</Compile>
656+
<CompileInclude="..\vs\ServiceAnalysis.fs">
657+
<Link>Service/ServiceAnalysis.fs</Link>
658+
</Compile>
659+
648660
<!-- the core of the F# Interactive fsi.exe implementation-->
649661
<EmbeddedTextInclude="..\fsi\FSIstrings.txt">
650662
<Link>FSIstrings.txt</Link>
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
3+
namespaceMicrosoft.FSharp.Compiler.SourceCodeServices
4+
5+
/// Active patterns over `FSharpSymbolUse`.
6+
[<RequireQualifiedAccess>]
7+
moduleSymbolUse=
8+
9+
let(|ActivePatternCase|_|)(symbol:FSharpSymbolUse)=
10+
match symbol.Symbolwith
11+
|:? FSharpActivePatternCaseas ap-> ActivePatternCase(ap)|> Some
12+
|_-> None
13+
14+
letprivateattributeSuffixLength="Attribute".Length
15+
16+
let(|Entity|_|)(symbol:FSharpSymbolUse):(FSharpEntity*(* cleanFullNames*) string list)option=
17+
match symbol.Symbolwith
18+
|:? FSharpEntityas ent->
19+
// strip generic parameters count suffix (List`1 => List)
20+
letcleanFullName=
21+
// `TryFullName` for type aliases is always `None`, so we have to make one by our own
22+
if ent.IsFSharpAbbreviationthen
23+
[ent.AccessPath+"."+ ent.DisplayName]
24+
else
25+
ent.TryFullName
26+
|> Option.toList
27+
|> List.map(fun fullName->
28+
if ent.GenericParameters.Count>0&& fullName.Length>2then
29+
fullName.[0..fullName.Length-3]
30+
else fullName)
31+
32+
letcleanFullNames=
33+
cleanFullName
34+
|> List.collect(fun cleanFullName->
35+
if ent.IsAttributeTypethen
36+
[cleanFullName; cleanFullName.[0..cleanFullName.Length- attributeSuffixLength-1]]
37+
else[cleanFullName]
38+
)
39+
Some(ent, cleanFullNames)
40+
|_-> None
41+
42+
let(|Field|_|)(symbol:FSharpSymbolUse)=
43+
match symbol.Symbolwith
44+
|:? FSharpFieldas field-> Some field
45+
|_-> None
46+
47+
let(|GenericParameter|_|)(symbol:FSharpSymbolUse)=
48+
match symbol.Symbolwith
49+
|:? FSharpGenericParameteras gp-> Some gp
50+
|_-> None
51+
52+
let(|MemberFunctionOrValue|_|)(symbol:FSharpSymbolUse)=
53+
match symbol.Symbolwith
54+
|:? FSharpMemberOrFunctionOrValueas func-> Some func
55+
|_-> None
56+
57+
let(|ActivePattern|_|)=function
58+
| MemberFunctionOrValue mwhen m.IsActivePattern-> Some m|_-> None
59+
60+
let(|Parameter|_|)(symbol:FSharpSymbolUse)=
61+
match symbol.Symbolwith
62+
|:? FSharpParameteras param-> Some param
63+
|_-> None
64+
65+
let(|StaticParameter|_|)(symbol:FSharpSymbolUse)=
66+
match symbol.Symbolwith
67+
|:? FSharpStaticParameteras sp-> Some sp
68+
|_-> None
69+
70+
let(|UnionCase|_|)(symbol:FSharpSymbolUse)=
71+
match symbol.Symbolwith
72+
|:? FSharpUnionCaseas uc-> Some uc
73+
|_-> None
74+
75+
let(|Constructor|_|)=function
76+
| MemberFunctionOrValue funcwhen func.IsConstructor|| func.IsImplicitConstructor-> Some func
77+
|_-> None
78+
79+
let(|TypeAbbreviation|_|)=function
80+
| Entity(entity,_)when entity.IsFSharpAbbreviation-> Some entity
81+
|_-> None
82+
83+
let(|Class|_|)=function
84+
| Entity(entity,_)when entity.IsClass-> Some entity
85+
| Entity(entity,_)when entity.IsFSharp&&
86+
entity.IsOpaque&&
87+
not entity.IsFSharpModule&&
88+
not entity.IsNamespace&&
89+
not entity.IsDelegate&&
90+
not entity.IsFSharpUnion&&
91+
not entity.IsFSharpRecord&&
92+
not entity.IsInterface&&
93+
not entity.IsValueType-> Some entity
94+
|_-> None
95+
96+
let(|Delegate|_|)=function
97+
| Entity(entity,_)when entity.IsDelegate-> Some entity
98+
|_-> None
99+
100+
let(|Event|_|)=function
101+
| MemberFunctionOrValue symbolwhen symbol.IsEvent-> Some symbol
102+
|_-> None
103+
104+
let(|Property|_|)=function
105+
| MemberFunctionOrValue symbolwhen symbol.IsProperty|| symbol.IsPropertyGetterMethod|| symbol.IsPropertySetterMethod-> Some symbol
106+
|_-> None
107+
108+
let inlineprivatenotCtorOrProp(symbol:FSharpMemberOrFunctionOrValue)=
109+
not symbol.IsConstructor&&not symbol.IsPropertyGetterMethod&&not symbol.IsPropertySetterMethod
110+
111+
typeFSharpSymbolwith
112+
memberx.IsOperatorOrActivePattern=
113+
letname= x.DisplayName
114+
if name.StartsWith"("&& name.EndsWith" )"&& name.Length>4
115+
then name.Substring(2, name.Length-4)|> String.forall(fun c-> c<>' ')
116+
elsefalse
117+
118+
typeFSharpMemberOrFunctionOrValuewith
119+
memberx.FullTypeSafe=try Some x.FullTypewith_-> None
120+
121+
let(|Method|_|)(symbolUse:FSharpSymbolUse)=
122+
match symbolUsewith
123+
| MemberFunctionOrValue symbolwhen
124+
symbol.IsModuleValueOrMember&&
125+
not symbolUse.IsFromPattern&&
126+
not symbol.IsOperatorOrActivePattern&&
127+
not symbol.IsPropertyGetterMethod&&
128+
not symbol.IsPropertySetterMethod-> Some symbol
129+
|_-> None
130+
131+
let(|Function|_|)(symbolUse:FSharpSymbolUse)=
132+
match symbolUsewith
133+
| MemberFunctionOrValue symbolwhen
134+
notCtorOrProp symbol&&
135+
symbol.IsModuleValueOrMember&&
136+
not symbol.IsOperatorOrActivePattern&&
137+
not symbolUse.IsFromPattern->
138+
139+
match symbol.FullTypeSafewith
140+
| Some fullTypewhen fullType.IsFunctionType-> Some symbol
141+
|_-> None
142+
|_-> None
143+
144+
let(|Operator|_|)(symbolUse:FSharpSymbolUse)=
145+
match symbolUsewith
146+
| MemberFunctionOrValue symbolwhen
147+
notCtorOrProp symbol&&
148+
not symbolUse.IsFromPattern&&
149+
not symbol.IsActivePattern&&
150+
symbol.IsOperatorOrActivePattern->
151+
152+
match symbol.FullTypeSafewith
153+
| Some fullTypewhen fullType.IsFunctionType-> Some symbol
154+
|_-> None
155+
|_-> None
156+
157+
let(|Pattern|_|)(symbolUse:FSharpSymbolUse)=
158+
match symbolUsewith
159+
| MemberFunctionOrValue symbolwhen
160+
notCtorOrProp symbol&&
161+
not symbol.IsOperatorOrActivePattern&&
162+
symbolUse.IsFromPattern->
163+
164+
match symbol.FullTypeSafewith
165+
| Some fullTypewhen fullType.IsFunctionType-> Some symbol
166+
|_-> None
167+
|_-> None
168+
169+
let(|ClosureOrNestedFunction|_|)=function
170+
| MemberFunctionOrValue symbolwhen
171+
notCtorOrProp symbol&&
172+
not symbol.IsOperatorOrActivePattern&&
173+
not symbol.IsModuleValueOrMember->
174+
175+
match symbol.FullTypeSafewith
176+
| Some fullTypewhen fullType.IsFunctionType-> Some symbol
177+
|_-> None
178+
|_-> None
179+
180+
let(|Val|_|)=function
181+
| MemberFunctionOrValue symbolwhen notCtorOrProp symbol&&
182+
not symbol.IsOperatorOrActivePattern->
183+
match symbol.FullTypeSafewith
184+
| Some_fullType-> Some symbol
185+
|_-> None
186+
|_-> None
187+
188+
let(|Enum|_|)=function
189+
| Entity(entity,_)when entity.IsEnum-> Some entity
190+
|_-> None
191+
192+
let(|Interface|_|)=function
193+
| Entity(entity,_)when entity.IsInterface-> Some entity
194+
|_-> None
195+
196+
let(|Module|_|)=function
197+
| Entity(entity,_)when entity.IsFSharpModule-> Some entity
198+
|_-> None
199+
200+
let(|Namespace|_|)=function
201+
| Entity(entity,_)when entity.IsNamespace-> Some entity
202+
|_-> None
203+
204+
let(|Record|_|)=function
205+
| Entity(entity,_)when entity.IsFSharpRecord-> Some entity
206+
|_-> None
207+
208+
let(|Union|_|)=function
209+
| Entity(entity,_)when entity.IsFSharpUnion-> Some entity
210+
|_-> None
211+
212+
let(|ValueType|_|)=function
213+
| Entity(entity,_)when entity.IsValueType&&not entity.IsEnum-> Some entity
214+
|_-> None
215+
216+
let(|ComputationExpression|_|)(symbol:FSharpSymbolUse)=
217+
if symbol.IsFromComputationExpressionthen Some symbol
218+
else None
219+
220+
let(|Attribute|_|)=function
221+
| Entity(entity,_)when entity.IsAttributeType-> Some entity
222+
|_-> None
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
2+
3+
namespaceMicrosoft.FSharp.Compiler.SourceCodeServices
4+
5+
[<RequireQualifiedAccess>]
6+
#if COMPILER_PUBLIC_API
7+
moduleSymbolUse=
8+
#else
9+
moduleinternalSymbolUse=
10+
#endif
11+
val(|ActivePatternCase|_|):FSharpSymbolUse->FSharpActivePatternCase option
12+
val(|Entity|_|):FSharpSymbolUse->(FSharpEntity*(* cleanFullNames*)string list)option
13+
val(|Field|_|):FSharpSymbolUse->FSharpField option
14+
val(|GenericParameter|_|):FSharpSymbolUse->FSharpGenericParameter option
15+
val(|MemberFunctionOrValue|_|):FSharpSymbolUse->FSharpMemberOrFunctionOrValue option
16+
val(|ActivePattern|_|):FSharpSymbolUse->FSharpMemberOrFunctionOrValue option
17+
val(|Parameter|_|):FSharpSymbolUse->FSharpParameter option
18+
val(|StaticParameter|_|):FSharpSymbolUse->FSharpStaticParameter option
19+
val(|UnionCase|_|):FSharpSymbolUse->FSharpUnionCase option
20+
val(|Constructor|_|):FSharpSymbolUse->FSharpMemberOrFunctionOrValue option
21+
val(|TypeAbbreviation|_|):FSharpSymbolUse->FSharpEntity option
22+
val(|Class|_|):FSharpSymbolUse->FSharpEntity option
23+
val(|Delegate|_|):FSharpSymbolUse->FSharpEntity option
24+
val(|Event|_|):FSharpSymbolUse->FSharpMemberOrFunctionOrValue option
25+
val(|Property|_|):FSharpSymbolUse->FSharpMemberOrFunctionOrValue option
26+
val(|Method|_|):FSharpSymbolUse->FSharpMemberOrFunctionOrValue option
27+
val(|Function|_|):FSharpSymbolUse->FSharpMemberOrFunctionOrValue option
28+
val(|Operator|_|):FSharpSymbolUse->FSharpMemberOrFunctionOrValue option
29+
val(|Pattern|_|):FSharpSymbolUse->FSharpMemberOrFunctionOrValue option
30+
val(|ClosureOrNestedFunction|_|):FSharpSymbolUse->FSharpMemberOrFunctionOrValue option
31+
val(|Val|_|):FSharpSymbolUse->FSharpMemberOrFunctionOrValue option
32+
val(|Enum|_|):FSharpSymbolUse->FSharpEntity option
33+
val(|Interface|_|):FSharpSymbolUse->FSharpEntity option
34+
val(|Module|_|):FSharpSymbolUse->FSharpEntity option
35+
val(|Namespace|_|):FSharpSymbolUse->FSharpEntity option
36+
val(|Record|_|):FSharpSymbolUse->FSharpEntity option
37+
val(|Union|_|):FSharpSymbolUse->FSharpEntity option
38+
val(|ValueType|_|):FSharpSymbolUse->FSharpEntity option
39+
val(|ComputationExpression|_|):FSharpSymbolUse->FSharpSymbolUse option
40+
val(|Attribute|_|):FSharpSymbolUse->FSharpEntity option

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp