Skip to content

Commit 743af27

Browse files
feat(amazonq): enable DefaultModuleDependenciesService with event reduction
1 parent 83ac4f5 commit 743af27

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/AmazonQLspService.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import software.aws.toolkits.core.utils.writeText
7373
import software.aws.toolkits.jetbrains.core.coroutines.ioDispatcher
7474
import software.aws.toolkits.jetbrains.services.amazonq.lsp.artifacts.ArtifactManager
7575
import software.aws.toolkits.jetbrains.services.amazonq.lsp.auth.DefaultAuthCredentialsService
76+
import software.aws.toolkits.jetbrains.services.amazonq.lsp.dependencies.DefaultModuleDependenciesService
7677
import software.aws.toolkits.jetbrains.services.amazonq.lsp.encryption.JwtEncryptionManager
7778
import software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat.AmazonQLspTypeAdapterFactory
7879
import software.aws.toolkits.jetbrains.services.amazonq.lsp.flareChat.AwsExtendedInitializeResult
@@ -592,9 +593,9 @@ private class AmazonQServerInstance(private val project: Project, private val cs
592593
WorkspaceServiceHandler(project, cs, lspInitResult).also {
593594
Disposer.register(this, it)
594595
}
595-
// DefaultModuleDependenciesService(project, cs).also {
596-
// Disposer.register(this, it)
597-
// }
596+
DefaultModuleDependenciesService(project, cs).also {
597+
Disposer.register(this, it)
598+
}
598599
}
599600
}
600601
}

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/dependencies/DefaultModuleDependenciesService.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,29 @@ class DefaultModuleDependenciesService(
4444
}
4545

4646
private fun syncAllModules() {
47+
val paramsMap = mutableMapOf<Pair<String, String>, DidChangeDependencyPathsParams>()
48+
4749
ModuleManager.getInstance(project).modules.forEach { module ->
4850
EP_NAME.forEachExtensionSafe {
4951
if (it.isApplicable(module)) {
50-
didChangeDependencyPaths(it.createParams(module))
52+
val params = it.createParams(module)
53+
val key = params.moduleName to params.runtimeLanguage
54+
55+
paramsMap.merge(key, params) { existing, new ->
56+
DidChangeDependencyPathsParams(
57+
moduleName = existing.moduleName,
58+
runtimeLanguage = existing.runtimeLanguage,
59+
paths = (existing.paths + new.paths).distinct(),
60+
includePatterns = (existing.includePatterns + new.includePatterns).distinct(),
61+
excludePatterns = (existing.excludePatterns + new.excludePatterns).distinct()
62+
)
63+
}
5164
return@forEachExtensionSafe
5265
}
5366
}
5467
}
68+
69+
paramsMap.values.forEach { didChangeDependencyPaths(it) }
5570
}
5671

5772
override fun dispose() {

0 commit comments

Comments
 (0)