def _fix_violation(self, oViolation):
     lTokens = oViolation.get_tokens()
     dAction = oViolation.get_action()
     oMoveToken = lTokens.pop(dAction['moveIndex'])
     rules_utils.insert_token(lTokens, dAction['insertIndex'], oMoveToken)
     rules_utils.insert_whitespace(lTokens, dAction['insertIndex'])
     lTokens = utils.fix_blank_lines(lTokens)
     oViolation.set_tokens(lTokens)
Exemple #2
0
 def _fix_violation(self, oViolation):
     lTokens = oViolation.get_tokens()
     if isinstance(lTokens[-1], parser.whitespace):
         lTokens.pop()
     oToken = lTokens.pop()
     rules_utils.insert_token(lTokens, 0, oToken)
     rules_utils.insert_whitespace(lTokens, 0)
     oViolation.set_tokens(lTokens)
 def _fix_violation(self, oViolation):
     lTokens = oViolation.get_tokens()
     if self.action == 'remove':
         rules_utils.remove_optional_item(lTokens, oViolation,
                                          self.insert_token)
     else:
         rules_utils.insert_token(lTokens, 1, self.insert_token)
         rules_utils.insert_whitespace(lTokens, 1)
         oViolation.set_tokens(lTokens)
    def _fix_violation(self, oViolation):
        lTokens = oViolation.get_tokens()
        iIndex = oViolation.get_token_value()

        rules_utils.insert_token(lTokens, 1, lTokens.pop(iIndex))
        rules_utils.insert_whitespace(lTokens, 1)
        lNewTokens = utils.remove_consecutive_whitespace_tokens(lTokens)
        lNewTokens = utils.fix_blank_lines(lNewTokens)

        oViolation.set_tokens(lNewTokens)
    def _fix_violation(self, oViolation):
        lTokens = oViolation.get_tokens()
        dAction = oViolation.get_action()

        oToken = lTokens.pop(dAction['move_index'])
        rules_utils.insert_token(lTokens, dAction['insert'], oToken)
        if self.bInsertWhitespace:
            rules_utils.insert_whitespace(lTokens, dAction['insert'])
        lTokens = utils.remove_consecutive_whitespace_tokens(lTokens)
        lTokens = utils.fix_blank_lines(lTokens)
        oViolation.set_tokens(lTokens)
 def _fix_violation(self, oViolation):
     lTokens = oViolation.get_tokens()
     if self.action == 'remove':
         rules_utils.remove_optional_item(lTokens, oViolation,
                                          self.insert_token)
     else:
         if oViolation.get_token_value() is not None:
             for iIndex in range(0, len(lTokens)):
                 if isinstance(lTokens[iIndex], self.anchor_token):
                     rules_utils.insert_token(
                         lTokens, iIndex,
                         self.insert_token(oViolation.get_token_value()))
                     rules_utils.insert_whitespace(lTokens, iIndex)
             oViolation.set_tokens(lTokens)
 def _fix_violation(self, oViolation):
     lTokens = oViolation.get_tokens()
     dAction = oViolation.get_action()
     oToken = lTokens.pop()
     rules_utils.insert_token(lTokens, dAction['insert'], oToken)
     oViolation.set_tokens(lTokens)
Exemple #8
0
def add_enclosing_parens(oViolation):
    lTokens = oViolation.get_tokens()
    rules_utils.insert_token(lTokens, 0, parser.open_parenthesis())
    lTokens.append(parser.close_parenthesis())
    oViolation.set_tokens(lTokens)