Esempio n. 1
0
 def __update_indent_state(self, function_name: str) -> None:
     if not self.__is_start_of_special_command(function_name):
         self.__state['indent'] -= 1
     if self.__state['has_first_class_keyword']:
         self.__state['indent'] -= 1
     if self.__is_end_of_special_command(function_name):
         self.__state['indent'] -= 1
     if KeywordVerifier.is_conditional_invocation(function_name):
         self.__state['indent'] -= 1
Esempio n. 2
0
 def test_recognition_of_conditional_invocation(self):
     self.assertTrue(KeywordVerifier.is_conditional_invocation('If('))
     self.assertTrue(KeywordVerifier.is_conditional_invocation('while('))
     self.assertTrue(KeywordVerifier.is_conditional_invocation('while ('))
     self.assertFalse(
         KeywordVerifier.is_conditional_invocation('foreach ('))
     self.assertFalse(KeywordVerifier.is_conditional_invocation('if2('))
     self.assertFalse(KeywordVerifier.is_conditional_invocation('if*'))
Esempio n. 3
0
def format_command_invocation(state: dict, settings: dict,
                              invocation: dict) -> str:
    if KeywordVerifier.is_conditional_invocation(invocation['function_name']):
        return ConditionFormatter(state, settings).format(invocation)
    return CommandFormatter(state, settings).format(invocation)
Esempio n. 4
0
 def __should_add_space_for_conditional(self, formatted: str) -> bool:
     return self.__settings.get('space_after_loop_condition') and \
            KeywordVerifier.is_conditional_invocation(formatted)
Esempio n. 5
0
 def __update_state(self, data: str):
     if KeywordVerifier.is_conditional_invocation(data):
         self.__state['indent'] += 1
     self.__state['indent'] += 1