@@ -22,10 +22,6 @@ export function registerDiagramCommands(context: vscode.ExtensionContext, output
2222 const activeEditor = vscode . window . activeTextEditor ;
2323 return await coordinator . createDiagramPanel ( FlowrDiagramType . Dataflow , activeEditor ) ;
2424 } ) ;
25- registerCommand ( context , 'vscode-flowr.dataflow-simplified' , async ( ) => {
26- const activeEditor = vscode . window . activeTextEditor ;
27- return await coordinator . createDiagramPanel ( FlowrDiagramType . Dataflow , activeEditor , true ) ;
28- } ) ;
2925 registerCommand ( context , 'vscode-flowr.ast' , async ( ) => {
3026 const activeEditor = vscode . window . activeTextEditor ;
3127 return await coordinator . createDiagramPanel ( FlowrDiagramType . Ast , activeEditor ) ;
@@ -43,10 +39,9 @@ enum FlowrDiagramType {
4339}
4440
4541interface DiagramPanelInformation {
46- type : FlowrDiagramType ;
47- panel : vscode . WebviewPanel ;
48- simplify : boolean ;
49- options : typeof DefaultDiagramOptions ;
42+ type : FlowrDiagramType ;
43+ panel : vscode . WebviewPanel ;
44+ options : typeof DefaultDiagramOptions ;
5045}
5146
5247interface ContentUpdateMessage {
@@ -78,21 +73,21 @@ class DiagramUpdateCoordinator {
7873 this . output = output ;
7974 }
8075
81- public async createDiagramPanel ( type : FlowrDiagramType , editor : vscode . TextEditor | undefined , simplify : boolean = false ) {
76+ public async createDiagramPanel ( type : FlowrDiagramType , editor : vscode . TextEditor | undefined ) {
8277 if ( ! editor ) {
8378 return ;
8479 }
8580
8681 const title = `${ nameFromDiagramType ( type ) } (${ path . basename ( editor . document . fileName ) } )` ;
8782 const options = optionsFromDiagramType ( type ) ;
88- const mermaid = await diagramFromTypeAndEditor ( type , editor , simplify , options ) ;
83+ const mermaid = await diagramFromTypeAndEditor ( type , editor , options ) ;
8984 const panel = createDiagramWebview ( type as string , title , mermaid , this . output , options ) ;
9085
9186 if ( ! panel ) {
9287 return undefined ;
9388 }
9489
95- const info = { type, panel, simplify , options } satisfies DiagramPanelInformation ;
90+ const info = { type, panel, options } satisfies DiagramPanelInformation ;
9691
9792 // Stop tracking panel when user closes it
9893 panel . onDidDispose ( ( ) => {
@@ -102,7 +97,6 @@ class DiagramUpdateCoordinator {
10297 // Handle settings update messages from panel
10398 panel . webview . onDidReceiveMessage ( ( msg : WebviewMessage ) => {
10499 const key = `${ DiagramSettingsPrefix } .${ msg . key } ` ;
105- console . log ( `Update: ${ JSON . stringify ( msg ) } ` ) ;
106100 if ( msg . keyInSet ) { // If setKey is set, the checkboxes are grouped into an array
107101 const current = new Set ( getConfig ( ) . get < string [ ] > ( key , [ ] ) ) ;
108102 if ( msg . value ) {
@@ -157,7 +151,7 @@ class DiagramUpdateCoordinator {
157151 }
158152
159153 public async updateWebviewPanel ( info : DiagramPanelInformation , textEditor : vscode . TextEditor ) {
160- const mermaid = await diagramFromTypeAndEditor ( info . type , textEditor , info . simplify , info . options ) ;
154+ const mermaid = await diagramFromTypeAndEditor ( info . type , textEditor , info . options ) ;
161155 info . panel . webview . postMessage ( {
162156 type : 'content_update' ,
163157 content : mermaid
@@ -194,12 +188,24 @@ const DefaultDiagramOptions = {
194188 } as DiagramOptionsCheckbox ,
195189} satisfies DiagramOptions ;
196190
191+ const DFGDiagramOptions = {
192+ // Default options for mode and sync
193+ ...DefaultDiagramOptions ,
194+ simplifyDfg : {
195+ type : 'checkbox' ,
196+ key : DiagramSettingsKeys . SimplifyDfg ,
197+ displayText : 'Simplify' ,
198+ default : true ,
199+ currentValue : true
200+ } as DiagramOptionsCheckbox ,
201+ } satisfies DiagramOptions ;
202+
197203const CFGDiagramOptions = {
198204 // Default options for mode and sync
199205 ...DefaultDiagramOptions ,
200- simplify : {
206+ simplifyCfg : {
201207 type : 'checkbox' ,
202- key : DiagramSettingsKeys . Simplify ,
208+ key : DiagramSettingsKeys . SimplifyCfg ,
203209 displayText : 'Simplify' ,
204210 default : true ,
205211 currentValue : true
@@ -220,7 +226,7 @@ function optionsFromDiagramType(type: FlowrDiagramType) {
220226
221227 switch ( type ) {
222228 case FlowrDiagramType . Dataflow :
223- options = DefaultDiagramOptions ;
229+ options = DFGDiagramOptions ;
224230 break ;
225231 case FlowrDiagramType . Controlflow :
226232 options = CFGDiagramOptions ;
@@ -259,13 +265,16 @@ function simplificationPassesFromOptions(options: DiagramOptions): CfgSimplifica
259265 return passes ;
260266}
261267
262- async function diagramFromTypeAndEditor ( type : FlowrDiagramType , editor : vscode . TextEditor , simplified : boolean , options : typeof DefaultDiagramOptions ) : Promise < string > {
268+ async function diagramFromTypeAndEditor ( type : FlowrDiagramType , editor : vscode . TextEditor , options : typeof DefaultDiagramOptions ) : Promise < string > {
263269 const session = await getFlowrSession ( ) ;
264270 switch ( type ) {
265- case FlowrDiagramType . Dataflow : return await session . retrieveDataflowMermaid ( editor . document , editor . selections , options . mode . currentValue , simplified ) ;
271+ case FlowrDiagramType . Dataflow : {
272+ const opts = options as typeof DFGDiagramOptions ;
273+ return await session . retrieveDataflowMermaid ( editor . document , editor . selections , options . mode . currentValue , opts . simplifyDfg . currentValue ) ;
274+ }
266275 case FlowrDiagramType . Controlflow : {
267276 const opts = options as typeof CFGDiagramOptions ;
268- return await session . retrieveCfgMermaid ( editor . document , editor . selections , opts . mode . currentValue , opts . simplify . currentValue , simplificationPassesFromOptions ( opts ) ) ;
277+ return await session . retrieveCfgMermaid ( editor . document , editor . selections , opts . mode . currentValue , opts . simplifyCfg . currentValue , simplificationPassesFromOptions ( opts ) ) ;
269278 }
270279 case FlowrDiagramType . Ast : return await session . retrieveAstMermaid ( editor . document , editor . selections , options . mode . currentValue ) ;
271280 default : assert ( false ) ;
0 commit comments