Skip to content

Commit

Permalink
Merge branch 'main' into feature/activity-tracking-CI-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Gro committed Oct 11, 2022
2 parents 6fc7aeb + 07b0a6b commit d502913
Show file tree
Hide file tree
Showing 53 changed files with 443 additions and 365 deletions.
2 changes: 1 addition & 1 deletion docs/tooling-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Most of the syntax operations require an entire document's source text or parse
|---------|---------------|---------------|-----------------|
| Most code fixes | Current document's typecheck data | Set (1 or more) of suggested text replacements | S-M |
| Semantic classification | Current document's typecheck data | Spans of text with semantic classification type for all constructs in a document | S-L |
| Code lenses | Current document's typecheck data and top-level declarations (for showing signatures); graph of all projects that reference the current one (for showing references) | Signature data for each top-level construct; spans of text for each reference to a top-level construct with navigation information | S-XL |
| Lenses | Current document's typecheck data and top-level declarations (for showing signatures); graph of all projects that reference the current one (for showing references) | Signature data for each top-level construct; spans of text for each reference to a top-level construct with navigation information | S-XL |
| Code generation / refactorings | Current document's typecheck data and/or current resolved symbol/symbols | Text replacement(s) | S-L |
| Code completion | Current document's typecheck data and currently-resolved symbol user is typing at | List of all symbols in scope that are "completable" based on where completion is invoked | S-L |
| Editor tooltips | Current document's typecheck data and resolved symbol where user invoked a tooltip | F# tooltip data based on inspecting a type and its declarations, then pretty-printing them | S-XL |
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">Používá se ve vzájemně rekurzivních vazbách, v deklaracích vlastností a s několika omezeními u generických parametrů.</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">Wird in gegenseitig rekursiven Bindungen, in Eigenschaftendeklarationen und bei mehreren Beschränkungen in Bezug auf generische Parameter verwendet.</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">Se usa en enlaces mutuamente recursivos, en declaraciones de propiedad y con varias restricciones en parámetros genéricos.</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">Utilisé dans les liaisons mutuellement récursives, dans les déclarations de propriété et avec plusieurs contraintes sur des paramètres génériques.</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">Usata in binding ricorsivi reciproci, dichiarazioni di proprietà e con più vincoli su parametri generici.</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">相互に再帰的なバインディング、プロパティの宣言、およびジェネリック パラメーターの複数の制約に使用します。</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">상호 재귀적 바인딩과 속성 선언에 사용되며 제네릭 매개 변수의 여러 제약 조건과 함께 사용됩니다.</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">Używane w powiązaniach wzajemnie cyklicznych, deklaracjach właściwości oraz z wieloma ograniczeniami parametrów ogólnych.</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">Usado em associações mutualmente recursivas, em declarações de propriedade e em múltiplas restrições em parâmetros genéricos.</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">Используется во взаимно рекурсивных привязках, объявлениях свойств и с несколькими ограничениями для универсальных параметров.</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">Karşılıklı yinelemeli bağlamalarda, özellik bildirimlerinde ve genel parametreler üzerinde birden çok kısıtlamayla kullanılır.</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">用于互相递归绑定、属性声明,并用于对泛型参数的多个约束。</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/xlf/FSComp.txt.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -7554,7 +7554,7 @@
</trans-unit>
<trans-unit id="keywordDescriptionAnd">
<source>Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</source>
<target state="translated">用於互相遞迴的繫結、屬性宣告,以及搭配泛型參數的多個條件約束。</target>
<target state="new">Used in mutually recursive bindings, in property declarations, and with multiple constraints on generic parameters.</target>
<note />
</trans-unit>
<trans-unit id="keywordDescriptionAs">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Microsoft.VisualStudio.FSharp.Editor

open System
open System.Composition
open System.Collections.Immutable

open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.Text
open Microsoft.CodeAnalysis.CodeFixes

[<ExportCodeFixProvider(FSharpConstants.FSharpLanguageName, Name = "ConvertCSharpUsingToFSharpOpen"); Shared>]
type internal FSharpConvertCSharpUsingToFSharpOpen
[<ImportingConstructor>]
(
) =
inherit CodeFixProvider()

let fixableDiagnosticIds = set ["FS0039"; "FS0201"]
let usingLength = "using".Length

let isCSharpUsingShapeWithPos (context: CodeFixContext) (sourceText: SourceText) =
// Walk back until whitespace
let mutable pos = context.Span.Start - 1
let mutable ch = sourceText.[pos]
while pos > 0 && not(Char.IsWhiteSpace(ch)) do
pos <- pos - 1
ch <- sourceText.[pos]

// Walk back whitespace
ch <- sourceText.[pos]
while pos > 0 && Char.IsWhiteSpace(ch) do
pos <- pos - 1
ch <- sourceText.[pos]

// Take 'using' slice and don't forget that offset because computer math is annoying
let start = pos - usingLength + 1
let span = TextSpan(start, usingLength)
let slice = sourceText.GetSubText(span).ToString()
struct(slice = "using", start)

let registerCodeFix (context: CodeFixContext) (diagnostics: ImmutableArray<Diagnostic>) (str: string) (span: TextSpan) =
let replacement =
let str = str.Replace("using", "open").Replace(";", "")
TextChange(span, str)
let title = SR.ConvertCSharpUsingToFSharpOpen()
let codeFix =
CodeFixHelpers.createTextChangeCodeFix(
title,
context,
(fun () -> asyncMaybe.Return [| replacement |]))
context.RegisterCodeFix(codeFix, diagnostics)

