-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from davelopez/add_clean_workflow_command
Add clean workflow command
- Loading branch information
Showing
7 changed files
with
204 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { window } from "vscode"; | ||
import { CleanWorkflowDocumentParams, CleanWorkflowDocumentRequest } from "../requestsDefinitions"; | ||
import { CustomCommand, getCommandFullIdentifier } from "./common"; | ||
|
||
/** | ||
* Command to 'clean' the selected workflow document. | ||
* It will apply edits to remove the non-workflow logic related parts. | ||
*/ | ||
export class CleanWorkflowCommand extends CustomCommand { | ||
public static id = getCommandFullIdentifier("cleanWorkflow"); | ||
readonly identifier: string = CleanWorkflowCommand.id; | ||
|
||
async execute(args: any[]): Promise<void> { | ||
if (!window.activeTextEditor) { | ||
return; | ||
} | ||
const { document } = window.activeTextEditor; | ||
|
||
const params: CleanWorkflowDocumentParams = { uri: this.client.code2ProtocolConverter.asUri(document.uri) }; | ||
const result = await this.client.sendRequest(CleanWorkflowDocumentRequest.type, params); | ||
if (!result) { | ||
throw new Error("Cannot clean the requested document. The server returned no result."); | ||
} | ||
if (result.error) { | ||
throw new Error(result.error); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters