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

Commit6d1b4bd

Browse files
Vasily KirichenkoVasily Kirichenko
Vasily Kirichenko
authored and
Vasily Kirichenko
committed
find in open decls sub namespaces (wip)
1 parent4ba197a commit6d1b4bd

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

‎src/fsharp/vs/ServiceAnalysis.fs‎

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,28 @@ module UnusedOpens =
104104

105105
typeNamespaceUse=
106106
{ Ident:string
107-
SymbolLocation:range}
107+
ExtraNamespaces:string[]}
108108

109-
letgetPartNamespace(fullIsland:string)(fullName:string)=
109+
letgetNamespaceInUse(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`
111111
letlengthDiff= fullName.Length- fullIsland.Length-2
112112
if lengthDiff<=0|| lengthDiff> fullName.Length-1then None
113-
else Some fullName.[0..lengthDiff]
114-
115-
letgetPossibleNamespaces(getSourceLineStr:int->string)(symbolUse:FSharpSymbolUse):Set<string>=
113+
else
114+
letrequiredOpenNamespace= fullName.[0..lengthDiff]
115+
letrest= fullName.[lengthDiff+1..]
116+
letextraNamespaces=
117+
match rest.Split'.'with
118+
|[||]|[|_|]->[||]
119+
| rest-> rest.[..rest.Length-2]
120+
Some{ Ident= requiredOpenNamespace; ExtraNamespaces= extraNamespaces}
121+
122+
letgetPossibleNamespaces(getSourceLineStr:int->string)(symbolUse:FSharpSymbolUse):NamespaceUse[]=
116123
letlineStr= getSourceLineStr symbolUse.RangeAlternate.StartLine
117-
match QuickParse.GetCompleteIdentifierIslandtrue lineStr symbolUse.RangeAlternate.EndColumnwith
118-
| Some(fullIsland,_,_)->
124+
letpartialName= QuickParse.GetPartialLongNameEx(lineStr, symbolUse.RangeAlternate.EndColumn-1)
125+
if partialName.PartialIdent=""then[||]
126+
else
127+
letqualifyingIsland= partialName.QualifyingIdents|> String.concat"."
128+
letfullIsland= qualifyingIsland+ partialName.PartialIdent
119129
letisQualified 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-
letpartNamespace=getPartNamespace fullIsland name
151+
letpartNamespace=getNamespaceInUse fullIsland name
142152
yield 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

150162
typeSymbolUseWithFullNames=
151163
{ SymbolUse:FSharpSymbolUse
152164
FullNames:string[][]}
153165

154166
typeSymbolUse=
155167
{ SymbolUse:FSharpSymbolUse
156-
PossibleNamespaces:Set<string>}
168+
PossibleNamespaces:NamespaceUse[]}
157169

158170
letgetSymbolUses(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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp