Skip to content

Add log messages to track target preparation #1478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2024
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
5 changes: 4 additions & 1 deletion Sources/SemanticIndex/SemanticIndexManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ public final actor SemanticIndexManager {
await self.prepare(targets: [target], priority: nil)
}
}
inProgressPrepareForEditorTask?.task.cancel()
if let inProgressPrepareForEditorTask {
logger.debug("Cancelling preparation of \(inProgressPrepareForEditorTask.document) because \(uri) was opened")
inProgressPrepareForEditorTask.task.cancel()
}
inProgressPrepareForEditorTask = InProgressPrepareForEditorTask(
id: id,
document: uri,
Expand Down
15 changes: 15 additions & 0 deletions Tests/SourceKitLSPTests/ExpectedIndexTaskTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//

import LSPLogging
import LanguageServerProtocol
import SKCore
import SemanticIndex
Expand Down Expand Up @@ -103,6 +104,7 @@ actor ExpectedIndexTaskTracker {
return
}
if Task.isCancelled {
logger.debug("Ignoring preparation task start because task is cancelled: \(taskDescription.targetsToPrepare)")
return
}
guard let expectedTargetsToPrepare = expectedPreparations.first else {
Expand All @@ -120,6 +122,7 @@ actor ExpectedIndexTaskTracker {
return
}
if Task.isCancelled {
logger.debug("Ignoring preparation task finish because task is cancelled: \(taskDescription.targetsToPrepare)")
return
}
guard let expectedTargetsToPrepare = expectedPreparations.first else {
Expand Down Expand Up @@ -147,6 +150,12 @@ actor ExpectedIndexTaskTracker {

func updateIndexStoreTaskDidStart(taskDescription: UpdateIndexStoreTaskDescription) -> Void {
if Task.isCancelled {
logger.debug(
"""
Ignoring update indexstore start because task is cancelled: \
\(taskDescription.filesToIndex.map(\.file.sourceFile))
"""
)
return
}
guard let expectedFilesToIndex = expectedIndexStoreUpdates?.first else {
Expand All @@ -165,6 +174,12 @@ actor ExpectedIndexTaskTracker {
return
}
if Task.isCancelled {
logger.debug(
"""
Ignoring update indexstore finish because task is cancelled: \
\(taskDescription.filesToIndex.map(\.file.sourceFile))
"""
)
return
}
guard let expectedFilesToIndex = expectedIndexStoreUpdates.first else {
Expand Down