Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ describe('codewhispererCodecoverageTracker', function () {
it('unsupported language', function () {
assert.strictEqual(CodeWhispererCodeCoverageTracker.getTracker('vb'), undefined)
assert.strictEqual(CodeWhispererCodeCoverageTracker.getTracker('ipynb'), undefined)
assert.strictEqual(CodeWhispererCodeCoverageTracker.getTracker('r'), undefined)
assert.strictEqual(CodeWhispererCodeCoverageTracker.getTracker('dart'), undefined)
assert.strictEqual(CodeWhispererCodeCoverageTracker.getTracker('swift'), undefined)
assert.strictEqual(CodeWhispererCodeCoverageTracker.getTracker('lua'), undefined)
assert.strictEqual(CodeWhispererCodeCoverageTracker.getTracker('powershell'), undefined)
})

it('supported language', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ describe('runtimeLanguageContext', function () {
['json', true],
['yaml', true],
['tf', true],
['dart', false],
['lua', false],
['powershell', false],
['r', false],
['swift', false],
['systemVerilog', false],
['vue', false],
['dart', true],
['lua', true],
['powershell', true],
['r', true],
['swift', true],
['systemVerilog', true],
['vue', true],
['plaintext', false],
['html', false],
['vb', false],
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('runtimeLanguageContext', function () {
})

describe('toRuntimeLanguage', function () {
const codewhispererLanguageIds: CodewhispererLanguage[][] = [
const codewhispererLanguageIds: [CodewhispererLanguage, string][] = [
['c', 'c'],
['cpp', 'cpp'],
['csharp', 'csharp'],
Expand All @@ -201,9 +201,19 @@ describe('runtimeLanguageContext', function () {
['sql', 'sql'],
['tsx', 'typescript'],
['typescript', 'typescript'],
['dart', 'dart'],
['lua', 'lua'],
['powershell', 'powershell'],
['r', 'r'],
['swift', 'swift'],
['systemVerilog', 'systemverilog'],
['vue', 'vue'],
]

for (const [inputCwsprLanguageId, expectedCwsprLanguageId] of codewhispererLanguageIds) {
if (inputCwsprLanguageId === 'systemVerilog') {
console.log()
}
it(`should return ${expectedCwsprLanguageId} if input codewhispererLanguageId is - ${inputCwsprLanguageId}`, function () {
const actual = languageContext.toRuntimeLanguage(inputCwsprLanguageId)
assert.strictEqual(actual, expectedCwsprLanguageId)
Expand Down Expand Up @@ -258,7 +268,7 @@ describe('runtimeLanguageContext', function () {
})
}

const arbitraryStrs: (string | undefined)[] = ['foo', undefined, 'bar', 'R', 'r', 'unknown']
const arbitraryStrs: (string | undefined)[] = ['foo', undefined, 'bar', 'unknown']
for (const inputStr of arbitraryStrs) {
it(`should return undefined when input str is ${inputStr}`, function () {
const actual = languageContext.getLanguageExtensionForNotebook(inputStr)
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/codewhisperer/models/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ export const platformLanguageIds = [
'packer',
'plaintext',
'jsonc',
'systemverilog',
'verilog',
'powershell',
'dart',
'lua',
'r',
'swift',
'vue',
] as const

export type PlatformLanguageId = (typeof platformLanguageIds)[number]
Expand Down
28 changes: 18 additions & 10 deletions packages/core/src/codewhisperer/util/runtimeLanguageContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createConstantMap, ConstantMap } from '../../shared/utilities/tsUtils'
import * as codewhispererClient from '../client/codewhisperer'
import * as CodeWhispererConstants from '../models/constants'

type RuntimeLanguage = Exclude<CodewhispererLanguage, 'jsx' | 'tsx'>
type RuntimeLanguage = Exclude<CodewhispererLanguage, 'jsx' | 'tsx' | 'systemVerilog'> | 'systemverilog'

const runtimeLanguageSet: ReadonlySet<RuntimeLanguage> = new Set([
'c',
Expand All @@ -30,6 +30,7 @@ const runtimeLanguageSet: ReadonlySet<RuntimeLanguage> = new Set([
'json',
'yaml',
'tf',
'systemverilog',
])

export class RuntimeLanguageContext {
Expand Down Expand Up @@ -93,6 +94,8 @@ export class RuntimeLanguageContext {
r: 'r',
swift: 'swift',
systemVerilog: 'systemVerilog',
systemverilog: 'systemVerilog',
verilog: 'systemVerilog',
vue: 'vue',
})
this.supportedLanguageExtensionMap = createConstantMap<string, CodewhispererLanguage>({
Expand Down Expand Up @@ -120,6 +123,17 @@ export class RuntimeLanguageContext {
ts: 'typescript',
yaml: 'yaml',
yml: 'yaml',
sv: 'systemVerilog',
svh: 'systemVerilog',
vh: 'systemVerilog',
dart: 'dart',
lua: 'lua',
wlua: 'lua',
swift: 'swift',
vue: 'vue',
ps1: 'powershell',
psm1: 'powershell',
r: 'r',
})
}

Expand Down Expand Up @@ -147,6 +161,9 @@ export class RuntimeLanguageContext {
case 'tsx':
return 'typescript'

case 'systemVerilog':
return 'systemverilog'

default:
if (!runtimeLanguageSet.has(language)) {
getLogger().error(`codewhisperer: unknown runtime language ${language}`)
Expand Down Expand Up @@ -242,15 +259,6 @@ export class RuntimeLanguageContext {
case 'plaintext':
return false

case 'dart':
case 'lua':
case 'powershell':
case 'r':
case 'swift':
case 'vue':
case 'systemVerilog':
return false

default:
return true
}
Expand Down
Loading