in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/project/FeatureDevSessionContext.kt [83:138]
override fun visitFile(file: VirtualFile): Boolean {
fun markIgnoredContent() {
val extension = file.extension.orEmpty()
ignoredExtensionMap[extension] = (ignoredExtensionMap[extension] ?: 0) + 1
}
fun addContent() {
if (file.isFile) {
totalSize += file.length
files.add(file)
if (maxProjectSizeBytes != null && totalSize > maxProjectSizeBytes) {
throw RepoSizeLimitError(AwsCoreBundle.message("amazonqFeatureDev.content_length.error_text"))
}
}
}
// Always include DevFile if it is enabled and present, taking precedence over other conditions:
if (isAutoBuildFeatureEnabled == true && isWorkspaceDevFile(file, addressableRoot)) {
addContent()
return true
}
// Large files always ignored:
if (file.length > MAX_FILE_SIZE_BYTES) {
markIgnoredContent()
return false
}
// Exclude files specified by gitignore or outside the workspace:
if (!isWorkspaceSourceContent(file, workspaceContentRoots, changeListManager, additionalGlobalIgnoreRules)) {
markIgnoredContent()
return false
}
// Exclude files and directories outside the selection root when working on a subset of the workspace:
if (!VfsUtil.isAncestor(selectionRoot, file, false)) {
// Because we traverse from the content root, ensure we continue traverse toward the selection root:
// (Handles when selection root is inside a content root)
if (VfsUtil.isAncestor(file, selectionRoot, false)) {
return true
}
markIgnoredContent()
return false
}
// When auto build is disabled, explicitly exclude devfile:
// FIXME: There should be a stronger signal to the agent than presence of the devfile in the uploaded files to enable auto build
if (isAutoBuildFeatureEnabled == false && isWorkspaceDevFile(file, addressableRoot)) {
markIgnoredContent()
return false
}
addContent()
return true
}