@@ -202,60 +202,6 @@ export function loadWorkspaceXml(xml: string, skipReport = false, opts?: DomToWo
202202 }
203203}
204204
205- function patchFloatingBlocks ( dom : Element , info : pxtc . BlocksInfo ) {
206- const onstarts = getBlocksWithType ( dom , ts . pxtc . ON_START_TYPE ) ;
207- let onstart = onstarts . length ? onstarts [ 0 ] : undefined ;
208- if ( onstart ) { // nothing to do
209- onstart . removeAttribute ( "deletable" ) ;
210- return ;
211- }
212-
213- let newnodes : Element [ ] = [ ] ;
214-
215- const blocks : pxt . Map < pxtc . SymbolInfo > = info . blocksById ;
216-
217- // walk top level blocks
218- let node = dom . firstElementChild ;
219- let insertNode : Element = undefined ;
220- while ( node ) {
221- const nextNode = node . nextElementSibling ;
222- // does this block is disable or have s nested statement block?
223- const nodeType = node . getAttribute ( "type" ) ;
224- if ( ! node . getAttribute ( "disabled" ) && ! node . getElementsByTagName ( "statement" ) . length
225- && ( buildinBlockStatements [ nodeType ] ||
226- ( blocks [ nodeType ] && blocks [ nodeType ] . retType == "void" && ! hasArrowFunction ( blocks [ nodeType ] ) ) )
227- ) {
228- // old block, needs to be wrapped in onstart
229- if ( ! insertNode ) {
230- insertNode = dom . ownerDocument . createElement ( "statement" ) ;
231- insertNode . setAttribute ( "name" , "HANDLER" ) ;
232- if ( ! onstart ) {
233- onstart = dom . ownerDocument . createElement ( "block" ) ;
234- onstart . setAttribute ( "type" , ts . pxtc . ON_START_TYPE ) ;
235- newnodes . push ( onstart ) ;
236- }
237- onstart . appendChild ( insertNode ) ;
238- insertNode . appendChild ( node ) ;
239-
240- node . removeAttribute ( "x" ) ;
241- node . removeAttribute ( "y" ) ;
242- insertNode = node ;
243- } else {
244- // event, add nested statement
245- const next = dom . ownerDocument . createElement ( "next" ) ;
246- next . appendChild ( node ) ;
247- insertNode . appendChild ( next ) ;
248- node . removeAttribute ( "x" ) ;
249- node . removeAttribute ( "y" ) ;
250- insertNode = node ;
251- }
252- }
253- node = nextNode ;
254- }
255-
256- newnodes . forEach ( n => dom . appendChild ( n ) ) ;
257- }
258-
259205/**
260206 * Patch to transform old function blocks to new ones, and rename child nodes
261207 */
@@ -347,9 +293,6 @@ export function importXml(pkgTargetVersion: string, xml: string, info: pxtc.Bloc
347293 for ( let i = 0 ; i < blocks . length ; ++ i )
348294 patchBlock ( info , enums , blocks [ i ] ) ;
349295
350- // patch floating blocks
351- patchFloatingBlocks ( doc . documentElement , info ) ;
352-
353296 // patch function blocks
354297 patchFunctionBlocks ( doc . documentElement , info )
355298
0 commit comments