Merge pull request #1467 from ajaxorg/jshint

update jshint and coffee
This commit is contained in:
Ruben Daniels 2013-07-06 03:47:08 -07:00
commit 95e0f2fffd
12 changed files with 5860 additions and 2701 deletions

View file

@ -69,6 +69,12 @@ var ElasticTabstopsLite = require("ace/ext/elastic_tabstops_lite").ElasticTabsto
var IncrementalSearch = require("ace/incremental_search").IncrementalSearch;
var workerModule = require("ace/worker/worker_client");
if (location.href.indexOf("noworker" !== -1)) {
workerModule.WorkerClient = workerModule.UIWorkerClient;
}
/*********** create editor ***************************/
var container = document.getElementById("editor-container");

View file

@ -1,5 +1,5 @@
/** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.1.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* @license RequireJS 2.1.6 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
@ -12,7 +12,7 @@ var requirejs, require, define;
(function (global) {
var req, s, head, baseElement, dataMain, src,
interactiveScript, currentlyAddingScript, mainScript, subPath,
version = '2.1.5',
version = '2.1.6',
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
jsSuffixRegExp = /\.js$/,
@ -22,7 +22,7 @@ var requirejs, require, define;
hasOwn = op.hasOwnProperty,
ap = Array.prototype,
apsp = ap.splice,
isBrowser = !!(typeof window !== 'undefined' && navigator && document),
isBrowser = !!(typeof window !== 'undefined' && navigator && window.document),
isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
//PS3 indicates loaded and complete, but need to wait for complete
//specifically. Sequence is 'loading', 'loaded', execution,
@ -134,6 +134,10 @@ var requirejs, require, define;
return document.getElementsByTagName('script');
}
function defaultOnError(err) {
throw err;
}
//Allow getting a global that expressed in
//dot notation, like 'a.b.c'.
function getGlobal(value) {
@ -500,7 +504,12 @@ var requirejs, require, define;
fn(defined[id]);
}
} else {
getModule(depMap).on(name, fn);
mod = getModule(depMap);
if (mod.error && name === 'error') {
fn(mod.error);
} else {
mod.on(name, fn);
}
}
}
@ -571,7 +580,13 @@ var requirejs, require, define;
id: mod.map.id,
uri: mod.map.url,
config: function () {
return (config.config && getOwn(config.config, mod.map.id)) || {};
var c,
pkg = getOwn(config.pkgs, mod.map.id);
// For packages, only support config targeted
// at the main module.
c = pkg ? getOwn(config.config, mod.map.id + '/' + pkg.main) :
getOwn(config.config, mod.map.id);
return c || {};
},
exports: defined[mod.map.id]
});
@ -840,8 +855,13 @@ var requirejs, require, define;
if (this.depCount < 1 && !this.defined) {
if (isFunction(factory)) {
//If there is an error listener, favor passing
//to that instead of throwing an error.
if (this.events.error) {
//to that instead of throwing an error. However,
//only do it for define()'d modules. require
//errbacks should not be called for failures in
//their callbacks (#699). However if a global
//onError is set, use that.
if ((this.events.error && this.map.isDefine) ||
req.onError !== defaultOnError) {
try {
exports = context.execCb(id, factory, depExports, exports);
} catch (e) {
@ -869,8 +889,8 @@ var requirejs, require, define;
if (err) {
err.requireMap = this.map;
err.requireModules = [this.map.id];
err.requireType = 'define';
err.requireModules = this.map.isDefine ? [this.map.id] : null;
err.requireType = this.map.isDefine ? 'define' : 'require';
return onError((this.error = err));
}
@ -1093,7 +1113,7 @@ var requirejs, require, define;
}));
if (this.errback) {
on(depMap, 'error', this.errback);
on(depMap, 'error', bind(this, this.errback));
}
}
@ -1605,7 +1625,7 @@ var requirejs, require, define;
},
/**
* Executes a module callack function. Broken out as a separate function
* Executes a module callback function. Broken out as a separate function
* solely to allow the build system to sequence the files in the built
* layer in the right sequence.
*
@ -1643,7 +1663,7 @@ var requirejs, require, define;
onScriptError: function (evt) {
var data = getScriptData(evt);
if (!hasPathFallback(data.id)) {
return onError(makeError('scripterror', 'Script error', evt, [data.id]));
return onError(makeError('scripterror', 'Script error for: ' + data.id, evt, [data.id]));
}
}
};
@ -1772,9 +1792,7 @@ var requirejs, require, define;
* function. Intercept/override it if you want custom error handling.
* @param {Error} err the error object.
*/
req.onError = function (err) {
throw err;
};
req.onError = defaultOnError;
/**
* Does the request to load a module for the browser case.
@ -1906,24 +1924,31 @@ var requirejs, require, define;
//baseUrl, if it is not already set.
dataMain = script.getAttribute('data-main');
if (dataMain) {
//Preserve dataMain in case it is a path (i.e. contains '?')
mainScript = dataMain;
//Set final baseUrl if there is not already an explicit one.
if (!cfg.baseUrl) {
//Pull off the directory of data-main for use as the
//baseUrl.
src = dataMain.split('/');
src = mainScript.split('/');
mainScript = src.pop();
subPath = src.length ? src.join('/') + '/' : './';
cfg.baseUrl = subPath;
dataMain = mainScript;
}
//Strip off any trailing .js since dataMain is now
//Strip off any trailing .js since mainScript is now
//like a module name.
dataMain = dataMain.replace(jsSuffixRegExp, '');
mainScript = mainScript.replace(jsSuffixRegExp, '');
//If mainScript is still a path, fall back to dataMain
if (req.jsExtRegExp.test(mainScript)) {
mainScript = dataMain;
}
//Put the data-main script in the files to load.
cfg.deps = cfg.deps ? cfg.deps.concat(dataMain) : [dataMain];
cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript];
return true;
}

View file

@ -25,7 +25,7 @@
*/
define(function(require, exports, module) {
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var buildLocationData, extend, flatten, last, repeat, _ref;
@ -214,11 +214,11 @@ define(function(require, exports, module) {
};
exports.throwSyntaxError = function(message, location) {
var error, _ref1, _ref2;
if ((_ref1 = location.last_line) == null) {
var error;
if (location.last_line == null) {
location.last_line = location.first_line;
}
if ((_ref2 = location.last_column) == null) {
if (location.last_column == null) {
location.last_column = location.first_column;
}
error = new SyntaxError(message);
@ -226,11 +226,13 @@ define(function(require, exports, module) {
throw error;
};
exports.prettyErrorMessage = function(error, fileName, code, useColors) {
exports.prettyErrorMessage = function(error, filename, code, useColors) {
var codeLine, colorize, end, first_column, first_line, last_column, last_line, marker, message, start, _ref1;
if (!error.location) {
return error.stack || ("" + error);
}
filename = error.filename || filename;
code = error.code || code;
_ref1 = error.location, first_line = _ref1.first_line, first_column = _ref1.first_column, last_line = _ref1.last_line, last_column = _ref1.last_column;
codeLine = code.split('\n')[first_line];
start = first_column;
@ -243,7 +245,7 @@ define(function(require, exports, module) {
codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end)) + codeLine.slice(end);
marker = colorize(marker);
}
message = "" + fileName + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + error.message + "\n" + codeLine + "\n" + marker;
message = "" + filename + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + error.message + "\n" + codeLine + "\n" + marker;
return message;
};

View file

@ -25,14 +25,14 @@
*/
define(function(require, exports, module) {
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, starts, throwSyntaxError, _ref, _ref1,
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, repeat, starts, throwSyntaxError, _ref, _ref1,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
_ref = require('./rewriter'), Rewriter = _ref.Rewriter, INVERSES = _ref.INVERSES;
_ref1 = require('./helpers'), count = _ref1.count, starts = _ref1.starts, compact = _ref1.compact, last = _ref1.last, invertLiterate = _ref1.invertLiterate, locationDataToString = _ref1.locationDataToString, throwSyntaxError = _ref1.throwSyntaxError;
_ref1 = require('./helpers'), count = _ref1.count, starts = _ref1.starts, compact = _ref1.compact, last = _ref1.last, repeat = _ref1.repeat, invertLiterate = _ref1.invertLiterate, locationDataToString = _ref1.locationDataToString, throwSyntaxError = _ref1.throwSyntaxError;
exports.Lexer = Lexer = (function() {
function Lexer() {}
@ -182,10 +182,10 @@ define(function(require, exports, module) {
}
lexedLength = number.length;
if (octalLiteral = /^0o([0-7]+)/.exec(number)) {
number = '0x' + (parseInt(octalLiteral[1], 8)).toString(16);
number = '0x' + parseInt(octalLiteral[1], 8).toString(16);
}
if (binaryLiteral = /^0b([01]+)/.exec(number)) {
number = '0x' + (parseInt(binaryLiteral[1], 2)).toString(16);
number = '0x' + parseInt(binaryLiteral[1], 2).toString(16);
}
this.token('NUMBER', number, 0, lexedLength);
return lexedLength;
@ -255,7 +255,7 @@ define(function(require, exports, module) {
if (here) {
this.token('HERECOMMENT', this.sanitizeHeredoc(here, {
herecomment: true,
indent: Array(this.indent + 1).join(' ')
indent: repeat(' ', this.indent)
}), 0, comment.length);
}
return comment.length;
@ -737,7 +737,7 @@ define(function(require, exports, module) {
column = this.chunkColumn;
if (lineCount > 0) {
lines = string.split('\n');
column = (last(lines)).length;
column = last(lines).length;
} else {
column += string.length;
}
@ -903,9 +903,9 @@ define(function(require, exports, module) {
BOOL = ['TRUE', 'FALSE'];
NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '++', '--', ']'];
NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '++', '--'];
NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING');
NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING', ']');
CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER'];

View file

@ -25,7 +25,7 @@
*/
define(function(require, exports, module) {
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, CodeFragment, Comment, Existence, Extends, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, last, locationDataToString, merge, multident, some, starts, throwSyntaxError, unfoldSoak, utility, _ref, _ref1, _ref2, _ref3,
__hasProp = {}.hasOwnProperty,
@ -71,7 +71,7 @@ define(function(require, exports, module) {
}
CodeFragment.prototype.toString = function() {
return "" + this.code + [this.locationData ? ": " + locationDataToString(this.locationData) : void 0];
return "" + this.code + (this.locationData ? ": " + locationDataToString(this.locationData) : '');
};
return CodeFragment;
@ -503,6 +503,8 @@ define(function(require, exports, module) {
fragments.push(this.makeCode(scope.assignedVariables().join(",\n" + (this.tab + TAB))));
}
fragments.push(this.makeCode(";\n" + (this.spaced ? '\n' : '')));
} else if (fragments.length && post.length) {
fragments.push(this.makeCode("\n"));
}
}
return fragments.concat(post);
@ -662,7 +664,7 @@ define(function(require, exports, module) {
Return.prototype.compileNode = function(o) {
var answer;
answer = [];
answer.push(this.makeCode(this.tab + ("return" + [this.expression ? " " : void 0])));
answer.push(this.makeCode(this.tab + ("return" + (this.expression ? " " : ""))));
if (this.expression) {
answer = answer.concat(this.expression.compileToFragments(o, LEVEL_PAREN));
}
@ -801,17 +803,16 @@ define(function(require, exports, module) {
};
Value.prototype.unfoldSoak = function(o) {
var _ref4,
_this = this;
return (_ref4 = this.unfoldedSoak) != null ? _ref4 : this.unfoldedSoak = (function() {
var fst, i, ifn, prop, ref, snd, _i, _len, _ref5, _ref6;
var _this = this;
return this.unfoldedSoak != null ? this.unfoldedSoak : this.unfoldedSoak = (function() {
var fst, i, ifn, prop, ref, snd, _i, _len, _ref4, _ref5;
if (ifn = _this.base.unfoldSoak(o)) {
(_ref5 = ifn.body.properties).push.apply(_ref5, _this.properties);
(_ref4 = ifn.body.properties).push.apply(_ref4, _this.properties);
return ifn;
}
_ref6 = _this.properties;
for (i = _i = 0, _len = _ref6.length; _i < _len; i = ++_i) {
prop = _ref6[i];
_ref5 = _this.properties;
for (i = _i = 0, _len = _ref5.length; _i < _len; i = ++_i) {
prop = _ref5[i];
if (!prop.soak) {
continue;
}
@ -1336,7 +1337,7 @@ define(function(require, exports, module) {
}
answer.push.apply(answer, fragments);
}
if ((fragmentsToText(answer)).indexOf('\n') >= 0) {
if (fragmentsToText(answer).indexOf('\n') >= 0) {
answer.unshift(this.makeCode("[\n" + o.indent));
answer.push(this.makeCode("\n" + this.tab + "]"));
} else {
@ -2334,7 +2335,7 @@ define(function(require, exports, module) {
Op.prototype.compileExistence = function(o) {
var fst, ref;
if (this.first.isComplex()) {
if (!o.isExistentialEquals && this.first.isComplex()) {
ref = new Literal(o.scope.freeVariable('ref'));
fst = new Parens(new Assign(ref, this.first));
} else {
@ -2438,7 +2439,7 @@ define(function(require, exports, module) {
var fragments, ref, sub, _ref4;
_ref4 = this.object.cache(o, LEVEL_LIST), sub = _ref4[0], ref = _ref4[1];
fragments = [].concat(this.makeCode(utility('indexOf') + ".call("), this.array.compileToFragments(o, LEVEL_LIST), this.makeCode(", "), ref, this.makeCode(") " + (this.negated ? '< 0' : '>= 0')));
if ((fragmentsToText(sub)) === (fragmentsToText(ref))) {
if (fragmentsToText(sub) === fragmentsToText(ref)) {
return fragments;
}
fragments = sub.concat(this.makeCode(', '), fragments);
@ -2610,6 +2611,9 @@ define(function(require, exports, module) {
if (this.range && this.pattern) {
this.name.error('cannot pattern match over range loops');
}
if (this.own && !this.object) {
this.index.error('cannot use own with for-in');
}
this.returns = false;
}

View file

@ -25,9 +25,9 @@
*/
define(function(require, exports, module) {
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_BLOCK, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref,
var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__slice = [].slice;
@ -300,7 +300,7 @@ define(function(require, exports, module) {
startImplicitCall(i + 1);
return forward(2);
}
if (this.matchTags(i, IMPLICIT_FUNC, 'INDENT', null, ':') && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) {
if (__indexOf.call(IMPLICIT_FUNC, tag) >= 0 && this.matchTags(i + 1, 'INDENT', null, ':') && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) {
startImplicitCall(i + 1);
stack.push(['INDENT', i + 2]);
return forward(3);
@ -385,8 +385,8 @@ define(function(require, exports, module) {
var action, condition, indent, outdent, starter;
starter = indent = outdent = null;
condition = function(token, i) {
var _ref;
return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && (starter !== 'IF' && starter !== 'THEN'));
var _ref, _ref1;
return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && starter !== 'THEN') && !(((_ref1 = token[0]) === 'CATCH' || _ref1 === 'FINALLY') && (starter === '->' || starter === '=>'));
};
action = function(token, i) {
return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent);
@ -501,8 +501,6 @@ define(function(require, exports, module) {
IMPLICIT_UNSPACED_CALL = ['+', '-'];
IMPLICIT_BLOCK = ['->', '=>', '{', '[', ','];
IMPLICIT_END = ['POST_IF', 'FOR', 'WHILE', 'UNTIL', 'WHEN', 'BY', 'LOOP', 'TERMINATOR'];
SINGLE_LINERS = ['ELSE', '->', '=>', 'TRY', 'FINALLY', 'THEN'];

View file

@ -25,7 +25,7 @@
*/
define(function(require, exports, module) {
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
var Scope, extend, last, _ref;

File diff suppressed because it is too large Load diff

View file

@ -74,7 +74,7 @@ module.exports = {
assert.equal(error.text, "Unclosed string.");
assert.equal(error.type, "error");
assert.equal(error.row, 0);
assert.equal(error.column, 0);
assert.equal(error.column, 2);
},
"test another invalid string": function() {
@ -86,7 +86,7 @@ module.exports = {
assert.equal(error.text, "Unclosed string.");
assert.equal(error.type, "error");
assert.equal(error.row, 0);
assert.equal(error.column, 3);
assert.equal(error.column, 4);
}
};

View file

@ -1,20 +1,42 @@
define(function(require, exports, module) {
/*global exports:true require:true define:true console:true */
/*global exports:true module:true require:true define:true global:true */
(function (root, name, factory) {
'use strict';
if (typeof exports !== 'undefined') {
factory(exports);
} else if (typeof define === 'function' && define.amd) {
var freeExports = typeof exports === 'object' && exports
// While CommonJS defines `module` as an object, component define it as a
// function
, freeModule = (typeof module === 'object' || typeof module === 'function') &&
module && module.exports === freeExports && module;
// Detect free variable `global`, from Node.js or Browserified code, and use
// it as `root`
var freeGlobal = typeof global === 'object' && global;
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)
root = freeGlobal;
// Some AMD build optimizers, like r.js, check for specific condition
// patterns like the following:
if (typeof define === 'function' && define.amd) {
define(['exports'], factory);
} else {
}
// check for `exports` after `define` in case a build optimizer adds an
// `exports` object
else if (freeExports && !freeExports.nodeType) {
// in Node.js or RingoJS v0.8.0+
if (freeModule) factory(freeModule.exports);
// in Narwhal or RingoJS v0.7.0-
else factory(freeExports);
}
// in a browser or Rhino
else {
factory((root[name] = {}));
}
}(this, 'luaparse', function (exports) {
'use strict';
exports.version = '0.0.11';
exports.version = '0.0.14';
var input, options, length;
@ -306,10 +328,9 @@ define(function(require, exports, module) {
var slice = Array.prototype.slice
, toString = Object.prototype.toString
// Simple indexOf implementation which only provides what's required.
, indexOf = Array.prototype.indexOf || function indexOf(element) {
for (var i = 0, length = this.length; i < length; i++) {
if (this[i] === element) return i;
, indexOf = function indexOf(array, element) {
for (var i = 0, length = array.length; i < length; i++) {
if (array[i] === element) return i;
}
return -1;
};
@ -446,7 +467,7 @@ define(function(require, exports, module) {
// containing its value and as well as its position in the input string (this
// is always enabled to provide proper debug messages).
//
// `readToken()` starts lexing and returns the following token in the stream.
// `lex()` starts lexing and returns the following token in the stream.
var index
, token
@ -456,7 +477,9 @@ define(function(require, exports, module) {
, line
, lineStart;
function readToken() {
exports.lex = lex;
function lex() {
skipWhiteSpace();
// Skip comments beginning with --
@ -887,7 +910,6 @@ define(function(require, exports, module) {
// Once the delimiter is found, iterate through the depth count and see
// if it matches.
if (']' === character) {
terminator = true;
for (var i = 0; i < level; i++) {
@ -914,7 +936,7 @@ define(function(require, exports, module) {
function next() {
token = lookahead;
lookahead = readToken();
lookahead = lex();
}
// Consume a token if its value matches. Once consumed or not, return the
@ -1045,7 +1067,7 @@ define(function(require, exports, module) {
// Add identifier name to the current scope if it doesnt already exist.
function scopeIdentifierName(name) {
if (-1 !== indexOf.call(scopes[scopeDepth], name)) return;
if (-1 !== indexOf(scopes[scopeDepth], name)) return;
scopes[scopeDepth].push(name);
}
@ -1058,7 +1080,7 @@ define(function(require, exports, module) {
// Attach scope information to node. If the node is global, store it in the
// globals array so we can return the information to the user.
function attachScope(node, isLocal) {
if (!isLocal && -1 === indexOf.call(globalNames, node.name)) {
if (!isLocal && -1 === indexOf(globalNames, node.name)) {
globalNames.push(node.name);
globals.push(node);
}
@ -1068,7 +1090,7 @@ define(function(require, exports, module) {
// Is the identifier name available in this scope.
function scopeHasName(name) {
return (-1 !== indexOf.call(scopes[scopeDepth], name));
return (-1 !== indexOf(scopes[scopeDepth], name));
}
@ -1285,9 +1307,9 @@ define(function(require, exports, module) {
expect('end');
return ast.forNumericStatement(variable, start, end, step, body);
}
// If not, it's a Generic For Statement
} else {
else {
// The namelist can contain one or more identifiers.
var variables = [variable];
while (consume(',')) {
@ -1446,8 +1468,9 @@ define(function(require, exports, module) {
if (consume(',')) continue;
else if (consume(')')) break;
}
// No arguments are allowed after a vararg.
} else if (VarargLiteral === token.type) {
else if (VarargLiteral === token.type) {
parameters.push(parsePrimaryExpression());
expect(')');
break;
@ -1729,7 +1752,6 @@ define(function(require, exports, module) {
var table = parseTableConstructor();
return ast.tableCallExpression(base, table);
}
} else if (StringLiteral === token.type) {
return ast.stringCallExpression(base, parsePrimaryExpression());
}
@ -1815,7 +1837,7 @@ define(function(require, exports, module) {
length = input.length;
// Initialize with a lookahead token.
lookahead = readToken();
lookahead = lex();
var chunk = parseChunk();
if (options.comments) chunk.comments = comments;
@ -1823,9 +1845,6 @@ define(function(require, exports, module) {
return chunk;
}
// Expose the lex function
exports.lex = readToken;
}));
/* vim: set sw=2 ts=2 et tw=79 : */

View file

@ -116,6 +116,7 @@ var WorkerClient = function(topLevelNamespaces, mod, classname) {
this.terminate = function() {
this._emit("terminate", {});
this.deltaQueue = null;
this.$worker.terminate();
this.$worker = null;
this.$doc.removeEventListener("change", this.changeListener);

View file

@ -1,21 +1,11 @@
var https = require("https")
, http = require("http")
, url = require("url")
, fs = require("fs")
, fs = require("fs");
var rootDir = __dirname + "/../lib/ace/"
var rootDir = __dirname + "/../lib/ace/";
var deps = [{
path: "mode/javascript/jshint.js",
url: "https://raw.github.com/jshint/jshint/master/src/stable/jshint.js",
needsFixup: true,
postProcess: function(t) {
return t.replace(
/"Expected a conditional expression and instead saw an assignment."/g,
'"Assignment in conditional expression"'
);
}
}, {
path: "mode/css/csslint.js",
url: "https://raw.github.com/stubbornella/csslint/master/release/csslint-node.js",
needsFixup: true
@ -25,52 +15,52 @@ var deps = [{
needsFixup: false
}, {
path: "mode/lua/luaparse.js",
url: "https://raw.github.com/oxyc/luaparse/master/lib/luaparse.js",
url: "https://raw.github.com/oxyc/luaparse/master/luaparse.js",
needsFixup: true
}]
}];
var download = function(href, callback) {
var options = url.parse(href);
protocol = options.protocol === "https:" ? https : http;
console.log("connecting to " + options.host + " " + options.path)
var request = protocol.get(options, function(res) {
var data = ""
res.setEncoding("utf-8")
var protocol = options.protocol === "https:" ? https : http;
console.log("connecting to " + options.host + " " + options.path);
protocol.get(options, function(res) {
var data = "";
res.setEncoding("utf-8");
res.on("data", function(chunk){
data += chunk
})
data += chunk;
});
res.on("end", function(){
callback(data)
})
})
}
callback(data);
});
});
};
var getDep = function(dep) {
download(dep.url, function(data) {
if (dep.needsFixup)
data = "define(function(require, exports, module) {\n"
+ data
+ "\n});"
+ "\n});";
if (dep.postProcess)
data = dep.postProcess(data)
data = dep.postProcess(data);
fs.writeFile(rootDir + dep.path, data, "utf-8", function(err){
if (err) throw err
console.log("File " + dep.path + " saved.")
})
})
}
if (err) throw err;
console.log("File " + dep.path + " saved.");
});
});
};
deps.forEach(getDep)
deps.forEach(getDep);
// coffee-script
void function(){
var rootHref = "https://raw.github.com/jashkenas/coffee-script/master/"
var path = "mode/coffee/"
var rootHref = "https://raw.github.com/jashkenas/coffee-script/master/";
var path = "mode/coffee/";
var subDir = "lib/coffee-script/"
var subDir = "lib/coffee-script/";
var deps = [
"helpers.js",
"lexer.js",
@ -83,50 +73,110 @@ void function(){
name: x,
href: rootHref + subDir + x,
path: rootDir + path + x
}
};
});
deps.push({name:"LICENSE", href: rootHref + "LICENSE"})
deps.push({name:"LICENSE", href: rootHref + "LICENSE"});
var downloads = {}, counter = 0
var downloads = {}, counter = 0;
deps.forEach(function(x) {
download(x.href, function(data) {
counter++
downloads[x.name] = data
counter++;
downloads[x.name] = data;
if (counter == deps.length)
allDone()
})
})
allDone();
});
});
function allDone() {
deps.pop()
var license = downloads["LICENSE"].split('\n')
license = "/**\n * " + license.join("\n * ") + "\n */"
deps.pop();
var license = downloads.LICENSE.split('\n');
license = "/**\n * " + license.join("\n * ") + "\n */";
deps.forEach(function(x) {
var data = downloads[x.name]
console.log(x.name)
console.log(!data)
var data = downloads[x.name];
console.log(x.name);
console.log(!data);
if (!data)
return
return;
if (x.name == "parser.js") {
data = data.replace("var parser = (function(){", "")
.replace(/\nreturn (new Parser)[\s\S]*$/, "\n\nmodule.exports = $1;\n\n")
.replace(/\nreturn (new Parser)[\s\S]*$/, "\n\nmodule.exports = $1;\n\n");
} else {
data = data.replace("(function() {", "")
.replace(/}\).call\(this\);\s*$/, "")
.replace(/\}\).call\(this\);\s*$/, "");
}
data = license
+ "\n\n"
+ "define(function(require, exports, module) {\n"
+ data
+ "\n});"
+ "\n});";
fs.writeFile(x.path, data, "utf-8", function(err){
if (err) throw err
console.log("File " + x.name + " saved.")
console.warn("mode/coffee/coffee-script file needs to updated manually")
console.warn("mode/coffee/parser.js: parseError function needs to be modified")
})
})
if (err) throw err;
console.log("File " + x.name + " saved.");
console.warn("mode/coffee/coffee-script file needs to updated manually");
console.warn("mode/coffee/parser.js: parseError function needs to be modified");
});
});
}
}()
}();
var spawn = require("child_process").spawn;
var run = function(cmd, cb) {
var proc = spawn("cmd", ["/c " + cmd]);
proc.stderr.setEncoding("utf8");
proc.stderr.on('data', function (data) {
// console.error(data);
});
proc.stdout.setEncoding("utf8");
proc.stdout.on('data', function (data) {
//console.log(data);
});
proc.on('exit', done);
proc.on('close', done);
function done(code) {
if (code !== 0) {
console.error(cmd + '::: process exited with code :::' + code);
}
cb()
}
}
function unquote(str) {
return str.replace(/\\(.)/g, function(x, a) {
return a == "n" ? "\n"
: a == "t" ? "\t"
: a == "r" ? "\r"
: a
});
}
run("npm install jshint", function() {
var jshintDist = fs.readFileSync("node_modules/jshint/dist/jshint.js", "utf8");
jshintDist = jshintDist.replace(
/(require.define.*)Function\(\[([^\]]*?)\],\s*"(.*)"\s*\)/g,
function(a, def, args, content) {
return def + "function("+args.replace(/["']/g, "") + ") {\n"
+ unquote(content)
+ "\n}";
}
);
jshintDist = jshintDist.replace(
/"Expected a conditional expression and instead saw an assignment."/g,
'"Assignment in conditional expression"'
);
jshintDist = 'define(function() {\n'
+ jshintDist + '\n'
+ 'var jsHint = require("/src/stable/jshint.js");\n'
+ 'return function(require, exports, module) {module.exports = jsHint;}\n'
+'}())';
fs.writeFileSync(rootDir + "mode/javascript/jshint.js", jshintDist);
});