Skip to content

Commit

Permalink
refactor: improve logging in bundle creation
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch committed Apr 20, 2022
1 parent 4fbfadd commit 920712d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions diagnostics/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func fetchAllRegisteredDocumentDiagnostics(uri sglsp.DocumentURI, level lsp.Scan
var bundleDocs = map[sglsp.DocumentURI]bool{}
if level == lsp.ScanLevelFile {
bundleDocs[uri] = true
registeredDocuments[uri] = true
} else {
registeredDocsMutex.Lock()
bundleDocs = registeredDocuments
Expand All @@ -92,8 +93,8 @@ func fetchAllRegisteredDocumentDiagnostics(uri sglsp.DocumentURI, level lsp.Scan
bundleCount := len(bundles)
wg.Add(2 + bundleCount)

dChan := make(chan lsp.DiagnosticResult, 10)
clChan := make(chan lsp.CodeLensResult, 10)
dChan := make(chan lsp.DiagnosticResult, len(registeredDocuments))
clChan := make(chan lsp.CodeLensResult, len(registeredDocuments))

for _, myBundle := range bundles {
go myBundle.FetchDiagnosticsData(string(uri), &wg, dChan, clChan)
Expand Down Expand Up @@ -169,13 +170,14 @@ func createOrExtendBundles(documents map[sglsp.DocumentURI]bool, bundles *[]*cod
for len(toAdd) > 0 {
if bundleIndex == -1 || bundleFull {
bundle = createBundle(bundles)
log.Debug().Int("bundleCount", len(*bundles)).Str("bundle", bundle.BundleHash).Msg("created new bundle")
log.Debug().Int("bundleCount", len(*bundles)).Msg("created new bundle")
} else {
bundle = (*bundles)[bundleIndex]
log.Debug().Int("bundleCount", len(*bundles)).Str("bundle", bundle.BundleHash).Msg("re-using bundle ")
log.Debug().Int("bundleCount", len(*bundles)).Msg("re-using bundle ")
}
toAdd = bundle.AddToBundleDocuments(toAdd).Files
if len(toAdd) > 0 {
log.Debug().Int("bundleCount", len(*bundles)).Msgf("File count: %d", len(bundle.BundleDocuments))
bundleFull = true
}
}
Expand Down

0 comments on commit 920712d

Please sign in to comment.