• 
      

    Add formal handling of file pattern matching for tools.

    Review Request #11531 — Created March 17, 2021 and submitted — Latest diff uploaded

    Information

    ReviewBot
    release-3.0.x

    Reviewers

    Most tools only operate on certain file types, and all tools had to
    implement their own logic for this. This meant that some were checking
    if a file ends with a pattern, some were splitting file extensions, and
    not all could agree on case-sensitive vs. case-insensitive matching.

    In an attempt to standardize this, a new
    BaseTool.get_can_handle_file() method has been added, which defaults
    to checking a new BaseTool.file_patterns for glob patterns.

    Comparison is case-insensitive. This is the right default behavior, but
    subclasses can always override get_can_handle_file() to perform their
    own logic, or continue just checking directly in handle_file() as they
    have in the past.

    We can extend this further down the road, if needed, to support other
    entries in file_patterns, such as compiled regex objects, to extend
    capabilities in a consistent way.

    As of this change, no tool uses this new functionality, but changes will
    be made to add support over time.

    Unit tests passed.

    Did some light testing with other in-progress tool work.

    Commits

    Files