override _.FixableDiagnosticIds = Seq.toImmutableArray fixableDiagnosticIds

override _.RegisterCodeFixesAsync context =
asyncMaybe {
let diagnostics =
context.Diagnostics
|> Seq.filter (fun x -> fixableDiagnosticIds |> Set.contains x.Id)
|> Seq.toImmutableArray

do! Option.guard(diagnostics.Length > 0)

let! sourceText = context.Document.GetTextAsync(context.CancellationToken)

// TODO: handle single-line case?
let statementWithSemicolonSpan = TextSpan(context.Span.Start, context.Span.Length + 1)

do! Option.guard (sourceText.Length >= statementWithSemicolonSpan.End)

let statementWithSemicolon = sourceText.GetSubText(statementWithSemicolonSpan).ToString()

// Top of the file case -- entire line gets a diagnostic
if (statementWithSemicolon.StartsWith("using") && statementWithSemicolon.EndsWith(";")) then
registerCodeFix context diagnostics statementWithSemicolon statementWithSemicolonSpan
else
// Only the identifier being opened has a diagnostic, so we try to find the rest of the statement
let struct(isCSharpUsingShape, start) = isCSharpUsingShapeWithPos context sourceText
if isCSharpUsingShape then
let len = (context.Span.Start - start) + statementWithSemicolonSpan.Length
let fullSpan = TextSpan(start, len)
let str = sourceText.GetSubText(fullSpan).ToString()
registerCodeFix context diagnostics str fullSpan
}
|> Async.Ignore
|> RoslynHelpers.StartAsyncUnitAsTask(context.CancellationToken)
2 changes: 1 addition & 1 deletion vsintegration/src/FSharp.Editor/Common/Constants.fs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module internal Guids =

[<Literal>]
/// "00BE7FD9-8145-4A2E-A1BF-3BAF0F4F47DD"
let codeLensOptionPageIdString = "00BE7FD9-8145-4A2E-A1BF-3BAF0F4F47DD"
let lensOptionPageIdString = "00BE7FD9-8145-4A2E-A1BF-3BAF0F4F47DD"

[<Literal>]
/// "8FDA964A-263D-4B4E-9560-29897535217C"
Expand Down
7 changes: 4 additions & 3 deletions vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
<Compile Include="CodeFix\AddInstanceMemberParameter.fs" />
<Compile Include="CodeFix\AddTypeAnnotationToObjectOfIndeterminateType.fs" />
<Compile Include="CodeFix\AddMissingRecToMutuallyRecFunctions.fs" />
<Compile Include="CodeFix\ConvertCSharpUsingToFSharpOpen.fs" />
<Compile Include="CodeFix\ConvertCSharpLambdaToFSharpLambda.fs" />
<Compile Include="CodeFix\MakeOuterBindingRecursive.fs" />
<Compile Include="CodeFix\RemoveReturnOrYield.fs" />
Expand Down Expand Up @@ -125,9 +126,9 @@
<Compile Include="Build\SetGlobalPropertiesForSdkProjects.fs" />
<Compile Include="AutomaticCompletion\BraceCompletionSessionProvider.fsi" />
<Compile Include="AutomaticCompletion\BraceCompletionSessionProvider.fs" />
<Compile Include="CodeLens\AbstractCodeLensDisplayService.fs" />
<Compile Include="CodeLens\FSharpCodeLensService.fs" />
<Compile Include="CodeLens\CodeLensProvider.fs" />
<Compile Include="Lens\LensDisplayService.fs" />
<Compile Include="Lens\LensService.fs" />
<Compile Include="Lens\LensProvider.fs" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion vsintegration/src/FSharp.Editor/FSharp.Editor.resx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<value>Advanced</value>
</data>
<data name="6013" xml:space="preserve">
<value>CodeLens</value>
<value>Lens</value>
</data>
<data name="6014" xml:space="preserve">
<value>Formatting</value>
Expand Down Expand Up @@ -291,4 +291,7 @@
<data name="UseTripleQuotedInterpolation" xml:space="preserve">
<value>Use triple quoted string interpolation.</value>
</data>
<data name="ConvertCSharpUsingToFSharpOpen" xml:space="preserve">
<value>Convert C# 'using' to F# 'open'</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ type internal FSharpSettingsFactory
[<ProvideLanguageEditorOptionPage(typeof<OptionsUI.CodeFixesOptionPage>, "F#", null, "Code Fixes", "6010")>]
[<ProvideLanguageEditorOptionPage(typeof<OptionsUI.LanguageServicePerformanceOptionPage>, "F#", null, "Performance", "6011")>]
[<ProvideLanguageEditorOptionPage(typeof<OptionsUI.AdvancedSettingsOptionPage>, "F#", null, "Advanced", "6012")>]
[<ProvideLanguageEditorOptionPage(typeof<OptionsUI.CodeLensOptionPage>, "F#", null, "CodeLens", "6013")>]
[<ProvideLanguageEditorOptionPage(typeof<OptionsUI.LensOptionPage>, "F#", null, "Lens", "6013")>]
[<ProvideLanguageEditorOptionPage(typeof<OptionsUI.FormattingOptionPage>, "F#", null, "Formatting", "6014")>]
[<ProvideFSharpVersionRegistration(FSharpConstants.projectPackageGuidString, "Microsoft Visual F#")>]
// 64 represents a hex number. It needs to be greater than 37 so the TextMate editor will not be chosen as higher priority.
Expand Down

0 comments on commit d502913

Please sign in to comment.