(fileName, scriptText, context?: sqlops.ObjectExplorerContext)
| 9 | private dbName: string = ''; |
| 10 | // places scriptText into fileName editor with current connection |
| 11 | public async placescript(fileName, scriptText, context?: sqlops.ObjectExplorerContext) { |
| 12 | try { |
| 13 | let connection; |
| 14 | if (context) { |
| 15 | let connection = context.connectionProfile; |
| 16 | this.connectionId = connection.id; |
| 17 | this.dbName = context.connectionProfile.databaseName; |
| 18 | await vscode.commands.executeCommand('explorer.query', context.connectionProfile); |
| 19 | } else { |
| 20 | await vscode.commands.executeCommand('newQuery'); |
| 21 | } |
| 22 | |
| 23 | let editor = vscode.window.activeTextEditor; |
| 24 | let doc = editor.document; |
| 25 | editor.edit(edit => { |
| 26 | edit.insert(new vscode.Position(0, 0), scriptText); |
| 27 | }); |
| 28 | |
| 29 | if (context && this.dbName) { |
| 30 | let providerName = context.connectionProfile.providerName; |
| 31 | let dProvider = await sqlops.dataprotocol.getProvider<sqlops.ConnectionProvider>(providerName, sqlops.DataProviderType.ConnectionProvider); |
| 32 | let connectionUri = await sqlops.connection.getUriForConnection(this.connectionId); |
| 33 | await dProvider.changeDatabase(connectionUri,this.dbName); |
| 34 | await sqlops.queryeditor.connect(doc.uri.toString(), this.connectionId); |
| 35 | } |
| 36 | } catch (err) { |
| 37 | vscode.window.showErrorMessage(err); |
| 38 | } |
| 39 | } |
| 40 | } |
no outgoing calls
no test coverage detected