-
Notifications
You must be signed in to change notification settings - Fork 743
feat(amazonq): Auto Debug Functionality #7609
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
Merged
Merged
Changes from 182 commits
Commits
Show all changes
200 commits
Select commit
Hold shift + click to select a range
efbb8f1
Merge master into feature/auto-debug
aws-toolkit-automation 7e68391
Merge master into feature/auto-debug
aws-toolkit-automation 868bba5
Merge master into feature/auto-debug
aws-toolkit-automation df621d7
Merge master into feature/auto-debug
aws-toolkit-automation 9a54cf6
Merge master into feature/auto-debug
aws-toolkit-automation c58802e
Merge master into feature/auto-debug
aws-toolkit-automation 162d158
Merge master into feature/auto-debug
aws-toolkit-automation 4cc1829
Merge master into feature/auto-debug
aws-toolkit-automation 124cee0
Merge master into feature/auto-debug
aws-toolkit-automation 548e5c6
auto debug feature
MarcoWang3 f064736
Merge master into feature/auto-debug
aws-toolkit-automation 2583a03
Merge master into feature/auto-debug
aws-toolkit-automation 8b53b53
fix integration errors
MarcoWang3 eaa5b32
Merge master into feature/auto-debug
aws-toolkit-automation e8fdfcc
Merge master into feature/auto-debug
aws-toolkit-automation de65371
Merge master into feature/auto-debug
aws-toolkit-automation 00aae62
Merge master into feature/auto-debug
aws-toolkit-automation 05a85f9
Merge master into feature/auto-debug
aws-toolkit-automation 5694abb
Merge master into feature/auto-debug
aws-toolkit-automation 23f0f8a
Merge master into feature/auto-debug
aws-toolkit-automation 530b2b9
Merge master into feature/auto-debug
aws-toolkit-automation a7fb1ce
Release 1.78.0
a23f8fc
Update version to snapshot version: 1.79.0-SNAPSHOT
cfc8229
fix(amazonq): add jitter for validation call of profiles (#7534)
Will-ShaoHua d4838ed
fix(stepfunctions): Add document URI check for save telemetry and ena…
l0minous 9f215f9
feat(amazonq): enable client-side build (#7226)
dhasani23 76622e9
migrate process env proxy settings to proxyUtil.ts
samgst-amazon 5be03f4
remove env merging from createServerOptions
samgst-amazon de6779f
No need to set CA certs when SSL verification is disabled
samgst-amazon ea0eeab
changelog
samgst-amazon 6cdb44e
missing await
samgst-amazon 24d8c05
fix(amazonq): minor text update (#7554)
dhasani23 95e52d2
fix(amazonq): fix for amazon q app initialization failure on sagemaker
ashishrp-aws 68fd9e3
fix(amazonq): fix to move isSagemaker to env
ashishrp-aws 973da57
Release 1.79.0
64c4e20
Update version to snapshot version: 1.80.0-SNAPSHOT
680f1fd
Release 3.67.0
07196a8
Update version to snapshot version: 3.68.0-SNAPSHOT
0fd93e9
fix(amazonq): Re-enable experimental proxy support
tsmithsz acbc8b3
refactor(stepfunctions): migrate to sdkv3 (#7560)
c47876e
fix(amazonq): Remove incompatible Node 18 flag
tsmithsz 7389db0
feat(amazonq): Add next edit suggestion (#7555)
floralph a89ce34
fix(amazonq): update cursor tracking based on autotrigger setting
floralph 4b65711
fix(amazonq): handling of CodeSuggestionState in tests
floralph dbe4b5e
fix: connect chat history to VSCode workspace file
jngyuamz 980a4ab
fix(amazonq): emit metric (#7584)
dhasani23 5059f55
fix: remove the depedency of the CDN js script.
grl-wang 4fc0da5
fix: removing logic to calculate addedCharacterCount and deletedChara…
atonaamz 03b9744
feat: trigger inline suggestion via acceptance for EDITS
atonaamz bd21853
fix(amazonq): do not trigger inline completion when user delete code …
leigaol 5fead78
Release 1.80.0
33a4c98
Update version to snapshot version: 1.81.0-SNAPSHOT
17833f3
fix an notification display error
MarcoWang3 b6aae18
Merge remote-tracking branch 'upstream/master' into feature/auto-debug
MarcoWang3 93ac431
fix an dependency error
MarcoWang3 33e3d75
Merge master into feature/auto-debug
aws-toolkit-automation 54d860e
Merge master into feature/auto-debug
aws-toolkit-automation 4ff7b37
Merge master into feature/auto-debug
aws-toolkit-automation 05dbdc3
Merge master into feature/auto-debug
aws-toolkit-automation 852f4ed
Merge master into feature/auto-debug
aws-toolkit-automation 975a34e
fix bugs in test file
MarcoWang3 6dc202d
fix code duplication issues
MarcoWang3 bbdeb78
fix remaining code duplication in contextMenuProvider
MarcoWang3 b34eb83
Merge master into feature/auto-debug
aws-toolkit-automation 6dd1ad4
Merge master into feature/auto-debug
aws-toolkit-automation 94e061a
Merge master into feature/auto-debug
aws-toolkit-automation ba241c3
Merge master into feature/auto-debug
aws-toolkit-automation 150b877
Merge master into feature/auto-debug
aws-toolkit-automation a5385fe
Merge master into feature/auto-debug
aws-toolkit-automation 53fc504
Merge master into feature/auto-debug
aws-toolkit-automation abe7617
Merge master into feature/auto-debug
aws-toolkit-automation 9f68219
Merge master into feature/auto-debug
aws-toolkit-automation 5e08e54
Merge master into feature/auto-debug
aws-toolkit-automation 5c15343
Merge master into feature/auto-debug
aws-toolkit-automation 2a56f00
Merge master into feature/auto-debug
aws-toolkit-automation fab3af1
Merge master into feature/auto-debug
aws-toolkit-automation a449560
Merge master into feature/auto-debug
aws-toolkit-automation 10b3515
Merge master into feature/auto-debug
aws-toolkit-automation ac79300
Merge master into feature/auto-debug
aws-toolkit-automation 059ba51
Merge master into feature/auto-debug
aws-toolkit-automation 75ff0d2
Merge master into feature/auto-debug
aws-toolkit-automation 200c1d1
Merge master into feature/auto-debug
aws-toolkit-automation 7e0e4ad
Merge master into feature/auto-debug
aws-toolkit-automation f3d7580
Merge master into feature/auto-debug
aws-toolkit-automation 6ce3264
Merge master into feature/auto-debug
aws-toolkit-automation 443773b
Merge master into feature/auto-debug
aws-toolkit-automation 0098e40
fix(amazonq): fix the logs
MarcoWang3 58c0543
fix(amazonq): fix the logs
MarcoWang3 089dd0a
remove accidentally added toolsForBuild.backup submodule
MarcoWang3 69f3a79
Merge master into feature/auto-debug
aws-toolkit-automation c2edf61
Merge master into feature/auto-debug
aws-toolkit-automation 85f407a
simplify code base
MarcoWang3 1eeecb8
Merge master into feature/auto-debug
aws-toolkit-automation 023bae6
fix log issue
MarcoWang3 cfc05ed
Merge master into feature/auto-debug
aws-toolkit-automation 5d04aeb
Merge master into feature/auto-debug
aws-toolkit-automation 770bdee
clean useless logs
MarcoWang3 6a0cda4
Remove wrongly pushed toolsForBuild.backup directory
MarcoWang3 1509ff6
Revert "clean useless logs"
MarcoWang3 6ef9ff3
clean unnecessary logs in client.ts
MarcoWang3 0bdd5a3
fix duplicated autoDebugLspClient files issue
MarcoWang3 858a3fa
Merge master into feature/auto-debug
aws-toolkit-automation 9fa1b0c
remove the norification functionality
MarcoWang3 f100e42
Merge master into feature/auto-debug
aws-toolkit-automation 8786815
add fix all with Amazon Q
MarcoWang3 d482d4b
clean debug outputs
MarcoWang3 6c639d3
Merge master into feature/auto-debug
aws-toolkit-automation a60c6ee
Simplify the message format
MarcoWang3 e7c7d93
Merge master into feature/auto-debug
aws-toolkit-automation af0bcce
Merge master into feature/auto-debug
aws-toolkit-automation 4a3d2be
Merge master into feature/auto-debug
aws-toolkit-automation cc524e3
Merge master into feature/auto-debug
aws-toolkit-automation 5e5fcf0
Merge master into feature/auto-debug
aws-toolkit-automation ffbec22
Merge master into feature/auto-debug
aws-toolkit-automation ed00a13
Merge master into feature/auto-debug
aws-toolkit-automation a2d3398
Merge master into feature/auto-debug
aws-toolkit-automation 1d26ee7
Merge master into feature/auto-debug
aws-toolkit-automation f0bf3d2
Merge master into feature/auto-debug
aws-toolkit-automation e86da4d
Merge master into feature/auto-debug
aws-toolkit-automation 624f13d
Merge master into feature/auto-debug
aws-toolkit-automation 03b6711
Merge master into feature/auto-debug
aws-toolkit-automation 5c1473e
Merge master into feature/auto-debug
aws-toolkit-automation ab99c0e
Merge master into feature/auto-debug
aws-toolkit-automation 5c593ef
Merge master into feature/auto-debug
aws-toolkit-automation 36df393
Merge master into feature/auto-debug
aws-toolkit-automation 2a7b45f
Merge master into feature/auto-debug
aws-toolkit-automation 1358049
Merge master into feature/auto-debug
aws-toolkit-automation 6513d6d
Merge master into feature/auto-debug
aws-toolkit-automation 31ee023
Merge master into feature/auto-debug
aws-toolkit-automation c16204d
Merge master into feature/auto-debug
aws-toolkit-automation 1f3aad4
Merge master into feature/auto-debug
aws-toolkit-automation 6330c75
Merge master into feature/auto-debug
aws-toolkit-automation e9c0748
Merge master into feature/auto-debug
aws-toolkit-automation a558694
Merge master into feature/auto-debug
aws-toolkit-automation 9d280ae
Merge master into feature/auto-debug
aws-toolkit-automation c0da0be
Merge master into feature/auto-debug
aws-toolkit-automation 61d0271
Merge master into feature/auto-debug
aws-toolkit-automation b585b41
Merge master into feature/auto-debug
aws-toolkit-automation 51c21d0
Merge master into feature/auto-debug
aws-toolkit-automation f51436b
Merge master into feature/auto-debug
aws-toolkit-automation c17ceab
Merge master into feature/auto-debug
aws-toolkit-automation 9770ee8
Merge master into feature/auto-debug
aws-toolkit-automation 52342b9
fix the duplicate client issue
MarcoWang3 13ad7ac
Revert workspace file changes - remove ../language-servers path
MarcoWang3 1635032
delete redundant codes
MarcoWang3 dfa633f
remove unused tests
MarcoWang3 bc9f24b
include all file types for quick fix
MarcoWang3 589f812
remove codes for feature agent loop debug
MarcoWang3 88fcafa
remove useless global sorces storage
MarcoWang3 63b052b
remove useless global storage of the sources
MarcoWang3 ee50bdd
fix excluded sources issue
MarcoWang3 a44427f
Merge remote changes after soft reset
MarcoWang3 ba8fda7
refactor the attempt codes
MarcoWang3 2dfee16
Merge master into feature/auto-debug
aws-toolkit-automation 62d2b98
Merge master into feature/auto-debug
aws-toolkit-automation 303922d
Merge master into feature/auto-debug
aws-toolkit-automation f6cdb18
refactor the code base
MarcoWang3 028b435
remove the usage of global variable
MarcoWang3 acd9d9e
Revert unrelated package.json and workspace changes
MarcoWang3 3d187fe
Merge upstream/feature/auto-debug
MarcoWang3 0465f54
revert changes to irrelevant files
MarcoWang3 877bbb5
refactor: extract hardcoded constants to constants file
MarcoWang3 841355b
fix a typo
MarcoWang3 9200aaa
Merge master into feature/auto-debug
aws-toolkit-automation a68f292
Merge master into feature/auto-debug
aws-toolkit-automation 4518b4a
remove useless logs and notifications
MarcoWang3 35136f8
Merge master into feature/auto-debug
aws-toolkit-automation 725e200
remove unnecessary logs
MarcoWang3 7ed41d3
refactor the code base
MarcoWang3 54346ff
Revert changes to workspace and launch.json from commit 725e200e2
MarcoWang3 1e2d0b8
remove redundant codes
MarcoWang3 a029caa
Merge master into feature/auto-debug
aws-toolkit-automation 3679ce6
remove languages restriction
MarcoWang3 081ec82
simplify the code base
MarcoWang3 9919754
remove codes for loop debug
MarcoWang3 b0ee230
fix explain problems comman issue
MarcoWang3 b8e9cce
make error messages prettier
MarcoWang3 90e258a
revert unnecessary changes
MarcoWang3 6ab208e
revert unnecessary order change
MarcoWang3 908dba8
move the activation inside autodebug feature
MarcoWang3 29a7501
simplify the connection logic
MarcoWang3 276b2f3
use existing mesasges
MarcoWang3 991bb70
remove redundant constructor
MarcoWang3 b5bf1f6
Merge master into feature/auto-debug
aws-toolkit-automation 6aeb7b8
Merge master into feature/auto-debug
aws-toolkit-automation 8a17406
Merge master into feature/auto-debug
aws-toolkit-automation 0c32ef8
fix the activation bug and simplify codes in commands.ts
MarcoWang3 e326590
Merge master into feature/auto-debug
aws-toolkit-automation f704737
remove diagnostic monitors for loop debug feature
MarcoWang3 d2c7a44
extract the common logics to improve code quality
MarcoWang3 357d703
move the autodebug under the chat directory
MarcoWang3 b7afc17
integrate with exsited utils
MarcoWang3 0b93c2c
Merge branch 'feature/auto-debug' into feature/auto-debug
laileni-aws 76c0f62
Merge master into feature/auto-debug
aws-toolkit-automation 89a1ff7
Merge master into feature/auto-debug
aws-toolkit-automation dbb1cc5
Merge master into feature/auto-debug
aws-toolkit-automation e00b3b0
Merge branch 'feature/auto-debug' into feature/auto-debug
ashishrp-aws 301bb33
edit a comment
MarcoWang3 6d98f04
Merge branch 'feature/auto-debug' of https://github.com/MarcoWang3/aw…
MarcoWang3 66824d8
Merge branch 'master' into feature/auto-debug
chungjac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import * as vscode from 'vscode' | ||
| import { getLogger } from 'aws-core-vscode/shared' | ||
| import { AutoDebugCommands } from './commands' | ||
| import { AutoDebugCodeActionsProvider } from './codeActionsProvider' | ||
| import { AutoDebugController } from './controller' | ||
|
|
||
| /** | ||
| * Auto Debug feature activation for Amazon Q | ||
| * This handles the complete lifecycle of the auto debug feature | ||
| */ | ||
| export class AutoDebugFeature implements vscode.Disposable { | ||
| private readonly logger = getLogger() | ||
| private readonly disposables: vscode.Disposable[] = [] | ||
|
|
||
| private autoDebugCommands?: AutoDebugCommands | ||
| private codeActionsProvider?: AutoDebugCodeActionsProvider | ||
| private controller?: AutoDebugController | ||
|
|
||
| constructor(private readonly context: vscode.ExtensionContext) {} | ||
|
|
||
| /** | ||
| * Activate the auto debug feature | ||
| */ | ||
| async activate(): Promise<void> { | ||
| try { | ||
| // Initialize the controller first | ||
| this.controller = new AutoDebugController() | ||
|
|
||
| // Initialize commands and register them with the controller | ||
| this.autoDebugCommands = new AutoDebugCommands() | ||
| this.autoDebugCommands.registerCommands(this.context, this.controller) | ||
|
|
||
| // Initialize code actions provider | ||
| this.codeActionsProvider = new AutoDebugCodeActionsProvider() | ||
| this.context.subscriptions.push(this.codeActionsProvider) | ||
|
|
||
| // Add all to disposables | ||
| this.disposables.push(this.controller, this.autoDebugCommands, this.codeActionsProvider) | ||
| } catch (error) { | ||
| this.logger.error('AutoDebugFeature: Failed to activate auto debug feature: %s', error) | ||
| throw error | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Get the auto debug controller instance | ||
| */ | ||
| getController(): AutoDebugController | undefined { | ||
| return this.controller | ||
| } | ||
|
|
||
| /** | ||
| * Dispose of all resources | ||
| */ | ||
| dispose(): void { | ||
| vscode.Disposable.from(...this.disposables).dispose() | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Factory function to activate auto debug feature with LSP client | ||
| * This is the main entry point for activating auto debug | ||
| */ | ||
| export async function activateAutoDebug( | ||
| context: vscode.ExtensionContext, | ||
| client?: any, | ||
| encryptionKey?: Buffer | ||
| ): Promise<AutoDebugFeature> { | ||
| const feature = new AutoDebugFeature(context) | ||
| await feature.activate() | ||
|
|
||
| return feature | ||
| } |
119 changes: 119 additions & 0 deletions
119
packages/amazonq/src/lsp/autoDebug/codeActionsProvider.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import * as vscode from 'vscode' | ||
|
|
||
| /** | ||
| * Provides code actions for Amazon Q Auto Debug features. | ||
| * Integrates with VS Code's quick fix system to offer debugging assistance. | ||
| */ | ||
| export class AutoDebugCodeActionsProvider implements vscode.CodeActionProvider, vscode.Disposable { | ||
| private readonly disposables: vscode.Disposable[] = [] | ||
|
|
||
| public static readonly providedCodeActionKinds = [vscode.CodeActionKind.QuickFix, vscode.CodeActionKind.Refactor] | ||
|
|
||
| constructor() { | ||
| this.registerProvider() | ||
| } | ||
|
|
||
| private registerProvider(): void { | ||
| // Register for all file types | ||
| const selector: vscode.DocumentSelector = [{ scheme: 'file' }] | ||
|
|
||
| this.disposables.push( | ||
| vscode.languages.registerCodeActionsProvider(selector, this, { | ||
| providedCodeActionKinds: AutoDebugCodeActionsProvider.providedCodeActionKinds, | ||
| }) | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Provides code actions for the given document and range | ||
| */ | ||
| public provideCodeActions( | ||
| document: vscode.TextDocument, | ||
| range: vscode.Range | vscode.Selection, | ||
| context: vscode.CodeActionContext, | ||
| token: vscode.CancellationToken | ||
| ): vscode.ProviderResult<(vscode.CodeAction | vscode.Command)[]> { | ||
| if (token.isCancellationRequested) { | ||
| return [] | ||
| } | ||
|
|
||
| const actions: vscode.CodeAction[] = [] | ||
|
|
||
| // Get diagnostics for the current range | ||
| const diagnostics = context.diagnostics.filter( | ||
| (diagnostic) => diagnostic.range.intersection(range) !== undefined | ||
| ) | ||
|
|
||
| if (diagnostics.length > 0) { | ||
| // Add "Fix with Amazon Q" action | ||
| actions.push(this.createFixWithQAction(document, range, diagnostics)) | ||
|
|
||
| // Add "Fix All with Amazon Q" action | ||
| actions.push(this.createFixAllWithQAction(document)) | ||
|
|
||
| // Add "Explain Problem" action | ||
| actions.push(this.createExplainProblemAction(document, range, diagnostics)) | ||
| } | ||
| return actions | ||
| } | ||
|
|
||
| private createFixWithQAction( | ||
| document: vscode.TextDocument, | ||
| range: vscode.Range, | ||
| diagnostics: vscode.Diagnostic[] | ||
| ): vscode.CodeAction { | ||
| const action = new vscode.CodeAction( | ||
| `Amazon Q: Fix Problem (${diagnostics.length} issue${diagnostics.length !== 1 ? 's' : ''})`, | ||
| vscode.CodeActionKind.QuickFix | ||
| ) | ||
|
|
||
| action.command = { | ||
| command: 'amazonq.01.fixWithQ', | ||
| title: 'Amazon Q: Fix Problem', | ||
| arguments: [range, diagnostics], | ||
| } | ||
|
|
||
| action.diagnostics = diagnostics | ||
| action.isPreferred = true // Make this the preferred quick fix | ||
|
|
||
| return action | ||
| } | ||
|
|
||
| private createFixAllWithQAction(document: vscode.TextDocument): vscode.CodeAction { | ||
| const action = new vscode.CodeAction('Amazon Q: Fix All Errors', vscode.CodeActionKind.QuickFix) | ||
|
|
||
| action.command = { | ||
| command: 'amazonq.02.fixAllWithQ', | ||
| title: 'Amazon Q: Fix All Errors', | ||
| } | ||
|
|
||
| return action | ||
| } | ||
|
|
||
| private createExplainProblemAction( | ||
| document: vscode.TextDocument, | ||
| range: vscode.Range, | ||
| diagnostics: vscode.Diagnostic[] | ||
| ): vscode.CodeAction { | ||
| const action = new vscode.CodeAction('Amazon Q: Explain Problem', vscode.CodeActionKind.QuickFix) | ||
|
|
||
| action.command = { | ||
| command: 'amazonq.03.explainProblem', | ||
| title: 'Amazon Q: Explain Problem', | ||
| arguments: [range, diagnostics], | ||
| } | ||
|
|
||
| action.diagnostics = diagnostics | ||
|
|
||
| return action | ||
| } | ||
|
|
||
| public dispose(): void { | ||
| vscode.Disposable.from(...this.disposables).dispose() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| /*! | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import * as vscode from 'vscode' | ||
| import { Commands, getLogger, messages } from 'aws-core-vscode/shared' | ||
| import { AutoDebugController } from './controller' | ||
|
|
||
| /** | ||
| * Auto Debug commands for Amazon Q | ||
| * Handles all command registrations and implementations | ||
| */ | ||
| export class AutoDebugCommands implements vscode.Disposable { | ||
| private readonly logger = getLogger() | ||
| private readonly disposables: vscode.Disposable[] = [] | ||
| private controller!: AutoDebugController | ||
|
|
||
| /** | ||
| * Register all auto debug commands | ||
| */ | ||
| registerCommands(context: vscode.ExtensionContext, controller: AutoDebugController): void { | ||
| this.controller = controller | ||
| this.disposables.push( | ||
| // Fix with Amazon Q command | ||
| Commands.register( | ||
| { | ||
| id: 'amazonq.01.fixWithQ', | ||
| name: 'Amazon Q: Fix Problem', | ||
| }, | ||
| async (range?: vscode.Range, diagnostics?: vscode.Diagnostic[]) => { | ||
| await this.fixWithAmazonQ(range, diagnostics) | ||
| } | ||
| ), | ||
|
|
||
| // Fix All with Amazon Q command | ||
| Commands.register( | ||
| { | ||
| id: 'amazonq.02.fixAllWithQ', | ||
| name: 'Amazon Q: Fix All Errors', | ||
| }, | ||
| async () => { | ||
| await this.fixAllWithAmazonQ() | ||
| } | ||
| ), | ||
|
|
||
| // Explain Problem with Amazon Q command | ||
| Commands.register( | ||
| { | ||
| id: 'amazonq.03.explainProblem', | ||
| name: 'Amazon Q: Explain Problem', | ||
| }, | ||
| async (range?: vscode.Range, diagnostics?: vscode.Diagnostic[]) => { | ||
| await this.explainProblem(range, diagnostics) | ||
| } | ||
| ) | ||
| ) | ||
|
|
||
| // Add all disposables to context | ||
| context.subscriptions.push(...this.disposables) | ||
| } | ||
|
|
||
| /** | ||
| * Generic error handling wrapper for command execution | ||
| */ | ||
| private async executeWithErrorHandling<T>( | ||
| action: () => Promise<T>, | ||
| errorMessage: string, | ||
| logContext: string | ||
| ): Promise<T | void> { | ||
| try { | ||
| return await action() | ||
| } catch (error) { | ||
| this.logger.error(`AutoDebugCommands: Error in ${logContext}: %s`, error) | ||
| void messages.showMessage('error', 'Amazon Q was not able to fix or explain the problem. Try again shortly') | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Check if there's an active editor and log warning if not | ||
| */ | ||
| private checkActiveEditor(): vscode.TextEditor | undefined { | ||
laileni-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const editor = vscode.window.activeTextEditor | ||
| if (!editor) { | ||
| this.logger.warn('AutoDebugCommands: No active editor found') | ||
| } | ||
| return editor | ||
| } | ||
|
|
||
| /** | ||
| * Fix with Amazon Q - fixes only the specific issues the user selected | ||
| */ | ||
| private async fixWithAmazonQ(range?: vscode.Range, diagnostics?: vscode.Diagnostic[]): Promise<void> { | ||
| await this.executeWithErrorHandling( | ||
| async () => { | ||
| const editor = this.checkActiveEditor() | ||
| if (!editor) { | ||
| return | ||
| } | ||
| await this.controller.fixSpecificProblems(range, diagnostics) | ||
| }, | ||
| 'Fix with Amazon Q', | ||
| 'fixWithAmazonQ' | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Fix All with Amazon Q - processes all errors in the current file | ||
| */ | ||
| private async fixAllWithAmazonQ(): Promise<void> { | ||
| await this.executeWithErrorHandling( | ||
| async () => { | ||
| const editor = this.checkActiveEditor() | ||
| if (!editor) { | ||
| return | ||
| } | ||
| await this.controller.fixAllProblemsInFile(10) // 10 errors per batch | ||
| }, | ||
| 'Fix All with Amazon Q', | ||
| 'fixAllWithAmazonQ' | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Explains the problem using Amazon Q | ||
| */ | ||
| private async explainProblem(range?: vscode.Range, diagnostics?: vscode.Diagnostic[]): Promise<void> { | ||
| await this.executeWithErrorHandling( | ||
| async () => { | ||
| const editor = this.checkActiveEditor() | ||
| if (!editor) { | ||
| return | ||
| } | ||
| await this.controller.explainProblems(range, diagnostics) | ||
| }, | ||
| 'Explain Problem', | ||
| 'explainProblem' | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
| * Dispose of all resources | ||
| */ | ||
| dispose(): void { | ||
| vscode.Disposable.from(...this.disposables).dispose() | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.