in src/models/sqlOutputContentProvider.ts [175:229]
public createQueryRunner(statusView: StatusView, uri: string, title: string): QueryRunner {
// Reuse existing query runner if it exists
let queryRunner: QueryRunner;
if (this._queryResultsMap.has(uri)) {
let existingRunner: QueryRunner = this._queryResultsMap.get(uri).queryRunner;
// If the query is already in progress, don't attempt to send it
if (existingRunner.isExecutingQuery) {
this._vscodeWrapper.showInformationMessage(LocalizedConstants.msgRunQueryInProgress);
return;
}
// If the query is not in progress, we can reuse the query runner
queryRunner = existingRunner;
queryRunner.resetHasCompleted();
} else {
// We do not have a query runner for this editor, so create a new one
// and map it to the results uri
queryRunner = new QueryRunner(uri, title, statusView ? statusView : this._statusView);
queryRunner.eventEmitter.on('start', (panelUri) => {
this._panels.get(uri).proxy.sendEvent('start', panelUri);
});
queryRunner.eventEmitter.on('resultSet', (resultSet) => {
this._panels.get(uri).proxy.sendEvent('resultSet', resultSet);
});
queryRunner.eventEmitter.on('batchStart', (batch) => {
// Build a message for the selection and send the message
// from the webview
let message = {
message: LocalizedConstants.runQueryBatchStartMessage,
selection: batch.selection,
isError: false,
time: new Date().toLocaleTimeString(),
link: {
text: Utils.formatString(LocalizedConstants.runQueryBatchStartLine, batch.selection.startLine + 1)
}
};
this._panels.get(uri).proxy.sendEvent('message', message);
});
queryRunner.eventEmitter.on('message', (message) => {
this._panels.get(uri).proxy.sendEvent('message', message);
});
queryRunner.eventEmitter.on('complete', (totalMilliseconds, hasError, isRefresh?) => {
if (!isRefresh) {
// only update query history with new queries
this._vscodeWrapper.executeCommand(Constants.cmdRefreshQueryHistory, uri, hasError);
}
this._panels.get(uri).proxy.sendEvent('complete', totalMilliseconds);
});
this._queryResultsMap.set(uri, new QueryRunnerState(queryRunner));
}
return queryRunner;
}