• Greg Spencer's avatar
    Rewrite the analyze-sample-code script to also analyze snippets (#23893) · 202b045b
    Greg Spencer authored
    This rewrites the sample code analysis script to be a little less of a hack (but still not pretty), and to handle snippets as well.
    
    It also changes the semantics of how sample code is handled: the namespace for the sample code is now limited to the file that it appears in, so some additional "Examples can assume:" blocks were added. The upside of this is that there will be far fewer name collisions.
    
    I fixed the output too: no longer will you get 4000 lines of numbered output with the error at the top and have to grep for the actual problem. It gives the filename and line number of the original location of the code (in the comment in the tree), and prints out the source code on the line that caused the problem along with the error.
    
    For snippets, it prints out the location of the start of the snippet and the source code line that causes the problem. It can't print out the original line, because snippets get formatted when they are written, so the line might not be in the same place.
    202b045b
analyze-sample-code_test.dart 1.16 KB