@@ -18,7 +18,6 @@ import software.aws.toolkits.core.utils.createTemporaryZipFile
18
18
import software.aws.toolkits.core.utils.debug
19
19
import software.aws.toolkits.core.utils.getLogger
20
20
import software.aws.toolkits.core.utils.putNextEntry
21
- import software.aws.toolkits.jetbrains.services.amazonq.FeatureDevSessionContext
22
21
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.sessionconfig.Payload
23
22
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.sessionconfig.PayloadContext
24
23
import software.aws.toolkits.jetbrains.services.codewhisperer.codescan.sessionconfig.PayloadMetadata
@@ -33,6 +32,7 @@ import software.aws.toolkits.jetbrains.services.codewhisperer.language.programmi
33
32
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.CODE_SCAN_CREATE_PAYLOAD_TIMEOUT_IN_SECONDS
34
33
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.DEFAULT_CODE_SCAN_TIMEOUT_IN_SECONDS
35
34
import software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererConstants.DEFAULT_PAYLOAD_LIMIT_IN_BYTES
35
+ import software.aws.toolkits.jetbrains.services.codewhisperer.util.GitIgnoreFilteringUtil
36
36
import software.aws.toolkits.jetbrains.services.codewhisperer.util.isWithin
37
37
import software.aws.toolkits.resources.message
38
38
import java.io.File
@@ -53,8 +53,6 @@ class CodeTestSessionConfig(
53
53
project.guessProjectDir() ? : error(" Cannot guess base directory for project ${project.name} " )
54
54
}
55
55
56
- private val featureDevSessionContext = FeatureDevSessionContext (project)
57
-
58
56
val fileIndex = ProjectRootManager .getInstance(project).fileIndex
59
57
60
58
/* *
@@ -186,15 +184,16 @@ class CodeTestSessionConfig(
186
184
187
185
moduleLoop@ for (module in project.modules) {
188
186
val changeListManager = ChangeListManager .getInstance(module.project)
189
- if (module.guessModuleDir() != null ) {
190
- stack.push(module.guessModuleDir())
187
+ module.guessModuleDir()?.let { moduleDir ->
188
+ val gitIgnoreFilteringUtil = GitIgnoreFilteringUtil (moduleDir)
189
+ stack.push(moduleDir)
191
190
while (stack.isNotEmpty()) {
192
191
val current = stack.pop()
193
192
194
193
if (! current.isDirectory) {
195
194
if (current.isFile && current.path != selectedFile?.path &&
196
195
! changeListManager.isIgnoredFile(current) &&
197
- runBlocking { ! featureDevSessionContext .ignoreFile(current) } &&
196
+ runBlocking { ! gitIgnoreFilteringUtil .ignoreFile(current) } &&
198
197
runReadAction { ! fileIndex.isInLibrarySource(current) }
199
198
) {
200
199
if (willExceedPayloadLimit(currentTotalFileSize, current.length)) {
@@ -217,7 +216,7 @@ class CodeTestSessionConfig(
217
216
} else {
218
217
// Directory case: only traverse if not ignored
219
218
if (! changeListManager.isIgnoredFile(current) &&
220
- runBlocking { ! featureDevSessionContext .ignoreFile(current) } &&
219
+ runBlocking { ! gitIgnoreFilteringUtil .ignoreFile(current) } &&
221
220
! traversedDirectories.contains(current) && current.isValid &&
222
221
runReadAction { ! fileIndex.isInLibrarySource(current) }
223
222
) {
@@ -242,21 +241,14 @@ class CodeTestSessionConfig(
242
241
return PayloadMetadata (files, currentTotalFileSize, currentTotalLines, maxCountLanguage.toTelemetryType())
243
242
}
244
243
245
- fun getPath (root : String , relativePath : String = ""): Path ? = try {
246
- Path .of(root, relativePath).normalize()
247
- } catch (e: Exception ) {
248
- LOG .debug { " Cannot find file at path $relativePath relative to the root $root " }
249
- null
250
- }
251
-
252
244
fun getRelativePath (): Path ? = try {
253
245
selectedFile?.path?.let { Path .of(projectRoot.path).relativize(Path .of(it)).normalize() }
254
246
} catch (e: Exception ) {
255
247
LOG .debug { " Cannot calculate relative path of $selectedFile with respect to $projectRoot " }
256
248
null
257
249
}
258
250
259
- fun File.toVirtualFile () = LocalFileSystem .getInstance().findFileByIoFile(this )
251
+ private fun File.toVirtualFile () = LocalFileSystem .getInstance().findFileByIoFile(this )
260
252
261
253
companion object {
262
254
private val LOG = getLogger<CodeTestSessionConfig >()
0 commit comments