Skip to content

Commit

Permalink
Daemon/fcs: temp ignore 1182 false positive for query symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
auduchinok committed Sep 6, 2023
1 parent cdc675c commit baae79b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ namespace JetBrains.ReSharper.Plugins.FSharp.Daemon.Stages

open System
open FSharp.Compiler.Diagnostics
open FSharp.Compiler.Symbols
open JetBrains.Application
open JetBrains.DocumentModel
open JetBrains.ReSharper.Feature.Services.Daemon
Expand Down Expand Up @@ -282,7 +283,28 @@ type FcsErrorsStageProcessBase(fsFile, daemonProcess) =

| UnusedValue ->
match fsFile.GetNode<IReferencePat>(range) with
| null -> UnusedHighlighting(error.Message, range) :> _
| null ->
match fsFile.GetNode<IReferenceExpr>(range) with
| null ->
UnusedHighlighting(error.Message, range) :> _

| refExpr ->
let tryGetSymbol (refExpr: IReferenceExpr) =
let reference = refExpr.Reference
let offset = reference.SymbolOffset
if not (offset.IsValid()) then Unchecked.defaultof<_> else

let fcsSymbolUse = refExpr.FSharpFile.GetSymbolDeclaration(offset.Offset)
if isNull fcsSymbolUse then Unchecked.defaultof<_> else

fcsSymbolUse.Symbol

match tryGetSymbol refExpr with
| :? FSharpMemberOrFunctionOrValue as mfv when mfv.IsReferencedValue ->
IgnoredHighlighting.Instance :> _
| _ ->
UnusedHighlighting(error.Message, range) :> _

| refPat ->

let pat = FSharpPatternUtil.ignoreParentAsPatsFromRight refPat
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Module

let _ =
query {
join a in [] on ("" = a)
join c in [] on ("" = "")
select a
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Module

let _ =
query {
join a in [] on ("" = a)
join |c|(0) in [] on ("" = "")
select a
}

---------------------------------------------------------
(0): ReSharper Dead Code: The value 'c' is unused
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type FcsErrorsHighlightingTest() =

[<Test>] member x.``Unused value - Operators 01``() = x.DoNamedTest()

[<TestReferences("System.Core")>]
[<Test>] member x.``Unused value - Query 01``() = x.DoNamedTest()
[<Test>] member x.``Unused value - Partial pattern 01``() = x.DoNamedTest()
[<Test>] member x.``Unused value - Partial pattern 02 - And``() = x.DoNamedTest()
[<Test>] member x.``Unused value 01 - Object expression``() = x.DoNamedTest()
Expand Down

0 comments on commit baae79b

Please sign in to comment.