Skip to content

Commit c092b9e

Browse files
Merge master into feature/emr
2 parents 4db9af8 + 6fead6e commit c092b9e

File tree

6 files changed

+31
-13
lines changed

6 files changed

+31
-13
lines changed

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"skippedTestReport": "ts-node ./scripts/skippedTestReport.ts ./packages/amazonq/test/e2e/"
4242
},
4343
"devDependencies": {
44-
"@aws-toolkits/telemetry": "^1.0.321",
44+
"@aws-toolkits/telemetry": "^1.0.322",
4545
"@playwright/browser-chromium": "^1.43.1",
4646
"@stylistic/eslint-plugin": "^2.11.0",
4747
"@types/he": "^1.2.3",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Add inline completion support for abap language"
4+
}

packages/amazonq/test/unit/codewhisperer/util/runtimeLanguageContext.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ describe('runtimeLanguageContext', function () {
177177
'jsx',
178178
'kotlin',
179179
'php',
180-
'plaintext',
181180
'python',
182181
'ruby',
183182
'rust',
@@ -288,7 +287,6 @@ describe('runtimeLanguageContext', function () {
288287
['jsx', 'jsx'],
289288
['kotlin', 'kt'],
290289
['php', 'php'],
291-
['plaintext', 'txt'],
292290
['python', 'py'],
293291
['ruby', 'rb'],
294292
['rust', 'rs'],

packages/core/src/codewhisperer/util/editorContext.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ export function extractContextForCodeWhisperer(editor: vscode.TextEditor): codew
151151
)
152152
let languageName = 'plaintext'
153153
if (!checkLeftContextKeywordsForJson(document.fileName, caretLeftFileContext, editor.document.languageId)) {
154-
languageName =
155-
runtimeLanguageContext.normalizeLanguage(editor.document.languageId) ?? editor.document.languageId
154+
languageName = runtimeLanguageContext.resolveLang(editor.document)
156155
}
157156
if (editor.document.uri.scheme === 'vscode-notebook-cell') {
158157
const notebook = getEnclosingNotebook(editor)

packages/core/src/codewhisperer/util/runtimeLanguageContext.ts

+21-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class RuntimeLanguageContext {
6767

6868
constructor() {
6969
this.supportedLanguageMap = createConstantMap<
70-
CodeWhispererConstants.PlatformLanguageId | CodewhispererLanguage,
70+
Exclude<CodeWhispererConstants.PlatformLanguageId | CodewhispererLanguage, 'plaintext'>,
7171
CodewhispererLanguage
7272
>({
7373
c: 'c',
@@ -85,7 +85,6 @@ export class RuntimeLanguageContext {
8585
jsx: 'jsx',
8686
kotlin: 'kotlin',
8787
packer: 'tf',
88-
plaintext: 'plaintext',
8988
php: 'php',
9089
python: 'python',
9190
ruby: 'ruby',
@@ -112,6 +111,7 @@ export class RuntimeLanguageContext {
112111
systemverilog: 'systemVerilog',
113112
verilog: 'systemVerilog',
114113
vue: 'vue',
114+
abap: 'abap',
115115
})
116116
this.supportedLanguageExtensionMap = createConstantMap<string, CodewhispererLanguage>({
117117
c: 'c',
@@ -152,6 +152,8 @@ export class RuntimeLanguageContext {
152152
ps1: 'powershell',
153153
psm1: 'powershell',
154154
r: 'r',
155+
abap: 'abap',
156+
acds: 'abap',
155157
})
156158
this.languageSingleLineCommentPrefixMap = createConstantMap<CodewhispererLanguage, string>({
157159
c: '// ',
@@ -185,9 +187,14 @@ export class RuntimeLanguageContext {
185187
vue: '', // vue lacks a single-line comment prefix
186188
yaml: '# ',
187189
yml: '# ',
190+
abap: '',
188191
})
189192
}
190193

194+
public resolveLang(doc: vscode.TextDocument): CodewhispererLanguage {
195+
return this.normalizeLanguage(doc.languageId) || this.byFileExt(doc) || 'plaintext'
196+
}
197+
191198
/**
192199
* To add a new platform language id:
193200
* 1. add new platform language ID constant in the file codewhisperer/constant.ts
@@ -317,8 +324,7 @@ export class RuntimeLanguageContext {
317324
} else {
318325
const normalizedLanguageId = this.normalizeLanguage(arg.languageId)
319326
const byLanguageId = !normalizedLanguageId || normalizedLanguageId === 'plaintext' ? false : true
320-
const extension = path.extname(arg.uri.fsPath)
321-
const byFileExtension = this.isFileFormatSupported(extension.substring(1))
327+
const byFileExtension = this.byFileExt(arg) !== undefined
322328

323329
return byLanguageId || byFileExtension
324330
}
@@ -341,6 +347,17 @@ export class RuntimeLanguageContext {
341347
public getLanguageFromFileExtension(fileExtension: string) {
342348
return this.supportedLanguageExtensionMap.get(fileExtension)
343349
}
350+
351+
private byFileExt(doc: vscode.TextDocument): CodewhispererLanguage | undefined {
352+
const extension = path.extname(doc.uri.fsPath)
353+
const byExt = this.supportedLanguageExtensionMap.get(extension.substring(1))
354+
355+
if (byExt === 'plaintext') {
356+
return undefined
357+
}
358+
359+
return byExt
360+
}
344361
}
345362

346363
export const runtimeLanguageContext = new RuntimeLanguageContext()

0 commit comments

Comments
 (0)