Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement check and codefix for mismatched parameters (#3527)
Issue opened: #3539
- Loading branch information
1 parent
3bec369
commit 0f259ed
Showing
25 changed files
with
223 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
neg100.fs(9,12,9,16): typecheck error FS3218: The argument names in the signature 'xxxx' and implementation 'qqqq' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
||
neg100.fs(8,12,8,16): typecheck error FS3218: The argument names in the signature 'xxx' and implementation 'qqqq' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
||
neg100.fs(7,12,7,16): typecheck error FS3218: The argument names in the signature 'xx' and implementation 'qqqq' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
||
neg100.fs(6,12,6,16): typecheck error FS3218: The argument names in the signature 'x' and implementation 'qqqq' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
||
neg100.fs(15,17,15,22): typecheck error FS3218: The argument names in the signature 'xxxx' and implementation 'qqqq3' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
||
neg100.fs(14,17,14,22): typecheck error FS3218: The argument names in the signature 'xxx' and implementation 'qqqq3' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
||
neg100.fs(13,17,13,22): typecheck error FS3218: The argument names in the signature 'xx' and implementation 'qqqq3' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
||
neg100.fs(12,17,12,22): typecheck error FS3218: The argument names in the signature 'x' and implementation 'qqqq3' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. | ||
|
||
neg100.fs(11,9,11,14): typecheck error FS3218: The argument names in the signature 'aaa' and implementation 'qqqq2' do not match. The argument name from the signature file will be used. This may cause problems when debugging or profiling. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
|
||
module M | ||
|
||
let ffff ok = ok + 3 | ||
let gggg1 (qqqq : int) = qqqq + 3 | ||
let gggg2 (qqqq : int) = qqqq + 3 | ||
let gggg3 (qqqq : int) = qqqq + 3 | ||
let gggg4 (qqqq : int) = qqqq + 3 | ||
|
||
type C( qqqq2: int) = | ||
member __.M1 (qqqq3: int) = qqqq2 + qqqq3 |> ignore | ||
member __.M2 (qqqq3: int) = qqqq2 + qqqq3 |> ignore | ||
member __.M3 (qqqq3: int) = qqqq2 + qqqq3 |> ignore | ||
member __.M4 (qqqq3: int) = qqqq2 + qqqq3 |> ignore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
|
||
module M | ||
|
||
val ffff : int -> int | ||
val gggg1 : x: int -> int | ||
val gggg2 : xx: int -> int | ||
val gggg3 : xxx: int -> int | ||
val gggg4 : xxxx: int -> int | ||
|
||
type C = | ||
new : aaa : int -> C | ||
member M1 : x:int -> unit | ||
member M2 : xx:int -> unit | ||
member M3 : xxx:int -> unit | ||
member M4 : xxxx:int -> unit |
2 changes: 1 addition & 1 deletion
2
vsintegration/src/FSharp.Editor/CodeFix/AddNewKeywordToDisposableConstructorInvocation.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
vsintegration/src/FSharp.Editor/CodeFix/AddOpenCodeFixProvider.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
vsintegration/src/FSharp.Editor/CodeFix/ImplementInterfaceCodeFixProvider.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
vsintegration/src/FSharp.Editor/CodeFix/MissingReferenceCodeFixProvider.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
vsintegration/src/FSharp.Editor/CodeFix/ProposeUppercaseLabel.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
vsintegration/src/FSharp.Editor/CodeFix/RenameParamToMatchSignature.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// 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.Collections.Immutable | ||
open System.Composition | ||
open System.Threading.Tasks | ||
|
||
open Microsoft.CodeAnalysis | ||
open Microsoft.CodeAnalysis.Text | ||
open Microsoft.CodeAnalysis.CodeFixes | ||
|
||
open Microsoft.FSharp.Compiler | ||
open Microsoft.FSharp.Compiler.SourceCodeServices | ||
open Microsoft.VisualStudio.FSharp.Editor.SymbolHelpers | ||
open Microsoft.FSharp.Compiler.SourceCodeServices.Keywords | ||
|
||
[<ExportCodeFixProvider(FSharpConstants.FSharpLanguageName, Name = "FSharpRenameParamToMatchSignature"); Shared>] | ||
type internal FSharpRenameParamToMatchSignature | ||
[<ImportingConstructor>] | ||
( | ||
checkerProvider: FSharpCheckerProvider, | ||
projectInfoManager: FSharpProjectOptionsManager | ||
) = | ||
|
||
inherit CodeFixProvider() | ||
static let userOpName = "RenameParamToMatchSignature" | ||
let fixableDiagnosticIds = ["FS3218"] | ||
|
||
|
||
override __.FixableDiagnosticIds = Seq.toImmutableArray fixableDiagnosticIds | ||
|
||
override __.RegisterCodeFixesAsync context : Task = | ||
asyncMaybe { | ||
match context.Diagnostics |> Seq.filter (fun x -> fixableDiagnosticIds |> List.contains x.Id) |> Seq.toList with | ||
| [diagnostic] -> | ||
let message = diagnostic.GetMessage() | ||
let parts = System.Text.RegularExpressions.Regex.Match(message, ".+'(.+)'.+'(.+)'.+") | ||
if parts.Success then | ||
|
||
let diagnostics = ImmutableArray.Create diagnostic | ||
let suggestion = parts.Groups.[1].Value | ||
let replacement = QuoteIdentifierIfNeeded suggestion | ||
let computeChanges() = | ||
asyncMaybe { | ||
let document = context.Document | ||
let! cancellationToken = Async.CancellationToken |> liftAsync | ||
let! sourceText = document.GetTextAsync(cancellationToken) | ||
let! symbolUses = getSymbolUsesOfSymbolAtLocationInDocument (document, context.Span.Start, projectInfoManager, checkerProvider.Checker, userOpName) | ||
let changes = | ||
[| for symbolUse in symbolUses do | ||
match RoslynHelpers.TryFSharpRangeToTextSpan(sourceText, symbolUse.RangeAlternate) with | ||
| None -> () | ||
| Some span -> | ||
let textSpan = Tokenizer.fixupSpan(sourceText, span) | ||
yield TextChange(textSpan, replacement) |] | ||
return changes | ||
} | ||
let title = FSComp.SR.replaceWithSuggestion suggestion | ||
let codefix = createTextChangeCodeFix(title, context, computeChanges) | ||
context.RegisterCodeFix(codefix, diagnostics) | ||
| _ -> () | ||
} |> Async.Ignore |> RoslynHelpers.StartAsyncUnitAsTask(context.CancellationToken) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.