Skip to content

Commit

Permalink
allowing the analyzer to be used via the console, also will check
Browse files Browse the repository at this point in the history
initializer twice


Former-commit-id: c78084c3d388e28e46205c507f4bd9d277009cb5 [formerly 5e4a73a8b0e1213d8ef6aee64e41b78b0478cf33]
Former-commit-id: 71b66960c9e2313ed5fa0a4509bc02dac6e1b48c
  • Loading branch information
andrewplummer committed Mar 22, 2012
1 parent d3bbb01 commit 3205202
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions lib/analyzer.js
Expand Up @@ -1836,15 +1836,21 @@ var SugarUnderscoreMethods = [
message = message.replace(/\t/g, TS);
if(stack) {
files = stack.match(new RegExp(URL_MATCH.source, 'g'));
var isConsole = stack.match(/console|Object\._evaluateOn/);
file = files[stackLevel];
if(!file || file.match(new RegExp('(' + baseExcludePackages.concat(SUGAR_ANALYZER_EXCLUDES).join('|') + ')[^\/]*\.js'))) {
if(!isConsole && (!file || file.match(new RegExp('(' + baseExcludePackages.concat(SUGAR_ANALYZER_EXCLUDES).join('|') + ')[^\/]*\.js')))) {
return;
}
match = file.match(URL_MATCH);
if(!skipMeta) {
message += '\n\n----------- File: ' + match[1] + ' ---------';
if(match[2]) message += '\n----------- Line: ' + match[2] + ' --------------';
if(match[3]) message += '\n----------- Char: ' + match[3] + ' --------------';
message += '\n\n';
if(isConsole) {
message += '----------- File: Console ---------';
} else {
match = file.match(URL_MATCH);
message += '----------- File: ' + match[1] + ' ---------';
if(match[2]) message += '\n----------- Line: ' + match[2] + ' --------------';
if(match[3]) message += '\n----------- Char: ' + match[3] + ' --------------';
}
if(docs){
message += '\n----------- Docs: http://sugarjs.com/api/' + docs + ' ---------';
}
Expand Down Expand Up @@ -1956,6 +1962,10 @@ var SugarUnderscoreMethods = [
welcome += "As your program calls various methods, it will warn you about Prototype's incompatibilities with Sugar, and give\n" +
'suggestions about how to refactor. You can run this before refactoring to get a general idea about what needs to change\n' +
'or you can flip out Prototype for Sugar, let breakages happen, and fix as you go!';
} else {
// No libs found, try initializing again after page load...
window.addEventListener('load', initialize);
return;
}
welcome += '\n\nAnalyzer options (set these as globals):\n\n' +
'SUGAR_ANALYZER_UNIQUE_MESSAGES = true/false | Display each message only once (default is true)\n' +
Expand Down
2 changes: 1 addition & 1 deletion unit_tests/environments/prototype/analyzer.html
Expand Up @@ -4,8 +4,8 @@
<title></title>
</head>
<body>
<script src="prototype-1.7.js" type="text/javascript"></script>
<script src="../../../lib/analyzer.js" type="text/javascript"></script>
<script src="prototype-1.7.js" type="text/javascript"></script>
<script src="../../../lib/core.js" type="text/javascript"></script>
<script type="text/javascript">

Expand Down
2 changes: 1 addition & 1 deletion unit_tests/environments/underscore/analyzer.html
Expand Up @@ -4,8 +4,8 @@
<title></title>
</head>
<body>
<script src="underscore.js" type="text/javascript"></script>
<script src="../../../lib/analyzer.js" type="text/javascript"></script>
<script src="underscore.js" type="text/javascript"></script>
<script type="text/javascript">

_.map(['a','b','c'], function(a){ return a.length; });
Expand Down

0 comments on commit 3205202

Please sign in to comment.