@@ -104,18 +104,28 @@ module UnusedOpens =
104104
105105type NamespaceUse =
106106{ Ident: string
107- SymbolLocation : range }
107+ ExtraNamespaces : string [] }
108108
109- let getPartNamespace ( fullIsland : string ) ( fullName : string ) =
109+ let getNamespaceInUse ( fullIsland : string ) ( fullName : string ) : NamespaceUse option =
110110// given a full island such as `Text.ISegment` and a full name of `MonoDevelop.Core.Text.ISegment`, return `MonoDevelop.Core`
111111let lengthDiff = fullName.Length- fullIsland.Length- 2
112112if lengthDiff<= 0 || lengthDiff> fullName.Length- 1 then None
113- else Some fullName.[ 0 .. lengthDiff]
114-
115- let getPossibleNamespaces ( getSourceLineStr : int -> string ) ( symbolUse : FSharpSymbolUse ) : Set < string > =
113+ else
114+ let requiredOpenNamespace = fullName.[ 0 .. lengthDiff]
115+ let rest = fullName.[ lengthDiff+ 1 ..]
116+ let extraNamespaces =
117+ match rest.Split'.' with
118+ | [||] | [|_|] -> [||]
119+ | rest-> rest.[.. rest.Length- 2 ]
120+ Some{ Ident= requiredOpenNamespace; ExtraNamespaces= extraNamespaces}
121+
122+ let getPossibleNamespaces ( getSourceLineStr : int -> string ) ( symbolUse : FSharpSymbolUse ) : NamespaceUse [] =
116123let lineStr = getSourceLineStr symbolUse.RangeAlternate.StartLine
117- match QuickParse.GetCompleteIdentifierIslandtrue lineStr symbolUse.RangeAlternate.EndColumnwith
118- | Some( fullIsland, _, _) ->
124+ let partialName = QuickParse.GetPartialLongNameEx( lineStr, symbolUse.RangeAlternate.EndColumn- 1 )
125+ if partialName.PartialIdent= " " then [||]
126+ else
127+ let qualifyingIsland = partialName.QualifyingIdents|> String.concat" ."
128+ let fullIsland = qualifyingIsland+ partialName.PartialIdent
119129let isQualified fullName = fullName= fullIsland
120130
121131( match symbolUsewith
@@ -138,30 +148,32 @@ module UnusedOpens =
138148| _ -> None)
139149|> Option.map( fun ( fullNames , declaringEntity ) ->
140150[| for namein fullNamesdo
141- let partNamespace = getPartNamespace fullIsland name
151+ let partNamespace = getNamespaceInUse fullIsland name
142152yield partNamespace
143- yield ! entityNamespace declaringEntity|])
153+ yield !
154+ entityNamespace declaringEntity
155+ |> List.map( Option.bind( getNamespaceInUse qualifyingIsland))
156+ |])
144157|> Option.toArray
145158|> Array.concat
146159|> Array.choose id
147- |> set
148- | None-> Set.empty
160+ |> Array.distinct
149161
150162type SymbolUseWithFullNames =
151163{ SymbolUse: FSharpSymbolUse
152164 FullNames: string [][] }
153165
154166type SymbolUse =
155167{ SymbolUse: FSharpSymbolUse
156- PossibleNamespaces: Set < string > }
168+ PossibleNamespaces: NamespaceUse [] }
157169
158170let getSymbolUses ( getSourceLineStr : int -> string ) ( symbolUses : FSharpSymbolUse []) : SymbolUse [] =
159171 symbolUses
160172|> Array.filter( fun ( symbolUse : FSharpSymbolUse ) ->
161- not symbolUse.IsFromDefinition&&
162- match symbolUse.Symbolwith
163- | :? FSharpEntityas e-> not e.IsNamespace
164- | _ -> true
173+ not symbolUse.IsFromDefinition// &&
174+ // match symbolUse.Symbol with
175+ // | :? FSharpEntity as e -> not e.IsNamespace
176+ // | _ -> true
165177)
166178|> Array.map( fun su ->
167179{ SymbolUse= su