Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/FsAutoComplete/LspHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,8 @@ type InlineValueDto =

type NotificationsDto =
{ Trace: bool option
TraceNamespaces: string array option }
TraceNamespaces: string array option
BackgroundServiceProgress: bool option }

type FSACDto =
{
Expand Down Expand Up @@ -791,22 +792,26 @@ type InlineValuesConfig =

type NotificationsConfig =
{ Trace: bool
TraceNamespaces: string array }
TraceNamespaces: string array
BackgroundServiceProgress: bool }

static member Default =
{ Trace = false
TraceNamespaces = [||] }
TraceNamespaces = [||]
BackgroundServiceProgress = false }

static member FromDto(dto: NotificationsDto) : NotificationsConfig =
let defaultConfig = NotificationsConfig.Default

{ Trace = defaultArg dto.Trace defaultConfig.Trace
TraceNamespaces = defaultArg dto.TraceNamespaces defaultConfig.TraceNamespaces }
TraceNamespaces = defaultArg dto.TraceNamespaces defaultConfig.TraceNamespaces
BackgroundServiceProgress = defaultArg dto.BackgroundServiceProgress defaultConfig.BackgroundServiceProgress }


member this.AddDto(dto: NotificationsDto) : NotificationsConfig =
{ Trace = defaultArg dto.Trace this.Trace
TraceNamespaces = defaultArg dto.TraceNamespaces this.TraceNamespaces }
TraceNamespaces = defaultArg dto.TraceNamespaces this.TraceNamespaces
BackgroundServiceProgress = defaultArg dto.BackgroundServiceProgress this.BackgroundServiceProgress }

type FSACConfig =
{
Expand Down
6 changes: 4 additions & 2 deletions src/FsAutoComplete/LspHelpers.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ type InlineValueDto =

type NotificationsDto =
{ Trace: bool option
TraceNamespaces: string array option }
TraceNamespaces: string array option
BackgroundServiceProgress: bool option }

type FSACDto =
{
Expand Down Expand Up @@ -366,7 +367,8 @@ type InlineValuesConfig =

type NotificationsConfig =
{ Trace: bool
TraceNamespaces: string array }
TraceNamespaces: string array
BackgroundServiceProgress: bool }

static member Default: NotificationsConfig
static member FromDto: dto: NotificationsDto -> NotificationsConfig
Expand Down
20 changes: 15 additions & 5 deletions src/FsAutoComplete/LspServers/AdaptiveServerState.fs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,9 @@ type AdaptiveState
let! ct = Async.CancellationToken
use! _l = analyzersLocker.LockAsync(ct)
use progress = progressLookup.CreateProgressReport(lspClient, cancellable = true)
do! progress.Begin($"Checking unused opens {fileName}...", message = filePathUntag)

if config.Notifications.BackgroundServiceProgress then
do! progress.Begin($"Checking unused opens {fileName}...", message = filePathUntag)

let! unused =
UnusedOpens.getUnusedOpens (tyRes.GetCheckResults, getSourceLine)
Expand All @@ -494,7 +496,9 @@ type AdaptiveState
let! ct = Async.CancellationToken
use! _l = analyzersLocker.LockAsync(ct)
use progress = progressLookup.CreateProgressReport(lspClient, cancellable = true)
do! progress.Begin($"Checking unused declarations {fileName}...", message = filePathUntag)

if config.Notifications.BackgroundServiceProgress then
do! progress.Begin($"Checking unused declarations {fileName}...", message = filePathUntag)

let isScript = Utils.isAScript (filePathUntag)

Expand All @@ -515,7 +519,9 @@ type AdaptiveState
let! ct = Async.CancellationToken
use! _l = analyzersLocker.LockAsync(ct)
use progress = progressLookup.CreateProgressReport(lspClient, cancellable = true)
do! progress.Begin($"Checking simplifying of names {fileName}...", message = filePathUntag)

if config.Notifications.BackgroundServiceProgress then
do! progress.Begin($"Checking simplifying of names {fileName}...", message = filePathUntag)

let! simplified =
SimplifyNames.getSimplifiableNames (tyRes.GetCheckResults, getSourceLine)
Expand All @@ -533,7 +539,9 @@ type AdaptiveState
let! ct = Async.CancellationToken
use! _l = analyzersLocker.LockAsync(ct)
use progress = progressLookup.CreateProgressReport(lspClient)
do! progress.Begin($"Checking for unnecessary parentheses {fileName}...", message = filePathUntag)

if config.Notifications.BackgroundServiceProgress then
do! progress.Begin($"Checking for unnecessary parentheses {fileName}...", message = filePathUntag)

let unnecessaryParentheses =
(System.Collections.Generic.HashSet(comparer = Range.comparer), tyRes.GetAST)
Expand Down Expand Up @@ -615,7 +623,9 @@ type AdaptiveState

try
use progress = new ServerProgressReport(lspClient)
do! progress.Begin("Running analyzers...", message = UMX.untag file)

if config.Notifications.BackgroundServiceProgress then
do! progress.Begin("Running analyzers...", message = UMX.untag file)

Loggers.analyzers.info (
Log.setMessage "begin analysis of {file}"
Expand Down