Skip to content

Commit 18d87af

Browse files
committed
negate instance member invocation
1 parent 339e5d7 commit 18d87af

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/FsAutoComplete/CodeFixes/NegateBooleanExpression.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ let fix (getParseResultsForFile: GetParseResultsForFile) : CodeFix =
8585
Path = path
8686
NeedsParensAfterNot = true }
8787

88+
// X.Y()
89+
| SynExpr.App(funcExpr = SynExpr.LongIdent(longDotId = LastIdentFromSynLongIdent ident))
90+
8891
// X().Y()
8992
| SynExpr.App(funcExpr = SynExpr.DotGet(longDotId = LastIdentFromSynLongIdent ident))
9093

test/FsAutoComplete.Tests.Lsp/CodeFixTests/NegateBooleanExpressionTests.fs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,24 @@ type X() =
180180
181181
let b = not (X().Y())"
182182

183+
testCaseAsync "negate instance member invocation"
184+
<| CodeFix.check
185+
server
186+
"
187+
open System.Collections.Generic
188+
189+
let foo () =
190+
let dict = dict []
191+
dict.TryAdd$0(\"foo\", \"bar\")
192+
()"
193+
Diagnostics.acceptAll
194+
selectCodeFix
195+
"
196+
open System.Collections.Generic
197+
198+
let foo () =
199+
let dict = dict []
200+
(not (dict.TryAdd(\"foo\", \"bar\")))
201+
()"
202+
183203
])

0 commit comments

Comments
 (0)