Skip to content

Commit 9bcb760

Browse files
committed
Merge branch 'master' into ec2/sshDryRun
2 parents 823a0e3 + f1cdbeb commit 9bcb760

File tree

29 files changed

+297
-193
lines changed

29 files changed

+297
-193
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Amazon Q chat: `@workspace` command shown in all tab types"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Code Transform: Enable support for Java 17 projects."
4+
}

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ describe('crossFileContextUtil', function () {
5050
const myCurrentEditor = await toTextEditor('', 'TargetFile.java', tempFolder, {
5151
preview: false,
5252
})
53+
54+
await assertTabCount(2)
55+
5356
const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
5457
assert.ok(actual)
55-
assert.ok(actual.supplementalContextItems.length === 3)
56-
58+
assert.strictEqual(actual.supplementalContextItems.length, 3)
5759
assert.strictEqual(actual.supplementalContextItems[0].content.split('\n').length, 50)
5860
assert.strictEqual(actual.supplementalContextItems[1].content.split('\n').length, 50)
5961
assert.strictEqual(actual.supplementalContextItems[2].content.split('\n').length, 50)
@@ -64,6 +66,9 @@ describe('crossFileContextUtil', function () {
6466
const myCurrentEditor = await toTextEditor('', 'TargetFile.java', tempFolder, {
6567
preview: false,
6668
})
69+
70+
await assertTabCount(2)
71+
6772
sinon.stub(FeatureConfigProvider.instance, 'getProjectContextGroup').returns('t1')
6873
sinon
6974
.stub(LspController.instance, 'queryInlineProjectContext')
@@ -78,7 +83,7 @@ describe('crossFileContextUtil', function () {
7883

7984
const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
8085
assert.ok(actual)
81-
assert.ok(actual.supplementalContextItems.length === 4)
86+
assert.strictEqual(actual.supplementalContextItems.length, 4)
8287
assert.strictEqual(actual?.strategy, 'codemap')
8388
assert.deepEqual(actual?.supplementalContextItems[0], {
8489
content: 'foo',
@@ -96,6 +101,9 @@ describe('crossFileContextUtil', function () {
96101
const myCurrentEditor = await toTextEditor('', 'TargetFile.java', tempFolder, {
97102
preview: false,
98103
})
104+
105+
await assertTabCount(2)
106+
99107
sinon.stub(FeatureConfigProvider.instance, 'getProjectContextGroup').returns('t2')
100108
sinon
101109
.stub(LspController.instance, 'queryInlineProjectContext')
@@ -130,7 +138,7 @@ describe('crossFileContextUtil', function () {
130138

131139
const actual = await crossFile.fetchSupplementalContextForSrc(myCurrentEditor, fakeCancellationToken)
132140
assert.ok(actual)
133-
assert.ok(actual.supplementalContextItems.length === 5)
141+
assert.strictEqual(actual.supplementalContextItems.length, 5)
134142
assert.strictEqual(actual?.strategy, 'bm25')
135143

136144
assert.deepEqual(actual?.supplementalContextItems[0], {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import assert from 'assert'
77
import * as vscode from 'vscode'
88
import * as sinon from 'sinon'
99
import * as crossFile from 'aws-core-vscode/codewhisperer'
10-
import { TestFolder } from 'aws-core-vscode/test'
10+
import { TestFolder, assertTabCount } from 'aws-core-vscode/test'
1111
import { FeatureConfigProvider } from 'aws-core-vscode/codewhisperer'
1212
import { toTextEditor } from 'aws-core-vscode/test'
1313

@@ -39,6 +39,8 @@ describe('supplementalContextUtil', function () {
3939
preview: false,
4040
})
4141

42+
await assertTabCount(4)
43+
4244
const actual = await crossFile.fetchSupplementalContext(editor, fakeCancellationToken)
4345
assert.ok(actual?.supplementalContextItems.length === 3)
4446
})
@@ -53,6 +55,8 @@ describe('supplementalContextUtil', function () {
5355
preview: false,
5456
})
5557

58+
await assertTabCount(4)
59+
5660
const actual = await crossFile.fetchSupplementalContext(editor, fakeCancellationToken)
5761
assert.ok(actual?.supplementalContextItems.length === 0)
5862
})

packages/core/src/amazonq/webview/ui/tabs/constants.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,23 @@
44
*/
55
import { isSQLTransformReady } from '../../../../dev/config'
66
import { TabType } from '../storages/tabsStorage'
7+
import { QuickActionCommandGroup } from '@aws/mynah-ui'
78

89
export type TabTypeData = {
910
title: string
1011
placeholder: string
1112
welcome: string
13+
contextCommands?: QuickActionCommandGroup[]
14+
}
15+
16+
const workspaceCommand: QuickActionCommandGroup = {
17+
groupName: 'Mention code',
18+
commands: [
19+
{
20+
command: '@workspace',
21+
description: '(BETA) Reference all code in workspace.',
22+
},
23+
],
1224
}
1325

1426
const commonTabData: TabTypeData = {
@@ -17,6 +29,7 @@ const commonTabData: TabTypeData = {
1729
welcome: `Hi, I'm Amazon Q. I can answer your software development questions.
1830
Ask me to explain, debug, or optimize your code.
1931
You can enter \`/\` to see a list of quick actions. Add @workspace to beginning of your message to include your entire workspace as context.`,
32+
contextCommands: [workspaceCommand],
2033
}
2134

2235
export const TabTypeDataMap: Record<TabType, TabTypeData> = {
@@ -42,8 +55,6 @@ I can help you with the following tasks:
4255
- Convert embedded SQL from Oracle databases to PostgreSQL
4356
4457
What would you like to do? You can enter 'language upgrade' or 'SQL conversion'.`
45-
: `Welcome to code transformation!
46-
47-
I can help you upgrade your Java 8 and 11 codebases to Java 17.`,
58+
: `Welcome to code transformation!`,
4859
},
4960
}

packages/core/src/amazonq/webview/ui/tabs/generator.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,7 @@ export class TabDataGenerator {
3535
'Amazon Q Developer uses generative AI. You may need to verify responses. See the [AWS Responsible AI Policy](https://aws.amazon.com/machine-learning/responsible-ai/policy/).',
3636
quickActionCommands: this.quickActionsGenerator.generateForTab(tabType),
3737
promptInputPlaceholder: TabTypeDataMap[tabType].placeholder,
38-
contextCommands: [
39-
{
40-
groupName: 'Mention code',
41-
commands: [
42-
{
43-
command: '@workspace',
44-
description: '(BETA) Reference all code in workspace.',
45-
},
46-
],
47-
},
48-
],
38+
contextCommands: TabTypeDataMap[tabType].contextCommands,
4939
chatItems: needWelcomeMessages
5040
? [
5141
{

packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ export class Messenger {
191191
value: JDKVersion.JDK11,
192192
label: JDKVersion.JDK11,
193193
},
194+
{
195+
value: JDKVersion.JDK17,
196+
label: JDKVersion.JDK17,
197+
},
194198
{
195199
value: JDKVersion.UNSUPPORTED,
196200
label: 'Other',

packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ export default class MessengerUtils {
4444
} else if (os.platform() === 'darwin') {
4545
const jdkVersion = transformByQState.getSourceJDKVersion()
4646
if (jdkVersion === JDKVersion.JDK8) {
47-
javaHomePrompt += ` ${CodeWhispererConstants.macJava8HomeHelpChatMessage}`
47+
javaHomePrompt += ` ${CodeWhispererConstants.macJavaVersionHomeHelpChatMessage(1.8)}`
4848
} else if (jdkVersion === JDKVersion.JDK11) {
49-
javaHomePrompt += ` ${CodeWhispererConstants.macJava11HomeHelpChatMessage}`
49+
javaHomePrompt += ` ${CodeWhispererConstants.macJavaVersionHomeHelpChatMessage(11)}`
50+
} else if (jdkVersion === JDKVersion.JDK17) {
51+
javaHomePrompt += ` ${CodeWhispererConstants.macJavaVersionHomeHelpChatMessage(17)}`
5052
}
5153
} else {
5254
javaHomePrompt += ` ${CodeWhispererConstants.linuxJavaHomeHelpChatMessage}`

packages/core/src/auth/providers/sharedCredentialsProviderFactory.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,23 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import fs from '../../shared/fs/fs'
76
import { getLogger, Logger } from '../../shared/logger'
87
import { loadSharedCredentialsSections, updateAwsSdkLoadConfigEnvVar } from '../credentials/sharedCredentials'
98
import { CredentialsProviderType } from './credentials'
109
import { BaseCredentialsProviderFactory } from './credentialsProviderFactory'
1110
import { SharedCredentialsProvider } from './sharedCredentialsProvider'
12-
import { getCredentialsFilename, getConfigFilename } from '../credentials/sharedCredentialsFile'
1311

1412
export class SharedCredentialsProviderFactory extends BaseCredentialsProviderFactory<SharedCredentialsProvider> {
1513
private readonly logger: Logger = getLogger()
1614

17-
private loadedCredentialsModificationMillis?: number
18-
private loadedConfigModificationMillis?: number
19-
2015
public async refresh(): Promise<void> {
21-
if (await this.needsRefresh()) {
22-
await this.loadSharedCredentialsProviders()
23-
}
16+
await this.loadSharedCredentialsProviders()
2417
}
2518

2619
public override getProviderType(): CredentialsProviderType | undefined {
2720
return SharedCredentialsProvider.getProviderType()
2821
}
2922

30-
protected override resetProviders() {
31-
this.loadedCredentialsModificationMillis = undefined
32-
this.loadedConfigModificationMillis = undefined
33-
34-
super.resetProviders()
35-
}
36-
37-
private async needsRefresh(): Promise<boolean> {
38-
const credentialsLastModMillis = await this.getLastModifiedMillis(getCredentialsFilename())
39-
const configLastModMillis = await this.getLastModifiedMillis(getConfigFilename())
40-
41-
return (
42-
this.loadedCredentialsModificationMillis !== credentialsLastModMillis ||
43-
this.loadedConfigModificationMillis !== configLastModMillis
44-
)
45-
}
46-
4723
private async loadSharedCredentialsProviders(): Promise<void> {
4824
this.resetProviders()
4925

@@ -52,9 +28,6 @@ export class SharedCredentialsProviderFactory extends BaseCredentialsProviderFac
5228
const errors = result.errors.map((e) => e.message).join('\t\n')
5329
getLogger().warn(`credentials: errors while parsing:\n%s`, errors)
5430
}
55-
56-
this.loadedCredentialsModificationMillis = await this.getLastModifiedMillis(getCredentialsFilename())
57-
this.loadedConfigModificationMillis = await this.getLastModifiedMillis(getConfigFilename())
5831
await updateAwsSdkLoadConfigEnvVar()
5932

6033
getLogger().verbose(
@@ -79,13 +52,4 @@ export class SharedCredentialsProviderFactory extends BaseCredentialsProviderFac
7952
this.addProvider(provider)
8053
}
8154
}
82-
83-
private async getLastModifiedMillis(filepath: string): Promise<number | undefined> {
84-
try {
85-
const stat = await fs.stat(filepath)
86-
return stat.mtime
87-
} catch (err) {
88-
return undefined
89-
}
90-
}
9155
}

packages/core/src/codewhisperer/commands/startTransformByQ.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ async function validateJavaHome(): Promise<boolean> {
174174
javaVersionUsedByMaven = JDKVersion.JDK8
175175
} else if (javaVersionUsedByMaven === '11.') {
176176
javaVersionUsedByMaven = JDKVersion.JDK11
177+
} else if (javaVersionUsedByMaven === '17.') {
178+
javaVersionUsedByMaven = JDKVersion.JDK17
177179
}
178180
}
179181
if (javaVersionUsedByMaven !== transformByQState.getSourceJDKVersion()) {

0 commit comments

Comments
 (0)