Example #1
0
 def __reindent_line_comments_after_keyword(self, args: List[str]) -> list:
     verifier = KeywordVerifier(self.__settings)
     for i in reversed(range(len(args))):
         if verifier.is_keyword(args[i]) and re.match(
                 Tokens.get_reindent_regex(), args[i]):
             self.__try_reindent_all_previous_comments(args, i)
     return args
Example #2
0
 def calculate(self, invocation: str) -> int:
     invocation = invocation.replace('\t',
                                     ' ' * self.__settings['tab_size'])
     invocation = re.sub(Tokens.get_reindent_regex(), '', invocation)
     invocation = re.sub(Tokens.remove_spaces(), '', invocation)
     return len(invocation)
Example #3
0
 def test_reindent_token_generation_and_matching(self):
     self.assertRegex(Tokens.reindent(1), Tokens.get_reindent_regex())
     self.assertRegex(Tokens.reindent(9), Tokens.get_reindent_regex())
     self.assertRegex(Tokens.reindent(), Tokens.get_reindent_regex())