adobe/brackets — pull request #1055 by njx (2012-06-15 01:57:19+00:00)
Title: Use CodeMirror tokenizer to find the end brace of a function

@jason-sanjose (@redmunds might also want to take a look)

This is modeled on the CSSUtils code, but it's a little different:

* The CSSUtils code pre-splits the entire file before walking through it. In the JS end brace scan case, we're starting with a chunk of text, and I didn't want to split the whole text needlessly, so we just split off a line at a time.
* The code to advance tokens is a lot simpler since I'm just relying on the token type returned by the CodeMirror mode (the CSSUtils code does work to parse comments, etc.--though it's possible that that code could be simplified as well).

It might make sense in the future to try to unify the two sets of code, but it didn't seem worth it given how simple the brace-finding code is. If we do end up trying to use the tokenizer to actually find functions, it might be better to refactor at that point.