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

Commit5e1255b

Browse files
all tests pass except type in type extension
1 parent05e7d26 commit5e1255b

File tree

2 files changed

+13
-28
lines changed

2 files changed

+13
-28
lines changed

‎src/fsharp/vs/ServiceAnalysis.fs‎

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ module UnusedOpens =
1111

1212
/// Represents single open statement.
1313
typeOpenStatement=
14-
{/// Full namespace or module identifier as it's presented in source code.
15-
Idents:Set<string>
16-
/// Modules.
17-
Modules:FSharpEntity list
14+
{ Modules:FSharpEntity list
1815
/// Range of open statement itself.
1916
Range:range
2017
/// Scope on which this open declaration is applied.
@@ -23,8 +20,7 @@ module UnusedOpens =
2320
IsGlobal:bool}
2421

2522
memberthis.AllChildSymbols=
26-
let recgetAllChildSymbolsInModule(modul:FSharpEntity)=
27-
seq{
23+
seq{for modulin this.Modulesdo
2824
for entin modul.NestedEntitiesdo
2925
yield ent:> FSharpSymbol
3026

@@ -35,36 +31,26 @@ module UnusedOpens =
3531
if ent.IsFSharpUnion&&not(hasAttribute<RequireQualifiedAccessAttribute> ent.Attributes)then
3632
for unionCasein ent.UnionCasesdo
3733
yieldupcast unionCase
38-
39-
if ent.IsFSharpModule&& hasAttribute<AutoOpenAttribute> ent.Attributesthen
40-
yield! getAllChildSymbolsInModule ent
41-
34+
4235
for fvin modul.MembersFunctionsAndValuesdo
4336
yieldupcast fv
4437

4538
for apCasein modul.ActivePatternCasesdo
46-
yieldupcast apCase
47-
}
48-
49-
seq{for modulin this.Modulesdo
50-
yield! getAllChildSymbolsInModule modul
39+
yieldupcast apCase
5140
}|> Seq.cache
5241

42+
let recgetModuleAndItsAutoOpens(modul:FSharpEntity)=
43+
[yield modul
44+
for entin modul.NestedEntitiesdo
45+
if ent.IsFSharpModule&& hasAttribute<AutoOpenAttribute> ent.Attributesthen
46+
yield! getModuleAndItsAutoOpens ent]
47+
5348
letgetOpenStatements(openDeclarations:FSharpOpenDeclaration list):OpenStatement list=
5449
openDeclarations
5550
|> List.choose(fun openDecl->
5651
match openDecl.LongId, openDecl.Rangewith
5752
| firstId::_, Some range->
58-
Some{ Idents=
59-
openDecl.Modules
60-
|> List.choose(fun x-> x.TryFullName|> Option.map(fun fullName-> x, fullName))
61-
|> List.collect(fun(modul,fullName)->
62-
[yield fullName
63-
if modul.HasFSharpModuleSuffixthen
64-
yield fullName.[..fullName.Length-7]// "Module" length plus zero index correction
65-
])
66-
|> Set.ofList
67-
Modules= openDecl.Modules
53+
Some{ Modules= openDecl.Modules|> List.collect getModuleAndItsAutoOpens
6854
Range= range
6955
AppliedScope= openDecl.AppliedScope
7056
IsGlobal= firstId.idText= MangledGlobalName}
@@ -93,7 +79,6 @@ module UnusedOpens =
9379
|> Array.exists(fun symbolUse->
9480
letinScope= rangeContainsRange openStatement.AppliedScope symbolUse.RangeAlternate
9581
ifnot inScopethenfalse
96-
//elif openStatement.Idents |> Set.intersect symbolUse.PossibleNamespaces |> Set.isEmpty then false
9782
else
9883
letmoduleSymbols= openStatement.AllChildSymbols|> Seq.toList
9984
moduleSymbols
@@ -107,7 +92,7 @@ module UnusedOpens =
10792
// if such open statement has already been marked as used in this or outer module, we skip it
10893
// (that is, do not mark as used so far)
10994
rangeContainsRange seenNs.AppliedScope openStatement.AppliedScope&&
110-
not(openStatement.Idents|>Set.intersectseenNs.Idents|>Set.isEmpty))
95+
openStatement.Modules|>List.exists(fun x->seenNs.Modules|>List.exists(fun s-> s.IsEffectivelySameAs x)))
11196
not alreadySeen
11297

11398
match openStatementswith

‎vsintegration/tests/unittests/UnusedOpensTests.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ open NormalModule.AutoOpenModule1.NestedNormalModule.AutoOpenModule2
184184
open NormalModule.AutoOpenModule1.NestedNormalModule
185185
let _ = Class()
186186
"""
187-
=>[12,(5,68)]
187+
=>[13,(5,52)]
188188

189189
[<Test>]
190190
let``open declaration is not marked as unused if there is a shortened attribute symbol from it``()=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp