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

Commit4ba197a

Browse files
Vasily KirichenkoVasily Kirichenko
Vasily Kirichenko
authored and
Vasily Kirichenko
committed
fix partially qualified name 1
1 parenta35e535 commit4ba197a

File tree

2 files changed

+40
-44
lines changed

2 files changed

+40
-44
lines changed

‎src/fsharp/vs/ServiceAnalysis.fs‎

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -102,53 +102,50 @@ module UnusedOpens =
102102
]
103103
| None->[]
104104

105-
letsymbolIsFullyQualified(getSourceLineStr:int->string)(sym:FSharpSymbolUse)(fullName:string)=
106-
letlineStr= getSourceLineStr sym.RangeAlternate.StartLine
107-
match QuickParse.GetCompleteIdentifierIslandtrue lineStr sym.RangeAlternate.EndColumnwith
108-
| Some(island,_,_)-> island= fullName
109-
| None->false
110-
111105
typeNamespaceUse=
112106
{ Ident:string
113107
SymbolLocation:range}
114108

115-
letgetPartNamespace(symbolUse:FSharpSymbolUse)(fullName:string)=
116-
// given a symbol range such as `Text.ISegment` and a full name of `MonoDevelop.Core.Text.ISegment`, return `MonoDevelop.Core`
117-
letlength= symbolUse.RangeAlternate.EndColumn- symbolUse.RangeAlternate.StartColumn
118-
letlengthDiff= fullName.Length- length-2
109+
letgetPartNamespace(fullIsland:string)(fullName:string)=
110+
// given a full island such as `Text.ISegment` and a full name of `MonoDevelop.Core.Text.ISegment`, return `MonoDevelop.Core`
111+
letlengthDiff= fullName.Length- fullIsland.Length-2
119112
if lengthDiff<=0|| lengthDiff> fullName.Length-1then None
120113
else Some fullName.[0..lengthDiff]
121114

122115
letgetPossibleNamespaces(getSourceLineStr:int->string)(symbolUse:FSharpSymbolUse):Set<string>=
123-
letisQualified= symbolIsFullyQualified getSourceLineStr symbolUse
124-
125-
(match symbolUsewith
126-
| SymbolUse.Entity(ent, cleanFullNames)whennot(cleanFullNames|> List.exists isQualified)->
127-
Some(cleanFullNames, Some ent)
128-
| SymbolUse.Field fwhennot(isQualified f.FullName)->
129-
Some([f.FullName], Some f.DeclaringEntity)
130-
| SymbolUse.MemberFunctionOrValue mfvwhennot(isQualified mfv.FullName)->
131-
Some([mfv.FullName], mfv.EnclosingEntity)
132-
| SymbolUse.Operator opwhennot(isQualified op.FullName)->
133-
Some([op.FullName], op.EnclosingEntity)
134-
| SymbolUse.ActivePattern apwhennot(isQualified ap.FullName)->
135-
Some([ap.FullName], ap.EnclosingEntity)
136-
| SymbolUse.ActivePatternCase apcwhennot(isQualified apc.FullName)->
137-
Some([apc.FullName], apc.Group.EnclosingEntity)
138-
| SymbolUse.UnionCase ucwhennot(isQualified uc.FullName)->
139-
Some([uc.FullName], Some uc.ReturnType.TypeDefinition)
140-
| SymbolUse.Parameter pwhennot(isQualified p.FullName)&& p.Type.HasTypeDefinition->
141-
Some([p.FullName], Some p.Type.TypeDefinition)
142-
|_-> None)
143-
|> Option.map(fun(fullNames,declaringEntity)->
144-
[|for namein fullNamesdo
145-
letpartNamespace= getPartNamespace symbolUse name
146-
yield partNamespace
147-
yield! entityNamespace declaringEntity|])
148-
|> Option.toArray
149-
|> Array.concat
150-
|> Array.choose id
151-
|> set
116+
letlineStr= getSourceLineStr symbolUse.RangeAlternate.StartLine
117+
match QuickParse.GetCompleteIdentifierIslandtrue lineStr symbolUse.RangeAlternate.EndColumnwith
118+
| Some(fullIsland,_,_)->
119+
letisQualified fullName= fullName= fullIsland
120+
121+
(match symbolUsewith
122+
| SymbolUse.Entity(ent, cleanFullNames)whennot(cleanFullNames|> List.exists isQualified)->
123+
Some(cleanFullNames, Some ent)
124+
| SymbolUse.Field fwhennot(isQualified f.FullName)->
125+
Some([f.FullName], Some f.DeclaringEntity)
126+
| SymbolUse.MemberFunctionOrValue mfvwhennot(isQualified mfv.FullName)->
127+
Some([mfv.FullName], mfv.EnclosingEntity)
128+
| SymbolUse.Operator opwhennot(isQualified op.FullName)->
129+
Some([op.FullName], op.EnclosingEntity)
130+
| SymbolUse.ActivePattern apwhennot(isQualified ap.FullName)->
131+
Some([ap.FullName], ap.EnclosingEntity)
132+
| SymbolUse.ActivePatternCase apcwhennot(isQualified apc.FullName)->
133+
Some([apc.FullName], apc.Group.EnclosingEntity)
134+
| SymbolUse.UnionCase ucwhennot(isQualified uc.FullName)->
135+
Some([uc.FullName], Some uc.ReturnType.TypeDefinition)
136+
| SymbolUse.Parameter pwhennot(isQualified p.FullName)&& p.Type.HasTypeDefinition->
137+
Some([p.FullName], Some p.Type.TypeDefinition)
138+
|_-> None)
139+
|> Option.map(fun(fullNames,declaringEntity)->
140+
[|for namein fullNamesdo
141+
letpartNamespace= getPartNamespace fullIsland name
142+
yield partNamespace
143+
yield! entityNamespace declaringEntity|])
144+
|> Option.toArray
145+
|> Array.concat
146+
|> Array.choose id
147+
|> set
148+
| None-> Set.empty
152149

153150
typeSymbolUseWithFullNames=
154151
{ SymbolUse:FSharpSymbolUse
@@ -161,10 +158,10 @@ module UnusedOpens =
161158
letgetSymbolUses(getSourceLineStr:int->string)(symbolUses:FSharpSymbolUse[]):SymbolUse[]=
162159
symbolUses
163160
|> Array.filter(fun(symbolUse: FSharpSymbolUse)->
164-
not symbolUse.IsFromDefinition
165-
//&&match symbolUse.Symbol with
166-
//| :? FSharpEntity as e -> not e.IsNamespace
167-
//| _ -> true
161+
not symbolUse.IsFromDefinition&&
162+
match symbolUse.Symbolwith
163+
|:? FSharpEntityas e->not e.IsNamespace
164+
|_->true
168165
)
169166
|> Array.map(fun su->
170167
{ SymbolUse= su

‎vsintegration/tests/unittests/UnusedOpensTests.fs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ type Site (x: int -> unit) = class end
263263
=>[4,(5,6)]
264264

265265
[<Test>]
266-
[<Ignore"Extensions are not supported yet">]
267266
let``static extension method applied to a type results that both namespaces/where the type is declared and where the extension is declared/is not marked as unused``()=
268267
"""
269268
module Extensions =

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp