@@ -13,7 +13,6 @@ import * as vscode from 'vscode'
1313import { AwsContext } from '../shared/awsContext'
1414import { createStateMachineFromTemplate } from './commands/createStateMachineFromTemplate'
1515import { publishStateMachine } from './commands/publishStateMachine'
16- import { AslVisualizationManager } from './commands/visualizeStateMachine/aslVisualizationManager'
1716import { Commands } from '../shared/vscode/commands2'
1817
1918import { ASL_FORMATS , YAML_ASL , JSON_ASL } from './constants/aslFormats'
@@ -23,6 +22,7 @@ import { ToolkitError } from '../shared/errors'
2322import { telemetry } from '../shared/telemetry/telemetry'
2423import { PerfLog } from '../shared/logger/perfLogger'
2524import { ASLLanguageClient } from './asl/client'
25+ import { WorkflowStudioEditorProvider } from './workflowStudio/workflowStudioEditorProvider'
2626
2727/**
2828 * Activate Step Functions related functionality for the extension.
@@ -54,28 +54,22 @@ export async function activate(
5454 }
5555}
5656
57- /*
58- * TODO: Determine behaviour when command is run against bad input, or
59- * non-json files. Determine if we want to limit the command to only a
60- * specifc subset of file types ( .json only, custom .states extension, etc...)
61- * Ensure tests are written for this use case as well.
62- */
6357export const previewStateMachineCommand = Commands . declare (
6458 'aws.previewStateMachine' ,
65- ( manager : AslVisualizationManager ) => async ( arg ?: vscode . TextEditor | vscode . Uri ) => {
66- try {
59+ ( ) => async ( arg ?: vscode . TextEditor | vscode . Uri ) => {
60+ await telemetry . run ( 'stepfunctions_previewstatemachine' , async ( ) => {
6761 arg ??= vscode . window . activeTextEditor
6862 const input = arg instanceof vscode . Uri ? arg : arg ?. document
6963
7064 if ( ! input ) {
7165 throw new ToolkitError ( 'No active text editor or document found' )
7266 }
7367
74- return await manager . visualizeStateMachine ( input )
75- } finally {
76- // TODO: Consider making the metric reflect the success/failure of the above call
77- telemetry . stepfunctions_previewstatemachine . emit ( )
78- }
68+ await vscode . commands . executeCommand ( 'vscode.openWith' , input , WorkflowStudioEditorProvider . viewType , {
69+ preserveFocus : true ,
70+ viewColumn : vscode . ViewColumn . Beside ,
71+ } )
72+ } )
7973 }
8074)
8175
@@ -84,11 +78,10 @@ async function registerStepFunctionCommands(
8478 awsContext : AwsContext ,
8579 outputChannel : vscode . OutputChannel
8680) : Promise < void > {
87- const visualizationManager = new AslVisualizationManager ( extensionContext )
8881 const cdkVisualizationManager = new AslVisualizationCDKManager ( extensionContext )
8982
9083 extensionContext . subscriptions . push (
91- previewStateMachineCommand . register ( visualizationManager ) ,
84+ previewStateMachineCommand . register ( ) ,
9285 renderCdkStateMachineGraph . register ( cdkVisualizationManager ) ,
9386 Commands . register ( 'aws.stepfunctions.createStateMachineFromTemplate' , async ( ) => {
9487 try {
@@ -144,15 +137,8 @@ function initializeCodeLens(context: vscode.ExtensionContext) {
144137 public async provideCodeLenses ( document : vscode . TextDocument ) : Promise < vscode . CodeLens [ ] > {
145138 const topOfDocument = new vscode . Range ( 0 , 0 , 0 , 0 )
146139
147- const openCustomEditorCommand : vscode . Command = {
148- command : 'aws.stepfunctions.switchToWorkflowStudio' ,
140+ const openCustomEditor = previewStateMachineCommand . build ( document . uri ) . asCodeLens ( topOfDocument , {
149141 title : localize ( 'AWS.command.stepFunctions.openWithWorkflowStudio' , 'Open with Workflow Studio' ) ,
150- arguments : [ document . uri ] ,
151- }
152- const openCustomEditor = new vscode . CodeLens ( topOfDocument , openCustomEditorCommand )
153-
154- const renderCodeLens = previewStateMachineCommand . build ( ) . asCodeLens ( topOfDocument , {
155- title : localize ( 'AWS.stepFunctions.render' , 'Render graph' ) ,
156142 } )
157143
158144 if ( ASL_FORMATS . includes ( document . languageId ) ) {
@@ -162,9 +148,9 @@ function initializeCodeLens(context: vscode.ExtensionContext) {
162148 }
163149 const publishCodeLens = new vscode . CodeLens ( topOfDocument , publishCommand )
164150
165- return [ openCustomEditor , publishCodeLens , renderCodeLens ]
151+ return [ publishCodeLens , openCustomEditor ]
166152 } else {
167- return [ openCustomEditor , renderCodeLens ]
153+ return [ openCustomEditor ]
168154 }
169155 }
170156 }
0 commit comments