Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit ecf9c10

Browse files
cartermpKevinRansom
authored andcommitted
Replace FSComp invocations in VS tooling with an FCS API (dotnet#6904)
1 parent f0663fd commit ecf9c10

File tree

5 files changed

+7
-12
lines changed

5 files changed

+7
-12
lines changed

CodeFix/FixIndexerAccess.fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
namespace Microsoft.VisualStudio.FSharp.Editor
44

5-
open System
65
open System.Composition
76
open System.Collections.Immutable
87
open System.Threading.Tasks
98

10-
open Microsoft.CodeAnalysis
119
open Microsoft.CodeAnalysis.Text
1210
open Microsoft.CodeAnalysis.CodeFixes
13-
open SymbolHelpers
11+
open FSharp.Compiler.SourceCodeServices
1412

1513
[<ExportCodeFixProvider(FSharpConstants.FSharpLanguageName, Name = "FixIndexerAccess"); Shared>]
1614
type internal FSharpFixIndexerAccessCodeFixProvider() =
@@ -50,7 +48,7 @@ type internal FSharpFixIndexerAccessCodeFixProvider() =
5048

5149
let codefix =
5250
CodeFixHelpers.createTextChangeCodeFix(
53-
FSComp.SR.addIndexerDot(),
51+
CompilerDiagnostics.getErrorMessage AddIndexerDot,
5452
context,
5553
(fun () -> asyncMaybe.Return [| TextChange(span, replacement.TrimEnd() + ".") |]))
5654

CodeFix/ProposeUppercaseLabel.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ open System.Composition
66
open System.Threading.Tasks
77
open Microsoft.CodeAnalysis.CodeFixes
88
open Microsoft.CodeAnalysis.CodeActions
9+
open FSharp.Compiler.SourceCodeServices
910

1011
[<ExportCodeFixProvider(FSharpConstants.FSharpLanguageName, Name = "ProposeUpperCaseLabel"); Shared>]
1112
type internal FSharpProposeUpperCaseLabelCodeFixProvider
@@ -24,7 +25,7 @@ type internal FSharpProposeUpperCaseLabelCodeFixProvider
2425
asyncMaybe {
2526
let textChanger (originalText: string) = originalText.[0].ToString().ToUpper() + originalText.Substring(1)
2627
let! solutionChanger, originalText = SymbolHelpers.changeAllSymbolReferences(context.Document, context.Span, textChanger, projectInfoManager, checkerProvider.Checker, userOpName)
27-
let title = FSComp.SR.replaceWithSuggestion (textChanger originalText)
28+
let title = CompilerDiagnostics.getErrorMessage (ReplaceWithSuggestion <| textChanger originalText)
2829
context.RegisterCodeFix(
2930
CodeAction.Create(title, solutionChanger, title),
3031
context.Diagnostics |> Seq.filter (fun x -> fixableDiagnosticIds |> List.contains x.Id) |> Seq.toImmutableArray)

CodeFix/RemoveUnusedOpens.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ open System.Composition
66
open System.Threading
77
open System.Threading.Tasks
88

9-
open Microsoft.CodeAnalysis
109
open Microsoft.CodeAnalysis.Diagnostics
1110
open Microsoft.CodeAnalysis.Text
1211
open Microsoft.CodeAnalysis.CodeFixes

CodeFix/RenameParamToMatchSignature.fs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22

33
namespace Microsoft.VisualStudio.FSharp.Editor
44

5-
open System
65
open System.Collections.Immutable
76
open System.Composition
87
open System.Threading.Tasks
98

10-
open Microsoft.CodeAnalysis
119
open Microsoft.CodeAnalysis.Text
1210
open Microsoft.CodeAnalysis.CodeFixes
1311

14-
open FSharp.Compiler
1512
open FSharp.Compiler.SourceCodeServices
1613
open Microsoft.VisualStudio.FSharp.Editor.SymbolHelpers
1714
open FSharp.Compiler.SourceCodeServices.Keywords
@@ -57,7 +54,7 @@ type internal FSharpRenameParamToMatchSignature
5754
yield TextChange(textSpan, replacement) |]
5855
return changes
5956
}
60-
let title = FSComp.SR.replaceWithSuggestion suggestion
57+
let title = CompilerDiagnostics.getErrorMessage (ReplaceWithSuggestion suggestion)
6158
let codefix = CodeFixHelpers.createTextChangeCodeFix(title, context, computeChanges)
6259
context.RegisterCodeFix(codefix, diagnostics)
6360
| _ -> ()

CodeFix/ReplaceWithSuggestion.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ type internal FSharpReplaceWithSuggestionCodeFixProvider
5959

6060
for suggestion in suggestions do
6161
let replacement = Keywords.QuoteIdentifierIfNeeded suggestion
62-
let codeFix =
62+
let codeFix =
6363
CodeFixHelpers.createTextChangeCodeFix(
64-
FSComp.SR.replaceWithSuggestion suggestion,
64+
CompilerDiagnostics.getErrorMessage (ReplaceWithSuggestion suggestion),
6565
context,
6666
(fun () -> asyncMaybe.Return [| TextChange(context.Span, replacement) |]))
6767

0 commit comments

Comments
 (0)