Skip to content

Commit 9796f7e

Browse files
leigaolrli
andauthored
fix(amazonq): Fix bug for @workspace cannot properly locate certain folders for certain project setup (#4975)
* fix wrong project root for @workspace for multi-folder project setup * change log * log * Update .changes/next-release/bugfix-9e318f1e-baa7-4d10-98de-edfa70fcd7e0.json Co-authored-by: Richard Li <[email protected]> * collect file from different paths --------- Co-authored-by: Richard Li <[email protected]>
1 parent bf33e46 commit 9796f7e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "`@workspace` cannot properly locate certain folders for certain project setup"
4+
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/editor/context/project/ProjectContextProvider.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import com.fasterxml.jackson.annotation.JsonProperty
88
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
99
import com.fasterxml.jackson.module.kotlin.readValue
1010
import com.intellij.openapi.Disposable
11+
import com.intellij.openapi.project.BaseProjectDirectories.Companion.getBaseDirectories
1112
import com.intellij.openapi.project.Project
12-
import com.intellij.openapi.project.guessProjectDir
1313
import com.intellij.openapi.vfs.VfsUtilCore
1414
import com.intellij.openapi.vfs.VirtualFile
1515
import com.intellij.openapi.vfs.VirtualFileVisitor
@@ -130,7 +130,7 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
130130
}
131131

132132
private fun initEncryption(): Boolean {
133-
logger.info { "project context: init key for ${project.guessProjectDir()} on port ${encoderServer.port}" }
133+
logger.info { "project context: init key for ${project.name} on port ${encoderServer.port}" }
134134
val url = URL("http://localhost:${encoderServer.port}/initialize")
135135
val payload = encoderServer.getEncryptionRequest()
136136
val connection = url.openConnection() as HttpURLConnection
@@ -148,7 +148,7 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
148148
var duration = (System.currentTimeMillis() - indexStartTime).toDouble()
149149
logger.debug { "project context file collection time: ${duration}ms" }
150150
logger.debug { "list of files collected: ${filesResult.files.joinToString("\n")}" }
151-
val projectRoot = project.guessProjectDir()?.path ?: return false
151+
val projectRoot = project.basePath ?: return false
152152
val payload = IndexRequestPayload(filesResult.files, projectRoot, false)
153153
val payloadJson = mapper.writeValueAsString(payload)
154154
val encrypted = encoderServer.encrypt(payloadJson)
@@ -275,7 +275,7 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
275275
var currentTotalFileSize = 0L
276276
val featureDevSessionContext = FeatureDevSessionContext(project)
277277
val allFiles = mutableListOf<VirtualFile>()
278-
project.guessProjectDir()?.let {
278+
project.getBaseDirectories().forEach {
279279
VfsUtilCore.visitChildrenRecursively(
280280
it,
281281
object : VirtualFileVisitor<Unit>(NO_FOLLOW_SYMLINKS) {

0 commit comments

Comments
 (0)