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

Commit30cd23e

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Unused opens analyzer (dotnet#2477)
* UnusedOpensDiagnosticAnalyzer* it works* remove unused coderefactor* RemoveUnusedOpens Code Fix* fix crash on EnclosingEntity* refactoring* add Seq.toImmutableArray combinator* bug fixhandle nested modules* fixed: it does not work on attributesremove unused opens* dog food
1 parenteab0815 commit30cd23e

File tree

50 files changed

+631
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+631
-304
lines changed

‎src/fsharp/CompileOps.fs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3153,8 +3153,8 @@ let GetScopedPragmasForHashDirective hd =
31533153
letGetScopedPragmasForInput input=
31543154

31553155
match inputwith
3156-
| ParsedInput.SigFile(ParsedSigFileInput(_,_,pragmas,_,_))-> pragmas
3157-
| ParsedInput.ImplFile(ParsedImplFileInput(_,_,_,pragmas,_,_,_))->pragmas
3156+
| ParsedInput.SigFile(ParsedSigFileInput(scopedPragmas=pragmas))-> pragmas
3157+
| ParsedInput.ImplFile(ParsedImplFileInput(scopedPragmas=pragmas))->pragmas
31583158

31593159

31603160

@@ -3425,7 +3425,7 @@ let ParseOneInputLexbuf (tcConfig:TcConfig,lexResourceManager,conditionalCompila
34253425
match reswith
34263426
| ParsedInput.SigFile(ParsedSigFileInput(_,_,_,_,specs))->
34273427
dprintf"parsing yielded%d specs"(List.collect flattenModSpec specs).Length
3428-
| ParsedInput.ImplFile(ParsedImplFileInput(_,_,_,_,_,impls,_))->
3428+
| ParsedInput.ImplFile(ParsedImplFileInput(modules=impls))->
34293429
dprintf"parsing yielded%d definitions"(List.collect flattenModImpl impls).Length
34303430
res
34313431
)
@@ -4631,7 +4631,7 @@ let ProcessMetaCommandsFromInput
46314631
letcanHaveScriptMetaCommands=
46324632
match inpwith
46334633
| ParsedInput.SigFile(_)->false
4634-
| ParsedInput.ImplFile(ParsedImplFileInput(_,isScript,_,_,_,_,_))-> isScript
4634+
| ParsedInput.ImplFile(ParsedImplFileInput(isScript= isScript))-> isScript
46354635

46364636
letProcessMetaCommand state hash=
46374637
let mutablematchedm= range0

‎src/fsharp/ast.fs‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,11 +1508,23 @@ type QualifiedNameOfFile =
15081508

15091509
[<NoEquality; NoComparison>]
15101510
typeParsedImplFileInput=
1511-
| ParsedImplFileInputoffileName:string*isScript:bool*QualifiedNameOfFile*ScopedPragmalist*ParsedHashDirectivelist*SynModuleOrNamespacelist*(bool*bool)
1511+
| ParsedImplFileInputof
1512+
fileName: string*
1513+
isScript: bool*
1514+
qualifiedNameOfFile: QualifiedNameOfFile*
1515+
scopedPragmas: ScopedPragma list*
1516+
hashDirectives: ParsedHashDirective list*
1517+
modules: SynModuleOrNamespace list*
1518+
((* isLastCompiland*) bool*(* isExe*) bool)
15121519

15131520
[<NoEquality; NoComparison>]
15141521
typeParsedSigFileInput=
1515-
| ParsedSigFileInputoffileName:string*QualifiedNameOfFile*ScopedPragmalist*ParsedHashDirectivelist*SynModuleOrNamespaceSiglist
1522+
| ParsedSigFileInputof
1523+
fileName: string*
1524+
qualifiedNameOfFile: QualifiedNameOfFile*
1525+
scopedPragmas: ScopedPragma list*
1526+
hashDirectives: ParsedHashDirective list*
1527+
modules: SynModuleOrNamespaceSig list
15161528

15171529
[<NoEquality; NoComparison; RequireQualifiedAccess>]
15181530
typeParsedInput=
@@ -1521,8 +1533,8 @@ type ParsedInput =
15211533

15221534
memberinp.Range=
15231535
match inpwith
1524-
| ParsedInput.ImplFile(ParsedImplFileInput(_,_,_,_,_,(SynModuleOrNamespace(range=m)::_),_))
1525-
| ParsedInput.SigFile(ParsedSigFileInput(_,_,_,_,(SynModuleOrNamespaceSig(range=m)::_)))-> m
1536+
| ParsedInput.ImplFile(ParsedImplFileInput(modules=SynModuleOrNamespace(range=m)::_))
1537+
| ParsedInput.SigFile(ParsedSigFileInput(modules=SynModuleOrNamespaceSig(range=m)::_))-> m
15261538
| ParsedInput.ImplFile(ParsedImplFileInput(fileName=filename))
15271539
| ParsedInput.SigFile(ParsedSigFileInput(fileName=filename))->
15281540
#if DEBUG

‎src/fsharp/vs/ServiceAssemblyContent.fs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ module internal Extensions =
2424
[<RequireQualifiedAccess>]
2525
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
2626
moduleOption=
27-
let inlineattempt(f:unit->'T)=try Some(f())with_-> None
28-
let inlineorElse v=function Some x-> Some x| None-> v
27+
letattempt(f:unit->'T)=try Some(f())with_-> None
2928

3029
[<RequireQualifiedAccess>]
3130
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
@@ -574,7 +573,7 @@ module internal ParsedInput =
574573
letaddIdent(ident:Ident)=
575574
identsByEndPos.[ident.idRange.End]<-[ident]
576575

577-
let recwalkImplFileInput(ParsedImplFileInput(_,_,_,_,_,moduleOrNamespaceList,_))=
576+
let recwalkImplFileInput(ParsedImplFileInput(modules=moduleOrNamespaceList))=
578577
List.iter walkSynModuleOrNamespace moduleOrNamespaceList
579578

580579
andwalkSynModuleOrNamespace(SynModuleOrNamespace(_,_,_,decls,_,attrs,_,_))=
@@ -947,7 +946,7 @@ module internal ParsedInput =
947946
|> Option.map(fun r-> r.StartColumn)
948947

949948

950-
let recwalkImplFileInput(ParsedImplFileInput(_,_,_,_,_,moduleOrNamespaceList,_))=
949+
let recwalkImplFileInput(ParsedImplFileInput(modules=moduleOrNamespaceList))=
951950
List.iter(walkSynModuleOrNamespace[]) moduleOrNamespaceList
952951

953952
andwalkSynModuleOrNamespace(parent:LongIdent)(SynModuleOrNamespace(ident,_,isModule,decls,_,_,_,range))=

‎src/fsharp/vs/ServiceInterfaceStubGenerator.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,10 @@ module internal InterfaceStubGenerator =
660660

661661
/// Find corresponding interface declaration at a given position
662662
lettryFindInterfaceDeclaration(pos:pos)(parsedInput:ParsedInput)=
663-
let recwalkImplFileInput(ParsedImplFileInput(_name,_isScript,_fileName,_scopedPragmas,_hashDirectives,moduleOrNamespaceList,_))=
663+
let recwalkImplFileInput(ParsedImplFileInput(modules=moduleOrNamespaceList))=
664664
List.tryPick walkSynModuleOrNamespace moduleOrNamespaceList
665665

666-
andwalkSynModuleOrNamespace(SynModuleOrNamespace(_,_,_,decls,_,_,_access,range))=
666+
andwalkSynModuleOrNamespace(SynModuleOrNamespace(decls=decls; range= range))=
667667
ifnot<| rangeContainsPos range posthen
668668
None
669669
else

‎src/fsharp/vs/ServiceNavigation.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ module NavigationImpl =
426426

427427
letgetNavigation(parsedInput:ParsedInput)=
428428
match parsedInputwith
429-
| ParsedInput.SigFile(ParsedSigFileInput(_,_,_,_, modules))-> getNavigationFromSigFile modules
430-
| ParsedInput.ImplFile(ParsedImplFileInput(_,_,_,_,_,modules,_))-> getNavigationFromImplFile modules
429+
| ParsedInput.SigFile(ParsedSigFileInput(modules= modules))-> getNavigationFromSigFile modules
430+
| ParsedInput.ImplFile(ParsedImplFileInput(modules=modules))-> getNavigationFromImplFile modules
431431

432432
letempty= FSharpNavigationItems([||])
433433

@@ -612,7 +612,7 @@ module NavigateTo =
612612
| SynMemberSig.Inherit_
613613
| SynMemberSig.Interface_->()
614614

615-
andwalkImplFileInpit(ParsedImplFileInput(fileName,_,_,_,_,moduleOrNamespaceList,_))=
615+
andwalkImplFileInpit(ParsedImplFileInput(fileName= fileName; modules= moduleOrNamespaceList))=
616616
letcontainer={ Type= ContainerType.File; Name= fileName}
617617
for itemin moduleOrNamespaceListdo
618618
walkSynModuleOrNamespace item container

‎src/fsharp/vs/ServiceUntypedParse.fs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
9797
ErrorScope.Protect Range.range0
9898
(fun()->
9999
match inputwith
100-
| Some(ParsedInput.ImplFile(ParsedImplFileInput(_modname,_isScript,_qualName,_pragmas,_hashDirectives,modules,_isLastCompiland)))->
100+
| Some(ParsedInput.ImplFile(ParsedImplFileInput(modules= modules)))->
101101
NavigationImpl.getNavigationFromImplFile modules
102-
| Some(ParsedInput.SigFile(ParsedSigFileInput(_modname,_qualName,_pragmas,_hashDirectives,_modules)))->
102+
| Some(ParsedInput.SigFile(ParsedSigFileInput_))->
103103
NavigationImpl.empty
104104
|_->
105105
NavigationImpl.empty)
@@ -343,7 +343,7 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
343343
letwalkImplFile(modules:SynModuleOrNamespace list)= List.collect walkModule modules
344344

345345
match inputwith
346-
| Some(ParsedInput.ImplFile(ParsedImplFileInput(_,_,_,_,_,modules,_)))-> walkImplFile modules
346+
| Some(ParsedInput.ImplFile(ParsedImplFileInput(modules= modules)))-> walkImplFile modules
347347
|_->[]
348348

349349
ErrorScope.Protect Range.range0
@@ -363,8 +363,8 @@ type FSharpParseFileResults(errors : FSharpErrorInfo[], input : Ast.ParsedInput
363363

364364
memberscope.FileName=
365365
match inputwith
366-
| Some(ParsedInput.ImplFile(ParsedImplFileInput(modname,_,_,_,_,_,_)))
367-
| Some(ParsedInput.SigFile(ParsedSigFileInput(modname,_,_,_,_)))-> modname
366+
| Some(ParsedInput.ImplFile(ParsedImplFileInput(fileName= modname)))
367+
| Some(ParsedInput.SigFile(ParsedSigFileInput(fileName= modname)))-> modname
368368
|_->""
369369

370370
// Get items for the navigation drop down bar
@@ -647,7 +647,7 @@ module UntypedParseImpl =
647647
if isPosInRange rangethen f()
648648
else None
649649

650-
let recwalkImplFileInput(ParsedImplFileInput(_,_,_,_,_,moduleOrNamespaceList,_))=
650+
let recwalkImplFileInput(ParsedImplFileInput(modules=moduleOrNamespaceList))=
651651
List.tryPick(walkSynModuleOrNamespacetrue) moduleOrNamespaceList
652652

653653
andwalkSynModuleOrNamespace isTopLevel(SynModuleOrNamespace(_,_,_,decls,_,attrs,_,r))=

‎src/fsharp/vs/ServiceXmlDocParser.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ module internal XmlDocParsing =
238238

239239
andgetXmlDocablesInput input=
240240
match inputwith
241-
| ParsedInput.ImplFile(ParsedImplFileInput(_,_,_,_,_,symModules,_))->
241+
| ParsedInput.ImplFile(ParsedImplFileInput(modules=symModules))->
242242
symModules|> List.collect getXmlDocablesSynModuleOrNamespace
243243
| ParsedInput.SigFile_->[]
244244

‎src/fsharp/vs/Symbols.fs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,19 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
514514
|> List.map(fun a-> FSharpAttribute(cenv, a))
515515
|> makeReadOnlyCollection
516516

517+
member__.AllCompilationPaths=
518+
checkIsResolved()
519+
let(CompilationPath.CompPath(_,parts))= entity.CompilationPath
520+
([], parts)||> List.fold(fun res(part,kind)->
521+
letparts=
522+
match kindwith
523+
| ModuleOrNamespaceKind.FSharpModuleWithSuffix->
524+
[part; part.[..part.Length-7]]
525+
|_->[part]
526+
527+
parts|> List.collect(fun part->
528+
res|> List.map(fun path-> path+"."+ part)))
529+
517530
overridex.Equals(other:obj)=
518531
box x=== other||
519532
match otherwith

‎src/fsharp/vs/Symbols.fsi‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,15 @@ and [<Class>] internal FSharpEntity =
271271
/// Indicates if the type is a delegate with the given Invoke signature
272272
memberFSharpDelegateSignature:FSharpDelegateSignature
273273

274-
/// Get the declared accessibility of the type
274+
/// Get the declared accessibility of the type
275275
memberAccessibility:FSharpAccessibility
276276

277-
/// Get the declared accessibility of the representation, not taking signatures into account
277+
/// Get the declared accessibility of the representation, not taking signatures into account
278278
memberRepresentationAccessibility:FSharpAccessibility
279279

280+
/// Get all compilation paths, taking `Module` suffixes into account.
281+
memberAllCompilationPaths:string list
282+
280283
/// Represents a delegate signature in an F# symbol
281284
and [<Class>]internalFSharpDelegateSignature=
282285
/// Get the argument types of the delegate signature

‎vsintegration/src/FSharp.Editor/BlockComment/CommentUncommentService.fs‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
namespaceMicrosoft.VisualStudio.FSharp.Editor
22

3-
openSystem.ComponentModel.Composition
4-
openMicrosoft.CodeAnalysis.Editor
5-
openMicrosoft.CodeAnalysis.Shared.Extensions
6-
openMicrosoft.CodeAnalysis.Text
7-
openMicrosoft.CodeAnalysis.Text.Shared.Extensions
8-
openMicrosoft.VisualStudio.Text
9-
openMicrosoft.VisualStudio.Text.Operations
10-
openMicrosoft.VisualStudio.Utilities
113
openMicrosoft.CodeAnalysis.Editor.Implementation.CommentSelection
124
openMicrosoft.CodeAnalysis.Host.Mef
13-
openMicrosoft.CodeAnalysis
145
openSystem.Composition
156

167
[<Shared>]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp