Skip to content

Commit

Permalink
update Analyzers and ProjInfo, and re-enable analyzers integration (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel authored May 15, 2024
1 parent 261d5bd commit 4b0abc7
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 195 deletions.
17 changes: 11 additions & 6 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,36 @@
"version": "8.0.3",
"commands": [
"paket"
]
],
"rollForward": false
},
"dotnet-reportgenerator-globaltool": {
"version": "5.0.2",
"commands": [
"reportgenerator"
]
],
"rollForward": false
},
"fantomas": {
"version": "6.3.1",
"commands": [
"fantomas"
]
],
"rollForward": false
},
"fsharp-analyzers": {
"version": "0.25.0",
"version": "0.26.0",
"commands": [
"fsharp-analyzers"
]
],
"rollForward": false
},
"telplin": {
"version": "0.9.6",
"commands": [
"telplin"
]
],
"rollForward": false
}
}
}
12 changes: 6 additions & 6 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ lowest_matching: true
nuget BenchmarkDotNet 0.13.5
nuget Fantomas.Client >= 0.9
nuget FSharp.Compiler.Service >= 43.8.300
nuget Ionide.Analyzers 0.10.0
nuget Ionide.Analyzers 0.11.0
nuget FSharp.Analyzers.Build 0.3.0
nuget Ionide.ProjInfo >= 0.64.0
nuget Ionide.ProjInfo.FCS >= 0.64.0
nuget Ionide.ProjInfo.ProjectSystem >= 0.64.0
nuget Ionide.ProjInfo.Sln >= 0.64.0
nuget Ionide.ProjInfo >= 0.65.0
nuget Ionide.ProjInfo.FCS >= 0.65.0
nuget Ionide.ProjInfo.ProjectSystem >= 0.65.0
nuget Ionide.ProjInfo.Sln >= 0.65.0
nuget Microsoft.Build >= 17.2 copy_local:false
nuget Microsoft.Build.Framework >= 17.4 copy_local:false
nuget Microsoft.Build.Utilities.Core >= 17.4 copy_local:false
nuget Microsoft.Build.Tasks.Core >= 17.4 copy_local: false
nuget Nuget.Frameworks >= 6.3 copy_local: false
nuget Microsoft.CodeAnalysis 4.5.0
# nuget FSharp.Analyzers.SDK # disabled because it conflicts with the floating FCS dependency
nuget FSharp.Analyzers.SDK 0.26.0
nuget ICSharpCode.Decompiler
nuget Mono.Cecil >= 0.11.4
nuget FSharpLint.Core
Expand Down
41 changes: 24 additions & 17 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ NUGET
FParsec (1.1.1) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net5.0)) (&& (== netstandard2.1) (>= net5.0))
FSharp.Core (>= 4.3.4)
FSharp.Analyzers.Build (0.3)
FSharp.Analyzers.SDK (0.26)
FSharp.Compiler.Service (43.8.300) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
FSharp.Core (8.0.300) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
McMaster.NETCore.Plugins (>= 1.4) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Microsoft.Extensions.Logging.Abstractions (>= 6.0) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
FSharp.Compiler.Service (43.8.300)
FSharp.Core (8.0.300)
System.Buffers (>= 4.5.1)
Expand Down Expand Up @@ -127,32 +132,35 @@ NUGET
Microsoft.Win32.Registry (>= 5.0)
System.Collections.Immutable (>= 5.0)
System.Reflection.Metadata (>= 5.0)
Ionide.Analyzers (0.10)
Ionide.Analyzers (0.11)
Ionide.KeepAChangelog.Tasks (0.1.8) - copy_local: true
Ionide.LanguageServerProtocol (0.4.23)
FSharp.Core (>= 6.0)
Newtonsoft.Json (>= 13.0.1)
StreamJsonRpc (>= 2.16.36)
Ionide.ProjInfo (0.64)
FSharp.Core (>= 7.0.400) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo.Sln (>= 0.64) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo (0.65)
FSharp.Core (>= 8.0.300) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo.Sln (>= 0.65) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Microsoft.Build (>= 17.2) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Microsoft.Build.Framework (>= 17.2) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
SemanticVersioning (>= 2.0.2) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo.FCS (0.64)
FSharp.Compiler.Service (>= 43.7.400) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
FSharp.Core (>= 7.0.400) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo (>= 0.64) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo.ProjectSystem (0.64)
FSharp.Compiler.Service (>= 43.7.400) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo.FCS (0.65)
FSharp.Compiler.Service (>= 43.8.300) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
FSharp.Core (>= 8.0.300) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo (>= 0.65) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo.ProjectSystem (0.65)
FSharp.Compiler.Service (>= 43.8.300) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
FSharp.Control.Reactive (>= 5.0.5) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
FSharp.Core (>= 7.0.400) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo (>= 0.64) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo.FCS (>= 0.64) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo.Sln (>= 0.64) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
FSharp.Core (>= 8.0.300) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo (>= 0.65) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo.FCS (>= 0.65) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo.Sln (>= 0.65) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Newtonsoft.Json (>= 13.0.1) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Ionide.ProjInfo.Sln (0.64)
Ionide.ProjInfo.Sln (0.65)
LinkDotNet.StringBuilder (1.18)
McMaster.NETCore.Plugins (1.4) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Microsoft.DotNet.PlatformAbstractions (>= 3.1.6) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= netcoreapp2.1)) (&& (== netstandard2.1) (>= netcoreapp2.1))
Microsoft.Extensions.DependencyModel (>= 5.0) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= netcoreapp2.1)) (&& (== netstandard2.1) (>= netcoreapp2.1))
MessagePack (2.5.108)
MessagePack.Annotations (>= 2.5.108)
Microsoft.Bcl.AsyncInterfaces (>= 6.0) - restriction: || (&& (== net7.0) (< net6.0)) (&& (== net8.0) (< net6.0)) (== netstandard2.0) (== netstandard2.1)
Expand Down Expand Up @@ -270,6 +278,7 @@ NUGET
Microsoft.Extensions.DependencyInjection.Abstractions (6.0)
Microsoft.Bcl.AsyncInterfaces (>= 6.0) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netstandard2.1)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netstandard2.1)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0) (&& (== netstandard2.1) (>= net461))
System.Threading.Tasks.Extensions (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netstandard2.1)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netstandard2.1)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0) (&& (== netstandard2.1) (>= net461))
Microsoft.Extensions.DependencyModel (5.0) - restriction: || (== net6.0) (== net7.0) (== net8.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Microsoft.Extensions.Logging (6.0)
Microsoft.Bcl.AsyncInterfaces (>= 6.0) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netstandard2.1)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netstandard2.1)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< netstandard2.1)) (== netstandard2.0) (&& (== netstandard2.1) (>= net461))
Microsoft.Extensions.DependencyInjection (>= 6.0)
Expand All @@ -278,8 +287,6 @@ NUGET
Microsoft.Extensions.Options (>= 6.0)
System.Diagnostics.DiagnosticSource (>= 6.0)
Microsoft.Extensions.Logging.Abstractions (6.0.2)
System.Buffers (>= 4.5.1) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< net6.0)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< net6.0)) (== netstandard2.0) (== netstandard2.1)
System.Memory (>= 4.5.4) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< net6.0)) (&& (== net8.0) (>= net461)) (&& (== net8.0) (< net6.0)) (== netstandard2.0) (== netstandard2.1)
Microsoft.Extensions.Logging.Configuration (6.0)
Microsoft.Extensions.Configuration (>= 6.0)
Microsoft.Extensions.Configuration.Abstractions (>= 6.0)
Expand Down
110 changes: 55 additions & 55 deletions src/FsAutoComplete.Core/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ open FSharp.Compiler.Text
open Ionide.ProjInfo
open Ionide.ProjInfo.ProjectSystem
open FsToolkit.ErrorHandling
// open FSharp.Analyzers
open FSharp.Analyzers
open FSharp.UMX
open FSharp.Compiler.Tokenization
open SymbolLocation
Expand Down Expand Up @@ -75,7 +75,7 @@ module AsyncResult =
type NotificationEvent =
| ParseError of errors: FSharpDiagnostic[] * file: string<LocalPath> * version: int
| Workspace of ProjectSystem.ProjectResponse
// | AnalyzerMessage of messages: FSharp.Analyzers.SDK.Message[] * file: string<LocalPath> * version: int
| AnalyzerMessage of messages: FSharp.Analyzers.SDK.Message[] * file: string<LocalPath> * version: int
| UnusedOpens of file: string<LocalPath> * opens: Range[] * version: int
// | Lint of file: string<LocalPath> * warningsWithCodes: Lint.EnrichedLintWarning list
| UnusedDeclarations of file: string<LocalPath> * decls: range[] * version: int
Expand Down Expand Up @@ -1137,59 +1137,59 @@ module Commands =



