1.0.0 初始版
This commit is contained in:
133
dist/commands.js
vendored
Normal file
133
dist/commands.js
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.registerCommands = registerCommands;
|
||||
const vscode = __importStar(require("vscode"));
|
||||
function registerCommands(context, model, provider, functionExtractor, output) {
|
||||
// 连接到 API
|
||||
console.log('注册 squirrel.connectToApi 命令...');
|
||||
const connectCommand = vscode.commands.registerCommand('squirrel.connectToApi', async () => {
|
||||
try {
|
||||
await vscode.window.withProgress({
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: '正在连接到 pvfUtility API...',
|
||||
cancellable: false
|
||||
}, async (progress) => {
|
||||
const success = await model.connect();
|
||||
if (success) {
|
||||
vscode.window.showInformationMessage('成功连接到 pvfUtility API');
|
||||
provider.refresh();
|
||||
// 连接成功后,自动提取所有文件中的函数信息
|
||||
console.log('开始提取所有文件中的函数信息...');
|
||||
await vscode.window.withProgress({
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: '正在提取函数信息...',
|
||||
cancellable: false
|
||||
}, async (progress) => {
|
||||
await functionExtractor.extractAllFunctions(model);
|
||||
vscode.window.showInformationMessage('函数信息提取完成');
|
||||
});
|
||||
}
|
||||
else {
|
||||
vscode.window.showErrorMessage('连接到 pvfUtility API 失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
vscode.window.showErrorMessage(`连接失败: ${error}`);
|
||||
}
|
||||
});
|
||||
// 刷新文件列表
|
||||
const refreshCommand = vscode.commands.registerCommand('squirrel.refreshFiles', async () => {
|
||||
if (!model.getIsConnected()) {
|
||||
vscode.window.showErrorMessage('请先连接到 pvfUtility API');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await vscode.window.withProgress({
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: '正在刷新文件列表...',
|
||||
cancellable: false
|
||||
}, async (progress) => {
|
||||
const success = await model.refresh();
|
||||
if (success) {
|
||||
vscode.window.showInformationMessage('文件列表刷新成功');
|
||||
provider.refresh();
|
||||
}
|
||||
else {
|
||||
vscode.window.showErrorMessage('刷新文件列表失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
vscode.window.showErrorMessage(`刷新失败: ${error}`);
|
||||
}
|
||||
});
|
||||
// 打开文件
|
||||
const openFileCommand = vscode.commands.registerCommand('squirrel.openFile', async (entry) => {
|
||||
if (!model.getIsConnected()) {
|
||||
vscode.window.showErrorMessage('请先连接到 pvfUtility API');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await vscode.window.withProgress({
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: `正在加载文件 ${entry.name}...`,
|
||||
cancellable: false
|
||||
}, async (progress) => {
|
||||
const content = await model.getFileContent(entry.key);
|
||||
if (content !== undefined) {
|
||||
// 创建虚拟文档
|
||||
const uri = vscode.Uri.parse(`squirrel:/${entry.key}`);
|
||||
const doc = await vscode.workspace.openTextDocument(uri);
|
||||
await vscode.window.showTextDocument(doc);
|
||||
provider.refresh();
|
||||
}
|
||||
else {
|
||||
vscode.window.showErrorMessage(`加载文件 ${entry.name} 失败`);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
vscode.window.showErrorMessage(`打开文件失败: ${error}`);
|
||||
}
|
||||
});
|
||||
// 保存文件(通过 VS Code 的保存事件处理,这个命令主要用于显示)
|
||||
const saveFileCommand = vscode.commands.registerCommand('squirrel.saveFile', async () => {
|
||||
vscode.window.showInformationMessage('使用 VS Code 的保存功能或 Ctrl+S 保存文件');
|
||||
});
|
||||
context.subscriptions.push(connectCommand, refreshCommand, openFileCommand, saveFileCommand);
|
||||
}
|
||||
//# sourceMappingURL=commands.js.map
|
||||
Reference in New Issue
Block a user