|
|
@@ -1,5 +1,6 @@
|
|
|
import * as vscode from "vscode"
|
|
|
import * as path from "path"
|
|
|
+import { ClineProvider } from "./webview/ClineProvider"
|
|
|
|
|
|
export const ACTION_NAMES = {
|
|
|
EXPLAIN: "Roo Code: Explain Code",
|
|
|
@@ -113,6 +114,18 @@ export class CodeActionProvider implements vscode.CodeActionProvider {
|
|
|
return action
|
|
|
}
|
|
|
|
|
|
+ private createActionPair(
|
|
|
+ baseTitle: string,
|
|
|
+ kind: vscode.CodeActionKind,
|
|
|
+ baseCommand: string,
|
|
|
+ args: any[],
|
|
|
+ ): vscode.CodeAction[] {
|
|
|
+ return [
|
|
|
+ this.createAction(`${baseTitle} in New Task`, kind, baseCommand, args),
|
|
|
+ this.createAction(`${baseTitle} in Current Task`, kind, `${baseCommand}InCurrentTask`, args),
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
private hasIntersectingRange(range1: vscode.Range, range2: vscode.Range): boolean {
|
|
|
// Optimize range intersection check
|
|
|
return !(
|
|
|
@@ -138,8 +151,9 @@ export class CodeActionProvider implements vscode.CodeActionProvider {
|
|
|
const actions: vscode.CodeAction[] = []
|
|
|
|
|
|
// Create actions using helper method
|
|
|
+ // Add explain actions
|
|
|
actions.push(
|
|
|
- this.createAction(ACTION_NAMES.EXPLAIN, vscode.CodeActionKind.QuickFix, COMMAND_IDS.EXPLAIN, [
|
|
|
+ ...this.createActionPair(ACTION_NAMES.EXPLAIN, vscode.CodeActionKind.QuickFix, COMMAND_IDS.EXPLAIN, [
|
|
|
filePath,
|
|
|
effectiveRange.text,
|
|
|
]),
|
|
|
@@ -154,7 +168,7 @@ export class CodeActionProvider implements vscode.CodeActionProvider {
|
|
|
if (relevantDiagnostics.length > 0) {
|
|
|
const diagnosticMessages = relevantDiagnostics.map(this.createDiagnosticData)
|
|
|
actions.push(
|
|
|
- this.createAction(ACTION_NAMES.FIX, vscode.CodeActionKind.QuickFix, COMMAND_IDS.FIX, [
|
|
|
+ ...this.createActionPair(ACTION_NAMES.FIX, vscode.CodeActionKind.QuickFix, COMMAND_IDS.FIX, [
|
|
|
filePath,
|
|
|
effectiveRange.text,
|
|
|
diagnosticMessages,
|
|
|
@@ -163,11 +177,14 @@ export class CodeActionProvider implements vscode.CodeActionProvider {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Add improve actions
|
|
|
actions.push(
|
|
|
- this.createAction(ACTION_NAMES.IMPROVE, vscode.CodeActionKind.RefactorRewrite, COMMAND_IDS.IMPROVE, [
|
|
|
- filePath,
|
|
|
- effectiveRange.text,
|
|
|
- ]),
|
|
|
+ ...this.createActionPair(
|
|
|
+ ACTION_NAMES.IMPROVE,
|
|
|
+ vscode.CodeActionKind.RefactorRewrite,
|
|
|
+ COMMAND_IDS.IMPROVE,
|
|
|
+ [filePath, effectiveRange.text],
|
|
|
+ ),
|
|
|
)
|
|
|
|
|
|
return actions
|