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

Commit99d0f40

Browse files
all not ignored tests pass
1 parent92cbb6b commit99d0f40

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

‎src/fsharp/symbols/Symbols.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
310310
#else
311311
elif entity.IsTypeAbbrevthen None
312312
#endif
313-
elif entity.IsNamespacethen Some entity.DemangledModuleOrNamespaceName
313+
elif entity.IsNamespacethen Some(entity.ToString())
314314
else
315315
match entity.CompiledRepresentationwith
316316
| CompiledTypeRepr.ILAsmNamed(tref,_,_)-> Some tref.FullName

‎src/fsharp/vs/ServiceAnalysis.fs‎

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@ module UnusedOpens =
1717
/// Range of open statement itself.
1818
Range:range
1919
/// Scope on which this open declaration is applied.
20-
AppliedScope:range}
20+
AppliedScope:range
21+
/// If it's prefixed with the special "global" namespace.
22+
IsGlobal:bool}
2123

2224
letgetOpenStatements(openDeclarations:FSharpOpenDeclaration list):OpenStatement list=
2325
openDeclarations
2426
|> List.choose(fun openDeclaration->
2527
match openDeclarationwith
26-
| FSharpOpenDeclaration.Open(longId, modules, appliedScope)whennot(List.isEmpty longId)->
28+
| FSharpOpenDeclaration.Open((firstId::_)as longId, modules, appliedScope)->
2729
Some{ Idents= modules|> List.choose(fun x-> x.TryFullName)|> Set.ofList
2830
Range=
29-
letfirst= List.head longId
30-
letlast= List.last longId
31-
mkRangeappliedScope.FileName first.idRange.Start last.idRange.End
32-
AppliedScope=appliedScope}
31+
letlastId= List.last longId
32+
mkRange appliedScope.FileName firstId.idRange.Start lastId.idRange.End
33+
AppliedScope=appliedScope
34+
IsGlobal=firstId.idText= MangledGlobalName}
3335
|_-> None// for now
3436
)
3537

@@ -73,7 +75,7 @@ module UnusedOpens =
7375

7476
typeNamespaceUse=
7577
{ Ident:string
76-
Location:range}
78+
SymbolLocation:range}
7779

7880
letgetPartNamespace(symbolUse:FSharpSymbolUse)(fullName:string)=
7981
// given a symbol range such as `Text.ISegment` and a full name of `MonoDevelop.Core.Text.ISegment`, return `MonoDevelop.Core`
@@ -137,32 +139,38 @@ module UnusedOpens =
137139
else None)
138140
|> List.map(fun ns->
139141
{ Ident= ns
140-
Location= su.RangeAlternate}))
142+
SymbolLocation= su.RangeAlternate}))
141143

142144
letgetUnusedOpens(checkFileResults:FSharpCheckFileResults,getSourceLineStr:int->string):Async<rangelist>=
143145

144146
letfilter(openStatements:OpenStatement list)(namespacesInUse:NamespaceUse list):OpenStatement list=
145147
let recfilterInner acc(openStatements:OpenStatement list)(seenOpenStatements:OpenStatement list)=
146148

147-
letnotUsed(os:OpenStatement)=
148-
ifos.Idents|> Set.exists(fun x-> x.StartsWith MangledGlobalName)thenfalse
149+
letisUsed(openStatement:OpenStatement)=
150+
ifopenStatement.IsGlobalthentrue
149151
else
150-
letnotUsedAnywhere=
151-
not(namespacesInUse|> List.exists(fun nsu->
152-
rangeContainsRange os.AppliedScope nsu.Location&& os.Idents|> Set.contains nsu.Ident))
153-
if notUsedAnywherethentrue
152+
letusedSomewhere=
153+
namespacesInUse
154+
|> List.exists(fun namespaceUse->
155+
letinScope= rangeContainsRange openStatement.AppliedScope namespaceUse.SymbolLocation
156+
ifnot inScopethenfalse
157+
else
158+
letidentMatches= openStatement.Idents|> Set.contains namespaceUse.Ident
159+
identMatches)
160+
161+
ifnot usedSomewherethenfalse
154162
else
155163
letalreadySeen=
156164
seenOpenStatements
157165
|> List.exists(fun seenNs->
158166
// if such open statement has already been marked as used in this or outer module, we skip it
159167
// (that is, do not mark as used so far)
160-
rangeContainsRange seenNs.AppliedScopeos.AppliedScope&&
161-
not(os.Idents|> Set.intersect seenNs.Idents|> Set.isEmpty))
162-
alreadySeen
168+
rangeContainsRange seenNs.AppliedScopeopenStatement.AppliedScope&&
169+
not(openStatement.Idents|> Set.intersect seenNs.Idents|> Set.isEmpty))
170+
notalreadySeen
163171

164172
match openStatementswith
165-
| os:: xswhennotUsed os->
173+
| os:: xswhennot(isUsed os)->
166174
filterInner(os:: acc) xs(os:: seenOpenStatements)
167175
| os:: xs->
168176
filterInner acc xs(os:: seenOpenStatements)

‎vsintegration/tests/unittests/UnusedOpensTests.fs‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -580,15 +580,6 @@ module Module =
580580
"""
581581
=>[]
582582

583-
[<Test>]
584-
let``should mark open declaration with global prefix in double backticks``()=
585-
"""
586-
module Module =
587-
open ``global``.Namesp
588-
let _ = System.String("")
589-
"""
590-
=>[3,(9,26)]
591-
592583
[<Test>]
593584
[<Ignore"Relative open statements are not supported yet">]
594585
let``record fields should be taken into account``()=

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp