diff --git a/vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs b/vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs index aee56efed4d..36eb5bc7a0e 100644 --- a/vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs +++ b/vsintegration/src/FSharp.Editor/Diagnostics/DocumentDiagnosticAnalyzer.fs @@ -110,8 +110,9 @@ type internal FSharpDocumentDiagnosticAnalyzer [] () = let! unnecessaryParentheses = match diagnosticType with - | DiagnosticsType.Semantic -> CancellableTask.singleton ImmutableArray.Empty - | DiagnosticsType.Syntax -> UnnecessaryParenthesesDiagnosticAnalyzer.GetDiagnostics document + | DiagnosticsType.Syntax when document.Project.IsFsharpRemoveParensEnabled -> + UnnecessaryParenthesesDiagnosticAnalyzer.GetDiagnostics document + | _ -> CancellableTask.singleton ImmutableArray.Empty if errors.Count = 0 && unnecessaryParentheses.IsEmpty then return ImmutableArray.Empty diff --git a/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs b/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs index 04e37fa8639..c531d386af3 100644 --- a/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs +++ b/vsintegration/src/FSharp.Editor/Options/EditorOptions.fs @@ -63,6 +63,7 @@ type CodeFixesOptions = UnusedOpens: bool UnusedDeclarations: bool SuggestNamesForErrors: bool + RemoveParens: bool } static member Default = @@ -73,6 +74,7 @@ type CodeFixesOptions = UnusedOpens = true UnusedDeclarations = true SuggestNamesForErrors = true + RemoveParens = false } [] @@ -250,6 +252,8 @@ module EditorOptionsExtensions = member this.IsFSharpCodeFixesUnusedOpensEnabled = this.EditorOptions.CodeFixes.UnusedOpens + member this.IsFsharpRemoveParensEnabled = this.EditorOptions.CodeFixes.RemoveParens + member this.IsFSharpCodeFixesSuggestNamesForErrorsEnabled = this.EditorOptions.CodeFixes.SuggestNamesForErrors diff --git a/vsintegration/src/FSharp.UIResources/CodeFixesOptionControl.xaml b/vsintegration/src/FSharp.UIResources/CodeFixesOptionControl.xaml index c9111067b4b..211e17fd3ce 100644 --- a/vsintegration/src/FSharp.UIResources/CodeFixesOptionControl.xaml +++ b/vsintegration/src/FSharp.UIResources/CodeFixesOptionControl.xaml @@ -31,6 +31,8 @@ + diff --git a/vsintegration/src/FSharp.UIResources/Strings.Designer.cs b/vsintegration/src/FSharp.UIResources/Strings.Designer.cs index a723eb86cb6..a7bcaa08413 100644 --- a/vsintegration/src/FSharp.UIResources/Strings.Designer.cs +++ b/vsintegration/src/FSharp.UIResources/Strings.Designer.cs @@ -384,6 +384,15 @@ public static string Project_Performance { } } + /// + /// Looks up a localized string similar to Remove unnecessary parentheses (experimental, might affect typing performance). + /// + public static string Remove_parens_code_fix { + get { + return ResourceManager.GetString("Remove_parens_code_fix", resourceCulture); + } + } + /// /// Looks up a localized string similar to Send additional performance telemetry. /// diff --git a/vsintegration/src/FSharp.UIResources/Strings.resx b/vsintegration/src/FSharp.UIResources/Strings.resx index 45341e046d0..b1362651cb3 100644 --- a/vsintegration/src/FSharp.UIResources/Strings.resx +++ b/vsintegration/src/FSharp.UIResources/Strings.resx @@ -285,4 +285,7 @@ Background analysis + + Remove unnecessary parentheses (experimental, might affect typing performance) + \ No newline at end of file diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf index 466ed87ec6f..4c1afb7bca0 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf @@ -127,6 +127,11 @@ Upřednostňovaná šířka popisu ve znacích + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry Odeslat další telemetrii výkonu diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf index 1f517d8e4cc..f93c85b0afc 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf @@ -127,6 +127,11 @@ Bevorzugte Beschreibungsbreite in Zeichen + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry Zusätzliche Leistungstelemetriedaten senden diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf index 644581f92bd..3b65a70284b 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.es.xlf @@ -127,6 +127,11 @@ Anchura preferida de la descripción en caracteres + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry Enviar telemetría de rendimiento adicional diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf index 68499f2c4dd..1fcb58d38a5 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.fr.xlf @@ -127,6 +127,11 @@ Largeur de description préférée en caractères + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry Envoyer une télémétrie de performances supplémentaire diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf index 484e7d17f83..ac84a49ac04 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.it.xlf @@ -127,6 +127,11 @@ Larghezza descrizione preferita in caratteri + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry Invia dati di telemetria aggiuntivi per le prestazioni diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf index 9d860549850..76036894dcb 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.ja.xlf @@ -127,6 +127,11 @@ 優先する説明の文字幅 + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry 追加のパフォーマンス テレメトリを送信する diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf index 554d0f3a6f4..f166bba08f3 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.ko.xlf @@ -127,6 +127,11 @@ 기본 설정 설명 너비(문자) + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry 추가 성능 원격 분석 보내기 diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf index f8a16928d83..c4d70ab3a1f 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.pl.xlf @@ -127,6 +127,11 @@ Preferowana szerokość opisu w znakach + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry Wysyłanie dodatkowych danych telemetrycznych dotyczących wydajności diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf index 46c9407d0a0..f1ef03e827e 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.pt-BR.xlf @@ -127,6 +127,11 @@ Largura de descrição preferencial em caracteres + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry Enviar telemetria de desempenho adicional diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf index 3d1d2fbeec1..4db5610e9bb 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.ru.xlf @@ -127,6 +127,11 @@ Предпочитаемая ширина описания в символах + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry Отправить дополнительные диагностические данные о производительности diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf index 020981e8513..95fa383de7e 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.tr.xlf @@ -127,6 +127,11 @@ Karakter olarak tercih edilen açıklama genişliği + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry Ek performans telemetrisi gönder diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf index 51078539abc..3b45fdaf529 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hans.xlf @@ -127,6 +127,11 @@ 以字符为单位的首选说明宽度 + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry 发送其他性能遥测 diff --git a/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf b/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf index 1b0cec83a53..50aede6ee96 100644 --- a/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf +++ b/vsintegration/src/FSharp.UIResources/xlf/Strings.zh-Hant.xlf @@ -127,6 +127,11 @@ 慣用説明寬度 (以字元為單位) + + Remove unnecessary parentheses (experimental, might affect typing performance) + Remove unnecessary parentheses (experimental, might affect typing performance) + + Send additional performance telemetry 傳送其他效能遙測 diff --git a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs index c1caae8ab64..d0d1dd9bf5c 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/RemoveUnnecessaryParenthesesTests.fs @@ -16,7 +16,13 @@ module private TopLevel = let private tryFix (code: string) = cancellableTask { - let document = Document.create Auto code + let mode = + WithSettings + { CodeFixesOptions.Default with + RemoveParens = true + } + + let document = Document.create mode code let sourceText = SourceText.From code let! diagnostics = FSharpDocumentDiagnosticAnalyzer.GetDiagnostics(document, DiagnosticsType.Syntax)