2 Object.defineProperty(exports, "__esModule", { value: true });
3 exports.generateImplStubs = void 0;
4 const coc_nvim_1 = require("coc.nvim");
5 const binaries_1 = require("../binaries");
6 const tools_1 = require("./tools");
7 const interfaceRegex = /^(\w+ \*?\w+ )?([\w./]+)$/;
8 async function generateImplStubs(document) {
10 const implInput = await coc_nvim_1.workspace.requestInput("Enter receiver and interface [f *File io.Closer]");
11 if (implInput == null) {
12 coc_nvim_1.workspace.showMessage("No input detected! Aborting.", "warning");
15 const matches = implInput.match(interfaceRegex);
17 throw Error(`Cannot parse input: ${implInput}`);
19 const edit = await runGoImpl(document, [matches[1], matches[2]]);
20 await coc_nvim_1.workspace.applyEdit({ changes: { [document.uri]: [edit] } });
23 coc_nvim_1.workspace.showMessage(error, "error");
26 exports.generateImplStubs = generateImplStubs;
27 async function runGoImpl(document, args) {
28 const stdout = await tools_1.execTool(binaries_1.IMPL, args);
29 const { line } = await coc_nvim_1.workspace.getCursorPosition();
30 const insertPos = { line: line + 1, character: 0 };
31 const lineText = await coc_nvim_1.workspace.getLine(document.uri, line);
32 const newText = lineText.trim() === ''
43 //# sourceMappingURL=impl.js.map