// let analyzerHandler
// (
// client: SDK.Client<SDK.EditorAnalyzerAttribute, SDK.EditorContext>,
// file: string<LocalPath>,
// content: ISourceText,
// pt,
// tast,
// checkFileResults: FSharpCheckFileResults
// ) =
// let ctx: SDK.EditorContext =
// { FileName = UMX.untag file
// SourceText = content
// ParseFileResults = pt
// CheckFileResults = Some checkFileResults
// TypedTree = Some tast
// CheckProjectResults = None }

// let extractResultsFromAnalyzer (r: SDK.AnalysisResult) =
// match r.Output with
// | Ok results ->
// Loggers.analyzers.info (
// Log.setMessage "Analyzer {analyzer} returned {count} diagnostics for file {file}"
// >> Log.addContextDestructured "analyzer" r.AnalyzerName
// >> Log.addContextDestructured "count" results.Length
// >> Log.addContextDestructured "file" (UMX.untag file)
// )

// results
// | Error e ->
// Loggers.analyzers.error (
// Log.setMessage "Analyzer {analyzer} errored while processing {file}: {message}"
// >> Log.addContextDestructured "analyzer" r.AnalyzerName
// >> Log.addContextDestructured "file" (UMX.untag file)
// >> Log.addContextDestructured "message" e.Message
// >> Log.addExn e
// )

