Skip to content

Commit 6822748

Browse files
committed
feat:单个文件可以鼠标右键直接解析和重构
1 parent 893c7b0 commit 6822748

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

package.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
"onCommand:codeReDesign.analyzeCode",
2121
"onCommand:codeReDesign.uploadThisCvb",
2222
"onCommand:codeReDesign.analyzeThisCvb",
23-
"onCommand:codeReDesign.compressThisCvb"
23+
"onCommand:codeReDesign.compressThisCvb",
24+
25+
"onCommand:codeReDesign.analyzeSingleFile",
26+
"onCommand:codeReDesign.uploadSingleFile"
2427
],
2528
"repository": {
2629
"type": "git",
@@ -97,6 +100,21 @@
97100
"title": "Show Guide",
98101
"category": "CodeReDesign",
99102
"icon": "${question}"
103+
},
104+
105+
{
106+
"command": "codeReDesign.analyzeSingleFile",
107+
"title": "CodeReDesign:Analyze single File",
108+
"when": "false",
109+
"category": "CodeReDesign",
110+
"icon": "${bug}"
111+
},
112+
{
113+
"command": "codeReDesign.uploadSingleFile",
114+
"title": "CodeReDesign:Upload single File",
115+
"when": "false",
116+
"category": "CodeReDesign",
117+
"icon": "${bug}"
100118
}
101119
],
102120
"viewsContainers": {
@@ -148,6 +166,18 @@
148166
"group": "navigation",
149167
"when": "panelFocus && activePanel == 'workbench.panel.output'"
150168
}
169+
],
170+
"explorer/context": [
171+
{
172+
"command": "codeReDesign.analyzeSingleFile",
173+
"group": "cvb@1",
174+
"when": "resourceExtname == .py || resourceExtname == .cpp || resourceExtname == .h || resourceExtname == .c || resourceExtname == .lua || resourceExtname == .js|| resourceExtname == .css"
175+
},
176+
{
177+
"command": "codeReDesign.uploadSingleFile",
178+
"group": "cvb@1",
179+
"when": "resourceExtname == .py || resourceExtname == .cpp || resourceExtname == .h || resourceExtname == .c || resourceExtname == .lua || resourceExtname == .js|| resourceExtname == .css"
180+
}
151181
]
152182
},
153183
"configuration": {

src/siderBar.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as vscode from 'vscode';
22
import * as path from 'path';
33
import * as fs from 'fs';
4-
import { applyCvbToWorkspace, compressCvb, Cvb} from './cvbManager';
4+
import { applyCvbToWorkspace, compressCvb, Cvb, generateCvb} from './cvbManager';
55
import { analyzeCode } from './deepseekApi';
66
import { getCurrentOperationController, resetCurrentOperationController, clearCurrentOperationController, doUploadCommand, saveAnalyzeCodeResult} from './extension';
77
import { showInputMultiLineBox } from './UIComponents';
@@ -78,6 +78,20 @@ export function registerCvbContextMenu(context: vscode.ExtensionContext) {
7878
});
7979
context.subscriptions.push(compressCvbCommand);
8080

81+
const analyzeSingleFileCommand = vscode.commands.registerCommand('codeReDesign.analyzeSingleFile', async (uri: vscode.Uri) => {
82+
const filePath = uri.fsPath || "";
83+
const cvbFile = await generateCvb([filePath], "分析单个文件:" + filePath);
84+
await analyzeThisCvb(cvbFile);
85+
});
86+
context.subscriptions.push(analyzeSingleFileCommand);
87+
88+
const uploadSingleFileCommand = vscode.commands.registerCommand('codeReDesign.uploadSingleFile', async (uri: vscode.Uri) => {
89+
const filePath = uri.fsPath || "";
90+
const cvbFile = await generateCvb([filePath], "重构单个文件:" + filePath);
91+
await uploadThisCvb(cvbFile);
92+
});
93+
context.subscriptions.push(uploadSingleFileCommand);
94+
8195
// 注册 TreeDataProvider
8296
const cvbViewProvider = new CvbViewProvider();
8397
vscode.window.registerTreeDataProvider('codeReDesign.cvbView', cvbViewProvider);

0 commit comments

Comments
 (0)