提交 9f45f7fc 编写于 作者: S Saul Rennison 提交者: Kevin Ransom (msft)

Add "Unused opens" to the "Code Fixes" settings (#2876)

上级 f3e952cb
......@@ -18,7 +18,6 @@ open Microsoft.VisualStudio.FSharp.LanguageService
type private TextVersionHash = int
// TODO Turn it on when user settings dialog is ready to switch it on and off.
[<DiagnosticAnalyzer(FSharpConstants.FSharpLanguageName)>]
type internal SimplifyNameDiagnosticAnalyzer() =
inherit DocumentDiagnosticAnalyzer()
......
......@@ -160,6 +160,7 @@ type internal UnusedOpensDiagnosticAnalyzer() =
static member GetUnusedOpenRanges(document: Document, options, checker: FSharpChecker) =
asyncMaybe {
do! Option.guard Settings.CodeFixes.UnusedOpens
let! sourceText = document.GetTextAsync()
let! _, parsedInput, checkResults = checker.ParseAndCheckDocument(document, options, sourceText = sourceText, allowStaleResults = true)
let! symbolUses = checkResults.GetAllUsesOfAllSymbolsInFile() |> liftAsync
......
......@@ -24,7 +24,8 @@ type QuickInfoOptions() =
[<CLIMutable>]
type CodeFixesOptions =
{ SimplifyName: bool }
{ SimplifyName: bool
UnusedOpens: bool }
[<Export(typeof<ISettings>)>]
type internal Settings [<ImportingConstructor>](store: SettingsStore) =
......@@ -37,7 +38,8 @@ type internal Settings [<ImportingConstructor>](store: SettingsStore) =
QuickInfoOptions()
|> store.RegisterDefault
{ SimplifyName = true }
{ SimplifyName = true
UnusedOpens = true }
|> store.RegisterDefault
interface ISettings
......
......@@ -21,7 +21,8 @@
<StackPanel>
<CheckBox x:Name="simplifyName" IsChecked="{Binding SimplifyName}"
Content="{x:Static local:Strings.Simplify_name_code_fix}"/>
<StackPanel Margin="15 0 0 0"/>
<CheckBox x:Name="unusedOpens" IsChecked="{Binding UnusedOpens}"
Content="{x:Static local:Strings.Unused_opens_code_fix}"/>
</StackPanel>
</GroupBox>
</StackPanel>
......
......@@ -133,7 +133,7 @@ public class Strings {
}
/// <summary>
/// Looks up a localized string similar to Simplify Name.
/// Looks up a localized string similar to Simplify names (remove unnecessary qualifiers).
/// </summary>
public static string Simplify_name_code_fix {
get {
......@@ -149,5 +149,14 @@ public class Strings {
return ResourceManager.GetString("Solid_underline", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Remove unused open statements.
/// </summary>
public static string Unused_opens_code_fix {
get {
return ResourceManager.GetString("Unused_opens_code_fix", resourceCulture);
}
}
}
}
......@@ -142,9 +142,12 @@
<value>S_how navigation links as</value>
</data>
<data name="Simplify_name_code_fix" xml:space="preserve">
<value>Simplify Name</value>
<value>Simplify names (remove unnecessary qualifiers)</value>
</data>
<data name="Solid_underline" xml:space="preserve">
<value>_Solid underline</value>
</data>
<data name="Unused_opens_code_fix" xml:space="preserve">
<value>Remove unused open statements</value>
</data>
</root>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册