@@ -16,6 +16,13 @@ export class RuntimeLanguageContext {
16
16
*/
17
17
private supportedLanguageMap : ConstantMap < CodeWhispererConstants . SupportedLanguage , CodewhispererLanguage >
18
18
19
+ /**
20
+ * A map storing CodeWhisperer supported programming language with key: vscLanguageId and value: language extension
21
+ * Key: vscLanguageId
22
+ * Value: language extension
23
+ */
24
+ private supportedLanguageExtensionMap : ConstantMap < CodeWhispererConstants . SupportedLanguage , string >
25
+
19
26
// A set contains vscode languageId and CodeWhispererLanguage
20
27
private supportedLanguageSet = new Set < string > ( )
21
28
@@ -39,6 +46,25 @@ export class RuntimeLanguageContext {
39
46
shellscript : 'shell' ,
40
47
sql : 'sql' ,
41
48
} )
49
+ this . supportedLanguageExtensionMap = createConstantMap < CodeWhispererConstants . SupportedLanguage , string > ( {
50
+ java : 'java' ,
51
+ python : 'py' ,
52
+ javascriptreact : 'jsx' ,
53
+ javascript : 'js' ,
54
+ typescript : 'ts' ,
55
+ typescriptreact : 'tsx' ,
56
+ csharp : 'cs' ,
57
+ c : 'c' ,
58
+ cpp : 'cpp' ,
59
+ go : 'go' ,
60
+ kotlin : 'kt' ,
61
+ php : 'php' ,
62
+ ruby : 'rb' ,
63
+ rust : 'rs' ,
64
+ scala : 'scala' ,
65
+ shellscript : 'sh' ,
66
+ sql : 'sql' ,
67
+ } )
42
68
43
69
const values = Array . from ( this . supportedLanguageMap . values ( ) )
44
70
const keys = Array . from ( this . supportedLanguageMap . keys ( ) )
@@ -55,6 +81,15 @@ export class RuntimeLanguageContext {
55
81
return this . supportedLanguageMap . get ( vscLanguageId ) ?? undefined
56
82
}
57
83
84
+ /**
85
+ * This is for notebook files map to a new filename with the corresponding language extension
86
+ * @param vscLanguageId : official vscode languageId
87
+ * @returns corresponding language extension if any, otherwise undefined
88
+ */
89
+ public getLanguageExtensionForNotebook ( vscLanguageId ?: string ) : string | undefined {
90
+ return this . supportedLanguageExtensionMap . get ( vscLanguageId ) ?? undefined
91
+ }
92
+
58
93
/**
59
94
* @param vscLanguageId : official vscode languageId
60
95
* @returns An object with a field language: CodewhispererLanguage, if no corresponding CodewhispererLanguage ID, plaintext is returned
0 commit comments