|
1 | 1 | import { PontManager } from "pontx-manager"; |
2 | 2 | import * as _ from "lodash"; |
3 | 3 | import * as vscode from "vscode"; |
4 | | -import { findAlicloudAPIConfig, findInterface, getSpecInfoFromName, plugins, showProgress, viewMetaFile, VSCodeLogger, wait } from "./utils"; |
| 4 | +import { |
| 5 | + findAlicloudAPIConfig, |
| 6 | + findInterface, |
| 7 | + getSpecInfoFromName, |
| 8 | + plugins, |
| 9 | + showProgress, |
| 10 | + viewMetaFile, |
| 11 | + VSCodeLogger, |
| 12 | + wait, |
| 13 | +} from "./utils"; |
5 | 14 | import { AlicloudAPIWebview } from "./webview"; |
6 | 15 | import { alicloudAPIMessageService } from "./Service"; |
7 | 16 | import { PontSpec } from "pontx-spec"; |
@@ -103,53 +112,53 @@ export class AlicloudApiCommands { |
103 | 112 |
|
104 | 113 | Promise.resolve(service.pontManager.innerManagerConfig.plugins.generate?.instance).then( |
105 | 114 | async (generatePlugin) => { |
106 | | - const {product, version} = getSpecInfoFromName(specName || ""); |
| 115 | + const { product, version } = getSpecInfoFromName(specName || ""); |
107 | 116 | const snippets = await codeSampleProvider({ |
108 | 117 | language: vscode.window.activeTextEditor?.document.languageId || "typescript", |
109 | 118 | product: product, |
110 | 119 | version: version, |
111 | 120 | apiName: apiName, |
112 | 121 | simplify: true, |
113 | 122 | }); |
114 | | - const VIEW_API_DOC_ID = "VSCODE_PONTX_SHOW_PICK_ITEM_VIEW_API_DOC"; |
115 | | - let pickItems = [ |
116 | | - { |
117 | | - label: "查看文档", |
118 | | - id: VIEW_API_DOC_ID, |
119 | | - }, |
| 123 | + const VIEW_API_DOC_ID = "VSCODE_PONTX_SHOW_PICK_ITEM_VIEW_API_DOC"; |
| 124 | + let pickItems = [ |
| 125 | + { |
| 126 | + label: "查看文档", |
| 127 | + id: VIEW_API_DOC_ID, |
| 128 | + }, |
| 129 | + ]; |
| 130 | + if (snippets?.length && vscode.window.activeTextEditor) { |
| 131 | + pickItems = [ |
| 132 | + ...pickItems, |
| 133 | + ...snippets.map((snippet) => { |
| 134 | + return { |
| 135 | + label: "插入代码段: " + snippet.name, |
| 136 | + id: snippet.name, |
| 137 | + description: snippet.description, |
| 138 | + }; |
| 139 | + }), |
120 | 140 | ]; |
121 | | - if (snippets?.length && vscode.window.activeTextEditor) { |
122 | | - pickItems = [ |
123 | | - ...pickItems, |
124 | | - ...snippets.map((snippet) => { |
125 | | - return { |
126 | | - label: "插入代码段: " + snippet.name, |
127 | | - id: snippet.name, |
128 | | - description: snippet.description, |
129 | | - }; |
130 | | - }), |
131 | | - ]; |
132 | | - } |
133 | | - return vscode.window |
134 | | - .showQuickPick(pickItems, { |
135 | | - matchOnDescription: true, |
136 | | - matchOnDetail: true, |
137 | | - }) |
138 | | - .then((snippet) => { |
139 | | - const foundSnippet = snippets.find((inst) => inst.name === snippet?.id); |
140 | | - if (foundSnippet) { |
141 | | - insertCode(foundSnippet.code); |
142 | | - } else if (snippet.id === VIEW_API_DOC_ID) { |
143 | | - vscode.commands.executeCommand("alicloud.api.openDocument", { |
144 | | - specName, |
145 | | - modName, |
146 | | - name: apiName, |
147 | | - spec: apiMeta, |
148 | | - pageType: "document", |
149 | | - schemaType: "api", |
150 | | - }); |
151 | | - } |
152 | | - }); |
| 141 | + } |
| 142 | + return vscode.window |
| 143 | + .showQuickPick(pickItems, { |
| 144 | + matchOnDescription: true, |
| 145 | + matchOnDetail: true, |
| 146 | + }) |
| 147 | + .then((snippet) => { |
| 148 | + const foundSnippet = snippets.find((inst) => inst.name === snippet?.id); |
| 149 | + if (foundSnippet) { |
| 150 | + insertCode(foundSnippet.code); |
| 151 | + } else if (snippet.id === VIEW_API_DOC_ID) { |
| 152 | + vscode.commands.executeCommand("alicloud.api.openDocument", { |
| 153 | + specName, |
| 154 | + modName, |
| 155 | + name: apiName, |
| 156 | + spec: apiMeta, |
| 157 | + pageType: "document", |
| 158 | + schemaType: "api", |
| 159 | + }); |
| 160 | + } |
| 161 | + }); |
153 | 162 | }, |
154 | 163 | ); |
155 | 164 | }); |
@@ -251,7 +260,7 @@ export class AlicloudApiCommands { |
251 | 260 | const lastPromptKey = "lastPromptTime"; |
252 | 261 | const globalState = context.globalState; |
253 | 262 | globalState.update(lastPromptKey, undefined); |
254 | | - console.log("update last prompt key to",globalState.get(lastPromptKey)) |
| 263 | + console.log("update last prompt key to", globalState.get(lastPromptKey)); |
255 | 264 | }); |
256 | 265 |
|
257 | 266 | vscode.commands.registerCommand("alicloud.api.restart", async () => { |
@@ -283,6 +292,7 @@ export class AlicloudApiCommands { |
283 | 292 | } |
284 | 293 | }, |
285 | 294 | ); |
| 295 | + return "ok"; |
286 | 296 | }); |
287 | 297 | vscode.commands.registerCommand("alicloud.api.openPontPanel", async () => { |
288 | 298 | await vscode.commands.executeCommand("alicloudApiExplorer.focus"); |
|
0 commit comments