-
Notifications
You must be signed in to change notification settings - Fork 736
feat(amazonq): add inline completion support for abap language #7303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
81b2b16
2fd9173
698e419
371fabf
7195dd0
83781c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "type": "Feature", | ||
| "description": "Add inline completion support for abap language" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,7 +177,6 @@ describe('runtimeLanguageContext', function () { | |
| 'jsx', | ||
| 'kotlin', | ||
| 'php', | ||
| 'plaintext', | ||
| 'python', | ||
| 'ruby', | ||
| 'rust', | ||
|
|
@@ -288,7 +287,6 @@ describe('runtimeLanguageContext', function () { | |
| ['jsx', 'jsx'], | ||
| ['kotlin', 'kt'], | ||
| ['php', 'php'], | ||
| ['plaintext', 'txt'], | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ['python', 'py'], | ||
| ['ruby', 'rb'], | ||
| ['rust', 'rs'], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,7 +67,7 @@ export class RuntimeLanguageContext { | |
|
|
||
| constructor() { | ||
| this.supportedLanguageMap = createConstantMap< | ||
| CodeWhispererConstants.PlatformLanguageId | CodewhispererLanguage, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| Exclude<CodeWhispererConstants.PlatformLanguageId | CodewhispererLanguage, 'plaintext'>, | ||
| CodewhispererLanguage | ||
| >({ | ||
| c: 'c', | ||
|
|
@@ -85,7 +85,6 @@ export class RuntimeLanguageContext { | |
| jsx: 'jsx', | ||
| kotlin: 'kotlin', | ||
| packer: 'tf', | ||
| plaintext: 'plaintext', | ||
| php: 'php', | ||
| python: 'python', | ||
| ruby: 'ruby', | ||
|
|
@@ -112,6 +111,7 @@ export class RuntimeLanguageContext { | |
| systemverilog: 'systemVerilog', | ||
| verilog: 'systemVerilog', | ||
| vue: 'vue', | ||
| abap: 'abap', | ||
| }) | ||
| this.supportedLanguageExtensionMap = createConstantMap<string, CodewhispererLanguage>({ | ||
| c: 'c', | ||
|
|
@@ -152,6 +152,8 @@ export class RuntimeLanguageContext { | |
| ps1: 'powershell', | ||
| psm1: 'powershell', | ||
| r: 'r', | ||
| abap: 'abap', | ||
| acds: 'abap', | ||
| }) | ||
| this.languageSingleLineCommentPrefixMap = createConstantMap<CodewhispererLanguage, string>({ | ||
| c: '// ', | ||
|
|
@@ -185,9 +187,14 @@ export class RuntimeLanguageContext { | |
| vue: '', // vue lacks a single-line comment prefix | ||
| yaml: '# ', | ||
| yml: '# ', | ||
| abap: '', | ||
| }) | ||
| } | ||
|
|
||
| public resolveLang(doc: vscode.TextDocument): CodewhispererLanguage { | ||
| return this.normalizeLanguage(doc.languageId) || this.byFileExt(doc) || 'plaintext' | ||
| } | ||
|
|
||
| /** | ||
| * To add a new platform language id: | ||
| * 1. add new platform language ID constant in the file codewhisperer/constant.ts | ||
|
|
@@ -317,8 +324,7 @@ export class RuntimeLanguageContext { | |
| } else { | ||
| const normalizedLanguageId = this.normalizeLanguage(arg.languageId) | ||
| const byLanguageId = !normalizedLanguageId || normalizedLanguageId === 'plaintext' ? false : true | ||
| const extension = path.extname(arg.uri.fsPath) | ||
| const byFileExtension = this.isFileFormatSupported(extension.substring(1)) | ||
| const byFileExtension = this.byFileExt(arg) !== undefined | ||
|
|
||
| return byLanguageId || byFileExtension | ||
| } | ||
|
|
@@ -341,6 +347,17 @@ export class RuntimeLanguageContext { | |
| public getLanguageFromFileExtension(fileExtension: string) { | ||
| return this.supportedLanguageExtensionMap.get(fileExtension) | ||
| } | ||
|
|
||
| private byFileExt(doc: vscode.TextDocument): CodewhispererLanguage | undefined { | ||
| const extension = path.extname(doc.uri.fsPath) | ||
| const byExt = this.supportedLanguageExtensionMap.get(extension.substring(1)) | ||
|
|
||
| if (byExt === 'plaintext') { | ||
| return undefined | ||
| } | ||
|
|
||
| return byExt | ||
| } | ||
| } | ||
|
|
||
| export const runtimeLanguageContext = new RuntimeLanguageContext() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is tested here
https://github.com/aws/aws-toolkit-vscode/blob/master/packages/amazonq/test/unit/codewhisperer/util/runtimeLanguageContext.test.ts#L51