Skip to content

fix: support inline completions in Docker Compose files#2784

Draft
laileni-aws wants to merge 1 commit into
aws:mainfrom
laileni-aws:fix/inline-completion-dockercompose-language
Draft

fix: support inline completions in Docker Compose files#2784
laileni-aws wants to merge 1 commit into
aws:mainfrom
laileni-aws:fix/inline-completion-dockercompose-language

Conversation

@laileni-aws

Copy link
Copy Markdown
Contributor

Problem

Amazon Q inline suggestions are not provided in Docker Compose files. Some IDEs (notably VS Code) identify docker-compose.yaml / docker-compose.yml with the editor language id dockercompose rather than yaml.

In shared/languageDetection.ts, getLanguageId resolves a document's language by:

  1. looking up the editor language id in qLanguageIdByDocumentLanguageId, then
  2. falling back to the file extension via languageByExtension.

dockercompose was not present in qLanguageIdByDocumentLanguageId, so the language id itself resolved to "unsupported". These files only worked when the extension fallback happened to match .yaml/.yml, and the inline completion handler logs languageId [dockercompose] not supported for the language-id path.

Fix

Map dockercompose to yaml in qLanguageIdByDocumentLanguageId, so the language is resolved directly from the reported language id (and consistently with the existing .yaml/.yml extension handling). Docker Compose files now receive the same completion support as other YAML files.

Because this is the shared Flare language server, the fix applies to every IDE that defers language support to the server (e.g. JetBrains and Eclipse send the document to the server without a client-side language allowlist).

Testing

  • Extended server/aws-lsp-codewhisperer/src/shared/languageDetection.test.ts:
    • getLanguageId maps the dockercompose language id to yaml;
    • getSupportedLanguageId resolves a dockercompose document to yaml (a supported language).
  • Ran the languageDetection unit tests: all passing (8/8).
  • prettier --check and eslint pass on the changed files.

Notes

Some IDEs (e.g. VS Code) report docker-compose files with the
'dockercompose' language id rather than 'yaml'. The server language
detection did not map 'dockercompose', so it only resolved these files
via the .yaml/.yml extension fallback and treated the language id as
unsupported. Map 'dockercompose' to 'yaml' so completions are provided
for docker-compose files regardless of how the client reports them.

Adds unit tests covering the language-id mapping and supported-language
resolution.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.05%. Comparing base (abb1096) to head (4dcc2e6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2784      +/-   ##
==========================================
- Coverage   60.20%   60.05%   -0.16%     
==========================================
  Files         281      281              
  Lines       71191    71194       +3     
  Branches     4575     4547      -28     
==========================================
- Hits        42861    42754     -107     
- Misses      28241    28352     +111     
+ Partials       89       88       -1     
Flag Coverage Δ
unittests 60.05% <100.00%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants