in src/controllers/mainController.ts [334:376]
public onRunQuery(callbackThis?: MainController): void {
// the 'this' context is lost in retry callback, so capture it here
let self: MainController = callbackThis ? callbackThis : this;
try {
if (!self.canRunCommand() || !self.validateTextDocumentHasFocus()) {
return;
}
// check if we're connected and editing a SQL file
if (self.isRetryRequiredBeforeQuery(self.onRunQuery)) {
return;
}
let editor = self._vscodeWrapper.activeTextEditor;
let uri = self._vscodeWrapper.activeTextEditorUri;
let title = path.basename(editor.document.fileName);
let querySelection: ISelectionData;
// Calculate the selection if we have a selection, otherwise we'll use null to indicate
// the entire document is the selection
if (!editor.selection.isEmpty) {
let selection = editor.selection;
querySelection = {
startLine: selection.start.line,
startColumn: selection.start.character,
endLine: selection.end.line,
endColumn: selection.end.character
};
}
// Trim down the selection. If it is empty after selecting, then we don't execute
let selectionToTrim = editor.selection.isEmpty ? undefined : editor.selection;
if (editor.document.getText(selectionToTrim).trim().length === 0) {
return;
}
Telemetry.sendTelemetryEvent('RunQuery');
self._outputContentProvider.runQuery(self._statusview, uri, querySelection, title);
} catch (err) {
Telemetry.sendTelemetryEventForException(err, 'onRunQuery');
}
}