Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mismatched parentheses: a quick way to find them?

I just rearranged a very large JavaScript file. I now get "Unexpected end of input." Somewhere in those hundred of functions, one has lost (or gained) a bracket. What's the quickest way to find it?

like image 234
Chris Tolworthy Avatar asked Sep 29 '11 13:09

Chris Tolworthy


3 Answers

You could try to parse your file with lint: http://www.javascriptlint.com/online_lint.php

If you have problems with the size of the file try to split it into smaller ones...

like image 64
mamoo Avatar answered Oct 18 '22 19:10

mamoo


A good trick when missing a brace in eclipse is to go to the final brace in the source module and double-click it. That will highlight all the way back to what it THINKS is the matching open brace. Where it highlights back to is invariably the START of where the problem is, so skip that open brace and go to the next one and start double-clicking open braces and you will usually find where the brace is missing pretty quickly. I learnt that the hard way with a source code file of 20,000+ lines of code and getting hundreds of errors without the slightest indication as where the real problem was as the errors started appearing thousands of lines earlier in the code.

like image 36
CESDewar Avatar answered Oct 18 '22 18:10

CESDewar


Re-format the file using something that indents well. Look for something that's too far to the left.

like image 44
Dave Newton Avatar answered Oct 18 '22 19:10

Dave Newton