forgeplus-react/src/forge/Newfile/ide-plugin.js

62 lines
1.4 KiB
JavaScript
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export const ExtensionCommand={
toggleBlame : 'code.blame.toggleBlame',
linkToCommit : 'code.blame.linktocommit',
onActive : 'code.blame.extension.active',
setPerference : 'code.blame.setPerference',
acrToggleBlame : 'code.blame.acrToggleBlame',
getBlameData : 'code.blame.getBlameData',
}
export default class IDEPlugin {
// // @ts-ignore
// commands: IPluginAPI['commands'];
// onActivate: () => void;
// linkToCommit: (commitId: string) => void;
/**
* 插件 ID用于唯一标识插件
*/
PLUGIN_ID = 'antcode-communication';
constructor(onActive, linkToCommit) {
this.onActivate = onActive;
this.linkToCommit = linkToCommit;
}
/**
* 激活插件
*/
activate = (ctx) => {
const { commands, context } = ctx;
this.commands = commands;
context.subscriptions.push(
commands.registerCommand(ExtensionCommand.onActive, () => {
this.onActivate();
}),
commands.registerCommand(ExtensionCommand.linkToCommit, (params) => {
const { commitId } = params;
this.linkToCommit(commitId);
})
);
};
/**
* 注销插件,可在此时机清理副作用
*/
deactivate() {}
/**
* 修改配置项
* @param name 配置项名称
* @param value 值
* @param global 是否全局生效
*/
setPerference(name, value, global) {
this.commands.executeCommand(
ExtensionCommand.setPerference,
name,
value,
!!global
);
}
}