nsiqcppstyle icon indicating copy to clipboard operation
nsiqcppstyle copied to clipboard

Try reduce the duplication in rule callbacks

Open kunaltyagi opened this issue 2 years ago • 1 comments

In a future PR, let's see if we can reduce the duplication by:

    def RunPreprocessRule(self, lexer: Lexer, contextStack: ??) -> None:
        """ Run rules which runs in the preprecessor blocks """
        _RunLexerRules(self.preprocessRules, lexer, contextStack)

    def _RunLexerRules(self, rules: List[Callable], lexer,  *args, **kwargs) -> None
        for rule in rules:
            data = lexer.Backup()
            rule(lexer, *args, **kwargs)
            lexer.Restore(data)

Originally posted by @kunaltyagi in https://github.com/kunaltyagi/nsiqcppstyle/pull/35#discussion_r908757475

This could be done for just some of the callbacks

kunaltyagi avatar Jul 04 '22 13:07 kunaltyagi

https://github.com/kunaltyagi/nsiqcppstyle/pull/35#discussion_r908763042

kunaltyagi avatar Jul 04 '22 13:07 kunaltyagi