Skip to content

Add option to toggle unused declarations analyzer #4074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions vsintegration/src/FSharp.Editor/CodeFix/RenameUnusedValue.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ type internal FSharpRenameUnusedValueCodeFixProvider

override __.RegisterCodeFixesAsync context : Task =
asyncMaybe {
// Don't show code fixes for unused values, even if they are compiler-generated.
do! Option.guard Settings.CodeFixes.UnusedDeclarations

let document = context.Document
let! sourceText = document.GetTextAsync()
let ident = sourceText.ToString(context.Span)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ type internal UnusedDeclarationsAnalyzer() =

override __.AnalyzeSemanticsAsync(document, cancellationToken) =
asyncMaybe {
do! Option.guard Settings.CodeFixes.UnusedDeclarations

do Trace.TraceInformation("{0:n3} (start) UnusedDeclarationsAnalyzer", DateTime.Now.TimeOfDay.TotalSeconds)
do! Async.Sleep DefaultTuning.UnusedDeclarationsAnalyzerInitialDelay |> liftAsync // be less intrusive, give other work priority most of the time
match getProjectInfoManager(document).TryGetOptionsForEditingDocumentOrProject(document) with
Expand Down
6 changes: 4 additions & 2 deletions vsintegration/src/FSharp.Editor/Options/EditorOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ type QuickInfoOptions =
type CodeFixesOptions =
{ SimplifyName: bool
AlwaysPlaceOpensAtTopLevel: bool
UnusedOpens: bool }
UnusedOpens: bool
UnusedDeclarations: bool }

[<CLIMutable>]
type LanguageServicePerformanceOptions =
Expand All @@ -59,7 +60,8 @@ type internal Settings [<ImportingConstructor>](store: SettingsStore) =
// See https://github.com/Microsoft/visualfsharp/pull/3238#issue-237699595
SimplifyName = false
AlwaysPlaceOpensAtTopLevel = false
UnusedOpens = true }
UnusedOpens = true
UnusedDeclarations = true }

store.RegisterDefault
{ EnableInMemoryCrossProjectReferences = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<StackPanel Margin="15 0 0 0"/>
<CheckBox x:Name="unusedOpens" IsChecked="{Binding UnusedOpens}"
Content="{x:Static local:Strings.Unused_opens_code_fix}"/>
<CheckBox x:Name="unusedDeclaration" IsChecked="{Binding UnusedDeclarations}"
Content="{x:Static local:Strings.Unused_declaration_code_fix}"/>
</StackPanel>
</GroupBox>
</StackPanel>
Expand Down
11 changes: 10 additions & 1 deletion vsintegration/src/FSharp.UIResources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vsintegration/src/FSharp.UIResources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,7 @@
<data name="Unused_opens_code_fix" xml:space="preserve">
<value>Remove unused open statements</value>
</data>
<data name="Unused_declaration_code_fix" xml:space="preserve">
<value>Analyze and suggest fixes for unused values</value>
</data>
</root>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">Odebrat nepoužívané otevřené výkazy</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">Nicht verwendete "open"-Anweisungen entfernen</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="new">Remove unused open statements</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">Quitar instrucciones open no usadas</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">Supprimer les instructions open inutilisées</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">Rimuovi istruzioni OPEN inutilizzate</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">未使用の Open ステートメントを削除する</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">사용되지 않는 open 문 제거</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">Usuń nieużywane otwarte instrukcje</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">Remover instruções abertas não usadas</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">Удалить неиспользуемые открытые операторы</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">Kullanılmayan açık deyimleri kaldır</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">删除未使用的 open 语句</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<target state="translated">移除未使用的 open 陳述式</target>
<note />
</trans-unit>
<trans-unit id="Unused_declaration_code_fix">
<source>Analyze and suggest fixes for unused values</source>
<target state="new">Analyze and suggest fixes for unused values</target>
<note />
</trans-unit>
</body>
</file>
</xliff>