Skip to content

Commit

Permalink
copy result handler (#87)
Browse files Browse the repository at this point in the history
* Remove duplicated types (#85)

* Remove duplicated types

* Remove max line length

* add copy result to query provider (#86)

* add copy result to query provider

* fix error

* update js

---------

Co-authored-by: Charles Gagnon <[email protected]>
  • Loading branch information
alanrenmsft and Charles-Gagnon authored Jun 9, 2023
1 parent fed4e05 commit 23e1f6e
Show file tree
Hide file tree
Showing 14 changed files with 463 additions and 829 deletions.
2 changes: 0 additions & 2 deletions lib/codeConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ function asScriptingParams(ownerURI, operation, metadata, paramDetails) {
type: metadata.metadataTypeName,
schema: metadata.schema,
name: metadata.name,
// cast to any since azdata needs to be updated to pickup this new field
// TODO: remove cast once updated azdata is published (8/24/2021 - karlb)
parentName: metadata.parentName,
parentTypeName: metadata.parentTypeName
};
Expand Down
17 changes: 10 additions & 7 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,7 @@ class ConnectionFeature extends SqlOpsFeature {
});
};
let registerOnConnectionChanged = (handler) => {
client.onNotification(protocol.ConnectionChangedNotification.type, (params) => {
handler({
connectionUri: params.ownerUri,
connection: params.connection
});
});
client.onNotification(protocol.ConnectionChangedNotification.type, handler);
};
azdata.dataprotocol.onDidChangeLanguageFlavor((params) => {
client.sendNotification(protocol.LanguageFlavorChangedNotification.type, params);
Expand Down Expand Up @@ -381,6 +376,12 @@ class QueryFeature extends SqlOpsFeature {
return Promise.reject(e);
});
};
let copyResults = (params) => {
return client.sendRequest(protocol.CopyResultsRequest.type, params).then(r => undefined, e => {
client.logFailedRequest(protocol.CopyResultsRequest.type, e);
return Promise.reject(e);
});
};
// Edit Data Requests
let commitEdit = (ownerUri) => {
let params = { ownerUri };
Expand Down Expand Up @@ -479,7 +480,8 @@ class QueryFeature extends SqlOpsFeature {
runQueryStatement,
runQueryString,
saveResults,
updateCell
updateCell,
copyResults
});
}
}
Expand All @@ -505,6 +507,7 @@ QueryFeature.messagesTypes = [
protocol.SaveResultsAsMarkdownRequest.type,
protocol.SaveResultsAsExcelRequest.type,
protocol.SaveResultsAsXmlRequest.type,
protocol.CopyResultsRequest.type,
protocol.EditCommitRequest.type,
protocol.EditCreateRowRequest.type,
protocol.EditDeleteRowRequest.type,
Expand Down
38 changes: 14 additions & 24 deletions lib/protocol.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,26 +104,13 @@ export declare namespace ConnectionRequest {
const type: RequestType<ConnectParams, boolean, void, void>;
}
export declare namespace ConnectionCompleteNotification {
const type: NotificationType<types.ConnectionCompleteParams, void>;
}
/**
* Parameters for the ConnectionChanged notification.
*/
export declare class ConnectionChangedParams {
/**
* Owner URI of the connection that changed.
*/
ownerUri: string;
/**
* Summary of details containing any connection changes.
*/
connection: types.ConnectionSummary;
const type: NotificationType<azdata.ConnectionInfoSummary, void>;
}
/**
* Connection changed event callback declaration.
*/
export declare namespace ConnectionChangedNotification {
const type: NotificationType<ConnectionChangedParams, void>;
const type: NotificationType<azdata.ChangedConnectionInfo, void>;
}
/**
* Connection request message format
Expand Down Expand Up @@ -307,6 +294,9 @@ export declare namespace SaveResultsAsExcelRequest {
export declare namespace SaveResultsAsXmlRequest {
const type: RequestType<azdata.SaveResultsRequestParams, azdata.SaveResultRequestResult, void, void>;
}
export declare namespace CopyResultsRequest {
const type: RequestType<azdata.CopyResultsRequestParams, void, void, void>;
}
export declare namespace SyntaxParseRequest {
const type: RequestType<azdata.SyntaxParseParams, azdata.SyntaxParseResult, void, void>;
}
Expand All @@ -330,7 +320,7 @@ export declare namespace ScriptingRequest {
const type: RequestType<types.ScriptingParams, azdata.ScriptingResult, void, void>;
}
export declare namespace ScriptingCompleteNotification {
const type: NotificationType<types.ScriptingCompleteParams, void>;
const type: NotificationType<azdata.ScriptingCompleteResult, void>;
}
export interface EditSessionOperationParams {
ownerUri: string;
Expand Down Expand Up @@ -383,28 +373,28 @@ export declare namespace EditSubsetRequest {
const type: RequestType<azdata.EditSubsetParams, azdata.EditSubsetResult, void, void>;
}
export declare namespace ObjectExplorerCreateSessionRequest {
const type: RequestType<azdata.ConnectionInfo, types.CreateSessionResponse, void, void>;
const type: RequestType<azdata.ConnectionInfo, azdata.ObjectExplorerSessionResponse, void, void>;
}
export declare namespace ObjectExplorerExpandRequest {
const type: RequestType<types.ExpandParams, boolean, void, void>;
const type: RequestType<azdata.ExpandNodeInfo, boolean, void, void>;
}
export declare namespace ObjectExplorerRefreshRequest {
const type: RequestType<types.ExpandParams, boolean, void, void>;
const type: RequestType<azdata.ExpandNodeInfo, boolean, void, void>;
}
export declare namespace ObjectExplorerCloseSessionRequest {
const type: RequestType<types.CloseSessionParams, types.CloseSessionResponse, void, void>;
const type: RequestType<azdata.ObjectExplorerCloseSessionInfo, azdata.ObjectExplorerCloseSessionResponse, void, void>;
}
export declare namespace ObjectExplorerFindNodesRequest {
const type: RequestType<types.FindNodesParams, types.FindNodesResponse, void, void>;
const type: RequestType<azdata.FindNodesInfo, azdata.ObjectExplorerFindNodesResponse, void, void>;
}
export declare namespace ObjectExplorerCreateSessionCompleteNotification {
const type: NotificationType<types.SessionCreatedParameters, void>;
const type: NotificationType<azdata.ObjectExplorerSession, void>;
}
export declare namespace ObjectExplorerSessionDisconnectedNotification {
const type: NotificationType<types.SessionDisconnectedParameters, void>;
const type: NotificationType<azdata.ObjectExplorerSession, void>;
}
export declare namespace ObjectExplorerExpandCompleteNotification {
const type: NotificationType<types.ExpandResponse, void>;
const type: NotificationType<azdata.ObjectExplorerExpandInfo, void>;
}
export declare namespace ListTasksRequest {
const type: RequestType<azdata.ListTasksParams, azdata.ListTasksResponse, void, void>;
Expand Down
15 changes: 8 additions & 7 deletions lib/protocol.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScriptingRequest = exports.MetadataQueryRequest = exports.QueryExecutionOptionsRequest = exports.QueryExecuteStringRequest = exports.SimpleExecuteRequest = exports.SyntaxParseRequest = exports.SaveResultsAsXmlRequest = exports.SaveResultsAsExcelRequest = exports.SaveResultsAsMarkdownRequest = exports.SaveResultsAsJsonRequest = exports.SaveResultsAsCsvRequest = exports.QueryExecuteStatementRequest = exports.QueryExecuteSubsetRequest = exports.QueryExecuteRequest = exports.QueryExecuteMessageNotification = exports.QueryExecuteResultSetUpdatedNotification = exports.QueryExecuteResultSetAvailableNotification = exports.QueryExecuteBatchCompleteNotification = exports.QueryExecuteBatchStartNotification = exports.QueryExecuteCompleteNotification = exports.ConnectionUriChangedParams = exports.ConnectionUriChangedNotification = exports.QueryDisposeRequest = exports.QueryCancelRequest = exports.CapabiltiesDiscoveryRequest = exports.CapabiltiesDiscoveryParams = exports.IntelliSenseReadyNotification = exports.ViewMetadataRequest = exports.TableMetadataRequest = exports.TableMetadataResult = exports.TableMetadataParams = exports.LanguageFlavorChangedNotification = exports.BuildConnectionInfoRequest = exports.GetConnectionStringRequest = exports.GetConnectionStringParams = exports.ListDatabasesRequest = exports.ListDatabasesParams = exports.ChangeDatabaseRequest = exports.ChangeDatabaseParams = exports.CancelConnectRequest = exports.CancelConnectParams = exports.DisconnectRequest = exports.DisconnectParams = exports.ChangePasswordRequest = exports.ConnectionChangedNotification = exports.ConnectionChangedParams = exports.ConnectionCompleteNotification = exports.ConnectionRequest = exports.RebuildIntelliSenseParams = exports.RebuildIntelliSenseNotification = void 0;
exports.ScriptingRequest = exports.MetadataQueryRequest = exports.QueryExecutionOptionsRequest = exports.QueryExecuteStringRequest = exports.SimpleExecuteRequest = exports.SyntaxParseRequest = exports.CopyResultsRequest = exports.SaveResultsAsXmlRequest = exports.SaveResultsAsExcelRequest = exports.SaveResultsAsMarkdownRequest = exports.SaveResultsAsJsonRequest = exports.SaveResultsAsCsvRequest = exports.QueryExecuteStatementRequest = exports.QueryExecuteSubsetRequest = exports.QueryExecuteRequest = exports.QueryExecuteMessageNotification = exports.QueryExecuteResultSetUpdatedNotification = exports.QueryExecuteResultSetAvailableNotification = exports.QueryExecuteBatchCompleteNotification = exports.QueryExecuteBatchStartNotification = exports.QueryExecuteCompleteNotification = exports.ConnectionUriChangedParams = exports.ConnectionUriChangedNotification = exports.QueryDisposeRequest = exports.QueryCancelRequest = exports.CapabiltiesDiscoveryRequest = exports.CapabiltiesDiscoveryParams = exports.IntelliSenseReadyNotification = exports.ViewMetadataRequest = exports.TableMetadataRequest = exports.TableMetadataResult = exports.TableMetadataParams = exports.LanguageFlavorChangedNotification = exports.BuildConnectionInfoRequest = exports.GetConnectionStringRequest = exports.GetConnectionStringParams = exports.ListDatabasesRequest = exports.ListDatabasesParams = exports.ChangeDatabaseRequest = exports.ChangeDatabaseParams = exports.CancelConnectRequest = exports.CancelConnectParams = exports.DisconnectRequest = exports.DisconnectParams = exports.ChangePasswordRequest = exports.ConnectionChangedNotification = exports.ConnectionCompleteNotification = exports.ConnectionRequest = exports.RebuildIntelliSenseParams = exports.RebuildIntelliSenseNotification = void 0;
exports.FileBrowserCloseRequest = exports.FileBrowserValidatedNotification = exports.FileBrowserValidateRequest = exports.FileBrowserExpandedNotification = exports.FileBrowserExpandRequest = exports.FileBrowserOpenedNotification = exports.FileBrowserOpenRequest = exports.RestoreConfigInfoRequest = exports.CancelRestorePlanRequest = exports.RestorePlanRequest = exports.RestoreRequest = exports.BackupConfigInfoRequest = exports.BackupRequest = exports.GetDatabaseInfoRequest = exports.CreateLoginRequest = exports.DefaultDatabaseInfoRequest = exports.CreateDatabaseRequest = exports.TaskCreatedNotification = exports.TaskStatusChangedNotification = exports.CancelTaskRequest = exports.ListTasksRequest = exports.ObjectExplorerExpandCompleteNotification = exports.ObjectExplorerSessionDisconnectedNotification = exports.ObjectExplorerCreateSessionCompleteNotification = exports.ObjectExplorerFindNodesRequest = exports.ObjectExplorerCloseSessionRequest = exports.ObjectExplorerRefreshRequest = exports.ObjectExplorerExpandRequest = exports.ObjectExplorerCreateSessionRequest = exports.EditSubsetRequest = exports.EditUpdateCellRequest = exports.EditSessionReadyNotification = exports.EditRevertRowRequest = exports.EditRevertCellRequest = exports.EditInitializeRequest = exports.EditDisposeRequest = exports.EditDeleteRowRequest = exports.EditCreateRowRequest = exports.EditCommitRequest = exports.ScriptingCompleteNotification = void 0;
const vscode_languageclient_1 = require("vscode-languageclient");
// ---- Refresh IntelliSense ----------------------------------------
Expand Down Expand Up @@ -28,12 +28,6 @@ var ConnectionCompleteNotification;
ConnectionCompleteNotification.type = new vscode_languageclient_1.NotificationType('connection/complete');
})(ConnectionCompleteNotification = exports.ConnectionCompleteNotification || (exports.ConnectionCompleteNotification = {}));
// ------------------------------- < Connection Changed Event > -------------------------------------
/**
* Parameters for the ConnectionChanged notification.
*/
class ConnectionChangedParams {
}
exports.ConnectionChangedParams = ConnectionChangedParams;
/**
* Connection changed event callback declaration.
*/
Expand Down Expand Up @@ -241,6 +235,13 @@ var SaveResultsAsXmlRequest;
SaveResultsAsXmlRequest.type = new vscode_languageclient_1.RequestType('query/saveXml');
})(SaveResultsAsXmlRequest = exports.SaveResultsAsXmlRequest || (exports.SaveResultsAsXmlRequest = {}));
// --------------------------------- </ Save Results as Xml Request > ------------------------------------------
// --------------------------------- < Copy Results Request > ------------------------------------------
// copy results to clipboard
var CopyResultsRequest;
(function (CopyResultsRequest) {
CopyResultsRequest.type = new vscode_languageclient_1.RequestType('query/copy');
})(CopyResultsRequest = exports.CopyResultsRequest || (exports.CopyResultsRequest = {}));
// --------------------------------- </ Copy Results Request > ------------------------------------------
// ------------------------------- < T-SQL Syntax Parse > -----------------------------------
var SyntaxParseRequest;
(function (SyntaxParseRequest) {
Expand Down
Loading

0 comments on commit 23e1f6e

Please sign in to comment.