@@ -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.
@@ -62,20 +62,20 @@ export async function activate(
6262 */
6363export const previewStateMachineCommand = Commands . declare (
6464 'aws.previewStateMachine' ,
65- ( manager : AslVisualizationManager ) => async ( arg ?: vscode . TextEditor | vscode . Uri ) => {
66- try {
65+ ( ) => async ( arg ?: vscode . TextEditor | vscode . Uri ) => {
66+ await telemetry . run ( 'stepfunctions_previewstatemachine' , async ( ) => {
6767 arg ??= vscode . window . activeTextEditor
6868 const input = arg instanceof vscode . Uri ? arg : arg ?. document
6969
7070 if ( ! input ) {
7171 throw new ToolkitError ( 'No active text editor or document found' )
7272 }
7373
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- }
74+ await vscode . commands . executeCommand ( 'vscode.openWith' , input , WorkflowStudioEditorProvider . viewType , {
75+ preserveFocus : true ,
76+ viewColumn : vscode . ViewColumn . Beside ,
77+ } )
78+ } )
7979 }
8080)
8181
@@ -84,11 +84,10 @@ async function registerStepFunctionCommands(
8484 awsContext : AwsContext ,
8585 outputChannel : vscode . OutputChannel
8686) : Promise < void > {
87- const visualizationManager = new AslVisualizationManager ( extensionContext )
8887 const cdkVisualizationManager = new AslVisualizationCDKManager ( extensionContext )
8988
9089 extensionContext . subscriptions . push (
91- previewStateMachineCommand . register ( visualizationManager ) ,
90+ previewStateMachineCommand . register ( ) ,
9291 renderCdkStateMachineGraph . register ( cdkVisualizationManager ) ,
9392 Commands . register ( 'aws.stepfunctions.createStateMachineFromTemplate' , async ( ) => {
9493 try {
@@ -144,15 +143,8 @@ function initializeCodeLens(context: vscode.ExtensionContext) {
144143 public async provideCodeLenses ( document : vscode . TextDocument ) : Promise < vscode . CodeLens [ ] > {
145144 const topOfDocument = new vscode . Range ( 0 , 0 , 0 , 0 )
146145
147- const openCustomEditorCommand : vscode . Command = {
148- command : 'aws.stepfunctions.switchToWorkflowStudio' ,
146+ const openCustomEditor = previewStateMachineCommand . build ( document . uri ) . asCodeLens ( topOfDocument , {
149147 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' ) ,
156148 } )
157149
158150 if ( ASL_FORMATS . includes ( document . languageId ) ) {
@@ -162,9 +154,9 @@ function initializeCodeLens(context: vscode.ExtensionContext) {
162154 }
163155 const publishCodeLens = new vscode . CodeLens ( topOfDocument , publishCommand )
164156
165- return [ openCustomEditor , publishCodeLens , renderCodeLens ]
157+ return [ publishCodeLens , openCustomEditor ]
166158 } else {
167- return [ openCustomEditor , renderCodeLens ]
159+ return [ openCustomEditor ]
168160 }
169161 }
170162 }
0 commit comments