// []

// async {
// try
// let! r = client.RunAnalyzersSafely ctx
// return r |> List.collect extractResultsFromAnalyzer |> List.toArray
// with ex ->
// Loggers.analyzers.error (
// Log.setMessage "Error while processing analyzers for {file}: {message}"
// >> Log.addContextDestructured "message" ex.Message
// >> Log.addExn ex
// >> Log.addContextDestructured "file" file
// )

// return [||]
// }
let analyzerHandler
(
client: SDK.Client<SDK.EditorAnalyzerAttribute, SDK.EditorContext>,
file: string<LocalPath>,
content: ISourceText,
pt,
tast,
checkFileResults: FSharpCheckFileResults
) =
let ctx: SDK.EditorContext =
{ FileName = UMX.untag file
SourceText = content
ParseFileResults = pt
CheckFileResults = Some checkFileResults
TypedTree = Some tast
CheckProjectResults = None }

let extractResultsFromAnalyzer (r: SDK.AnalysisResult) =
match r.Output with
| Ok results ->
Loggers.analyzers.info (
Log.setMessage "Analyzer {analyzer} returned {count} diagnostics for file {file}"
>> Log.addContextDestructured "analyzer" r.AnalyzerName
>> Log.addContextDestructured "count" results.Length
>> Log.addContextDestructured "file" (UMX.untag file)
)

results
| Error e ->
Loggers.analyzers.error (
Log.setMessage "Analyzer {analyzer} errored while processing {file}: {message}"
>> Log.addContextDestructured "analyzer" r.AnalyzerName
>> Log.addContextDestructured "file" (UMX.untag file)
>> Log.addContextDestructured "message" e.Message
>> Log.addExn e
)

[]

async {
try
let! r = client.RunAnalyzersSafely ctx
return r |> List.collect extractResultsFromAnalyzer |> List.toArray
with ex ->
Loggers.analyzers.error (
Log.setMessage "Error while processing analyzers for {file}: {message}"
>> Log.addContextDestructured "message" ex.Message
>> Log.addExn ex
>> Log.addContextDestructured "file" file
)

return [||]
}

type Commands() =

Expand Down
2 changes: 1 addition & 1 deletion src/FsAutoComplete.Core/paket.references
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#FSharp.Analyzers.SDK
FSharp.Analyzers.SDK
ICSharpCode.Decompiler
Microsoft.SourceLink.GitHub
FSharp.UMX
Expand Down
Loading

0 comments on commit 4b0abc7

Please sign in to comment.