@@ -307,6 +307,9 @@ def declFormat(self):
307307
308308 @property
309309 def className (self ):
310+ """ Return className of the source in.
311+
312+ """
310313 if isinstance (self , Class ):
311314 return self .name
312315 elif self .parent is not None :
@@ -380,10 +383,7 @@ def newSwitch(self):
380383 while_stat = Statement (self , 'while' )
381384 while_stat .setExpression ('True' )
382385 self .addSource (while_stat )
383- s = Statement (while_stat , 'if' )
384- s .expr = 'False'
385- while_stat .addSource (s )
386- return while_stat , s
386+ return while_stat
387387
388388 def newStatement (self , name ):
389389 """ creates a new Statement as a child of this block
@@ -407,7 +407,21 @@ def newStatementBefore(self, name, stat=None):
407407 self .addSourceBefore (s , stat )
408408 return s
409409
410+ def removeStatement (self , stat ):
411+ """ remove a statement from source.
412+
413+ @param stat Statement to be removed.
414+ @return None
415+ """
416+ idx = self .lines .index (stat )
417+ del self .lines [idx ]
418+
410419 def newVariable (self , name = None ):
420+ """ creates a new Variable for the block
421+
422+ @param name name of the variable
423+ @return Variable instance
424+ """
411425 var = Variable (self )
412426 self .addVariable (var , True )
413427 return var
@@ -459,23 +473,6 @@ def setName(self, name):
459473 """
460474 self .name = name
461475
462- def fixSwitch (self , while_block , block ):
463- """ fixes the first clause in an generated switch statement
464-
465- @param block Statement instance and child of this block
466- @return None
467- """
468- lines = while_block .lines
469- if (not block in lines ) or (block .name != 'if' ):
470- return
471- i = lines .index (block )
472- if (len (lines ) > i ):
473- next = lines [i + 1 ]
474- if next .name == 'elif' :
475- lines .remove (next )
476- block .expr = next .expr
477- block .lines = next .lines
478-
479476 def trimLines (self ):
480477 """ removes empty lines from the end of this block
481478
0 commit comments