Skip to content

Commit dcaceb2

Browse files
authored
feat(amazonq): support Dockerfile files in /dev (#5131)
Add `Dockerfile`, `Dockerfile.build` and `*.dockerfile` to list of supported file extensions for /dev
1 parent 824566e commit dcaceb2

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Amazon Q /dev: support `Dockerfile` files"
4+
}

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/FeatureDevSessionContext.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Lo
6868
"dist/?"
6969
).map { Regex(it) }
7070

71+
// well known source files that do not have extensions
72+
private val wellKnownSourceFiles = setOf(
73+
"Dockerfile",
74+
"Dockerfile.build"
75+
)
76+
7177
// projectRoot: is the directory where the project is located when selected to open a project.
7278
val projectRoot = project.guessProjectDir() ?: error("Cannot guess base directory for project ${project.name}")
7379

@@ -117,6 +123,8 @@ class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Lo
117123
return deferredResults.any { it.await() }
118124
}
119125

126+
private fun wellKnown(file: VirtualFile): Boolean = wellKnownSourceFiles.contains(file.name)
127+
120128
suspend fun zipFiles(projectRoot: VirtualFile): File = withContext(getCoroutineBgContext()) {
121129
val files = mutableListOf<VirtualFile>()
122130
val ignoredExtensionMap = mutableMapOf<String, Long>().withDefault { 0L }
@@ -126,8 +134,9 @@ class FeatureDevSessionContext(val project: Project, val maxProjectSizeBytes: Lo
126134
projectRoot,
127135
object : VirtualFileVisitor<Unit>() {
128136
override fun visitFile(file: VirtualFile): Boolean {
137+
val isWellKnown = runBlocking { wellKnown(file) }
129138
val isFileIgnoredByExtension = runBlocking { ignoreFileByExtension(file) }
130-
if (isFileIgnoredByExtension) {
139+
if (!isWellKnown && isFileIgnoredByExtension) {
131140
val extension = file.extension.orEmpty()
132141
ignoredExtensionMap[extension] = (ignoredExtensionMap[extension] ?: 0) + 1
133142
return false

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/services/telemetry/TelemetryUtils.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ val ALLOWED_CODE_EXTENSIONS = setOf(
4040
"d",
4141
"dart",
4242
"dfm",
43+
"dockerfile",
4344
"dpr",
4445
"e",
4546
"el",

0 commit comments

Comments
 (0)