@@ -102,53 +102,50 @@ module UnusedOpens =
102102]
103103| None-> []
104104
105- let symbolIsFullyQualified ( getSourceLineStr : int -> string ) ( sym : FSharpSymbolUse ) ( fullName : string ) =
106- let lineStr = getSourceLineStr sym.RangeAlternate.StartLine
107- match QuickParse.GetCompleteIdentifierIslandtrue lineStr sym.RangeAlternate.EndColumnwith
108- | Some( island, _, _) -> island= fullName
109- | None-> false
110-
111105type NamespaceUse =
112106{ Ident: string
113107 SymbolLocation: range }
114108
115- let getPartNamespace ( 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- let length = symbolUse.RangeAlternate.EndColumn- symbolUse.RangeAlternate.StartColumn
118- let lengthDiff = fullName.Length- length- 2
109+ let getPartNamespace ( 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+ let lengthDiff = fullName.Length- fullIsland.Length- 2
119112if lengthDiff<= 0 || lengthDiff> fullName.Length- 1 then None
120113else Some fullName.[ 0 .. lengthDiff]
121114
122115let getPossibleNamespaces ( getSourceLineStr : int -> string ) ( symbolUse : FSharpSymbolUse ) : Set < string > =
123- let isQualified = symbolIsFullyQualified getSourceLineStr symbolUse
124-
125- ( match symbolUsewith
126- | SymbolUse.Entity( ent, cleanFullNames) when not ( cleanFullNames|> List.exists isQualified) ->
127- Some( cleanFullNames, Some ent)
128- | SymbolUse.Field fwhen not ( isQualified f.FullName) ->
129- Some([ f.FullName], Some f.DeclaringEntity)
130- | SymbolUse.MemberFunctionOrValue mfvwhen not ( isQualified mfv.FullName) ->
131- Some([ mfv.FullName], mfv.EnclosingEntity)
132- | SymbolUse.Operator opwhen not ( isQualified op.FullName) ->
133- Some([ op.FullName], op.EnclosingEntity)
134- | SymbolUse.ActivePattern apwhen not ( isQualified ap.FullName) ->
135- Some([ ap.FullName], ap.EnclosingEntity)
136- | SymbolUse.ActivePatternCase apcwhen not ( isQualified apc.FullName) ->
137- Some([ apc.FullName], apc.Group.EnclosingEntity)
138- | SymbolUse.UnionCase ucwhen not ( isQualified uc.FullName) ->
139- Some([ uc.FullName], Some uc.ReturnType.TypeDefinition)
140- | SymbolUse.Parameter pwhen not ( 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- let partNamespace = getPartNamespace symbolUse name
146- yield partNamespace
147- yield ! entityNamespace declaringEntity|])
148- |> Option.toArray
149- |> Array.concat
150- |> Array.choose id
151- |> set
116+ let lineStr = getSourceLineStr symbolUse.RangeAlternate.StartLine
117+ match QuickParse.GetCompleteIdentifierIslandtrue lineStr symbolUse.RangeAlternate.EndColumnwith
118+ | Some( fullIsland, _, _) ->
119+ let isQualified fullName = fullName= fullIsland
120+
121+ ( match symbolUsewith
122+ | SymbolUse.Entity( ent, cleanFullNames) when not ( cleanFullNames|> List.exists isQualified) ->
123+ Some( cleanFullNames, Some ent)
124+ | SymbolUse.Field fwhen not ( isQualified f.FullName) ->
125+ Some([ f.FullName], Some f.DeclaringEntity)
126+ | SymbolUse.MemberFunctionOrValue mfvwhen not ( isQualified mfv.FullName) ->
127+ Some([ mfv.FullName], mfv.EnclosingEntity)
128+ | SymbolUse.Operator opwhen not ( isQualified op.FullName) ->
129+ Some([ op.FullName], op.EnclosingEntity)
130+ | SymbolUse.ActivePattern apwhen not ( isQualified ap.FullName) ->
131+ Some([ ap.FullName], ap.EnclosingEntity)
132+ | SymbolUse.ActivePatternCase apcwhen not ( isQualified apc.FullName) ->
133+ Some([ apc.FullName], apc.Group.EnclosingEntity)
134+ | SymbolUse.UnionCase ucwhen not ( isQualified uc.FullName) ->
135+ Some([ uc.FullName], Some uc.ReturnType.TypeDefinition)
136+ | SymbolUse.Parameter pwhen not ( 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+ let partNamespace = 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
153150type SymbolUseWithFullNames =
154151{ SymbolUse: FSharpSymbolUse
@@ -161,10 +158,10 @@ module UnusedOpens =
161158let getSymbolUses ( 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