Initial esprima annotator

This commit is contained in:
benedikt willi 2014-04-15 16:06:27 +02:00
parent e2fe6d009c
commit 4c544420f8
690 changed files with 50741 additions and 50476 deletions

242
annotator.js Normal file
View file

@ -0,0 +1,242 @@
/*
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define */
define(['exports', 'thirdparty/esprima-master/esprima', 'thirdparty/lodash-amd/modern/main'], function (exports, esprima, _) {
/**
* From esmorph.js:
* Traverse a AST and run a visitor function on each node
* @param {type} object to run visitor on
* @param {type} visitor The function that should be run on visitor
* @param {type} path Description
*/
function traverse(object, visitor, path) {
var key, child;
if (typeof path === 'undefined') {
path = [];
}
visitor.call(null, object, path);
for (key in object) {
if (object.hasOwnProperty(key)) {
child = object[key];
if (typeof child === 'object' && child !== null) {
traverse(child, visitor, [object].concat(path));
}
}
}
}
/**
* From esmorph.js
* Find a return statement within a function which is the exit for
* the said function. If there is no such explicit exit, a null
* will be returned instead.
* @param {object} functionNode The node that should be inspected for a return statement
*/
function findExit(functionNode) {
var exit = null;
function isFunction(node) {
return node.type && node.range &&
(node.type === esprima.Syntax.FunctionDeclaration ||
node.type === esprima.Syntax.FunctionExpression);
}
traverse(functionNode, function (node, path) {
var i, parent;
if (node.type === esprima.Syntax.ReturnStatement) {
for (i = 0; i < path.length; ++i) {
parent = path[i];
if (isFunction(parent)) {
if (parent.range === functionNode.range) {
exit = node;
}
break;
}
}
}
});
return exit;
}
/**
* Add node.loc.start.column spaces to get the same indentation as the node
* @param {type} node The node you want to get the indentation for
*/
function getIndentation(node) {
return Array(node.loc.start.column).join(' ');
}
/**
* Build the type specific jsDoc parts
* @param {node} node The node you want to build the jsDoc for
* @param {string} indentation The indentation the jsDoc string should get
* @return {string} Returns type specific jsDocs part
*/
function buildJsDoc(node, indentation) {
var jsDoc = "";
switch (node.type) {
case esprima.Syntax.Literal:
jsDoc += "\n" + indentation + " * @type {" + typeof node.value + "}";
break;
case esprima.Syntax.FunctionDeclaration:
case esprima.Syntax.FunctionExpression:
jsDoc += "\n" + indentation + " * @type {function}";
_.forEach(node.params, function (v, key) {
jsDoc += getParamString(v, indentation);
});
jsDoc += getReturnString(node, indentation);
break;
case esprima.Syntax.ObjectExpression:
jsDoc += "\n" + indentation + " * @type {object}";
break;
default:
break;
}
return jsDoc;
}
/**
* Returns the jsDoc string representation for a parameter of a function
* @param {type} param The parameter you want to get the jsDoc representation for
* @return {type} Description
*/
function getParamString(param, indentation) {
return "\n" + indentation + " * @param {Type} " + param.name + " Description";
}
/**
* Try to find a return statement to a function, if it finds one, return the corresponding jsDoc string
* @param {type} node The node from which you want to find the return value.
* @return {type} Description
*/
function getReturnString(node, indentation) {
var returnStatement = findExit(node);
//Todo: find the type of the returned argument, as it is, it's always an object
return (_.isObject(returnStatement) ? "\n" + indentation + " * @return {" + typeof returnStatement.argument + "} Description" : "");
}
/**
* Annotate ExpressionStatement
* @param {type} node The ast node you want to annotate
* @return {type} Description
*/
exports.ExpressionStatement = function (node) {
var indentation = getIndentation(node),
jsDoc = "/**";
jsDoc += "\n" + indentation + " * Description";
switch (node.expression.type) {
case esprima.Syntax.Literal:
case esprima.Syntax.CallExpression:
return;
case esprima.Syntax.AssignmentExpression:
if (node.expression.left.property.name === node.expression.left.property.name.toUpperCase()) jsDoc += "\n" + indentation + " * @const";
jsDoc += buildJsDoc(node.expression.right, indentation);
}
jsDoc += "\n" + indentation + " */\n" + indentation;
return jsDoc;
};
/**
* Annotate VariableDeclaration
* @param {type} node Description
* @return {type} Description
*/
exports.VariableDeclaration = function (node) {
// Add node.loc.start.column spaces to get the same indentation as the node
var indentation = getIndentation(node),
jsDoc = "/**";
jsDoc += "\n" + indentation + " * Description";
// Add each declaration
_.forEach(node.declarations, function (value, key) {
jsDoc += "\n" + indentation + " * @name " + value.id.name; //Todo: remove this line, as jsDoc will check the name at generation time
// check if variable is uppercase, if so, it's a constant
if (value.id.name === value.id.name.toUpperCase()) jsDoc += "\n" + indentation + " * @const";
// check the type with which the variable is initialized
if (value.init !== null) {
jsDoc += buildJsDoc(value.init, indentation);
}
// check if first character is an underline, if so it's a private variable
if (value.id.name.charAt(0) === '_') jsDoc += "\n" + indentation + " * @private";
});
jsDoc += "\n" + indentation + " */\n" + indentation;
return jsDoc;
};
/**
* Annotate FunctionDeclaration
* @param {type} node Description
*/
exports.FunctionDeclaration = function (node) {
var indentation = getIndentation(node),
jsDoc = "/**";
jsDoc += "\n" + indentation + " * Description";
jsDoc += buildJsDoc(node, indentation);
jsDoc += "\n" + indentation + " */\n" + indentation;
return jsDoc;
};
/**
* Annotate Properties
* @param {type} node Description
* @return {type} Description
*/
exports.Property = function (node) {
var indentation = getIndentation(node),
jsDoc = "/**";
jsDoc += "\n" + indentation + " * Description";
jsDoc += "\n" + indentation + " * @name " + node.key.name;
// check if variable is uppercase, if so, it's a constant
if (node.key.name === node.key.name.toUpperCase()) jsDoc += "\n" + indentation + " * @const";
// check the type with which the variable is initialized
if (node.value !== null) {
jsDoc += buildJsDoc(node.value, indentation);
}
// check if first character is an underline, if so it's a private variable
if (node.key.name.charAt(0) === '_') jsDoc += "\n" + indentation + " * @private";
jsDoc += "\n" + indentation + " */\n" + indentation;
return jsDoc;
};
});

172
main.js
View file

@ -34,135 +34,113 @@ define(function (require, exports, module) {
EditorManager = brackets.getModule("editor/EditorManager"),
KeyBindingManager = brackets.getModule("command/KeyBindingManager"),
Menus = brackets.getModule("command/Menus"),
Acorn_loose = require("thirdparty/acorn/acorn_loose"),
Walker = require("thirdparty/acorn/util/walk");
esprima = require("thirdparty/esprima-master/esprima"),
estraverse = require("thirdparty/estraverse-master/estraverse"),
annotator = require("annotator"),
_ = require("thirdparty/lodash-amd/modern/main");
var EMPTY_MSG = "No function found";
var DUPLICATE_MSG = "There is already some JSDoc for the next annotatable";
var COMMAND_ID = "annotate.annotate";
var MENU_NAME = "Annotate function";
// Global editor instance
var _editor = {};
var _output = {};
/**
* Create a jsdoc annotation and prepend it in the active document
*/
*/
var annotate = function () {
// Get current active editor
_editor = EditorManager.getCurrentFullEditor();
//Get cursor position and set it to the beginning of the line
var pos = _editor.getCursorPos();
pos.ch = 0;
//pos.ch = 0;
// Get the text from the start of the document to the current cursor position and count it's length'
var txtTo = _editor._codeMirror.getRange({
var txtTo = _editor.document.getRange({
line: 0,
ch: 0
}, pos);
var cursorPosition = txtTo.length;
// Get full txt
var fullTxt = _editor._codeMirror.getValue();
var fullTxt = _editor.document.getText();
// Parse text
var acornTxtFull = Acorn_loose.parse_dammit(fullTxt, {
locations: true
// get the ast
var ast = esprima.parse(fullTxt, {
tolerant: true,
attachComment: true,
loc: true,
range: true
});
// Find next function
var found = new Walker.findNodeAfter(acornTxtFull, cursorPosition, "Function");
var isAnnotated = false;
var lastAnnotatable;
if (found) {
// There was a result, so build jsdoc
_output = {};
_output.loc = found.node.loc;
_output.prefix = "";
_output.name = found.node.id ? found.node.id.name : null;
_output.params = [];
_output.returnValue = undefined;
// Add parameters to the _output object
found.node.params.forEach(function (param) {
_output.params.push(param.name);
});
// Find and add return value
var foundReturnValue = new Walker.findNodeAfter(found.node, 0, "ReturnStatement");
_output.returnValue = foundReturnValue.node ? foundReturnValue.node.argument.name : undefined;
// set prefix (find first none whitespace character)
var codeLine = _editor._codeMirror.getLine(_output.loc.start.line - 1);
_output.prefix = codeLine.substr(0, codeLine.length - codeLine.trimLeft().length).replace(/[^\s\n]/g, ' ');
// build annotation string
var _outputString = _getJSDocString(_output);
// insertJsdoc string into editor
_insertJSDocString(_outputString, _output.loc);
} else {
// No function definition found
window.alert(EMPTY_MSG);
}
};
/**
* Get a functions name
*/
var _getName = function () {
//Todo
};
/**
* Get a functions return value
*/
var _getReturnValue = function () {
//Todo
};
/**
* Build the string representation of the
* @param {object} jsdoc object containing jsdoc properties
* @returns {string} annotation as a string
*/
var _getJSDocString = function (jsdoc) {
var jsdocString = jsdoc.prefix + "/**\n";
if (jsdoc.name && jsdoc.name.charAt(0) === "_") {
jsdocString += jsdoc.prefix + " * @private \n";
}
// Add description
jsdocString += jsdoc.prefix + " * Description \n";
jsdoc.params.forEach(function (param) {
jsdocString += jsdoc.prefix + " * @param {type} " + param + " Description \n";
// traverse the ast
estraverse.traverse(ast, {
enter: enter
});
if (jsdoc.returnValue)
jsdocString += jsdoc.prefix + " * @returns {type} Description \n";
jsdocString += jsdoc.prefix + " */ \n";
function enter(node, parent) {
// If one annotation is done, break traversing the tree
if (isAnnotated) return estraverse.VisitorOption.Break;
// Check if node is annotatable and if so, call it's anotation function
if (isAnnotatable(node)) {
// Only annotate the element after the cursor
if (node.range[0] < cursorPosition) {
lastAnnotatable = node;
} else {
isAnnotated = true;
var jsDoc;
// Create jsDoc annotation
jsDoc = annotator[lastAnnotatable.type](lastAnnotatable, parent);
return jsdocString;
};
// Check if there is already a jsdoc annotation for this annnotatable
var jsDocCommentExists = false;
_.forEach(lastAnnotatable.leadingComments, function (value, key) {
if (value.type === "Block" && value.value.charAt(0) === "*") {
// jsDoc comment
jsDocCommentExists = true;
//Todo: Maybe ask, whether user wants to overwrite last comment?...
}
});
/**
* Insert the JSDoc annotation string to the document
* @param {string} jSDocString The JSDoc annotation string
* @param {location} loc location of the function found
*/
var _insertJSDocString = function (jSDocString, loc) {
var pos = {
line: loc.start.line - 1,
ch: 0
};
// Insert jsDoc into output variable
if (_.isString(jsDoc) && !jsDocCommentExists) {
var insertLocation = {
line: lastAnnotatable.loc.start.line-1,
ch: lastAnnotatable.loc.start.column
};
_editor.document.replaceRange(jsDoc, insertLocation);
EditorManager.focusEditor();
}
}
}
}
// Place jsdocString in the editor
_editor._codeMirror.replaceRange(jSDocString, pos);
EditorManager.focusEditor();
/**
* Check if a node is of an annotatable type
* @param {object} Check if node is annotatable
*/
function isAnnotatable(node) {
// Annotatable elements
var ANNOTATABLES = [
esprima.Syntax.ExpressionStatement,
esprima.Syntax.VariableDeclaration,
esprima.Syntax.FunctionDeclaration,
esprima.Syntax.Property
]; // That's it for the timebeeing
if (ANNOTATABLES.indexOf(node.type) != -1) {
return true;
} else {
return false;
}
}
};
// Register stuff when brackets finished loading
@ -171,5 +149,5 @@ define(function (require, exports, module) {
var menu = Menus.getMenu(Menus.AppMenuBar.EDIT_MENU);
menu.addMenuDivider();
menu.addMenuItem(COMMAND_ID); //"menu-edit-annotate",
menu.addMenuItem(COMMAND_ID); //"menu-edit-annotate"
});

View file

@ -11,8 +11,8 @@ define(function (require, exports, module) {
var greetings = "Hello world";
function declaration(input) {
function declaration(input) {
var content = "stuff";
}

View file

@ -1,23 +0,0 @@
Copyright (C) 2012-2014 by Marijn Haverbeke <marijnh@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Please note that some subdirectories of the CodeMirror distribution
include their own LICENSE files, and are released under different
licences.

View file

@ -1,218 +0,0 @@
# Acorn
A tiny, fast JavaScript parser, written completely in JavaScript.
## Installation
The easiest way to install acorn is with [`npm`][npm].
[npm]: http://npmjs.org
```sh
npm install acorn
```
Alternately, download the source.
```sh
git clone https://github.com/marijnh/acorn.git
```
## Components
When run in a CommonJS (node.js) or AMD environment, exported values
appear in the interfaces exposed by the individual files, as usual.
When loaded in the browser without any kind of module management, a
single global object `acorn` will be defined, and all the exported
properties will be added to that.
### acorn.js
This file contains the actual parser (and is what you get when you
`require("acorn")` in node.js).
**parse**`(input, options)` is used to parse a JavaScript program.
The `input` parameter is a string, `options` can be undefined or an
object setting some of the options listed below. The return value will
be an abstract syntax tree object as specified by the
[Mozilla Parser API][mozapi].
When encountering a syntax error, the parser will raise a
`SyntaxError` object with a meaningful message. The error object will
have a `pos` property that indicates the character offset at which the
error occurred, and a `loc` object that contains a `{line, column}`
object referring to that same position.
[mozapi]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be
either 3 or 5. This influences support for strict mode, the set of
reserved words, and support for getters and setter. Default is 5.
- **strictSemicolons**: If `true`, prevents the parser from doing
automatic semicolon insertion, and statements that do not end with
a semicolon will generate an error. Defaults to `false`.
- **allowTrailingCommas**: If `false`, the parser will not allow
trailing commas in array and object literals. Default is `true`.
- **forbidReserved**: If `true`, using a reserved word will generate
an error. Defaults to `false`. When given the value `"everywhere"`,
reserved words and keywords can also not be used as property names
(as in Internet Explorer's old parser).
- **allowReturnOutsideFunction**: By default, a return statement at
the top level raises an error. Set this to `true` to accept such
code.
- **locations**: When `true`, each node has a `loc` object attached
with `start` and `end` subobjects, each of which contains the
one-based line and zero-based column numbers in `{line, column}`
form. Default is `false`.
- **onComment**: If a function is passed for this option, whenever a
comment is encountered the function will be called with the
following parameters:
- `block`: `true` if the comment is a block comment, false if it
is a line comment.
- `text`: The content of the comment.
- `start`: Character offset of the start of the comment.
- `end`: Character offset of the end of the comment.
When the `locations` options is on, the `{line, column}` locations
of the comments start and end are passed as two additional
parameters.
Note that you are not allowed to call the parser from the
callback—that will corrupt its internal state.
- **ranges**: Nodes have their start and end characters offsets
recorded in `start` and `end` properties (directly on the node,
rather than the `loc` object, which holds line/column data. To also
add a [semi-standardized][range] "range" property holding a
`[start, end]` array with the same numbers, set the `ranges` option
to `true`.
- **program**: It is possible to parse multiple files into a single
AST by passing the tree produced by parsing the first file as the
`program` option in subsequent parses. This will add the toplevel
forms of the parsed file to the "Program" (top) node of an existing
parse tree.
- **sourceFile**: When the `locations` option is `true`, you can pass
this option to add a `sourceFile` attribute in every nodes `loc`
object. Note that the contents of this option are not examined or
processed in any way; you are free to use whatever format you
choose.
- **directSourceFile**: Like `sourceFile`, but the property will be
added directly to the nodes, rather than to a `loc` object.
[range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
**getLineInfo**`(input, offset)` can be used to get a `{line,
column}` object for a given program string and character offset.
**tokenize**`(input, options)` exports a primitive interface to
Acorn's tokenizer. The function takes an input string and options
similar to `parse` (though only some options are meaningful here), and
returns a function that can be called repeatedly to read a single
token, and returns a `{start, end, type, value}` object (with added
`startLoc` and `endLoc` properties when the `locations` option is
enabled). This object will be reused (updated) for each token, so you
can't count on it staying stable.
**tokTypes** holds an object mapping names to the token type objects
that end up in the `type` properties of tokens.
### acorn_loose.js ###
This file implements an error-tolerant parser. It exposes a single
function.
**parse_dammit**`(input, options)` takes the same arguments and
returns the same syntax tree as the `parse` function in `acorn.js`,
but never raises an error, and will do its best to parse syntactically
invalid code in as meaningful a way as it can. It'll insert identifier
nodes with name `"✖"` as placeholders in places where it can't make
sense of the input. Depends on `acorn.js`, because it uses the same
tokenizer.
### util/walk.js ###
Implements an abstract syntax tree walker. Will store its interface in
`acorn.walk` when used without a module system.
**simple**`(node, visitors, base, state)` does a 'simple' walk over
a tree. `node` should be the AST node to walk, and `visitors` an
object with properties whose names correspond to node types in the
[Mozilla Parser API][mozapi]. The properties should contain functions
that will be called with the node object and, if applicable the state
at that point. The last two arguments are optional. `base` is a walker
algorithm, and `state` is a start state. The default walker will
simply visit all statements and expressions and not produce a
meaningful state. (An example of a use of state it to track scope at
each point in the tree.)
**ancestor**`(node, visitors, base, state)` does a 'simple' walk over
a tree, building up an array of ancestor nodes (including the current node)
and passing the array to callbacks in the `state` parameter.
**recursive**`(node, state, functions, base)` does a 'recursive'
walk, where the walker functions are responsible for continuing the
walk on the child nodes of their target node. `state` is the start
state, and `functions` should contain an object that maps node types
to walker functions. Such functions are called with `(node, state, c)`
arguments, and can cause the walk to continue on a sub-node by calling
the `c` argument on it with `(node, state)` arguments. The optional
`base` argument provides the fallback walker functions for node types
that aren't handled in the `functions` object. If not given, the
default walkers will be used.
**make**`(functions, base)` builds a new walker object by using the
walker functions in `functions` and filling in the missing ones by
taking defaults from `base`.
**findNodeAt**`(node, start, end, test, base, state)` tries to
locate a node in a tree at the given start and/or end offsets, which
satisfies the predicate `test`. `start` end `end` can be either `null`
(as wildcard) or a number. `test` may be a string (indicating a node
type) or a function that takes `(nodeType, node)` arguments and
returns a boolean indicating whether this node is interesting. `base`
and `state` are optional, and can be used to specify a custom walker.
Nodes are tested from inner to outer, so if two nodes match the
boundaries, the inner one will be preferred.
**findNodeAround**`(node, pos, test, base, state)` is a lot like
`findNodeAt`, but will match any node that exists 'around' (spanning)
the given position.
**findNodeAfter**`(node, pos, test, base, state)` is similar to
`findNodeAround`, but will match all nodes *after* the given position
(testing outer nodes before inner nodes).
## Command line interface
The `bin/acorn` utility can be used to parse a file from the command
line. It accepts as arguments its input file and the following
options:
- `--ecma3|--ecma5`: Sets the ECMAScript version to parse. Default is
version 5.
- `--strictSemicolons`: Prevents the parser from doing automatic
semicolon insertion. Statements that do not end in semicolons will
generate an error.
- `--locations`: Attaches a "loc" object to each node with "start" and
"end" subobjects, each of which contains the one-based line and
zero-based column numbers in `{line, column}` form.
- `--compact`: No whitespace is used in the AST output.
- `--silent`: Do not output the AST, just return the exit status.
- `--help`: Print the usage information and quit.
The utility spits out the syntax tree as JSON data.

File diff suppressed because it is too large Load diff

View file

@ -1,780 +0,0 @@
// Acorn: Loose parser
//
// This module provides an alternative parser (`parse_dammit`) that
// exposes that same interface as `parse`, but will try to parse
// anything as JavaScript, repairing syntax error the best it can.
// There are circumstances in which it will raise an error and give
// up, but they are very rare. The resulting AST will be a mostly
// valid JavaScript AST (as per the [Mozilla parser API][api], except
// that:
//
// - Return outside functions is allowed
//
// - Label consistency (no conflicts, break only to existing labels)
// is not enforced.
//
// - Bogus Identifier nodes with a name of `"✖"` are inserted whenever
// the parser got too confused to return anything meaningful.
//
// [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
//
// The expected use for this is to *first* try `acorn.parse`, and only
// if that fails switch to `parse_dammit`. The loose parser might
// parse badly indented code incorrectly, so **don't** use it as
// your default parser.
//
// Quite a lot of acorn.js is duplicated here. The alternative was to
// add a *lot* of extra cruft to that file, making it less readable
// and slower. Copying and editing the code allowed me to make
// invasive changes and simplifications without creating a complicated
// tangle.
(function(root, mod) {
if (typeof exports == "object" && typeof module == "object") return mod(exports, require("./acorn")); // CommonJS
if (typeof define == "function" && define.amd) return define(["exports", "./acorn"], mod); // AMD
mod(root.acorn || (root.acorn = {}), root.acorn); // Plain browser env
})(this, function(exports, acorn) {
"use strict";
var tt = acorn.tokTypes;
var options, input, fetchToken, context;
exports.parse_dammit = function(inpt, opts) {
if (!opts) opts = {};
input = String(inpt);
options = opts;
if (!opts.tabSize) opts.tabSize = 4;
fetchToken = acorn.tokenize(inpt, opts);
sourceFile = options.sourceFile || null;
context = [];
nextLineStart = 0;
ahead.length = 0;
next();
return parseTopLevel();
};
var lastEnd, token = {start: 0, end: 0}, ahead = [];
var curLineStart, nextLineStart, curIndent, lastEndLoc, sourceFile;
function next() {
lastEnd = token.end;
if (options.locations)
lastEndLoc = token.endLoc;
if (ahead.length)
token = ahead.shift();
else
token = readToken();
if (token.start >= nextLineStart) {
while (token.start >= nextLineStart) {
curLineStart = nextLineStart;
nextLineStart = lineEnd(curLineStart) + 1;
}
curIndent = indentationAfter(curLineStart);
}
}
function readToken() {
for (;;) {
try {
return fetchToken();
} catch(e) {
if (!(e instanceof SyntaxError)) throw e;
// Try to skip some text, based on the error message, and then continue
var msg = e.message, pos = e.raisedAt, replace = true;
if (/unterminated/i.test(msg)) {
pos = lineEnd(e.pos);
if (/string/.test(msg)) {
replace = {start: e.pos, end: pos, type: tt.string, value: input.slice(e.pos + 1, pos)};
} else if (/regular expr/i.test(msg)) {
var re = input.slice(e.pos, pos);
try { re = new RegExp(re); } catch(e) {}
replace = {start: e.pos, end: pos, type: tt.regexp, value: re};
} else {
replace = false;
}
} else if (/invalid (unicode|regexp|number)|expecting unicode|octal literal|is reserved|directly after number/i.test(msg)) {
while (pos < input.length && !isSpace(input.charCodeAt(pos))) ++pos;
} else if (/character escape|expected hexadecimal/i.test(msg)) {
while (pos < input.length) {
var ch = input.charCodeAt(pos++);
if (ch === 34 || ch === 39 || isNewline(ch)) break;
}
} else if (/unexpected character/i.test(msg)) {
pos++;
replace = false;
} else if (/regular expression/i.test(msg)) {
replace = true;
} else {
throw e;
}
resetTo(pos);
if (replace === true) replace = {start: pos, end: pos, type: tt.name, value: "✖"};
if (replace) {
if (options.locations) {
replace.startLoc = acorn.getLineInfo(input, replace.start);
replace.endLoc = acorn.getLineInfo(input, replace.end);
}
return replace;
}
}
}
}
function resetTo(pos) {
var ch = input.charAt(pos - 1);
var reAllowed = !ch || /[\[\{\(,;:?\/*=+\-~!|&%^<>]/.test(ch) ||
/[enwfd]/.test(ch) && /\b(keywords|case|else|return|throw|new|in|(instance|type)of|delete|void)$/.test(input.slice(pos - 10, pos));
fetchToken.jumpTo(pos, reAllowed);
}
function copyToken(token) {
var copy = {start: token.start, end: token.end, type: token.type, value: token.value};
if (options.locations) {
copy.startLoc = token.startLoc;
copy.endLoc = token.endLoc;
}
return copy;
}
function lookAhead(n) {
// Copy token objects, because fetchToken will overwrite the one
// it returns, and in this case we still need it
if (!ahead.length)
token = copyToken(token);
while (n > ahead.length)
ahead.push(copyToken(readToken()));
return ahead[n-1];
}
var newline = /[\n\r\u2028\u2029]/;
function isNewline(ch) {
return ch === 10 || ch === 13 || ch === 8232 || ch === 8329;
}
function isSpace(ch) {
return (ch < 14 && ch > 8) || ch === 32 || ch === 160 || isNewline(ch);
}
function pushCx() {
context.push(curIndent);
}
function popCx() {
curIndent = context.pop();
}
function lineEnd(pos) {
while (pos < input.length && !isNewline(input.charCodeAt(pos))) ++pos;
return pos;
}
function indentationAfter(pos) {
for (var count = 0;; ++pos) {
var ch = input.charCodeAt(pos);
if (ch === 32) ++count;
else if (ch === 9) count += options.tabSize;
else return count;
}
}
function closes(closeTok, indent, line, blockHeuristic) {
if (token.type === closeTok || token.type === tt.eof) return true;
if (line != curLineStart && curIndent < indent && tokenStartsLine() &&
(!blockHeuristic || nextLineStart >= input.length ||
indentationAfter(nextLineStart) < indent)) return true;
return false;
}
function tokenStartsLine() {
for (var p = token.start - 1; p >= curLineStart; --p) {
var ch = input.charCodeAt(p);
if (ch !== 9 && ch !== 32) return false;
}
return true;
}
function Node(start) {
this.type = null;
this.start = start;
this.end = null;
}
Node.prototype = acorn.Node.prototype;
function SourceLocation(start) {
this.start = start || token.startLoc || {line: 1, column: 0};
this.end = null;
if (sourceFile !== null) this.source = sourceFile;
}
function startNode() {
var node = new Node(token.start);
if (options.locations)
node.loc = new SourceLocation();
if (options.directSourceFile)
node.sourceFile = options.directSourceFile;
return node;
}
function startNodeFrom(other) {
var node = new Node(other.start);
if (options.locations)
node.loc = new SourceLocation(other.loc.start);
return node;
}
function finishNode(node, type) {
node.type = type;
node.end = lastEnd;
if (options.locations)
node.loc.end = lastEndLoc;
return node;
}
function getDummyLoc() {
if (options.locations) {
var loc = new SourceLocation();
loc.end = loc.start;
return loc;
}
};
function dummyIdent() {
var dummy = new Node(token.start);
dummy.type = "Identifier";
dummy.end = token.start;
dummy.name = "✖";
dummy.loc = getDummyLoc();
return dummy;
}
function isDummy(node) { return node.name == "✖"; }
function eat(type) {
if (token.type === type) {
next();
return true;
}
}
function canInsertSemicolon() {
return (token.type === tt.eof || token.type === tt.braceR || newline.test(input.slice(lastEnd, token.start)));
}
function semicolon() {
eat(tt.semi);
}
function expect(type) {
if (eat(type)) return true;
if (lookAhead(1).type == type) {
next(); next();
return true;
}
if (lookAhead(2).type == type) {
next(); next(); next();
return true;
}
}
function checkLVal(expr) {
if (expr.type === "Identifier" || expr.type === "MemberExpression") return expr;
return dummyIdent();
}
function parseTopLevel() {
var node = startNode();
node.body = [];
while (token.type !== tt.eof) node.body.push(parseStatement());
return finishNode(node, "Program");
}
function parseStatement() {
var starttype = token.type, node = startNode();
switch (starttype) {
case tt._break: case tt._continue:
next();
var isBreak = starttype === tt._break;
node.label = token.type === tt.name ? parseIdent() : null;
semicolon();
return finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
case tt._debugger:
next();
semicolon();
return finishNode(node, "DebuggerStatement");
case tt._do:
next();
node.body = parseStatement();
node.test = eat(tt._while) ? parseParenExpression() : dummyIdent();
semicolon();
return finishNode(node, "DoWhileStatement");
case tt._for:
next();
pushCx();
expect(tt.parenL);
if (token.type === tt.semi) return parseFor(node, null);
if (token.type === tt._var) {
var init = startNode();
next();
parseVar(init, true);
if (init.declarations.length === 1 && eat(tt._in))
return parseForIn(node, init);
return parseFor(node, init);
}
var init = parseExpression(false, true);
if (eat(tt._in)) {return parseForIn(node, checkLVal(init));}
return parseFor(node, init);
case tt._function:
next();
return parseFunction(node, true);
case tt._if:
next();
node.test = parseParenExpression();
node.consequent = parseStatement();
node.alternate = eat(tt._else) ? parseStatement() : null;
return finishNode(node, "IfStatement");
case tt._return:
next();
if (eat(tt.semi) || canInsertSemicolon()) node.argument = null;
else { node.argument = parseExpression(); semicolon(); }
return finishNode(node, "ReturnStatement");
case tt._switch:
var blockIndent = curIndent, line = curLineStart;
next();
node.discriminant = parseParenExpression();
node.cases = [];
pushCx();
expect(tt.braceL);
for (var cur; !closes(tt.braceR, blockIndent, line, true);) {
if (token.type === tt._case || token.type === tt._default) {
var isCase = token.type === tt._case;
if (cur) finishNode(cur, "SwitchCase");
node.cases.push(cur = startNode());
cur.consequent = [];
next();
if (isCase) cur.test = parseExpression();
else cur.test = null;
expect(tt.colon);
} else {
if (!cur) {
node.cases.push(cur = startNode());
cur.consequent = [];
cur.test = null;
}
cur.consequent.push(parseStatement());
}
}
if (cur) finishNode(cur, "SwitchCase");
popCx();
eat(tt.braceR);
return finishNode(node, "SwitchStatement");
case tt._throw:
next();
node.argument = parseExpression();
semicolon();
return finishNode(node, "ThrowStatement");
case tt._try:
next();
node.block = parseBlock();
node.handler = null;
if (token.type === tt._catch) {
var clause = startNode();
next();
expect(tt.parenL);
clause.param = parseIdent();
expect(tt.parenR);
clause.guard = null;
clause.body = parseBlock();
node.handler = finishNode(clause, "CatchClause");
}
node.finalizer = eat(tt._finally) ? parseBlock() : null;
if (!node.handler && !node.finalizer) return node.block;
return finishNode(node, "TryStatement");
case tt._var:
next();
node = parseVar(node);
semicolon();
return node;
case tt._while:
next();
node.test = parseParenExpression();
node.body = parseStatement();
return finishNode(node, "WhileStatement");
case tt._with:
next();
node.object = parseParenExpression();
node.body = parseStatement();
return finishNode(node, "WithStatement");
case tt.braceL:
return parseBlock();
case tt.semi:
next();
return finishNode(node, "EmptyStatement");
default:
var expr = parseExpression();
if (isDummy(expr)) {
next();
if (token.type === tt.eof) return finishNode(node, "EmptyStatement");
return parseStatement();
} else if (starttype === tt.name && expr.type === "Identifier" && eat(tt.colon)) {
node.body = parseStatement();
node.label = expr;
return finishNode(node, "LabeledStatement");
} else {
node.expression = expr;
semicolon();
return finishNode(node, "ExpressionStatement");
}
}
}
function parseBlock() {
var node = startNode();
pushCx();
expect(tt.braceL);
var blockIndent = curIndent, line = curLineStart;
node.body = [];
while (!closes(tt.braceR, blockIndent, line, true))
node.body.push(parseStatement());
popCx();
eat(tt.braceR);
return finishNode(node, "BlockStatement");
}
function parseFor(node, init) {
node.init = init;
node.test = node.update = null;
if (eat(tt.semi) && token.type !== tt.semi) node.test = parseExpression();
if (eat(tt.semi) && token.type !== tt.parenR) node.update = parseExpression();
popCx();
expect(tt.parenR);
node.body = parseStatement();
return finishNode(node, "ForStatement");
}
function parseForIn(node, init) {
node.left = init;
node.right = parseExpression();
popCx();
expect(tt.parenR);
node.body = parseStatement();
return finishNode(node, "ForInStatement");
}
function parseVar(node, noIn) {
node.declarations = [];
node.kind = "var";
while (token.type === tt.name) {
var decl = startNode();
decl.id = parseIdent();
decl.init = eat(tt.eq) ? parseExpression(true, noIn) : null;
node.declarations.push(finishNode(decl, "VariableDeclarator"));
if (!eat(tt.comma)) break;
}
if (!node.declarations.length) {
var decl = startNode();
decl.id = dummyIdent();
node.declarations.push(finishNode(decl, "VariableDeclarator"));
}
return finishNode(node, "VariableDeclaration");
}
function parseExpression(noComma, noIn) {
var expr = parseMaybeAssign(noIn);
if (!noComma && token.type === tt.comma) {
var node = startNodeFrom(expr);
node.expressions = [expr];
while (eat(tt.comma)) node.expressions.push(parseMaybeAssign(noIn));
return finishNode(node, "SequenceExpression");
}
return expr;
}
function parseParenExpression() {
pushCx();
expect(tt.parenL);
var val = parseExpression();
popCx();
expect(tt.parenR);
return val;
}
function parseMaybeAssign(noIn) {
var left = parseMaybeConditional(noIn);
if (token.type.isAssign) {
var node = startNodeFrom(left);
node.operator = token.value;
node.left = checkLVal(left);
next();
node.right = parseMaybeAssign(noIn);
return finishNode(node, "AssignmentExpression");
}
return left;
}
function parseMaybeConditional(noIn) {
var expr = parseExprOps(noIn);
if (eat(tt.question)) {
var node = startNodeFrom(expr);
node.test = expr;
node.consequent = parseExpression(true);
node.alternate = expect(tt.colon) ? parseExpression(true, noIn) : dummyIdent();
return finishNode(node, "ConditionalExpression");
}
return expr;
}
function parseExprOps(noIn) {
var indent = curIndent, line = curLineStart;
return parseExprOp(parseMaybeUnary(noIn), -1, noIn, indent, line);
}
function parseExprOp(left, minPrec, noIn, indent, line) {
if (curLineStart != line && curIndent < indent && tokenStartsLine()) return left;
var prec = token.type.binop;
if (prec != null && (!noIn || token.type !== tt._in)) {
if (prec > minPrec) {
var node = startNodeFrom(left);
node.left = left;
node.operator = token.value;
next();
if (curLineStart != line && curIndent < indent && tokenStartsLine())
node.right = dummyIdent();
else
node.right = parseExprOp(parseMaybeUnary(noIn), prec, noIn, indent, line);
var node = finishNode(node, /&&|\|\|/.test(node.operator) ? "LogicalExpression" : "BinaryExpression");
return parseExprOp(node, minPrec, noIn, indent, line);
}
}
return left;
}
function parseMaybeUnary(noIn) {
if (token.type.prefix) {
var node = startNode(), update = token.type.isUpdate;
node.operator = token.value;
node.prefix = true;
next();
node.argument = parseMaybeUnary(noIn);
if (update) node.argument = checkLVal(node.argument);
return finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
}
var expr = parseExprSubscripts();
while (token.type.postfix && !canInsertSemicolon()) {
var node = startNodeFrom(expr);
node.operator = token.value;
node.prefix = false;
node.argument = checkLVal(expr);
next();
expr = finishNode(node, "UpdateExpression");
}
return expr;
}
function parseExprSubscripts() {
return parseSubscripts(parseExprAtom(), false, curIndent, curLineStart);
}
function parseSubscripts(base, noCalls, startIndent, line) {
for (;;) {
if (curLineStart != line && curIndent <= startIndent && tokenStartsLine()) {
if (token.type == tt.dot && curIndent == startIndent)
--startIndent;
else
return base;
}
if (eat(tt.dot)) {
var node = startNodeFrom(base);
node.object = base;
if (curLineStart != line && curIndent <= startIndent && tokenStartsLine())
node.property = dummyIdent();
else
node.property = parsePropertyName() || dummyIdent();
node.computed = false;
base = finishNode(node, "MemberExpression");
} else if (token.type == tt.bracketL) {
pushCx();
next();
var node = startNodeFrom(base);
node.object = base;
node.property = parseExpression();
node.computed = true;
popCx();
expect(tt.bracketR);
base = finishNode(node, "MemberExpression");
} else if (!noCalls && token.type == tt.parenL) {
pushCx();
var node = startNodeFrom(base);
node.callee = base;
node.arguments = parseExprList(tt.parenR);
base = finishNode(node, "CallExpression");
} else {
return base;
}
}
}
function parseExprAtom() {
switch (token.type) {
case tt._this:
var node = startNode();
next();
return finishNode(node, "ThisExpression");
case tt.name:
return parseIdent();
case tt.num: case tt.string: case tt.regexp:
var node = startNode();
node.value = token.value;
node.raw = input.slice(token.start, token.end);
next();
return finishNode(node, "Literal");
case tt._null: case tt._true: case tt._false:
var node = startNode();
node.value = token.type.atomValue;
node.raw = token.type.keyword;
next();
return finishNode(node, "Literal");
case tt.parenL:
var tokStart1 = token.start;
next();
var val = parseExpression();
val.start = tokStart1;
val.end = token.end;
expect(tt.parenR);
return val;
case tt.bracketL:
var node = startNode();
pushCx();
node.elements = parseExprList(tt.bracketR);
return finishNode(node, "ArrayExpression");
case tt.braceL:
return parseObj();
case tt._function:
var node = startNode();
next();
return parseFunction(node, false);
case tt._new:
return parseNew();
default:
return dummyIdent();
}
}
function parseNew() {
var node = startNode(), startIndent = curIndent, line = curLineStart;
next();
node.callee = parseSubscripts(parseExprAtom(), true, startIndent, line);
if (token.type == tt.parenL) {
pushCx();
node.arguments = parseExprList(tt.parenR);
} else {
node.arguments = [];
}
return finishNode(node, "NewExpression");
}
function parseObj() {
var node = startNode();
node.properties = [];
pushCx();
next();
var propIndent = curIndent, line = curLineStart;
while (!closes(tt.braceR, propIndent, line)) {
var name = parsePropertyName();
if (!name) { if (isDummy(parseExpression(true))) next(); eat(tt.comma); continue; }
var prop = {key: name}, isGetSet = false, kind;
if (eat(tt.colon)) {
prop.value = parseExpression(true);
kind = prop.kind = "init";
} else if (options.ecmaVersion >= 5 && prop.key.type === "Identifier" &&
(prop.key.name === "get" || prop.key.name === "set")) {
isGetSet = true;
kind = prop.kind = prop.key.name;
prop.key = parsePropertyName() || dummyIdent();
prop.value = parseFunction(startNode(), false);
} else {
next();
eat(tt.comma);
continue;
}
node.properties.push(prop);
eat(tt.comma);
}
popCx();
eat(tt.braceR);
return finishNode(node, "ObjectExpression");
}
function parsePropertyName() {
if (token.type === tt.num || token.type === tt.string) return parseExprAtom();
if (token.type === tt.name || token.type.keyword) return parseIdent();
}
function parseIdent() {
var node = startNode();
node.name = token.type === tt.name ? token.value : token.type.keyword;
next();
return finishNode(node, "Identifier");
}
function parseFunction(node, isStatement) {
if (token.type === tt.name) node.id = parseIdent();
else if (isStatement) node.id = dummyIdent();
else node.id = null;
node.params = [];
pushCx();
expect(tt.parenL);
while (token.type == tt.name) {
node.params.push(parseIdent());
eat(tt.comma);
}
popCx();
eat(tt.parenR);
node.body = parseBlock();
return finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
}
function parseExprList(close) {
var indent = curIndent, line = curLineStart, elts = [], continuedLine = nextLineStart;
next(); // Opening bracket
if (curLineStart > continuedLine) continuedLine = curLineStart;
while (!closes(close, indent + (curLineStart <= continuedLine ? 1 : 0), line)) {
var elt = parseExpression(true);
if (isDummy(elt)) {
if (closes(close, indent, line)) break;
next();
} else {
elts.push(elt);
}
while (eat(tt.comma)) {}
}
popCx();
eat(close);
return elts;
}
});

View file

@ -1,39 +0,0 @@
#!/usr/bin/env node
var path = require("path");
var fs = require("fs");
var acorn = require("../acorn.js");
var infile, parsed, options = {}, silent = false, compact = false;
function help(status) {
console.log("usage: " + path.basename(process.argv[1]) + " infile [--ecma3|--ecma5] [--strictSemicolons]");
console.log(" [--locations] [--compact] [--silent] [--help]");
process.exit(status);
}
for (var i = 2; i < process.argv.length; ++i) {
var arg = process.argv[i];
if (arg == "--ecma3") options.ecmaVersion = 3;
else if (arg == "--ecma5") options.ecmaVersion = 5;
else if (arg == "--strictSemicolons") options.strictSemicolons = true;
else if (arg == "--locations") options.locations = true;
else if (arg == "--silent") silent = true;
else if (arg == "--compact") compact = true;
else if (arg == "--help") help(0);
else if (arg[0] == "-") help(1);
else infile = arg;
}
if (!infile) help(1);
try {
var code = fs.readFileSync(infile, "utf8");
parsed = acorn.parse(code, options);
} catch(e) {
console.log(e.message);
process.exit(1);
}
if (!silent)
console.log(JSON.stringify(parsed, null, compact ? null : 2));

View file

@ -1,192 +0,0 @@
/*--------------------- Layout and Typography ----------------------------*/
body {
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
font-size: 15px;
line-height: 22px;
color: #252519;
margin: 0; padding: 0;
}
a {
color: #261a3b;
}
a:visited {
color: #261a3b;
}
p {
margin: 0 0 15px 0;
}
h1, h2, h3, h4, h5, h6 {
margin: 0px 0 15px 0;
}
h1 {
margin-top: 40px;
}
hr {
border: 0 none;
border-top: 1px solid #e5e5ee;
height: 1px;
margin: 20px 0;
}
#container {
position: relative;
}
#background {
position: fixed;
top: 0; left: 525px; right: 0; bottom: 0;
background: #f5f5ff;
border-left: 1px solid #e5e5ee;
z-index: -1;
}
#jump_to, #jump_page {
background: white;
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
font: 10px Arial;
text-transform: uppercase;
cursor: pointer;
text-align: right;
}
#jump_to, #jump_wrapper {
position: fixed;
right: 0; top: 0;
padding: 5px 10px;
}
#jump_wrapper {
padding: 0;
display: none;
}
#jump_to:hover #jump_wrapper {
display: block;
}
#jump_page {
padding: 5px 0 3px;
margin: 0 0 25px 25px;
}
#jump_page .source {
display: block;
padding: 5px 10px;
text-decoration: none;
border-top: 1px solid #eee;
}
#jump_page .source:hover {
background: #f5f5ff;
}
#jump_page .source:first-child {
}
table td {
border: 0;
outline: 0;
}
td.docs, th.docs {
max-width: 450px;
min-width: 450px;
min-height: 5px;
padding: 10px 25px 1px 50px;
overflow-x: hidden;
vertical-align: top;
text-align: left;
}
.docs pre {
margin: 15px 0 15px;
padding-left: 15px;
}
.docs p tt, .docs p code {
background: #f8f8ff;
border: 1px solid #dedede;
font-size: 12px;
padding: 0 0.2em;
}
.pilwrap {
position: relative;
}
.pilcrow {
font: 12px Arial;
text-decoration: none;
color: #454545;
position: absolute;
top: 3px; left: -20px;
padding: 1px 2px;
opacity: 0;
-webkit-transition: opacity 0.2s linear;
}
td.docs:hover .pilcrow {
opacity: 1;
}
td.code, th.code {
padding: 14px 15px 16px 25px;
width: 100%;
vertical-align: top;
background: #f5f5ff;
border-left: 1px solid #e5e5ee;
}
pre, tt, code {
font-size: 12px; line-height: 18px;
font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
margin: 0; padding: 0;
}
/*---------------------- Syntax Highlighting -----------------------------*/
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
body .hll { background-color: #ffffcc }
body .c { color: #408080; font-style: italic } /* Comment */
body .err { border: 1px solid #FF0000 } /* Error */
body .k { color: #954121 } /* Keyword */
body .o { color: #666666 } /* Operator */
body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
body .cp { color: #BC7A00 } /* Comment.Preproc */
body .c1 { color: #408080; font-style: italic } /* Comment.Single */
body .cs { color: #408080; font-style: italic } /* Comment.Special */
body .gd { color: #A00000 } /* Generic.Deleted */
body .ge { font-style: italic } /* Generic.Emph */
body .gr { color: #FF0000 } /* Generic.Error */
body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
body .gi { color: #00A000 } /* Generic.Inserted */
body .go { color: #808080 } /* Generic.Output */
body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
body .gs { font-weight: bold } /* Generic.Strong */
body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
body .gt { color: #0040D0 } /* Generic.Traceback */
body .kc { color: #954121 } /* Keyword.Constant */
body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
body .kp { color: #954121 } /* Keyword.Pseudo */
body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
body .kt { color: #B00040 } /* Keyword.Type */
body .m { color: #666666 } /* Literal.Number */
body .s { color: #219161 } /* Literal.String */
body .na { color: #7D9029 } /* Name.Attribute */
body .nb { color: #954121 } /* Name.Builtin */
body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
body .no { color: #880000 } /* Name.Constant */
body .nd { color: #AA22FF } /* Name.Decorator */
body .ni { color: #999999; font-weight: bold } /* Name.Entity */
body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
body .nf { color: #0000FF } /* Name.Function */
body .nl { color: #A0A000 } /* Name.Label */
body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
body .nt { color: #954121; font-weight: bold } /* Name.Tag */
body .nv { color: #19469D } /* Name.Variable */
body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
body .w { color: #bbbbbb } /* Text.Whitespace */
body .mf { color: #666666 } /* Literal.Number.Float */
body .mh { color: #666666 } /* Literal.Number.Hex */
body .mi { color: #666666 } /* Literal.Number.Integer */
body .mo { color: #666666 } /* Literal.Number.Oct */
body .sb { color: #219161 } /* Literal.String.Backtick */
body .sc { color: #219161 } /* Literal.String.Char */
body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
body .s2 { color: #219161 } /* Literal.String.Double */
body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
body .sh { color: #219161 } /* Literal.String.Heredoc */
body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
body .sx { color: #954121 } /* Literal.String.Other */
body .sr { color: #BB6688 } /* Literal.String.Regex */
body .s1 { color: #219161 } /* Literal.String.Single */
body .ss { color: #19469D } /* Literal.String.Symbol */
body .bp { color: #954121 } /* Name.Builtin.Pseudo */
body .vc { color: #19469D } /* Name.Variable.Class */
body .vg { color: #19469D } /* Name.Variable.Global */
body .vi { color: #19469D } /* Name.Variable.Instance */
body .il { color: #666666 } /* Literal.Number.Integer.Long */

File diff suppressed because it is too large Load diff

View file

@ -1,17 +0,0 @@
{
"name": "acorn",
"description": "ECMAScript parser",
"homepage": "http://marijnhaverbeke.nl/acorn/",
"main": "acorn.js",
"version": "0.5.1",
"engines": {"node": ">=0.4.0"},
"maintainers": [{"name": "Marijn Haverbeke",
"email": "marijnh@gmail.com",
"web": "http://marijnhaverbeke.nl"}],
"repository": {"type": "git",
"url": "http://marijnhaverbeke.nl/git/acorn"},
"licenses": [{"type": "MIT",
"url": "http://marijnhaverbeke.nl/acorn/LICENSE"}],
"scripts": {"test": "node test/run.js"},
"bin": {"acorn": "./bin/acorn"}
}

View file

@ -1,90 +0,0 @@
<!doctype html>
<head>
<meta charset="utf-8">
<title>Acorn benchmark</title>
<script src="../acorn.js"></script>
<script src="compare/esprima.js"></script>
<script src="compare/uglifyjs2.js"></script>
<script src="jquery-string.js"></script>
<script src="codemirror-string.js"></script>
<style>
td { text-align: right; padding-right: 20px; }
th { text-align: left; padding-right: 40px; }
body { max-width: 50em; padding: 1em 2em; }
h1 { font-size: 150%; }
</style>
</head>
<h1>Acorn/Esprima/UglifyJS2 speed comparison</h1>
<p>This will run each of the three parsers on the source code of
jQuery 1.6.4 and CodeMirror 3.0b1 for two seconds, and show a table
indicating the number of lines parsed per second. Note that UglifyJS
always stores location data, and is thus not fairly compared by the
benchmark <em>without</em> location data.<p>
<p>Also note that having the developer tools open in Chrome, or
Firebug in Firefox <em>heavily</em> influences the numbers you get. In
Chrome, the effect even lingers (in the tab) after you close the
developer tools. Load in a fresh tab to get (halfway) stable
numbers.</p>
<button onclick="run(false)">Compare <strong>without</strong> location data</button>
<button onclick="run(true)">Compare <strong>with</strong> location data</button>
<button onclick="run(false, true)">Run only Acorn</button>
<span id="running"></span>
<script>
function runAcorn(code, locations) {
acorn.parse(code, {locations: locations});
}
function runEsprima(code, locations) {
esprima.parse(code, {loc: locations});
}
function runUglifyJS(code) {
uglifyjs.parse(code);
}
var totalLines = codemirror30.split("\n").length + jquery164.split("\n").length;
function benchmark(runner, locations) {
// Give it a chance to warm up (first runs are usually outliers)
runner(jquery164, locations);
runner(codemirror30, locations);
var t0 = +new Date, t1, lines = 0;
for (;;) {
runner(jquery164, locations);
runner(codemirror30, locations);
lines += totalLines;
t1 = +new Date;
if (t1 - t0 > 2000) break;
}
return lines / ((t1 - t0) / 1000);
}
function showOutput(values) {
var html = "<hr><table>";
for (var i = 0; i < values.length; ++i)
html += "<tr><th>" + values[i].name + "</td><td>" + Math.round(values[i].score) + " lines per second</td><td>" +
Math.round(values[i].score * 100 / values[0].score) + "%</td></tr>";
document.body.appendChild(document.createElement("div")).innerHTML = html;
}
function run(locations, acornOnly) {
var running = document.getElementById("running");
running.innerHTML = "Running benchmark...";
var data = [{name: "Acorn", runner: runAcorn},
{name: "Esprima", runner: runEsprima},
{name: "UglifyJS2", runner: runUglifyJS}];
if (acornOnly) data.length = 1;
var pos = 0;
function next() {
data[pos].score = benchmark(data[pos].runner, locations);
if (++pos == data.length) {
running.innerHTML = "";
showOutput(data);
} else setTimeout(next, 100);
}
setTimeout(next, 50);
}
</script>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,92 +0,0 @@
(function(exports) {
var tests = [];
var acorn = typeof require == "undefined" ? window.acorn : require("../acorn.js");
exports.test = function(code, ast, options) {
tests.push({code: code, ast: ast, options: options});
};
exports.testFail = function(code, message, options) {
tests.push({code: code, error: message, options: options});
};
exports.testAssert = function(code, assert, options) {
tests.push({code: code, assert: assert, options: options});
};
exports.runTests = function(callback) {
var opts = {locations: true};
for (var i = 0; i < tests.length; ++i) {
var test = tests[i];
try {
var ast = acorn.parse(test.code, test.options || opts);
if (test.error) callback("fail", test.code,
"Expected error message: " + test.error + "\nBut parsing succeeded.");
else if (test.assert) {
var error = test.assert(ast);
if (error) callback("fail", test.code,
"\n Assertion failed:\n " + error);
else callback("ok", test.code);
} else {
var mis = misMatch(test.ast, ast);
if (!mis) callback("ok", test.code);
else callback("fail", test.code, mis);
}
} catch(e) {
if (test.error && e instanceof SyntaxError) {
if (e.message == test.error) callback("ok", test.code);
else callback("fail", test.code,
"Expected error message: " + test.error + "\nGot error message: " + e.message);
} else {
callback("error", test.code, e.message || e.toString());
}
}
}
};
function ppJSON(v) { return JSON.stringify(v, null, 2); }
function addPath(str, pt) {
if (str.charAt(str.length-1) == ")")
return str.slice(0, str.length-1) + "/" + pt + ")";
return str + " (" + pt + ")";
}
function misMatch(exp, act) {
if (!exp || !act || (typeof exp != "object") || (typeof act != "object")) {
if (exp !== act) return ppJSON(exp) + " !== " + ppJSON(act);
} else if (exp.splice) {
if (!act.slice) return ppJSON(exp) + " != " + ppJSON(act);
if (act.length != exp.length) return "array length mismatch " + exp.length + " != " + act.length;
for (var i = 0; i < act.length; ++i) {
var mis = misMatch(exp[i], act[i]);
if (mis) return addPath(mis, i);
}
} else {
for (var prop in exp) {
var mis = misMatch(exp[prop], act[prop]);
if (mis) return addPath(mis, prop);
}
}
}
function mangle(ast) {
if (typeof ast != "object" || !ast) return;
if (ast.slice) {
for (var i = 0; i < ast.length; ++i) mangle(ast[i]);
} else {
var loc = ast.start && ast.end && {start: ast.start, end: ast.end};
if (loc) { delete ast.start; delete ast.end; }
for (var name in ast) if (ast.hasOwnProperty(name)) mangle(ast[name]);
if (loc) ast.loc = loc;
}
}
exports.printTests = function() {
var out = "";
for (var i = 0; i < tests.length; ++i) {
if (tests[i].error) continue;
mangle(tests[i].ast);
out += "test(" + JSON.stringify(tests[i].code) + ", " + JSON.stringify(tests[i].ast, null, 2) + ");\n\n";
}
document.body.innerHTML = "";
document.body.appendChild(document.createElement("pre")).appendChild(document.createTextNode(out));
};
})(typeof exports == "undefined" ? window : exports);

View file

@ -1,24 +0,0 @@
<!doctype html>
<head>
<meta charset="utf-8">
<title>Acorn test suite</title>
<script src="../acorn.js"></script>
<script src="driver.js"></script>
<script src="tests.js" charset="utf-8"></script>
</head>
<script>
var testsRun = 0, failed = 0;
function report(state, code, message) {
if (state != "ok") {++failed; console.log(code, message);}
++testsRun;
}
window.onload = function(){
var t0 = +new Date;
runTests(report);
var out = testsRun + " tests run in " + (+new Date - t0) + "ms\n";
if (failed) out += failed + " failures.\n";
else out += "All passed.\n";
document.body.appendChild(document.createElement("pre")).appendChild(document.createTextNode(out));
};
</script>

File diff suppressed because it is too large Load diff

View file

@ -1,14 +0,0 @@
var driver = require("./driver.js");
require("./tests.js");
var testsRun = 0, failed = 0;
function report(state, code, message) {
if (state != "ok") {++failed; console.log(code, message);}
++testsRun;
}
var t0 = +new Date;
driver.runTests(report);
console.log(testsRun + " tests run in " + (+new Date - t0) + "ms");
if (failed) console.log(failed + " failures.");
else console.log("All passed.");

File diff suppressed because it is too large Load diff

View file

@ -1,330 +0,0 @@
// AST walker module for Mozilla Parser API compatible trees
(function(mod) {
if (typeof exports == "object" && typeof module == "object") return mod(exports); // CommonJS
if (typeof define == "function" && define.amd) return define(["exports"], mod); // AMD
mod((this.acorn || (this.acorn = {})).walk = {}); // Plain browser env
})(function(exports) {
"use strict";
// A simple walk is one where you simply specify callbacks to be
// called on specific nodes. The last two arguments are optional. A
// simple use would be
//
// walk.simple(myTree, {
// Expression: function(node) { ... }
// });
//
// to do something with all expressions. All Parser API node types
// can be used to identify node types, as well as Expression,
// Statement, and ScopeBody, which denote categories of nodes.
//
// The base argument can be used to pass a custom (recursive)
// walker, and state can be used to give this walked an initial
// state.
exports.simple = function(node, visitors, base, state) {
if (!base) base = exports.base;
function c(node, st, override) {
var type = override || node.type, found = visitors[type];
base[type](node, st, c);
if (found) found(node, st);
}
c(node, state);
};
// An ancestor walk builds up an array of ancestor nodes (including
// the current node) and passes them to the callback as the state parameter.
exports.ancestor = function(node, visitors, base, state) {
if (!base) base = exports.base;
if (!state) state = [];
function c(node, st, override) {
var type = override || node.type, found = visitors[type];
if (node != st[st.length - 1]) {
st = st.slice();
st.push(node);
}
base[type](node, st, c);
if (found) found(node, st);
}
c(node, state);
};
// A recursive walk is one where your functions override the default
// walkers. They can modify and replace the state parameter that's
// threaded through the walk, and can opt how and whether to walk
// their child nodes (by calling their third argument on these
// nodes).
exports.recursive = function(node, state, funcs, base) {
var visitor = funcs ? exports.make(funcs, base) : base;
function c(node, st, override) {
visitor[override || node.type](node, st, c);
}
c(node, state);
};
function makeTest(test) {
if (typeof test == "string")
return function(type) { return type == test; };
else if (!test)
return function() { return true; };
else
return test;
}
function Found(node, state) { this.node = node; this.state = state; }
// Find a node with a given start, end, and type (all are optional,
// null can be used as wildcard). Returns a {node, state} object, or
// undefined when it doesn't find a matching node.
exports.findNodeAt = function(node, start, end, test, base, state) {
test = makeTest(test);
try {
if (!base) base = exports.base;
var c = function(node, st, override) {
var type = override || node.type;
if ((start == null || node.start <= start) &&
(end == null || node.end >= end))
base[type](node, st, c);
if (test(type, node) &&
(start == null || node.start == start) &&
(end == null || node.end == end))
throw new Found(node, st);
};
c(node, state);
} catch (e) {
if (e instanceof Found) return e;
throw e;
}
};
// Find the innermost node of a given type that contains the given
// position. Interface similar to findNodeAt.
exports.findNodeAround = function(node, pos, test, base, state) {
test = makeTest(test);
try {
if (!base) base = exports.base;
var c = function(node, st, override) {
var type = override || node.type;
if (node.start > pos || node.end < pos) return;
base[type](node, st, c);
if (test(type, node)) throw new Found(node, st);
};
c(node, state);
} catch (e) {
if (e instanceof Found) return e;
throw e;
}
};
// Find the outermost matching node after a given position.
exports.findNodeAfter = function(node, pos, test, base, state) {
test = makeTest(test);
try {
if (!base) base = exports.base;
var c = function(node, st, override) {
if (node.end < pos) return;
var type = override || node.type;
if (node.start >= pos && test(type, node)) throw new Found(node, st);
base[type](node, st, c);
};
c(node, state);
} catch (e) {
if (e instanceof Found) return e;
throw e;
}
};
// Find the outermost matching node before a given position.
exports.findNodeBefore = function(node, pos, test, base, state) {
test = makeTest(test);
if (!base) base = exports.base;
var max;
var c = function(node, st, override) {
if (node.start > pos) return;
var type = override || node.type;
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node))
max = new Found(node, st);
base[type](node, st, c);
};
c(node, state);
return max;
};
// Used to create a custom walker. Will fill in all missing node
// type properties with the defaults.
exports.make = function(funcs, base) {
if (!base) base = exports.base;
var visitor = {};
for (var type in base) visitor[type] = base[type];
for (var type in funcs) visitor[type] = funcs[type];
return visitor;
};
function skipThrough(node, st, c) { c(node, st); }
function ignore(_node, _st, _c) {}
// Node walkers.
var base = exports.base = {};
base.Program = base.BlockStatement = function(node, st, c) {
for (var i = 0; i < node.body.length; ++i)
c(node.body[i], st, "Statement");
};
base.Statement = skipThrough;
base.EmptyStatement = ignore;
base.ExpressionStatement = function(node, st, c) {
c(node.expression, st, "Expression");
};
base.IfStatement = function(node, st, c) {
c(node.test, st, "Expression");
c(node.consequent, st, "Statement");
if (node.alternate) c(node.alternate, st, "Statement");
};
base.LabeledStatement = function(node, st, c) {
c(node.body, st, "Statement");
};
base.BreakStatement = base.ContinueStatement = ignore;
base.WithStatement = function(node, st, c) {
c(node.object, st, "Expression");
c(node.body, st, "Statement");
};
base.SwitchStatement = function(node, st, c) {
c(node.discriminant, st, "Expression");
for (var i = 0; i < node.cases.length; ++i) {
var cs = node.cases[i];
if (cs.test) c(cs.test, st, "Expression");
for (var j = 0; j < cs.consequent.length; ++j)
c(cs.consequent[j], st, "Statement");
}
};
base.ReturnStatement = function(node, st, c) {
if (node.argument) c(node.argument, st, "Expression");
};
base.ThrowStatement = function(node, st, c) {
c(node.argument, st, "Expression");
};
base.TryStatement = function(node, st, c) {
c(node.block, st, "Statement");
if (node.handler) c(node.handler.body, st, "ScopeBody");
if (node.finalizer) c(node.finalizer, st, "Statement");
};
base.WhileStatement = function(node, st, c) {
c(node.test, st, "Expression");
c(node.body, st, "Statement");
};
base.DoWhileStatement = base.WhileStatement;
base.ForStatement = function(node, st, c) {
if (node.init) c(node.init, st, "ForInit");
if (node.test) c(node.test, st, "Expression");
if (node.update) c(node.update, st, "Expression");
c(node.body, st, "Statement");
};
base.ForInStatement = function(node, st, c) {
c(node.left, st, "ForInit");
c(node.right, st, "Expression");
c(node.body, st, "Statement");
};
base.ForInit = function(node, st, c) {
if (node.type == "VariableDeclaration") c(node, st);
else c(node, st, "Expression");
};
base.DebuggerStatement = ignore;
base.FunctionDeclaration = function(node, st, c) {
c(node, st, "Function");
};
base.VariableDeclaration = function(node, st, c) {
for (var i = 0; i < node.declarations.length; ++i) {
var decl = node.declarations[i];
if (decl.init) c(decl.init, st, "Expression");
}
};
base.Function = function(node, st, c) {
c(node.body, st, "ScopeBody");
};
base.ScopeBody = function(node, st, c) {
c(node, st, "Statement");
};
base.Expression = skipThrough;
base.ThisExpression = ignore;
base.ArrayExpression = function(node, st, c) {
for (var i = 0; i < node.elements.length; ++i) {
var elt = node.elements[i];
if (elt) c(elt, st, "Expression");
}
};
base.ObjectExpression = function(node, st, c) {
for (var i = 0; i < node.properties.length; ++i)
c(node.properties[i].value, st, "Expression");
};
base.FunctionExpression = base.FunctionDeclaration;
base.SequenceExpression = function(node, st, c) {
for (var i = 0; i < node.expressions.length; ++i)
c(node.expressions[i], st, "Expression");
};
base.UnaryExpression = base.UpdateExpression = function(node, st, c) {
c(node.argument, st, "Expression");
};
base.BinaryExpression = base.AssignmentExpression = base.LogicalExpression = function(node, st, c) {
c(node.left, st, "Expression");
c(node.right, st, "Expression");
};
base.ConditionalExpression = function(node, st, c) {
c(node.test, st, "Expression");
c(node.consequent, st, "Expression");
c(node.alternate, st, "Expression");
};
base.NewExpression = base.CallExpression = function(node, st, c) {
c(node.callee, st, "Expression");
if (node.arguments) for (var i = 0; i < node.arguments.length; ++i)
c(node.arguments[i], st, "Expression");
};
base.MemberExpression = function(node, st, c) {
c(node.object, st, "Expression");
if (node.computed) c(node.property, st, "Expression");
};
base.Identifier = base.Literal = ignore;
// A custom walker that keeps track of the scope chain and the
// variables defined in it.
function makeScope(prev, isCatch) {
return {vars: Object.create(null), prev: prev, isCatch: isCatch};
}
function normalScope(scope) {
while (scope.isCatch) scope = scope.prev;
return scope;
}
exports.scopeVisitor = exports.make({
Function: function(node, scope, c) {
var inner = makeScope(scope);
for (var i = 0; i < node.params.length; ++i)
inner.vars[node.params[i].name] = {type: "argument", node: node.params[i]};
if (node.id) {
var decl = node.type == "FunctionDeclaration";
(decl ? normalScope(scope) : inner).vars[node.id.name] =
{type: decl ? "function" : "function name", node: node.id};
}
c(node.body, inner, "ScopeBody");
},
TryStatement: function(node, scope, c) {
c(node.block, scope, "Statement");
if (node.handler) {
var inner = makeScope(scope, true);
inner.vars[node.handler.param.name] = {type: "catch clause", node: node.handler.param};
c(node.handler.body, inner, "ScopeBody");
}
if (node.finalizer) c(node.finalizer, scope, "Statement");
},
VariableDeclaration: function(node, scope, c) {
var target = normalScope(scope);
for (var i = 0; i < node.declarations.length; ++i) {
var decl = node.declarations[i];
target.vars[decl.id.name] = {type: "var", node: decl.id};
if (decl.init) c(decl.init, scope, "Expression");
}
}
});
});

92
thirdparty/esprima-master/.eslintrc vendored Executable file
View file

@ -0,0 +1,92 @@
{
"env": {
"browser": true,
"node": true,
"amd": true
},
"rules": {
"no-alert": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-bitwise": 0,
"no-catch-shadow": 2,
"no-console": 2,
"no-comma-dangle": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-div-regex": 2,
"no-dupe-keys": 2,
"no-else-return": 2,
"no-empty": 2,
"no-empty-class": 2,
"no-eq-null": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-func-assign": 2,
"no-floating-decimal": 2,
"no-implied-eval": 2,
"no-with": 2,
"no-fallthrough": 2,
"no-global-strict": 2,
"no-unreachable": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-unused-expressions": 0,
"no-octal": 2,
"no-octal-escape": 2,
"no-obj-calls": 2,
"no-multi-str": 2,
"no-new-wrappers": 2,
"no-new": 2,
"no-new-func": 2,
"no-native-reassign": 2,
"no-plusplus": 0,
"no-delete-var": 2,
"no-return-assign": 2,
"no-new-object": 2,
"no-label-var": 2,
"no-ternary": 0,
"no-self-compare": 2,
"no-sync": 2,
"no-underscore-dangle": 2,
"no-loop-func": 2,
"no-empty-label": 2,
"no-unused-vars": 0,
"no-script-url": 2,
"no-proto": 2,
"no-iterator": 2,
"no-mixed-requires": [0, false],
"no-wrap-func": 2,
"no-shadow": 2,
"no-use-before-define": 0,
"no-redeclare": 2,
"no-regex-spaces": 2,
"brace-style": 0,
"block-scoped-var": 0,
"camelcase": 2,
"complexity": [0, 11],
"consistent-this": [0, "that"],
"curly": 2,
"dot-notation": 2,
"eqeqeq": 2,
"guard-for-in": 0,
"max-depth": [0, 4],
"max-len": [0, 80, 4],
"max-params": [0, 3],
"max-statements": [0, 10],
"new-cap": 2,
"new-parens": 2,
"one-var": 0,
"quotes": [2, "single"],
"quote-props": 0,
"radix": 0,
"semi": 2,
"strict": 2,
"unnecessary-strict": 0,
"use-isnan": 2,
"wrap-iife": 2,
"wrap-regex": 0
}
}

2
thirdparty/esprima-master/.gitignore vendored Executable file
View file

@ -0,0 +1,2 @@
coverage
node_modules

119
thirdparty/esprima-master/.jscs.json vendored Executable file
View file

@ -0,0 +1,119 @@
{
"requireCurlyBraces": [
"if",
"else",
"for",
"while",
"do",
"try",
"catch"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],
"requireParenthesesAroundIIFE": true,
"requireSpacesInFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"requireMultipleVarDecl": true,
"disallowEmptyBlocks": true,
"disallowSpacesInsideObjectBrackets": true,
"disallowSpacesInsideParentheses": true,
"requireSpacesInsideObjectBrackets": "all",
"disallowDanglingUnderscores": true,
"disallowSpaceAfterObjectKeys": true,
"requireCommaBeforeLineBreak": true,
"requireOperatorBeforeLineBreak": [
"?",
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!==",
">",
">=",
"<",
"<="
],
"disallowLeftStickedOperators": [
"?",
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!==",
">",
">=",
"<",
"<="
],
"requireRightStickedOperators": ["!"],
"disallowRightStickedOperators": [
"?",
"+",
"/",
"*",
":",
"=",
"==",
"===",
"!=",
"!==",
">",
">=",
"<",
"<="
],
"requireLeftStickedOperators": [","],
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"requireSpaceBeforeBinaryOperators": [
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!=="
],
"requireSpaceAfterBinaryOperators": [
"+",
"-",
"/",
"*",
"=",
"==",
"===",
"!=",
"!=="
],
"disallowImplicitTypeConversion": ["numeric", "boolean", "binary", "string"],
"requireCamelCaseOrUpperCaseIdentifiers": true,
"disallowKeywords": ["with"],
"disallowMultipleLineStrings": true,
"validateLineBreaks": "LF",
"validateQuoteMarks": "'",
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowKeywordsOnNewLine": ["else"],
"requireLineFeedAtFileEnd": true,
"requireDotNotation": true
}

8
thirdparty/esprima-master/.npmignore vendored Executable file
View file

@ -0,0 +1,8 @@
.git
.travis.yml
/node_modules/
/assets/
/coverage/
/demo/
/test/3rdparty
/tools/

5
thirdparty/esprima-master/.travis.yml vendored Executable file
View file

@ -0,0 +1,5 @@
language: node_js
node_js:
- 0.8
- 0.9

20
thirdparty/esprima-master/CONTRIBUTING.md vendored Executable file
View file

@ -0,0 +1,20 @@
# Contribution Guide
This page describes how to contribute changes to Esprima.
Please do **not** create a pull request without reading this guide first. Failure to do so may result in the **rejection** of the pull request.
**1. Create a ticket in the [issue tracker](http://issues.esprima.org)**.
This serves as a placeholder for important feedback, review, or any future updates.
**2. Run all the tests**. This requires Node.js: `npm install` to set up, `npm test` to run the tests.
**3. Work on a feature branch**. If the change still needs some tweaks, it will not clutter the master branch.
**4. Write a reasonable commit message:**
* Keep the first line < 72 characters. Write additional paragraphs if necessary.
* Put the link to the ticket. This is important for cross-referencing purposes.
For more information, please check the [detailed contribution guide](http://esprima.org/doc/index.html#contribution).

49
thirdparty/esprima-master/ChangeLog vendored Executable file
View file

@ -0,0 +1,49 @@
2014-03-26: Version 1.1.1
* Fix token handling of forward slash after an array literal (issue 512)
2014-03-23: Version 1.1.0
* Optionally attach comments to the owning syntax nodes (issue 197)
* Simplify binary parsing with stack-based shift reduce (issue 352)
* Always include the raw source of literals (issue 376)
* Add optional input source information (issue 386)
* Tokenizer API for pure lexical scanning (issue 398)
* Improve the web site and its online demos (issue 337, 400, 404)
* Performance improvement for location tracking (issue 417, 424)
* Support HTML comment syntax (issue 451)
* Drop support for legacy browsers (issue 474)
2013-08-27: Version 1.0.4
* Minimize the payload for packages (issue 362)
* Fix missing cases on an empty switch statement (issue 436)
* Support escaped ] in regexp literal character classes (issue 442)
* Tolerate invalid left-hand side expression (issue 130)
2013-05-17: Version 1.0.3
* Variable declaration needs at least one declarator (issue 391)
* Fix benchmark's variance unit conversion (issue 397)
* IE < 9: \v should be treated as vertical tab (issue 405)
* Unary expressions should always have prefix: true (issue 418)
* Catch clause should only accept an identifier (issue 423)
* Tolerate setters without parameter (issue 426)
2012-11-02: Version 1.0.2
Improvement:
* Fix esvalidate JUnit output upon a syntax error (issue 374)
2012-10-28: Version 1.0.1
Improvements:
* esvalidate understands shebang in a Unix shell script (issue 361)
* esvalidate treats fatal parsing failure as an error (issue 361)
* Reduce Node.js package via .npmignore (issue 362)
2012-10-22: Version 1.0.0
Initial release.

19
thirdparty/esprima-master/LICENSE.BSD vendored Executable file
View file

@ -0,0 +1,19 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

24
thirdparty/esprima-master/README.md vendored Executable file
View file

@ -0,0 +1,24 @@
**Esprima** ([esprima.org](http://esprima.org), BSD license) is a high performance,
standard-compliant [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
parser written in ECMAScript (also popularly known as
[JavaScript](http://en.wikipedia.org/wiki/JavaScript>JavaScript)).
Esprima is created and maintained by [Ariya Hidayat](http://twitter.com/ariyahidayat),
with the help of [many contributors](https://github.com/ariya/esprima/contributors).
### Features
- Full support for ECMAScript 5.1 ([ECMA-262](http://www.ecma-international.org/publications/standards/Ecma-262.htm))
- Sensible [syntax tree format](http://esprima.org/doc/index.html#ast) compatible with Mozilla
[Parser AST](https://developer.mozilla.org/en/SpiderMonkey/Parser_API)
- Optional tracking of syntax node location (index-based and line-column)
- Heavily tested (> 700 [unit tests](http://esprima.org/test/) with [full code coverage](http://esprima.org/test/coverage.html))
- [Partial support](http://esprima.org/doc/es6.html) support for ECMAScript 6
Esprima serves as a **building block** for some JavaScript
language tools, from [code instrumentation](http://esprima.org/demo/functiontrace.html)
to [editor autocompletion](http://esprima.org/demo/autocomplete.html).
Esprima runs on many popular web browsers, as well as other ECMAScript platforms such as
[Rhino](http://www.mozilla.org/rhino), [Nashorn](http://openjdk.java.net/projects/nashorn/), and [Node.js](https://npmjs.org/package/esprima).
For more information, check the web site [esprima.org](http://esprima.org).

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

487
thirdparty/esprima-master/assets/json2.js vendored Executable file
View file

@ -0,0 +1,487 @@
/*
http://www.JSON.org/json2.js
2011-10-19
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
This code should be minified before deployment.
See http://javascript.crockford.com/jsmin.html
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
NOT CONTROL.
This file creates a global JSON object containing two methods: stringify
and parse.
JSON.stringify(value, replacer, space)
value any JavaScript value, usually an object or array.
replacer an optional parameter that determines how object
values are stringified for objects. It can be a
function or an array of strings.
space an optional parameter that specifies the indentation
of nested structures. If it is omitted, the text will
be packed without extra whitespace. If it is a number,
it will specify the number of spaces to indent at each
level. If it is a string (such as '\t' or '&nbsp;'),
it contains the characters used to indent at each level.
This method produces a JSON text from a JavaScript value.
When an object value is found, if the object contains a toJSON
method, its toJSON method will be called and the result will be
stringified. A toJSON method does not serialize: it returns the
value represented by the name/value pair that should be serialized,
or undefined if nothing should be serialized. The toJSON method
will be passed the key associated with the value, and this will be
bound to the value
For example, this would serialize Dates as ISO strings.
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
You can provide an optional replacer method. It will be passed the
key and value of each member, with this bound to the containing
object. The value that is returned from your method will be
serialized. If your method returns undefined, then the member will
be excluded from the serialization.
If the replacer parameter is an array of strings, then it will be
used to select the members to be serialized. It filters the results
such that only members with keys listed in the replacer array are
stringified.
Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined.
The optional space parameter produces a stringification of the
value that is filled with line breaks and indentation to make it
easier to read.
If the space parameter is a non-empty string, then that string will
be used for indentation. If the space parameter is a number, then
the indentation will be that many spaces.
Example:
text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
text = JSON.stringify([new Date()], function (key, value) {
return this[key] instanceof Date ?
'Date(' + this[key] + ')' : value;
});
// text is '["Date(---current time---)"]'
JSON.parse(text, reviver)
This method parses a JSON text to produce an object or array.
It can throw a SyntaxError exception.
The optional reviver parameter is a function that can filter and
transform the results. It receives each of the keys and values,
and its return value is used instead of the original value.
If it returns what it received, then the structure is not modified.
If it returns undefined then the member is deleted.
Example:
// Parse the text. Values that look like ISO date strings will
// be converted to Date objects.
myData = JSON.parse(text, function (key, value) {
var a;
if (typeof value === 'string') {
a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
});
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
var d;
if (typeof value === 'string' &&
value.slice(0, 5) === 'Date(' &&
value.slice(-1) === ')') {
d = new Date(value.slice(5, -1));
if (d) {
return d;
}
}
return value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
*/
/*jslint evil: true, regexp: true */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
var JSON;
if (!JSON) {
JSON = {};
}
(function () {
'use strict';
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function (key) {
return isFinite(this.valueOf())
? this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z'
: null;
};
String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function (key) {
return this.valueOf();
};
}
var cx = new RegExp('[\u0000\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]', 'g'),
escapable = new RegExp('[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]', 'g'),
gap,
indent,
meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string'
? c
: '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
function str(key, holder) {
// Produce a string from holder[key].
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0
? '[]'
: gap
? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
: '[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === 'string') {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0
? '{}'
: gap
? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
: '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = '';
indent = '';
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === 'string') {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
return str('', {'': value});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== 'function') {
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return typeof reviver === 'function'
? walk({'': j}, '')
: j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('JSON.parse');
};
}
}());

View file

@ -0,0 +1,419 @@
.textview {
background-color: white;
padding: 1px 2px;
}
.textviewContainer {
background-color: #eaeaea;
font-family: 'Lucida Sans Unicode', 'Lucida Grande', Verdana, Arial, Helvetica, Myriad, Tahoma, clean, sans-serif;
font-size: 10pt;
min-width: 50px;
min-height: 50px;
}
.textviewContent {
cursor: auto;
}
.textviewLeftRuler {
border-right: 1px solid #eaeaea;
}
.textviewRightRuler {
border-left: 1px solid #eaeaea;
}
.ruler {
}
.ruler.annotations {
width: 16px;
}
.ruler.folding {
background-color: white;
width: 14px;
}
.ruler.lines {
background-color: white;
text-align: right;
}
.ruler.overview {
width: 14px;
}
.rulerLines {
color: silver;
}
.rulerLines.even
.rulerLines.odd {
}
.annotation {
}
.annotation.error,
.annotation.warning,
.annotation.task,
.annotation.bookmark,
.annotation.breakpoint,
.annotation.collapsed,
.annotation.expanded,
.annotation.currentBracket,
.annotation.matchingBracket,
.annotation.currentLine,
.annotation.matchingSearch,
.annotation.readOccurrence,
.annotation.writeOccurrence,
.annotation.currentSearch {
}
.annotationHTML {
cursor: pointer;
width: 16px;
height: 16px;
display: inline-block;
vertical-align: middle;
background-position: center;
background-repeat: no-repeat;
}
.annotationHTML.error {
background-image: url("data:image/gif;base64,R0lGODlhEAAQANUAAPVvcvWHiPVucvRuc+ttcfV6f91KVN5LU99PV/FZY/JhaM4oN84pONE4Rd1ATfJLWutVYPRgbdxpcsgWKMgZKs4lNfE/UvE/U+artcpdSc5uXveimslHPuBhW/eJhfV5efaCgO2CgP+/v+PExP///////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACUALAAAAAAQABAAAAZ+wJJwSCwaScgkySgkjTQZTkYzWhadnE5oE+pwqkSshwQqkzxfa4kkQXxEpA9J9EFI1KQGQQBAigYCBA14ExEWF0gXihETeA0QD3AkD5QQg0NsDnAJmwkOd5gYFSQKpXAFDBhqaxgLBwQBBAapq00YEg0UDRKqTGtKSL7Cw8JBADs=");
}
.annotationHTML.warning {
background-image: url("data:image/gif;base64,R0lGODlhEAAQANUAAP7bc//egf/ij/7ijv/jl/7kl//mnv7lnv/uwf7CTP7DTf7DT/7IW//Na/7Na//NbP7QdP/dmbltAIJNAF03AMSAJMSCLKqASa2DS6uBSquCSrGHTq6ETbCHT7WKUrKIUcCVXL+UXMOYX8GWXsSZYMiib6+ETbOIUcOXX86uhd3Muf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACsALAAAAAAQABAAAAZowJVwSCwaj0ihikRSJYcoBEL0XKlGkcjImQQhJBREKFnyICoThKeE/AAW6AXgdPyUAgrLJBEo0YsbAQyDhAEdRRwDDw8OaA4NDQImRBgFEJdglxAEGEQZKQcHBqOkKRpFF6mqq1WtrUEAOw==");
}
.annotationHTML.task {
background-image: url("data:image/gif;base64,R0lGODlhEAAQAMQAAN7s4uTy6ICvY423c2WdP2ugR3mqWYeza2ejOl6VNVqPM1aJMURsJ2GaOnKlT8PbsbPDqGmmO1OCLk98LEhxKGWfOWKaN0t2KkJoJf///////wAAAAAAAAAAAAAAAAAAACH5BAEAABoALAAAAAAQABAAAAVmoCaOZDk+UaquDxkNcCxHJHLceI6QleD/vkCmQrIYjkiDMGAhJRzQ6NKRICkKgYJ2qVWQFktCmEBYkCSNZSbQaDckpAl5TCZMSBdtAaDXX0gUUYJRFCQMSYgGDCQQGI6PkBAmkyUhADs=");
}
.annotationHTML.bookmark {
background-image: url("data:image/gif;base64,R0lGODlhEAAQALMAAP7//+/VNPzZS/vifeumAPrBOOSlHOSuRP///wAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAgALAAAAAAQABAAAARLEMlJq5Xn3EvIrkenfRIhCB5pmKhRdbAJAGhssuc8n6eJoAKdkOaTAIdEQeWoA1oGsiZhYAnIcqiApVPjElyUbkFSgCkn5XElLYkAADs=");
}
.annotationHTML.breakpoint {
background-image: url("data:image/gif;base64,R0lGODlhEAAQANUAAFheoFxkoFxnpmt0pmZxpnF7rYyWwmJwpnaFs3aDrWt8rXGBrYycwmZ3mXuNs42cu77F03GIs3aJrYGVu2J5oKCuxeDj6LK/03GLrYieu3aIoIygu6m4zcLN3MTM1m6Rs2aLriRgkSZilXGXtoGcs7LD0QBLhSZikihol3ScubrO2Yaqu5q4xpO0wpm7yabF0ZO9yaXI0r3X3tHj6P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAADQALAAAAAAQABAAAAafQJpwSCwWLYZBIDAwWIw0A+FFpW6aRUPCxe1yE4ahhdCCxWSzmSwGgxGeUceKpUqhUCkVa7UK0wgkJCUjJoUmIyWBBEIEGhoeJ4YmJx6OAUIADQ0QIZIhEJoAQgEUFBUgkiAVpZdRCxIPFx8iIh8XDw4FfhYHDhgZHB0dHBkYEwdwUQoTEc3OEwp+QwYHCBMMDBMIB9JESAJLAk5Q5EVBADs=");
}
.annotationHTML.collapsed {
width: 14px;
height: 14px;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAWBJREFUeNpi/P//PwMlgImBQkCxASzoAp++fo+6de+Z+fXbD/Jev/nAICoiwKCpqrBBTUlqNR835zJ09YzIYfDxy7eo/cevLmXlYGNQUJAEahZieP3mHcODB08Zfv/4w+BoqR3Nz8O1DKcXzt94HPqXmZlBU1+LgZNfkMHazIOBA0hr6uswgMTP33gYijcMLlx/EMAnLs7w7sc/hg9AG0HgPZB+B8S84hJA+UcBeMPg+at3DJIMnAxZzt5wsUhnXzDdsmIVWB6vAcLCfAys3z4wzN64huEfkJ/uH8IwexOQDQymD2/fgeXxekFLRWHD51evGDhZGRi4WSFSnCwgNjB2Xr1m0AbK4zXAQkdhNdPf3wx3r91g+PruLcOqnasYvn54x3Dv2k0G5r+/GMyB8nijEQTefvoadeH6w9Cbtx8GvH//kUFQkJ9BQ1V+g76m/GphPu5lBA0YenmBYgMAAgwA34GIKjmLxOUAAAAASUVORK5CYII=");
}
.annotationHTML.expanded {
width: 14px;
height: 14px;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAT5JREFUeNrUksFKw0AURW+mTWw67SSEiG209U90r4jddFO34l+5U0HdZCHiFwiCOz9AlMSmGEpMOqk1TWJSFGyFbATR2dyZd+Dw3mOENE3xkyP8PYHrBT3OX7uW43ZefA6FUaw1dJPSyrmu1k8KBYOh37Od4XFZLEPXFdRrFMGIw3U9TKMYqw1tb0VjcxLy9eEF425CCIxWE5JcxSQGxCyNloG87gXhwWIHc4J767lTZQw8ShFGSZbxRyaQmZJxd3NRUJ6ffwQNEi6PzG/L2tjdmvFCgcKqKL2F2Olu43MzggDka+IjPuOFI7Sbujn2fUglYKkkzFIi+R0I/QDrGS8UqDX5QkhiOHYfE84hkhSTkGNgOyDJFCzjhYLTq+vDtrG8r1LZtB6fcHtzB+uhD5VWzLx+lvF/8JV/XfAuwADsrJbMGG4l4AAAAABJRU5ErkJggg==");
}
.annotationHTML.multiple {
background-image: url("data:image/gif;base64,R0lGODlhEAAQANUAAOdpa+yJiuFYXOFYXeBYXONwded8f+NwdmhwkHB4iPr7/ezx+fP2+2h4kOzy+Wh4iPr8/gCBwTaczjaXyjaYyjaXyTaYyfr8/QCMzQCMzACHxzao2jal2Dak1zag03iAgI/Ckn64fZrHmX+4fZLCianPopPCiarOoqbLlafLlbnXq7nWq6fLlMTcsoCIeJCQcIiIeKCYaJiQcO16ee16evGVlfGWlfahn/ahoPWhn/WhoPe1tP///////wAAAAAAACH5BAEAAD0ALAAAAAAQABAAAAaRwJ5wSCwaj8WYcslcDmObaDTGq1Zjzw4mk+FQIRcFTzaUeTRoj4zHaI+HL0lkLnnxFgsH7zWEWSoTFBMwVlUwQy6JMDCJjYwuQx8tk5MfOzk4OjcfkSssKCkqHzY0MzQ1nEIJJSYkJCcJAQCzAQlDDyIjISMiCQYEAgMGD0MNIMfHDQUHBc3EQgjR0tPSSNY9QQA7");
}
.annotationHTML.overlay {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAHCAYAAADEUlfTAAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJEAQvB2JVdrAAAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAAAD1JREFUCNdtjkESADAEAzemf69f66HMqGlOIhYiFRFRtSQBWAY7mzx+EDTL6sSgb1jTk7Q87rxyqe37fXsAa78gLyZnRgEAAAAASUVORK5CYII=");
background-position: right bottom;
position: relative;
top: -16px;
}
.annotationHTML.currentBracket {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sLEBULCGQmEKAAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAnklEQVQ4y7VTsRHDIBATJg1HCUzAHEzFBExAzwZsRMkE9gifKhc72ODYibr/+xcnoQdugq0LAujEwmbn0UxQh4OxpjX1XgshwFqLnPM5PQTQGlprWpbl3RhJ/CSQUm7qPYLp7i8cEpRSoJT6ju0lIaVEQgiKMQ4lHHpQayVjzHWCn5jIOcc8z9dMBADvPZxz3SC1tzCI8vgWdvL+VzwB8JSj2GFTyxIAAAAASUVORK5CYII=");
}
.annotationHTML.matchingBracket {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sLEBUMAsuyb3kAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAoklEQVQ4y61TsQ3EIAw80DcI0USKGIApWIsB2IGGKbJPugxBR3VfvfRRCOSTvw7LPuPzGXgI8f0gwAsFu5rXIYMdDiEOIdnKW5YFzjnEGH+bhwA/KKVwmibu0BhRnpEZY1BrHTaVT7fQJZjnGeu63tOAJFNKVEox53yqQZfAWstt27oidgm01ve3UEqBaBjnspG89wgh3LiFgZXHt3Dh23/FGxKViehm0X85AAAAAElFTkSuQmCC");
}
.annotationHTML.currentLine {
background-image: url("data:image/gif;base64,R0lGODlhEAAQAMQAALxe0bNWzbdZzrlb0KpPx61RybBTy6VLxadNxZGctIeUroyYsG92hHyMqIKRq2l9nmyAoHGDonaIpStXj6q80k1aXf///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABYALAAAAAAQABAAAAVCoCWOZGmeKDql5ppOMGXBk/zOoltSNO6XrlXwxIPNYiMGq8SoLC2MaNPygEQkDYdikUg6LQcEoWAICAaA5HPNLoUAADs=");
}
.annotationHTML.matchingSearch {
background-image: url("data:image/gif;base64,R0lGODlhEAAQANUAALClrLu1ubOpsKqdp6eapKufqMTAw7attLSrsrGnr62jq8C7v765vaebpb22vLmyuMbCxsnGycfEx8G+wcrIysTBxUltof//yf///v70jergpPvws+nWc/npqvrpqvrpq/raffffnvXVkfTVkvXUkd+9f+SiOemvV+uyXa2OX7mYZqeIXKuNX/ClO7KQYqiIXJ59Vp19VpFvTo9uTZBvTpNyUJNyUf///////wAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAADgALAAAAAAQABAAAAZ4QJxwSCwajS2aS1U6DlunzcagcuKgG4sn5HJiLZ2QiHbEbj6hEapVTKVYr3OItG5TIhVGLF0npigUEAsPAjV9Q24pEhMBCAoybEUmGRcrDgcAAzNGkxcYNzAJBQSbRJ0YqBc2DaVEHJ6pGTStRBqfGBcZILRWvThBADs=");
}
.annotationHTML.currentSearch {
background-image: url("data:image/gif;base64,R0lGODlhEAAQANUAALClrLu1ubOpsKqdp6eapKufqMTAw7attLSrsrGnr62jq8C7v765vaebpb22vLmyuMbCxsnGycfEx8G+wcrIysTBxUltof//yf///v70jergpPvws+nWc/npqvrpqvrpq/raffffnvXVkfTVkvXUkd+9f+SiOemvV+uyXa2OX7mYZqeIXKuNX/ClO7KQYqiIXJ59Vp19VpFvTo9uTZBvTpNyUJNyUf///////wAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAADgALAAAAAAQABAAAAZ4QJxwSCwajS2aS1U6DlunzcagcuKgG4sn5HJiLZ2QiHbEbj6hEapVTKVYr3OItG5TIhVGLF0npigUEAsPAjV9Q24pEhMBCAoybEUmGRcrDgcAAzNGkxcYNzAJBQSbRJ0YqBc2DaVEHJ6pGTStRBqfGBcZILRWvThBADs=");
}
.annotationOverview {
cursor: pointer;
border-radius: 2px;
left: 2px;
width: 8px;
}
.annotationOverview.task {
background-color: lightgreen;
border: 1px solid green;
}
.annotationOverview.breakpoint {
background-color: lightblue;
border: 1px solid blue;
}
.annotationOverview.bookmark {
background-color: yellow;
border: 1px solid orange;
}
.annotationOverview.error {
background-color: lightcoral;
border: 1px solid darkred;
}
.annotationOverview.warning {
background-color: Gold;
border: 1px solid black;
}
.annotationOverview.currentBracket {
background-color: lightgray;
border: 1px solid red;
}
.annotationOverview.matchingBracket {
background-color: lightgray;
border: 1px solid red;
}
.annotationOverview.currentLine {
background-color: #EAF2FE;
border: 1px solid black;
}
.annotationOverview.matchingSearch {
background-color: #C3E1FF;
border: 1px solid black;
}
.annotationOverview.currentSearch {
background-color: #53D1FF;
border: 1px solid black;
}
.annotationOverview.readOccurrence {
background-color: lightgray;
border: 1px solid black;
}
.annotationOverview.writeOccurrence {
background-color: Gold;
border: 1px solid darkred;
}
.annotationRange {
background-repeat: repeat-x;
background-position: left bottom;
}
.annotationRange.task {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sLDhEoIrb7JmcAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAGUlEQVQI12NggIH/DGdhDCM45z/DfyiBAADgdQjGhI/4DAAAAABJRU5ErkJggg==");
}
.annotationRange.breakpoint {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sLDhEqHTKradgAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAIklEQVQI11XJMQ0AMAzAMGMafwrFlD19+sUKIJTFo9k+B/kQ+Qr2bIVKOgAAAABJRU5ErkJggg==");
}
.annotationRange.bookmark {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
}
.annotationRange.error {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJDw4cOCW1/KIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg==");
}
.annotationRange.warning {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sJFhQXEbhTg7YAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII=");
}
.annotationRange.currentBracket {
}
.annotationRange.matchingBracket {
outline: 1px solid red;
}
.annotationRange.currentSearch {
background-color: #53D1FF;
}
.annotationRange.matchingSearch {
background-color: #C3E1FF;
}
.annotationRange.currentSearch {
background-color: #53D1FF;
}
.annotationRange.readOccurrence {
background-color: lightgray;
}
.annotationRange.writeOccurrence {
background-color: yellow;
}
.annotationLine {
}
.annotationLine.currentLine {
background-color: #EAF2FE;
}
.tooltip .textview {
color: InfoText !important;
background-color: InfoBackground !important;
padding: 0px;
}
.textviewTooltip {
font-family: monospace;
font-size: 10pt;
background-color: InfoBackground;
color: InfoText;
padding: 2px;
border-radius: 4px;
border: 1px solid black;
z-index: 100;
position: fixed;
overflow: hidden;
white-space: pre;
}
.textviewTooltip em {
font-style: normal;
font-weight: bold;
}
.tooltip .annotationLine.currentLine {
background-color: transparent;
}
.contentassist {
display: none;
background-color: #FFFFFF;
padding: 2px;
top: 100px;
left: 100px;
border: 1px solid #CCCCCC;
z-index:10;
cursor: default;
overflow: auto;
height: 150px;
width: 200px;
}
.contentassist .selected {
background-color: #EAF2FE;
}
.token_singleline_comment {
color: green;
}
.token_multiline_comment {
color: green;
}
.token_doc_comment {
color: #00008F;
}
a.token_singleline_comment, a.token_multiline_comment, a.token_doc_comment {
text-decoration: underline;
}
.token_doc_html_markup {
color: #7F7F9F;
}
.token_doc_tag {
color: #7F9FBF;
}
.token_task_tag {
color: #7F9FBF;
}
.token_string {
color: blue;
}
.token_number {
color: blue;
}
.token_keyword {
color: darkred;
font-weight: bold;
}
.token_space {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAIAAABv85FHAAAABnRSTlMA/wAAAACkwsAdAAAAIUlEQVR4nGP4z8CAC+GUIEXuABhgkTuABEiRw2cmae4EAH05X7xDolNRAAAAAElFTkSuQmCC");
background-repeat: no-repeat;
background-position: center center;
}
.token_tab {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAJCAIAAACJ2loDAAAABnRSTlMA/wD/AP83WBt9AAAAMklEQVR4nGP4TwRgoK6i52c3bz5w6zMSA6tJn28d2Lx589nnCAYu63AaSLxJRLoJPwAAeNk0aG4opfMAAAAASUVORK5CYII=");
background-repeat: no-repeat;
background-position: left center;
}
.line_caret {
background-color: #EAF2FE;
}
.comment {
color: green;
}
.comment-block-documentation {
color: #00008F;
}
.constant {
font-style: italic;
color: blue;
}
.constant-character-entity {
font-style: normal;
}
.entity {
color: #3f7f7f;
}
.entity-name-function, .entity-name-type {
font-weight: bold;
}
.invalid-illegal {
color: white;
background-color: red;
}
.invalid-deprecated {
text-decoration: line-through;
}
.invalid {
color: red;
font-weight: bold;
}
.keyword-control {
color: #7F0055;
font-weight: bold;
}
.keyword-operator {
color: #ddd;
}
.markup-heading {
font-weight: bold;
}
.markup-quote {
font-style: italic;
}
.meta-tag {
color: #3f7f7f;
}
.storage {
color: #7F0055;
}
.string {
color: blue;
}
.support {
color: #21439c;
}
.variable {
color: #0000c0;
}
.variable-parameter {
color: black;
}
.variable-language {
color: #7F0055;
font-weight: bold;
}
.entity-name-tag {
color: #3f7f7f;
}
.entity-other-attribute-name {
color: #7f007f;
}
.punctuation-definition-comment {
color: #3f5fbf;
}
.punctuation-definition-string {
color: blue;
}
.string-quoted {
color: #2a00ff;
}
.cm-meta { color: #00008F; }
.cm-keyword { font-weight: bold; color: #7F0055; }
.cm-atom { color: #21439c; }
.cm-number { color: black; }
.cm-def { color: green; }
.cm-variable { color: black; }
.cm-variable-2 { color: #004080; }
.cm-variable-3 { color: #004080; }
.cm-property { color: black; }
.cm-operator { color: #222; }
.cm-comment { color: green; }
.cm-string { color: blue; }
.cm-error { color: #ff0000; }
.cm-qualifier { color: gray; }
.cm-builtin { color: #7F0055; }
.cm-bracket { color: white; background-color: gray; }
.cm-tag { color: #3f7f7f; }
.cm-attribute { color: #7f007f; }

View file

@ -0,0 +1,764 @@
/*
Copyright (c) 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Mihai Sucan (Mozilla Foundation) - fix for Bug#334583 Bug#348471 Bug#349485 Bug#350595 Bug#360726 Bug#361180 Bug#362835 Bug#362428 Bug#362286 Bug#354270 Bug#361474 Bug#363945 Bug#366312 Bug#370584
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
Felipe Heidrich (IBM Corporation) - initial API and implementation
Silenio Quarti (IBM Corporation) - initial API and implementation
Copyright (c) 2009, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
Copyright (c) 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
Copyright (c) 2012 VMware, Inc.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
Andrew Eisenberg - rename to jsTemplateContentAssist.js
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2011, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Copyright (c) 2010, 2012 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors: IBM Corporation - initial API and implementation
Alex Lakatos - fix for bug#369781
Copyright (c) 2013 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
RequireJS i18n 1.0.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
Copyright (c) 2011 IBM Corporation and others.
All rights reserved. This program and the accompanying materials are made
available under the terms of the Eclipse Public License v1.0
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
Contributors:
IBM Corporation - initial API and implementation
*/
var requirejs,require,define;
(function(s){function r(c,j){var q,a,b,d,e,i,f,g,k,h=j&&j.split("/"),l=o.map,m=l&&l["*"]||{};if(c&&c.charAt(0)===".")if(j){h=h.slice(0,h.length-1);c=h.concat(c.split("/"));for(g=0;g<c.length;g+=1)if(q=c[g],q===".")c.splice(g,1),g-=1;else if(q==="..")if(g===1&&(c[2]===".."||c[0]===".."))break;else g>0&&(c.splice(g-1,2),g-=2);c=c.join("/")}else c.indexOf("./")===0&&(c=c.substring(2));if((h||m)&&l){q=c.split("/");for(g=q.length;g>0;g-=1){a=q.slice(0,g).join("/");if(h)for(k=h.length;k>0;k-=1)if(b=l[h.slice(0,
k).join("/")])if(b=b[a]){d=b;e=g;break}if(d)break;!i&&m&&m[a]&&(i=m[a],f=g)}!d&&i&&(d=i,e=f);d&&(q.splice(0,e,d),c=q.join("/"))}return c}function p(c,j){return function(){return a.apply(s,q.call(arguments,0).concat([c,j]))}}function f(c){return function(j){return r(j,c)}}function h(c){return function(j){i[c]=j}}function l(u){if(j.call(g,u)){var q=g[u];delete g[u];c[u]=!0;e.apply(s,q)}if(!j.call(i,u)&&!j.call(c,u))throw Error("No "+u);return i[u]}function k(c){var j,q=c?c.indexOf("!"):-1;q>-1&&(j=
c.substring(0,q),c=c.substring(q+1,c.length));return[j,c]}function m(c){return function(){return o&&o.config&&o.config[c]||{}}}var e,a,b,d,i={},g={},o={},c={},j=Object.prototype.hasOwnProperty,q=[].slice;b=function(c,j){var q,a=k(c),b=a[0],c=a[1];b&&(b=r(b,j),q=l(b));b?c=q&&q.normalize?q.normalize(c,f(j)):r(c,j):(c=r(c,j),a=k(c),b=a[0],c=a[1],b&&(q=l(b)));return{f:b?b+"!"+c:c,n:c,pr:b,p:q}};d={require:function(c){return p(c)},exports:function(c){var j=i[c];return typeof j!=="undefined"?j:i[c]={}},
module:function(c){return{id:c,uri:"",exports:i[c],config:m(c)}}};e=function(q,a,e,n){var B,f,t,o,k=[],m,n=n||q;if(typeof e==="function"){a=!a.length&&e.length?["require","exports","module"]:a;for(o=0;o<a.length;o+=1)if(t=b(a[o],n),f=t.f,f==="require")k[o]=d.require(q);else if(f==="exports")k[o]=d.exports(q),m=!0;else if(f==="module")B=k[o]=d.module(q);else if(j.call(i,f)||j.call(g,f)||j.call(c,f))k[o]=l(f);else if(t.p)t.p.load(t.n,p(n,!0),h(f),{}),k[o]=i[f];else throw Error(q+" missing "+f);a=e.apply(i[q],
k);if(q)if(B&&B.exports!==s&&B.exports!==i[q])i[q]=B.exports;else if(a!==s||!m)i[q]=a}else q&&(i[q]=e)};requirejs=require=a=function(c,j,q,n,B){if(typeof c==="string")return d[c]?d[c](j):l(b(c,j).f);else c.splice||(o=c,j.splice?(c=j,j=q,q=null):c=s);j=j||function(){};typeof q==="function"&&(q=n,n=B);n?e(s,c,j,q):setTimeout(function(){e(s,c,j,q)},4);return a};a.config=function(c){o=c;return a};define=function(c,q,a){q.splice||(a=q,q=[]);!j.call(i,c)&&!j.call(g,c)&&(g[c]=[c,q,a])};define.amd={jQuery:!0}})();
define("almond",function(){});
define("orion/editor/eventTarget",[],function(){function s(){}s.addMixin=function(r){var p=s.prototype,f;for(f in p)p.hasOwnProperty(f)&&(r[f]=p[f])};s.prototype={addEventListener:function(r,p,f){if(!this._eventTypes)this._eventTypes={};var h=this._eventTypes[r];h||(h=this._eventTypes[r]={level:0,listeners:[]});h.listeners.push({listener:p,useCapture:f})},dispatchEvent:function(r){var p=r.type;this._dispatchEvent("pre"+p,r);this._dispatchEvent(p,r);this._dispatchEvent("post"+p,r)},_dispatchEvent:function(r,
p){var f=this._eventTypes?this._eventTypes[r]:null;if(f){var h=f.listeners;try{if(f.level++,h)for(var l=0,k=h.length;l<k;l++)if(h[l]){var m=h[l].listener;typeof m==="function"?m.call(this,p):m.handleEvent&&typeof m.handleEvent==="function"&&m.handleEvent(p)}}finally{if(f.level--,f.compact&&f.level===0){for(l=h.length-1;l>=0;l--)h[l]||h.splice(l,1);h.length===0&&delete this._eventTypes[r];f.compact=!1}}}},isListening:function(r){return!this._eventTypes?!1:this._eventTypes[r]!==void 0},removeEventListener:function(r,
p,f){if(this._eventTypes){var h=this._eventTypes[r];if(h){for(var l=h.listeners,k=0,m=l.length;k<m;k++){var e=l[k];if(e&&e.listener===p&&e.useCapture===f){h.level!==0?(l[k]=null,h.compact=!0):l.splice(k,1);break}}l.length===0&&delete this._eventTypes[r]}}}};return{EventTarget:s}});
define("orion/editor/util",[],function(){var s=navigator.userAgent,r=parseFloat(s.split("MSIE")[1])||void 0,p=parseFloat(s.split("Firefox/")[1]||s.split("Minefield/")[1])||void 0,f=s.indexOf("Opera")!==-1,h=parseFloat(s.split("Chrome/")[1])||void 0,l=s.indexOf("Safari")!==-1&&!h,k=parseFloat(s.split("WebKit/")[1])||void 0,m=s.indexOf("Android")!==-1,e=s.indexOf("iPad")!==-1,s=s.indexOf("iPhone")!==-1,a=e||s,b=navigator.platform.indexOf("Mac")!==-1,d=navigator.platform.indexOf("Win")!==-1,i=navigator.platform.indexOf("Linux")!==
-1;return{formatMessage:function(a){var b=arguments;return a.replace(/\$\{([^\}]+)\}/g,function(c,j){return b[(j<<0)+1]})},createElement:function(a,b){return a.createElementNS?a.createElementNS("http://www.w3.org/1999/xhtml",b):a.createElement(b)},isIE:r,isFirefox:p,isOpera:f,isChrome:h,isSafari:l,isWebkit:k,isAndroid:m,isIPad:e,isIPhone:s,isIOS:a,isMac:b,isWindows:d,isLinux:i,platformDelimiter:d?"\r\n":"\n"}});
define("orion/editor/textModel",["orion/editor/eventTarget","orion/editor/util"],function(s,r){function p(f,h){this._lastLineIndex=-1;this._text=[""];this._lineOffsets=[0];this.setText(f);this.setLineDelimiter(h)}p.prototype={find:function(f){if(this._text.length>1)this._text=[this._text.join("")];var h=f.string,l=h;!f.regex&&h&&(l=h.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&"));var k=null,m;if(l){var h=f.reverse,e=f.wrap,a=f.wholeWord,b=f.caseInsensitive,d=f.start||0,i=f.end,f=f.end!==void 0,g=
"";g.indexOf("g")===-1&&(g+="g");b&&g.indexOf("i")===-1&&(g+="i");a&&(l="\\b"+l+"\\b");var o=this._text[0],c,j,q=0;f&&(o=o.substring(d,i),q=d);var u=RegExp(l,g);if(h)m=function(){var a=null;for(u.lastIndex=0;;){j=u.lastIndex;c=u.exec(o);if(j===u.lastIndex)return null;if(c){if(!(c.index<d)){if(!e||a)break;d=o.length}a={start:c.index+q,end:u.lastIndex+q}}else break}if(a)d=a.start;return a};else{if(!f)u.lastIndex=d;m=function(){for(;;){j=u.lastIndex;c=u.exec(o);if(j===u.lastIndex)break;if(c)return{start:c.index+
q,end:u.lastIndex+q};if(!(j!==0&&e))break}return null}}k=m()}return{next:function(){var c=k;c&&(k=m());return c},hasNext:function(){return k!==null}}},getCharCount:function(){for(var f=0,h=0;h<this._text.length;h++)f+=this._text[h].length;return f},getLine:function(f,h){var l=this.getLineCount();if(!(0<=f&&f<l))return null;var k=this._lineOffsets[f];if(f+1<l){l=this.getText(k,this._lineOffsets[f+1]);if(h)return l;for(var k=l.length,m;(m=l.charCodeAt(k-1))===10||m===13;)k--;return l.substring(0,k)}else return this.getText(k)},
getLineAtOffset:function(f){var h=this.getCharCount();if(!(0<=f&&f<=h))return-1;var l=this.getLineCount();if(f===h)return l-1;var k,m,e=this._lastLineIndex;if(0<=e&&e<l&&(k=this._lineOffsets[e],m=e+1<l?this._lineOffsets[e+1]:h,k<=f&&f<m))return e;for(var a=l,b=-1;a-b>1;)if(e=Math.floor((a+b)/2),k=this._lineOffsets[e],m=e+1<l?this._lineOffsets[e+1]:h,f<=k)a=e;else if(f<m){a=e;break}else b=e;return this._lastLineIndex=a},getLineCount:function(){return this._lineOffsets.length},getLineDelimiter:function(){return this._lineDelimiter},
getLineEnd:function(f,h){var l=this.getLineCount();if(!(0<=f&&f<l))return-1;if(f+1<l){l=this._lineOffsets[f+1];if(h)return l;for(var k=this.getText(Math.max(this._lineOffsets[f],l-2),l),m=k.length,e;(e=k.charCodeAt(m-1))===10||e===13;)m--;return l-(k.length-m)}else return this.getCharCount()},getLineStart:function(f){return!(0<=f&&f<this.getLineCount())?-1:this._lineOffsets[f]},getText:function(f,h){f===void 0&&(f=0);h===void 0&&(h=this.getCharCount());if(f===h)return"";for(var l=0,k=0,m;k<this._text.length;){m=
this._text[k].length;if(f<=l+m)break;l+=m;k++}for(var e=l,a=k;k<this._text.length;){m=this._text[k].length;if(h<=l+m)break;l+=m;k++}if(a===k)return this._text[a].substring(f-e,h-l);e=this._text[a].substring(f-e);l=this._text[k].substring(0,h-l);return e+this._text.slice(a+1,k).join("")+l},onChanging:function(f){return this.dispatchEvent(f)},onChanged:function(f){return this.dispatchEvent(f)},setLineDelimiter:function(f,h){f==="auto"&&(f=void 0,this.getLineCount()>1&&(f=this.getText(this.getLineEnd(0),
this.getLineEnd(0,!0))));this._lineDelimiter=f?f:r.platformDelimiter;if(h){var l=this.getLineCount();if(l>1){for(var k=Array(l),m=0;m<l;m++)k[m]=this.getLine(m);this.setText(k.join(this._lineDelimiter))}}},setText:function(f,h,l){f===void 0&&(f="");h===void 0&&(h=0);l===void 0&&(l=this.getCharCount());if(!(h===l&&f==="")){for(var k=this.getLineAtOffset(h),m=this.getLineAtOffset(l),e=h,a=l-h,b=m-k,d=f.length,i=0,g=this.getLineCount(),o=0,c=0,j=0,q=[];;){o!==-1&&o<=j&&(o=f.indexOf("\r",j));c!==-1&&
c<=j&&(c=f.indexOf("\n",j));if(c===-1&&o===-1)break;j=o!==-1&&c!==-1?o+1===c?c+1:(o<c?o:c)+1:o!==-1?o+1:c+1;q.push(h+j);i++}this.onChanging({type:"Changing",text:f,start:e,removedCharCount:a,addedCharCount:d,removedLineCount:b,addedLineCount:i});q.length===0&&(o=this.getLineStart(k),m=m+1<g?this.getLineStart(m+1):this.getCharCount(),h!==o&&(f=this.getText(o,h)+f,h=o),l!==m&&(f+=this.getText(l,m),l=m));m=d-a;for(o=k+b+1;o<g;o++)this._lineOffsets[o]+=m;k=[k+1,b].concat(q);Array.prototype.splice.apply(this._lineOffsets,
k);for(m=q=0;m<this._text.length;){o=this._text[m].length;if(h<=q+o)break;q+=o;m++}g=q;for(k=m;m<this._text.length;){o=this._text[m].length;if(l<=q+o)break;q+=o;m++}o=this._text[m];h=this._text[k].substring(0,h-g);l=o.substring(l-q);k=[k,m-k+1];h&&k.push(h);f&&k.push(f);l&&k.push(l);Array.prototype.splice.apply(this._text,k);if(this._text.length===0)this._text=[""];this.onChanged({type:"Changed",start:e,removedCharCount:a,addedCharCount:d,removedLineCount:b,addedLineCount:i})}}};s.EventTarget.addMixin(p.prototype);
return{TextModel:p}});
define("orion/editor/keyBinding",["orion/editor/util"],function(s){function r(p,f,h,l,k){this.keyCode=typeof p==="string"?p.toUpperCase().charCodeAt(0):p;this.mod1=f!==void 0&&f!==null?f:!1;this.mod2=h!==void 0&&h!==null?h:!1;this.mod3=l!==void 0&&l!==null?l:!1;this.mod4=k!==void 0&&k!==null?k:!1}r.prototype={match:function(p){return this.keyCode===p.keyCode?this.mod1!==(s.isMac?p.metaKey:p.ctrlKey)?!1:this.mod2!==p.shiftKey?!1:this.mod3!==p.altKey?!1:s.isMac&&this.mod4!==p.ctrlKey?!1:!0:!1},equals:function(p){return!p?
!1:this.keyCode!==p.keyCode?!1:this.mod1!==p.mod1?!1:this.mod2!==p.mod2?!1:this.mod3!==p.mod3?!1:this.mod4!==p.mod4?!1:!0}};return{KeyBinding:r}});
define("orion/editor/textView",["orion/editor/textModel","orion/editor/keyBinding","orion/editor/eventTarget","orion/editor/util"],function(s,r,p,f){function h(c,j,q,u){typeof c.addEventListener==="function"?c.addEventListener(j,q,u===!0):c.attachEvent("on"+j,q)}function l(c,j,q){if(q){j.className="";for(var q=j.attributes,u=q.length;u-- >0;)(!f.isIE||f.isIE>=9||f.isIE<9&&q[u].specified)&&j.removeAttribute(q[u].name)}if(c){if(c.styleClass)j.className=c.styleClass;if(q=c.style)for(var a in q)q.hasOwnProperty(a)&&
(j.style[a]=q[a]);if(c=c.attributes)for(var b in c)c.hasOwnProperty(b)&&j.setAttribute(b,c[b])}}function k(c){return c instanceof Array?c.slice(0):c}function m(c,j){if(c===j)return!0;if(c&&!j||!c&&j)return!1;if(c&&c.constructor===String||j&&j.constructor===String)return!1;if(c instanceof Array||j instanceof Array){if(!(c instanceof Array&&j instanceof Array))return!1;if(c.length!==j.length)return!1;for(var q=0;q<c.length;q++)if(!m(c[q],j[q]))return!1;return!0}if(!(c instanceof Object)||!(j instanceof
Object))return!1;for(q in c)if(c.hasOwnProperty(q)){if(!j.hasOwnProperty(q))return!1;if(!m(c[q],j[q]))return!1}for(q in j)if(!c.hasOwnProperty(q))return!1;return!0}function e(c,j,q){for(var a=0,b=0,d=0,n=c.length;d<n;){a!==-1&&a<=d&&(a=c.indexOf("\r",d));b!==-1&&b<=d&&(b=c.indexOf("\n",d));var e=d,i;if(b===-1&&a===-1){j(c.substring(d));break}a!==-1&&b!==-1?a+1===b?(i=a,d=b+1):(i=a<b?a:b,d=(a<b?a:b)+1):a!==-1?(i=a,d=a+1):(i=b,d=b+1);j(c.substring(e,i));q()}}function a(c){var j,q,a,b,d=c.ownerDocument.defaultView||
c.ownerDocument.parentWindow;if(d.getComputedStyle)c=d.getComputedStyle(c,null),j=c.getPropertyValue("padding-left"),q=c.getPropertyValue("padding-top"),a=c.getPropertyValue("padding-right"),b=c.getPropertyValue("padding-bottom");else if(c.currentStyle)j=c.currentStyle.paddingLeft,q=c.currentStyle.paddingTop,a=c.currentStyle.paddingRight,b=c.currentStyle.paddingBottom;return{left:parseInt(j,10)||0,top:parseInt(q,10)||0,right:parseInt(a,10)||0,bottom:parseInt(b,10)||0}}function b(c){var j,q,u,b,d=
c._trim;if(!d){var d=a(c),n=c.ownerDocument.defaultView||c.ownerDocument.parentWindow;if(n.getComputedStyle)b=n.getComputedStyle(c,null),j=b.getPropertyValue("border-left-width"),q=b.getPropertyValue("border-top-width"),u=b.getPropertyValue("border-right-width"),b=b.getPropertyValue("border-bottom-width");else if(c.currentStyle)j=c.currentStyle.borderLeftWidth,q=c.currentStyle.borderTopWidth,u=c.currentStyle.borderRightWidth,b=c.currentStyle.borderBottomWidth;j=parseInt(j,10)||0;q=parseInt(q,10)||
0;u=parseInt(u,10)||0;b=parseInt(b,10)||0;d.left+=j;d.top+=q;d.right+=u;d.bottom+=b;c._trim=d}return d}function d(c,j,q){this.start=c;this.end=j;this.caret=q}function i(c){this.left=c.left;this.top=c.top;this.right=c.right;this.bottom=c.bottom}function g(c,j,q){this.view=c;this.lineIndex=j;this._lineDiv=q}function o(c){this._init(c)}d.prototype={clone:function(){return new d(this.start,this.end,this.caret)},collapse:function(){this.caret?this.end=this.start:this.start=this.end},extend:function(c){this.caret?
this.start=c:this.end=c;if(this.start>this.end)c=this.start,this.start=this.end,this.end=c,this.caret=!this.caret},setCaret:function(c){this.end=this.start=c;this.caret=!1},getCaret:function(){return this.caret?this.start:this.end},toString:function(){return"start="+this.start+" end="+this.end+(this.caret?" caret is at start":" caret is at end")},isEmpty:function(){return this.start===this.end},equals:function(c){return this.caret===c.caret&&this.start===c.start&&this.end===c.end}};i.prototype={toString:function(){return"{l="+
this.left+", t="+this.top+", r="+this.right+", b="+this.bottom+"}"}};g.prototype={create:function(c,j){if(!this._lineDiv){var q=this._lineDiv=this._createLine(c,j,this.lineIndex);q._line=this;return q}},_createLine:function(c,j,q){var a=this.view,b=a._model,d=b.getLine(q),n=b.getLineStart(q),e={type:"LineStyle",textView:a,lineIndex:q,lineText:d,lineStart:n};if(d.length<2E3)a.onLineStyle(e);b=j||f.createElement(c.ownerDocument,"div");if(!j||!m(j.viewStyle,e.style)){l(e.style,b,j);if(j)j._trim=null;
b.viewStyle=e.style;b.setAttribute("role","presentation")}b.lineIndex=q;q=[];this._createRanges(e.ranges,d,0,d.length,n,{tabOffset:0,ranges:q});d=" ";!a._fullSelection&&f.isIE<9&&(d="\ufeff");f.isWebkit&&(d="\u200c");q.push({text:d,style:a._metrics.largestFontStyle,ignoreChars:1});var i,t,g,o,k,d=a=0,h,w;if(j){if(t=j.modelChangedEvent)t.removedLineCount===0&&t.addedLineCount===0?(w=t.start-n,h=t.addedCharCount-t.removedCharCount):w=-1,j.modelChangedEvent=void 0;t=j.firstChild}for(n=0;n<q.length;n++){i=
q[n];o=i.text;a+=o.length;e=i.style;if(t)if(k=t.firstChild.data,g=t.viewStyle,k===o&&m(e,g)){d+=k.length;t._rectsCache=void 0;i=t=t.nextSibling;continue}else for(;t;){if(w!==-1){g=a;g>=w&&(g-=h);k=(k=t.firstChild.data)?k.length:0;if(d+k>g)break;d+=k}g=t.nextSibling;b.removeChild(t);t=g}i=this._createSpan(b,o,e,i.ignoreChars);t?b.insertBefore(i,t):b.appendChild(i);if(j)j.lineWidth=void 0}if(j)for(c=i?i.nextSibling:null;c;)g=c.nextSibling,j.removeChild(c),c=g;else c.appendChild(b);return b},_createRanges:function(c,
j,q,a,b,d){if(!(q>=a)){if(c)for(var n=0;n<c.length;n++){var e=c[n];if(!(e.end<=b+q)){var i=Math.max(b+q,e.start)-b;if(i>=a)break;var f=Math.min(b+a,e.end)-b;if(i<f){i=Math.max(q,i);f=Math.min(a,f);for(q<i&&this._createRange(j,q,i,null,d);n+1<c.length&&c[n+1].start-b===f&&m(e.style,c[n+1].style);)e=c[n+1],f=Math.min(b+a,e.end)-b,n++;this._createRange(j,i,f,e.style,d);q=f}}}q<a&&this._createRange(j,q,a,null,d)}},_createRange:function(c,j,q,a,b){if(!(j>=q)){var d=this.view._customTabSize;if(d&&d!==8)for(var n=
c.indexOf("\t",j);n!==-1&&n<q;){j<n&&(j={text:c.substring(j,n),style:a},b.ranges.push(j),b.tabOffset+=j.text.length);j=d-b.tabOffset%d;if(j>0){for(var e="\u00a0",i=1;i<j;i++)e+=" ";j={text:e,style:a,ignoreChars:j-1};b.ranges.push(j);b.tabOffset+=j.text.length}j=n+1;n=c.indexOf("\t",j)}j<q&&(j={text:c.substring(j,q),style:a},b.ranges.push(j),b.tabOffset+=j.text.length)}},_createSpan:function(c,j,q,a){var b=q&&q.tagName==="A";if(b)c.hasLink=!0;var b=b&&this.view._linksVisible?"a":"span",d=c.ownerDocument,
c=f.createElement(c.ownerDocument,b);c.appendChild(d.createTextNode(j));l(q,c);if(b==="A"){var n=this.view,e=this._getWindow();h(c,"click",function(c){return n._handleLinkClick(c?c:e.event)},!1)}c.viewStyle=q;if(a)c.ignoreChars=a;return c},_ensureCreated:function(){return this._lineDiv?this._lineDiv:this._createdDiv=this.create(this.view._clientDiv,null)},getBoundingClientRect:function(c,j){var q=this._ensureCreated(),a=this.view;if(c===void 0)return this._getLineBoundingClientRect(q,!0);var b=a._model,
d=q.ownerDocument,n=this.lineIndex,e=null;if(c<b.getLineEnd(n)){b=b.getLineStart(n);for(n=q.firstChild;n;){var g=n.firstChild,t=g.length;n.ignoreChars&&(t-=n.ignoreChars);if(b+t>c){e=c-b;if(a._isRangeRects)d=d.createRange(),d.setStart(g,e),d.setEnd(g,e+1),e=new i(d.getBoundingClientRect());else if(f.isIE)d=d.body.createTextRange(),d.moveToElementText(n),d.collapse(),d.moveEnd("character",e+1),d.moveStart("character",e),e=new i(d.getBoundingClientRect());else{var o=g.data;n.removeChild(g);n.appendChild(d.createTextNode(o.substring(0,
e)));var k=f.createElement(d,"span");k.appendChild(d.createTextNode(o.substring(e,e+1)));n.appendChild(k);n.appendChild(d.createTextNode(o.substring(e+1)));e=new i(k.getBoundingClientRect());n.innerHTML="";n.appendChild(g);this._createdDiv||(d=a._getSelection(),(b<=d.start&&d.start<b+t||b<=d.end&&d.end<b+t)&&a._updateDOMSelection())}f.isIE&&(d=q.ownerDocument.defaultView||q.ownerDocument.parentWindow,q=d.screen.logicalXDPI/d.screen.deviceXDPI,d=d.screen.logicalYDPI/d.screen.deviceYDPI,e.left*=q,e.right*=
q,e.top*=d,e.bottom*=d);break}b+=t;n=n.nextSibling}}q=this.getBoundingClientRect();if(!e)a._wrapMode?(a=this.getClientRects(),e=a[a.length-1],e.left=e.right,e.left+=q.left,e.top+=q.top,e.right+=q.left,e.bottom+=q.top):(e=new i(q),e.left=e.right);if(j||j===void 0)e.left-=q.left,e.top-=q.top,e.right-=q.left,e.bottom-=q.top;return e},_getClientRects:function(c,j){var q,a,b,d;if(!c._rectsCache){q=c.getClientRects();a=Array(q.length);for(d=0;d<q.length;d++)b=a[d]=new i(q[d]),b.left-=j.left,b.top-=j.top,
b.right-=j.left,b.bottom-=j.top;c._rectsCache=a}q=c._rectsCache;a=[q.length];for(d=0;d<q.length;d++)a[d]=new i(q[d]);return a},getClientRects:function(c){if(!this.view._wrapMode)return[this.getBoundingClientRect()];for(var j=this._ensureCreated(),q=[],a=j.firstChild,b,d=j.getBoundingClientRect();a;){for(var n=this._getClientRects(a,d),j=0;j<n.length;j++){var e=n[j],i;if(e.top!==e.bottom){var f=e.top+(e.bottom-e.top)/2;for(i=0;i<q.length;i++)if(b=q[i],b.top<=f&&f<b.bottom)break;if(i===q.length)q.push(e);
else{if(e.left<b.left)b.left=e.left;if(e.top<b.top)b.top=e.top;if(e.right>b.right)b.right=e.right;if(e.bottom>b.bottom)b.bottom=e.bottom}}}a=a.nextSibling}return c!==void 0?q[c]:q},_getLineBoundingClientRect:function(c,j){var q=new i(c.getBoundingClientRect());if(!this.view._wrapMode){q.right=q.left;for(var a=c.lastChild;a&&a.ignoreChars===a.firstChild.length;)a=a.previousSibling;if(a)a=a.getBoundingClientRect(),q.right=a.right+b(c).right}j&&(a=b(c),q.left+=a.left,q.right-=a.right);return q},getLineCount:function(){return!this.view._wrapMode?
1:this.getClientRects().length},getLineIndex:function(c){if(!this.view._wrapMode)return 0;for(var j=this.getClientRects(),c=this.getBoundingClientRect(c),c=c.top+(c.bottom-c.top)/2,q=0;q<j.length;q++)if(j[q].top<=c&&c<j[q].bottom)return q;return j.length-1},getLineStart:function(c){if(!this.view._wrapMode||c===0)return this.view._model.getLineStart(c);var j=this.getClientRects();return this.getOffset(j[c].left+1,j[c].top+1)},getOffset:function(c,j){var q=this.view,a=q._model,b=this.lineIndex,d=a.getLineStart(b),
a=a.getLineEnd(b);if(d===a)return d;var n=this._ensureCreated(),b=this.getBoundingClientRect(),e,i;if(q._wrapMode){e=this.getClientRects();if(j<e[0].top)j=e[0].top;for(var g=0;g<e.length;g++)if(i=e[g],i.top<=j&&j<i.bottom)break;if(c<i.left)c=i.left;c>i.right&&(c=i.right-1)}else c<0&&(c=0),c>b.right-b.left&&(c=b.right-b.left);var o=n.ownerDocument,g=o.defaultView||o.parentWindow,k=f.isIE?g.screen.logicalXDPI/g.screen.deviceXDPI:1,h=f.isIE?g.screen.logicalYDPI/g.screen.deviceYDPI:1,g=d,l=n.firstChild;
a:for(;l;){var m=l.firstChild,n=m.length;l.ignoreChars&&(n-=l.ignoreChars);var p,r,s;e=this._getClientRects(l,b);for(var y=0;y<e.length;y++)if(i=e[y],i.left<=c&&c<i.right&&(!q._wrapMode||i.top<=j&&j<i.bottom)){if(f.isIE||q._isRangeRects){for(var o=q._isRangeRects?o.createRange():o.body.createTextRange(),y=n,F=-1;y-F>1;){var G=Math.floor((y+F)/2);i=F+1;e=G===n-1&&l.ignoreChars?m.length:G+1;q._isRangeRects?(o.setStart(m,i),o.setEnd(m,e)):(o.moveToElementText(l),o.move("character",i),o.moveEnd("character",
e-i));e=o.getClientRects();for(var L=!1,I=0;I<e.length;I++)if(i=e[I],p=i.left*k-b.left,s=i.right*k-b.left,r=i.top*h-b.top,i=i.bottom*h-b.top,p<=c&&c<s&&(!q._wrapMode||r<=j&&j<i)){L=!0;break}L?y=G:F=G}g+=y;i=y;e=y===n-1&&l.ignoreChars?m.length:Math.min(y+1,m.length);q._isRangeRects?(o.setStart(m,i),o.setEnd(m,e)):(o.moveToElementText(l),o.move("character",i),o.moveEnd("character",e-i));i=o.getClientRects()[0];p=i.left*k-b.left;s=i.right*k-b.left;c>p+(s-p)/2&&g++}else{i=[];for(k=0;k<n;k++)i.push("<span>"),
k===n-1?i.push(m.data.substring(k)):i.push(m.data.substring(k,k+1)),i.push("</span>");l.innerHTML=i.join("");for(k=l.firstChild;k;){i=k.getBoundingClientRect();p=i.left-b.left;s=i.right-b.left;if(p<=c&&c<s){c>p+(s-p)/2&&g++;break}g++;k=k.nextSibling}if(!this._createdDiv)l.innerHTML="",l.appendChild(m),b=q._getSelection(),(g<=b.start&&b.start<g+n||g<=b.end&&b.end<g+n)&&q._updateDOMSelection()}break a}g+=n;l=l.nextSibling}return Math.min(a,Math.max(d,g))},getNextOffset:function(c,j,q){return j==="line"?
(j=this.view._model,c=j.getLineAtOffset(c),q>0?j.getLineEnd(c):j.getLineStart(c)):j==="wordend"?this._getNextOffset_W3C(c,j,q):f.isIE?this._getNextOffset_IE(c,j,q):this._getNextOffset_W3C(c,j,q)},_getNextOffset_W3C:function(c,j,q){function a(c){return 33<=c&&c<=47||58<=c&&c<=64||91<=c&&c<=94||c===96||123<=c&&c<=126}if(j==="word"||j==="wordend"){var b=this.view._model,d=b.getLineAtOffset(c),n=b.getLine(d),e=b.getLineStart(d),d=b.getLineEnd(d),b=n.length;c-=e;var i,f;if(q>0){if(c===b)return d;i=n.charCodeAt(c);
f=a(i);q=!f&&!(i===32||i===9);for(c++;c<b;){i=n.charCodeAt(c);d=a(i);if(j==="wordend"){if(!d&&f)break}else if(d&&!f)break;i=!d&&!(i===32||i===9);if(j==="wordend"){if(!i&&q)break}else if(i&&!q)break;q=i;f=d;c++}}else{if(c===0)return e;c--;i=n.charCodeAt(c);f=a(i);for(q=!f&&!(i===32||i===9);0<c;){i=n.charCodeAt(c-1);d=a(i);if(j==="wordend"){if(d&&!f)break}else if(!d&&f)break;i=!d&&!(i===32||i===9);if(j==="wordend"){if(i&&!q)break}else if(!i&&q)break;q=i;f=d;c--}}return e+c}return c+q},_getNextOffset_IE:function(c,
j,q){var a=this._ensureCreated(),b=this.view._model,d=this.lineIndex,n=0,e;e=b.getLineStart(d);var i=a.ownerDocument;if(c===b.getLineEnd(d))n=i.body.createTextRange(),n.moveToElementText(a.lastChild),e=n.text.length,n.moveEnd(j,q),n=c+n.text.length-e;else if(c===e&&q<0)n=e;else for(a=a.firstChild;a;){b=a.firstChild.length;a.ignoreChars&&(b-=a.ignoreChars);if(e+b>c){n=i.body.createTextRange();c===e&&q<0?n.moveToElementText(a.previousSibling):(n.moveToElementText(a),n.collapse(),n.moveEnd("character",
c-e));e=n.text.length;n.moveEnd(j,q);n=c+n.text.length-e;break}e=b+e;a=a.nextSibling}return n},destroy:function(){var c=this._createdDiv;if(c)c.parentNode.removeChild(c),this._createdDiv=null}};o.prototype={addRuler:function(c,j){c.setView(this);var a=this._rulers;if(j!==void 0){var b,d;for(b=0,d=0;b<a.length&&d<j;b++)c.getLocation()===a[b].getLocation()&&d++;a.splice(d,0,c);j=d}else a.push(c);this._createRuler(c,j);this._update()},computeSize:function(){var c=0,j=0,a=this._model,b=this._clientDiv;
if(!b)return{width:c,height:j};var d=b.style.width;if(f.isWebkit)b.style.width="0x7fffffffpx";for(var a=a.getLineCount(),e=0;e<a;e++){var n=this._getLine(e),i=n.getBoundingClientRect(),c=Math.max(c,i.right-i.left);j+=i.bottom-i.top;n.destroy()}if(f.isWebkit)b.style.width=d;b=this._getViewPadding();c+=b.right+b.left;j+=b.bottom+b.top;return{width:c,height:j}},convert:function(c,j,a){if(this._clientDiv){var b=this._getScroll(),d=this._getViewPadding(),e=this._viewDiv.getBoundingClientRect();j==="document"&&
(c.x!==void 0&&(c.x+=-b.x+e.left+d.left),c.y!==void 0&&(c.y+=-b.y+e.top+d.top));a==="document"&&(c.x!==void 0&&(c.x+=b.x-e.left-d.left),c.y!==void 0&&(c.y+=b.y-e.top-d.top));return c}},destroy:function(){for(var c=0;c<this._rulers.length;c++)this._rulers[c].setView(null);this.rulers=null;this._destroyView();this.onDestroy({type:"Destroy"});this._actions=this._keyBindings=this._doubleClickSelection=this._selection=this._model=this._parent=null},focus:function(){this._clientDiv&&(this._updateDOMSelection(),
f.isOpera&&this._clientDiv.blur(),this._clientDiv.focus(),this._updateDOMSelection())},hasFocus:function(){return this._hasFocus},getActionDescription:function(c){if(c=this._actions[c])return c.actionDescription},getActions:function(c){var j=[],a=this._actions,b;for(b in a)a.hasOwnProperty(b)&&(c||!a[b].defaultHandler)&&j.push(b);return j},getBottomIndex:function(c){return!this._clientDiv?0:this._getBottomIndex(c)},getBottomPixel:function(){return!this._clientDiv?0:this._getScroll().y+this._getClientHeight()},
getCaretOffset:function(){return this._getSelection().getCaret()},getClientArea:function(){if(!this._clientDiv)return{x:0,y:0,width:0,height:0};var c=this._getScroll();return{x:c.x,y:c.y,width:this._getClientWidth(),height:this._getClientHeight()}},getHorizontalPixel:function(){return!this._clientDiv?0:this._getScroll().x},getKeyBindings:function(c){for(var j=[],a=this._keyBindings,b=0;b<a.length;b++)a[b].actionID===c&&j.push(a[b].keyBinding);return j},getLineHeight:function(c){return!this._clientDiv?
0:this._getLineHeight(c)},getLineIndex:function(c){return!this._clientDiv?0:this._getLineIndex(c)},getLinePixel:function(c){return!this._clientDiv?0:this._getLinePixel(c)},getLocationAtOffset:function(c){if(!this._clientDiv)return{x:0,y:0};var j=this._model,c=Math.min(Math.max(0,c),j.getCharCount()),j=j.getLineAtOffset(c),a=this._getLine(j),c=a.getBoundingClientRect(c);a.destroy();a=c.left;j=this._getLinePixel(j)+c.top;return{x:a,y:j}},getOptions:function(){var c;if(arguments.length===0)c=this._defaultOptions();
else if(arguments.length===1){if(c=arguments[0],typeof c==="string")return k(this["_"+c])}else{c={};for(var j in arguments)arguments.hasOwnProperty(j)&&(c[arguments[j]]=void 0)}for(var a in c)c.hasOwnProperty(a)&&(c[a]=k(this["_"+a]));return c},getModel:function(){return this._model},getOffsetAtLocation:function(c,j){if(!this._clientDiv)return 0;var a=this._getLineIndex(j),b=this._getLine(a),a=b.getOffset(c,j-this._getLinePixel(a));b.destroy();return a},getRulers:function(){return this._rulers.slice(0)},
getSelection:function(){var c=this._getSelection();return{start:c.start,end:c.end}},getText:function(c,j){return this._model.getText(c,j)},getTopIndex:function(c){return!this._clientDiv?0:this._getTopIndex(c)},getTopPixel:function(){return!this._clientDiv?0:this._getScroll().y},invokeAction:function(c,j){if(this._clientDiv){var a=this._actions[c];if(a){if(!j&&a.handler&&a.handler())return;if(a.defaultHandler)return a.defaultHandler()}return!1}},isDestroyed:function(){return!this._clientDiv},onContextMenu:function(c){return this.dispatchEvent(c)},
onDragStart:function(c){return this.dispatchEvent(c)},onDrag:function(c){return this.dispatchEvent(c)},onDragEnd:function(c){return this.dispatchEvent(c)},onDragEnter:function(c){return this.dispatchEvent(c)},onDragOver:function(c){return this.dispatchEvent(c)},onDragLeave:function(c){return this.dispatchEvent(c)},onDrop:function(c){return this.dispatchEvent(c)},onDestroy:function(c){return this.dispatchEvent(c)},onLineStyle:function(c){return this.dispatchEvent(c)},onModelChanged:function(c){return this.dispatchEvent(c)},
onModelChanging:function(c){return this.dispatchEvent(c)},onModify:function(c){return this.dispatchEvent(c)},onMouseDown:function(c){return this.dispatchEvent(c)},onMouseUp:function(c){return this.dispatchEvent(c)},onMouseMove:function(c){return this.dispatchEvent(c)},onMouseOver:function(c){return this.dispatchEvent(c)},onMouseOut:function(c){return this.dispatchEvent(c)},onSelection:function(c){return this.dispatchEvent(c)},onScroll:function(c){return this.dispatchEvent(c)},onVerify:function(c){return this.dispatchEvent(c)},
onFocus:function(c){return this.dispatchEvent(c)},onBlur:function(c){return this.dispatchEvent(c)},redraw:function(){if(!(this._redrawCount>0)){var c=this._model.getLineCount();this.redrawRulers(0,c);this.redrawLines(0,c)}},redrawRulers:function(c,j){if(!(this._redrawCount>0))for(var a=this.getRulers(),b=0;b<a.length;b++)this.redrawLines(c,j,a[b])},redrawLines:function(c,j,a){if(!(this._redrawCount>0)&&(c===void 0&&(c=0),j===void 0&&(j=this._model.getLineCount()),c!==j)){var b=this._clientDiv;if(b){if(a)for(var d=
(a.getLocation()==="left"?this._leftDiv:this._rightDiv).firstChild.rows[0].cells,e=0;e<d.length;e++)if(d[e].firstChild._ruler===a){b=d[e].firstChild;break}a?b.rulerChanged=!0:this._lineHeight&&this._resetLineHeight(c,j);if(!a||a.getOverview()==="page")for(b=b.firstChild;b;){d=b.lineIndex;if(c<=d&&d<j)b.lineChanged=!0;b=b.nextSibling}if(!a&&!this._wrapMode&&c<=this._maxLineIndex&&this._maxLineIndex<j)this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0;this._queueUpdate()}}},
redrawRange:function(c,j){if(!(this._redrawCount>0)){var a=this._model;c===void 0&&(c=0);j===void 0&&(j=a.getCharCount());var b=a.getLineAtOffset(c),a=a.getLineAtOffset(Math.max(c,j-1))+1;this.redrawLines(b,a)}},removeRuler:function(c){for(var j=this._rulers,a=0;a<j.length;a++)if(j[a]===c){j.splice(a,1);c.setView(null);this._destroyRuler(c);this._update();break}},resize:function(){this._clientDiv&&this._handleResize(null)},setAction:function(c,j,a){if(c){var b=this._actions,d=b[c];d||(d=b[c]={});
d.handler=j;d.actionDescription=a}},setKeyBinding:function(c,j){for(var a=this._keyBindings,b=0;b<a.length;b++){var d=a[b];if(d.keyBinding.equals(c)){j?d.actionID=j:d.predefined?d.actionID=null:a.splice(b,1);return}}j&&a.push({keyBinding:c,actionID:j})},setCaretOffset:function(c,j){var a=this._model.getCharCount(),c=Math.max(0,Math.min(c,a));this._setSelection(new d(c,c,!1),j===void 0||j)},setHorizontalPixel:function(c){this._clientDiv&&(c=Math.max(0,c),this._scrollView(c-this._getScroll().x,0))},
setRedraw:function(c){c?--this._redrawCount===0&&this.redraw():this._redrawCount++},setModel:function(c){if(c&&c!==this._model){this._model.removeEventListener("preChanging",this._modelListener.onChanging);this._model.removeEventListener("postChanged",this._modelListener.onChanged);var j=this._model.getLineCount(),a=this._model.getCharCount(),b=c.getLineCount(),d=c.getCharCount(),e={type:"ModelChanging",text:c.getText(),start:0,removedCharCount:a,addedCharCount:d,removedLineCount:j,addedLineCount:b};
this.onModelChanging(e);this._model=c;e={type:"ModelChanged",start:0,removedCharCount:a,addedCharCount:d,removedLineCount:j,addedLineCount:b};this.onModelChanged(e);this._model.addEventListener("preChanging",this._modelListener.onChanging);this._model.addEventListener("postChanged",this._modelListener.onChanged);this._reset();this._update()}},setOptions:function(c){var j=this._defaultOptions(),a;for(a in c)if(c.hasOwnProperty(a)){var b=c[a];if(!m(this["_"+a],b)){var d=j[a]?j[a].update:null;d?d.call(this,
b):this["_"+a]=k(b)}}},setSelection:function(c,j,a){var b=c>j;if(b)var e=c,c=j,j=e;e=this._model.getCharCount();c=Math.max(0,Math.min(c,e));j=Math.max(0,Math.min(j,e));this._setSelection(new d(c,j,b),a===void 0||a)},setText:function(c,j,a){var b=j===void 0&&a===void 0;j===void 0&&(j=0);a===void 0&&(a=this._model.getCharCount());this._modifyContent({text:c,start:j,end:a,_code:!0},!b);if(b)this._columnX=-1,this._setSelection(new d(0,0,!1),!0),f.isFirefox&&this._fixCaret()},setTopIndex:function(c){this._clientDiv&&
this._scrollView(0,this._getLinePixel(Math.max(0,c))-this._getScroll().y)},setTopPixel:function(c){this._clientDiv&&this._scrollView(0,Math.max(0,c)-this._getScroll().y)},showSelection:function(){return this._showCaret(!0)},update:function(c,j){this._clientDiv&&(c&&this._updateStyle(),j===void 0||j?this._update():this._queueUpdate())},_handleRootMouseDown:function(c){if(f.isFirefox&&c.which===1)this._clientDiv.contentEditable=!1,this._ignoreBlur=(this._overlayDiv||this._clientDiv).draggable=!0;var j=
this._overlayDiv||this._clientDiv;if(f.isIE<9)j=this._viewDiv;for(var a=c.target?c.target:c.srcElement;a;){if(j===a)return;a=a.parentNode}c.preventDefault&&c.preventDefault();c.stopPropagation&&c.stopPropagation();if(!this._isW3CEvents){var b=this;this._getWindow().setTimeout(function(){b._clientDiv.focus()},0)}},_handleRootMouseUp:function(c){if(f.isFirefox&&c.which===1)this._clientDiv.contentEditable=!0,(this._overlayDiv||this._clientDiv).draggable=!1,this._fixCaret(),this._ignoreBlur=!1},_handleBlur:function(){if(!this._ignoreBlur){this._hasFocus=
!1;if(f.isIE<9&&!this._getSelection().isEmpty()){var c=this._rootDiv,j=f.createElement(c.ownerDocument,"div");c.appendChild(j);c.removeChild(j)}if(this._selDiv1)if(this._selDiv1.style.background="lightgray",this._selDiv2.style.background="lightgray",this._selDiv3.style.background="lightgray",c=this._getWindow(),j=this._selDiv1.ownerDocument,c.getSelection){j=c.getSelection();for(c=j.anchorNode;c;){if(c===this._clientDiv){j.rangeCount>0&&j.removeAllRanges();break}c=c.parentNode}}else if(j.selection){this._ignoreSelect=
!1;for(c=j.selection.createRange().parentElement();c;){if(c===this._clientDiv){j.selection.empty();break}c=c.parentNode}this._ignoreSelect=!0}if(!this._ignoreFocus)this.onBlur({type:"Blur"})}},_handleContextMenu:function(c){f.isIE&&this._lastMouseButton===3&&this._updateDOMSelection();var j=!1;if(this.isListening("ContextMenu"))j=this._createMouseEvent("ContextMenu",c),j.screenX=c.screenX,j.screenY=c.screenY,this.onContextMenu(j),j=j.defaultPrevented;if(j)return c.preventDefault&&c.preventDefault(),
!1},_handleCopy:function(c){if(!this._ignoreCopy&&this._doCopy(c))return c.preventDefault&&c.preventDefault(),!1},_handleCut:function(c){if(this._doCut(c))return c.preventDefault&&c.preventDefault(),!1},_handleDataModified:function(){this._startIME()},_handleDblclick:function(c){this._lastMouseTime=c.timeStamp?c.timeStamp:(new Date).getTime();if(this._clickCount!==2)this._clickCount=2,this._handleMouse(c)},_handleDragStart:function(c){if(f.isFirefox){var j=this;this._getWindow().setTimeout(function(){j._clientDiv.contentEditable=
!0;j._clientDiv.draggable=!1;j._ignoreBlur=!1},0)}if(this.isListening("DragStart")&&this._dragOffset!==-1)this._isMouseDown=!1,this.onDragStart(this._createMouseEvent("DragStart",c)),this._dragOffset=-1;else return c.preventDefault&&c.preventDefault(),!1},_handleDrag:function(c){if(this.isListening("Drag"))this.onDrag(this._createMouseEvent("Drag",c))},_handleDragEnd:function(c){this._dropTarget=!1;this._dragOffset=-1;if(this.isListening("DragEnd"))this.onDragEnd(this._createMouseEvent("DragEnd",
c));f.isFirefox&&(this._fixCaret(),c.dataTransfer.dropEffect==="none"&&!c.dataTransfer.mozUserCancelled&&this._fixCaret())},_handleDragEnter:function(c){var j=!0;this._dropTarget=!0;this.isListening("DragEnter")&&(j=!1,this.onDragEnter(this._createMouseEvent("DragEnter",c)));if(f.isWebkit||j)return c.preventDefault&&c.preventDefault(),!1},_handleDragOver:function(c){var j=!0;this.isListening("DragOver")&&(j=!1,this.onDragOver(this._createMouseEvent("DragOver",c)));if(f.isWebkit||j){if(j)c.dataTransfer.dropEffect=
"none";c.preventDefault&&c.preventDefault();return!1}},_handleDragLeave:function(c){this._dropTarget=!1;if(this.isListening("DragLeave"))this.onDragLeave(this._createMouseEvent("DragLeave",c))},_handleDrop:function(c){this._dropTarget=!1;if(this.isListening("Drop"))this.onDrop(this._createMouseEvent("Drop",c));c.preventDefault&&c.preventDefault();return!1},_handleFocus:function(){this._hasFocus=!0;f.isIOS&&this._lastTouchOffset!==void 0?(this.setCaretOffset(this._lastTouchOffset,!0),this._lastTouchOffset=
void 0):this._updateDOMSelection();if(this._selDiv1){var c=this._highlightRGB;this._selDiv1.style.background=c;this._selDiv2.style.background=c;this._selDiv3.style.background=c}if(!this._ignoreFocus)this.onFocus({type:"Focus"})},_handleKeyDown:function(c){var j=!1;switch(c.keyCode){case 16:case 17:case 18:case 91:j=!0;break;default:this._setLinksVisible(!1)}if(c.keyCode===229){if(this._readonly)return c.preventDefault&&c.preventDefault(),!1;j=!0;f.isSafari&&f.isMac&&c.ctrlKey&&(j=!1);j&&this._startIME()}else j||
this._commitIME();if((f.isMac||f.isLinux)&&f.isFirefox<4||f.isOpera)return this._keyDownEvent=c,!0;if(this._doAction(c))return c.preventDefault?(c.preventDefault(),c.stopPropagation()):(c.cancelBubble=!0,c.returnValue=!1,c.keyCode=0),!1},_handleKeyPress:function(c){if(f.isMac&&f.isWebkit&&(63232<=c.keyCode&&c.keyCode<=63487||c.keyCode===13||c.keyCode===8))return c.preventDefault&&c.preventDefault(),!1;if(((f.isMac||f.isLinux)&&f.isFirefox<4||f.isOpera)&&this._doAction(this._keyDownEvent))return c.preventDefault&&
c.preventDefault(),!1;var j=f.isMac?c.metaKey:c.ctrlKey;if(c.charCode!==void 0&&j)switch(c.charCode){case 99:case 118:case 120:return!0}j=!1;if(f.isMac){if(c.ctrlKey||c.metaKey)j=!0}else if(f.isFirefox){if(c.ctrlKey||c.altKey)j=!0}else c.ctrlKey^c.altKey&&(j=!0);if(!j&&(j=f.isOpera?c.which:c.charCode!==void 0?c.charCode:c.keyCode,j>31))return this._doContent(String.fromCharCode(j)),c.preventDefault&&c.preventDefault(),!1},_handleKeyUp:function(c){(f.isMac?c.metaKey:c.ctrlKey)||this._setLinksVisible(!1);
c.keyCode===13&&this._commitIME()},_handleLinkClick:function(c){if(!(f.isMac?c.metaKey:c.ctrlKey))return c.preventDefault&&c.preventDefault(),!1},_handleMouse:function(c){var j=this._getWindow(),a=!0,b=j;if(f.isIE||f.isFirefox&&!this._overlayDiv)b=this._clientDiv;if(this._overlayDiv){if(this._hasFocus)this._ignoreFocus=!0;var d=this;j.setTimeout(function(){d.focus();d._ignoreFocus=!1},0)}this._clickCount===1?(a=this._setSelectionTo(c.clientX,c.clientY,c.shiftKey,!f.isOpera&&this._hasFocus&&this.isListening("DragStart")))&&
this._setGrab(b):(this._isW3CEvents&&this._setGrab(b),this._doubleClickSelection=null,this._setSelectionTo(c.clientX,c.clientY,c.shiftKey),this._doubleClickSelection=this._getSelection());return a},_handleMouseDown:function(c){if(this._linksVisible)if((c.target||c.srcElement).tagName!=="A")this._setLinksVisible(!1);else return;this._commitIME();var j=c.which;j||(c.button===4&&(j=2),c.button===2&&(j=3),c.button===1&&(j=1));var a=j!==2&&c.timeStamp?c.timeStamp:(new Date).getTime(),b=a-this._lastMouseTime,
d=Math.abs(this._lastMouseX-c.clientX),e=Math.abs(this._lastMouseY-c.clientY),n=this._lastMouseButton===j;this._lastMouseX=c.clientX;this._lastMouseY=c.clientY;this._lastMouseTime=a;this._lastMouseButton=j;if(j===1)this._isMouseDown=!0,n&&b<=this._clickTime&&d<=this._clickDist&&e<=this._clickDist?this._clickCount++:this._clickCount=1;if(this.isListening("MouseDown")&&(a=this._createMouseEvent("MouseDown",c),this.onMouseDown(a),a.defaultPrevented)){c.preventDefault();return}if(j===1&&this._handleMouse(c)&&
(f.isIE>=9||f.isOpera||f.isChrome||f.isSafari||f.isFirefox&&!this._overlayDiv))this._hasFocus||this.focus(),c.preventDefault();f.isFirefox&&this._lastMouseButton===3&&this._updateDOMSelection()},_handleMouseOver:function(c){if(this.isListening("MouseOver"))this.onMouseOver(this._createMouseEvent("MouseOver",c))},_handleMouseOut:function(c){if(this.isListening("MouseOut"))this.onMouseOut(this._createMouseEvent("MouseOut",c))},_handleMouseMove:function(c){var j=this._isClientDiv(c);if(this.isListening("MouseMove")&&
j)this.onMouseMove(this._createMouseEvent("MouseMove",c));if(!this._dropTarget){var a=this._linksVisible||this._lastMouseMoveX!==c.clientX||this._lastMouseMoveY!==c.clientY;this._lastMouseMoveX=c.clientX;this._lastMouseMoveY=c.clientY;this._setLinksVisible(a&&!this._isMouseDown&&(f.isMac?c.metaKey:c.ctrlKey));if(!this._isW3CEvents){if(c.button===0)return this._setGrab(null),!0;if(!this._isMouseDown&&c.button===1&&(this._clickCount&1)!==0&&j)return this._clickCount=2,this._handleMouse(c,this._clickCount)}if(this._isMouseDown&&
this._dragOffset===-1){var j=c.clientX,c=c.clientY,b=this._getViewPadding(),d=this._viewDiv.getBoundingClientRect(),e=this._getClientWidth(),n=this._getClientHeight(),a=d.left+b.left,i=d.top+b.top,e=d.left+b.left+e,b=d.top+b.top+n,d=this._model,n=d.getLineAtOffset(this._getSelection().getCaret());c<i&&n!==0?this._doAutoScroll("up",j,c-i):c>b&&n!==d.getLineCount()-1?this._doAutoScroll("down",j,c-b):j<a&&!this._wrapMode?this._doAutoScroll("left",j-a,c):j>e&&!this._wrapMode?this._doAutoScroll("right",
j-e,c):(this._endAutoScroll(),this._setSelectionTo(j,c,!0))}}},_isClientDiv:function(c){for(var j=this._overlayDiv||this._clientDiv,c=c.target?c.target:c.srcElement;c;){if(j===c)return!0;c=c.parentNode}return!1},_createMouseEvent:function(c,j){var a=this.convert({x:j.clientX,y:j.clientY},"page","document");return{type:c,event:j,clickCount:this._clickCount,x:a.x,y:a.y,preventDefault:function(){this.defaultPrevented=!0}}},_handleMouseUp:function(c){var j=c.which?c.button===0:c.button===1;if(this.isListening("MouseUp")&&
(this._isClientDiv(c)||j&&this._isMouseDown))this.onMouseUp(this._createMouseEvent("MouseUp",c));if(!this._linksVisible&&j&&this._isMouseDown){if(this._dragOffset!==-1)j=this._getSelection(),j.extend(this._dragOffset),j.collapse(),this._setSelection(j,!0,!0),this._dragOffset=-1;this._isMouseDown=!1;this._endAutoScroll();this._isW3CEvents&&this._setGrab(null);f.isFirefox&&c.preventDefault()}},_handleMouseWheel:function(c){var j=this._getLineHeight(),a=0,b=0;f.isIE||f.isOpera?b=-c.wheelDelta/40*j:f.isFirefox?
(j=f.isMac?c.detail*3:Math.max(-256,Math.min(256,c.detail))*j,c.axis===c.HORIZONTAL_AXIS?a=j:b=j):f.isMac?(b=a=40,c.wheelDeltaX%120!==0&&(a=1),c.wheelDeltaY%120!==0&&(b=1),a=-c.wheelDeltaX/a,-1<a&&a<0&&(a=-1),0<a&&a<1&&(a=1),b=-c.wheelDeltaY/b,-1<b&&b<0&&(b=-1),0<b&&b<1&&(b=1)):(a=-c.wheelDeltaX,b=-c.wheelDeltaY/120*8*j);if(f.isSafari){for(j=c.target;j&&j.lineIndex===void 0;)j=j.parentNode;this._mouseWheelLine=j}j=this._getScroll();this._scrollView(a,b);a=this._getScroll();if(j.x!==a.x||j.y!==a.y)return c.preventDefault&&
c.preventDefault(),!1},_handlePaste:function(c){if(!this._ignorePaste&&this._doPaste(c)){if(f.isIE){var a=this;this._ignoreFocus=!0;this._getWindow().setTimeout(function(){a._updateDOMSelection();a._ignoreFocus=!1},0)}c.preventDefault&&c.preventDefault();return!1}},_handleResize:function(){var c=this._parent.clientWidth,a=this._parent.clientHeight;if(this._parentWidth!==c||this._parentHeight!==a)this._parentWidth!==c&&this._resetLineHeight(),this._parentWidth=c,this._parentHeight=a,f.isIE<9?this._queueUpdate():
this._update()},_handleRulerEvent:function(c){for(var a=c.target?c.target:c.srcElement,b=a.lineIndex;a&&!a._ruler;){if(b===void 0&&a.lineIndex!==void 0)b=a.lineIndex;a=a.parentNode}a=a?a._ruler:null;if(b===void 0&&a&&a.getOverview()==="document"){var b=this._getClientHeight(),d=this._model.getLineCount(),e=this._getViewPadding(),i=this._viewDiv.getBoundingClientRect(),b=Math.floor((c.clientY-i.top-this._metrics.scrollWidth)*d/(b+e.top+e.bottom-2*this._metrics.scrollWidth));0<=b&&b<d||(b=void 0)}if(a)switch(c.type){case "click":if(a.onClick)a.onClick(b,
c);break;case "dblclick":if(a.onDblClick)a.onDblClick(b,c);break;case "mousemove":if(a.onMouseMove)a.onMouseMove(b,c);break;case "mouseover":if(a.onMouseOver)a.onMouseOver(b,c);break;case "mouseout":if(a.onMouseOut)a.onMouseOut(b,c)}},_handleScroll:function(){var c=this._getScroll(),a=this._hScroll,b=this._vScroll;if(a!==c.x||b!==c.y)this._checkOverlayScroll(),this._hScroll=c.x,this._vScroll=c.y,this._commitIME(),this._update(b===c.y),this.onScroll({type:"Scroll",oldValue:{x:a,y:b},newValue:c})},
_handleSelectStart:function(c){if(this._ignoreSelect)return c&&c.preventDefault&&c.preventDefault(),!1},_getModelOffset:function(c,a){if(c){var b;b=c.tagName==="DIV"?c:c.parentNode.parentNode;var d=0,e=b.lineIndex;if(c.tagName!=="DIV")for(b=b.firstChild;b;){var i=b.firstChild;if(i===c){b.ignoreChars&&(d-=b.ignoreChars);d+=a;break}b.ignoreChars&&(d-=b.ignoreChars);d+=i.data.length;b=b.nextSibling}return Math.max(0,d)+this._model.getLineStart(e)}},_updateSelectionFromDOM:function(){var c=this._getWindow().getSelection(),
a=this._getModelOffset(c.anchorNode,c.anchorOffset),c=this._getModelOffset(c.focusNode,c.focusOffset);a===void 0||c===void 0||this._setSelection(new d(a,c),!1,!1)},_handleSelectionChange:function(){if(this._imeOffset===-1)if(f.isAndroid){var c=this._getWindow();this._selTimer&&c.clearTimeout(this._selTimer);var a=this;this._selTimer=c.setTimeout(function(){if(a._clientDiv)a._selTimer=null,a._updateSelectionFromDOM()},250)}else this._updateSelectionFromDOM()},_handleTextInput:function(c){this._imeOffset=
-1;if(f.isAndroid){for(var a=this._getWindow().getSelection(),b=a.anchorNode;b;){if(b.lineIndex!==void 0)break;b=b.parentNode}if(b){var d=this._model,e=b.lineIndex,i=d.getLine(e),n=i,g=0,d=d.getLineStart(e);if(a.rangeCount>0)a.getRangeAt(0).deleteContents(),e=b.ownerDocument.createTextNode(c.data),a.getRangeAt(0).insertNode(e),g=this._getDOMText(b,e),n=g.text,g=g.offset,e.parentNode.removeChild(e);b.lineRemoved=!0;for(b=0;i.charCodeAt(b)===n.charCodeAt(b)&&b<g;)b++;a=i.length-1;for(e=n.length-i.length;i.charCodeAt(a)===
n.charCodeAt(a+e)&&a+e>=g+c.data.length;)a--;a++;i=n.substring(b,a+e);b+=d;a+=d;this._modifyContent({text:i,start:b,end:a,_ignoreDOMSelection:!0},!0)}}else this._doContent(c.data);c.preventDefault()},_handleTouchStart:function(c){this._commitIME();var a=this._getWindow();if(this._touchScrollTimer)this._vScrollDiv.style.display="none",this._hScrollDiv.style.display="none",a.clearInterval(this._touchScrollTimer),this._touchScrollTimer=null;var b=c.touches;if(b.length===1){var b=b[0],d=b.clientX,e=b.clientY;
this._touchStartX=d;this._touchStartY=e;if(f.isAndroid&&(e<b.pageY-a.pageYOffset||d<b.pageX-a.pageXOffset))d=b.pageX-a.pageXOffset,e=b.pageY-a.pageYOffset;a=this.convert({x:d,y:e},"page","document");this._lastTouchOffset=this.getOffsetAtLocation(a.x,a.y);this._touchStartTime=c.timeStamp;this._touching=!0}},_handleTouchMove:function(c){var a=c.touches;if(a.length===1){a=a[0];this._touchCurrentX=a.clientX;this._touchCurrentY=a.clientY;if(!this._touchScrollTimer&&c.timeStamp-this._touchStartTime<200){this._vScrollDiv.style.display=
"block";if(!this._wrapMode)this._hScrollDiv.style.display="block";var b=this,d=this._getWindow();this._touchScrollTimer=d.setInterval(function(){var c=0,a=0;if(b._touching)c=b._touchStartX-b._touchCurrentX,a=b._touchStartY-b._touchCurrentY,b._touchSpeedX=c/10,b._touchSpeedY=a/10,b._touchStartX=b._touchCurrentX,b._touchStartY=b._touchCurrentY;else if(Math.abs(b._touchSpeedX)<0.1&&Math.abs(b._touchSpeedY)<0.1){b._vScrollDiv.style.display="none";b._hScrollDiv.style.display="none";d.clearInterval(b._touchScrollTimer);
b._touchScrollTimer=null;return}else c=b._touchSpeedX*10,a=b._touchSpeedY*10,b._touchSpeedX*=0.95,b._touchSpeedY*=0.95;b._scrollView(c,a)},10)}this._touchScrollTimer&&c.preventDefault()}},_handleTouchEnd:function(c){if(c.touches.length===0)this._touching=!1},_doAction:function(c){for(var a=this._keyBindings,b=0;b<a.length;b++){var d=a[b];if(d.keyBinding.match(c)){if(d.actionID&&(c=this._actions[d.actionID]))if(c.handler){if(!c.handler())return c.defaultHandler?typeof c.defaultHandler()==="boolean":
!1}else if(c.defaultHandler)return typeof c.defaultHandler()==="boolean";return!0}}return!1},_doBackspace:function(c){var a=this._getSelection();if(a.isEmpty()){var b=this._model,d=a.getCaret(),e=b.getLineAtOffset(d),i=b.getLineStart(e);if(d===i)e>0&&a.extend(b.getLineEnd(e-1));else{var n=!1;this._expandTab&&c.unit==="character"&&(d-i)%this._tabSize===0&&(n=!/[^ ]/.test(b.getText(i,d)));n?a.extend(d-this._tabSize):(b=this._getLine(e),a.extend(b.getNextOffset(d,c.unit,-1)),b.destroy())}}this._modifyContent({text:"",
start:a.start,end:a.end},!0);return!0},_doContent:function(c){var a=this._getSelection();this._modifyContent({text:c,start:a.start,end:a.end,_ignoreDOMSelection:!0},!0)},_doCopy:function(c){var a=this._getSelection();return!a.isEmpty()?this._setClipboardText(this._getBaseText(a.start,a.end),c):!0},_doCursorNext:function(c){if(!c.select&&this._clearSelection("next"))return!0;var a=this._model,b=this._getSelection(),d=b.getCaret(),e=a.getLineAtOffset(d);d===a.getLineEnd(e)?e+1<a.getLineCount()&&b.extend(a.getLineStart(e+
1)):(a=this._getLine(e),b.extend(a.getNextOffset(d,c.unit,1)),a.destroy());c.select||b.collapse();this._setSelection(b,!0);return!0},_doCursorPrevious:function(c){if(!c.select&&this._clearSelection("previous"))return!0;var a=this._model,b=this._getSelection(),d=b.getCaret(),e=a.getLineAtOffset(d);d===a.getLineStart(e)?e>0&&b.extend(a.getLineEnd(e-1)):(a=this._getLine(e),b.extend(a.getNextOffset(d,c.unit,-1)),a.destroy());c.select||b.collapse();this._setSelection(b,!0);return!0},_doCut:function(c){var a=
this._getSelection();return!a.isEmpty()?(a=this._getBaseText(a.start,a.end),this._doContent(""),this._setClipboardText(a,c)):!0},_doDelete:function(c){var a=this._getSelection();if(a.isEmpty()){var b=this._model,d=a.getCaret(),e=b.getLineAtOffset(d);d===b.getLineEnd(e)?e+1<b.getLineCount()&&a.extend(b.getLineStart(e+1)):(b=this._getLine(e),a.extend(b.getNextOffset(d,c.unit,1)),b.destroy())}this._modifyContent({text:"",start:a.start,end:a.end},!0);return!0},_doEnd:function(c){var a=this._getSelection(),
b=this._model;if(c.ctrl)a.extend(b.getCharCount());else{var d=a.getCaret(),e=b.getLineAtOffset(d);if(this._wrapMode){var i=this._getLine(e),d=i.getLineIndex(d),d=d===i.getLineCount()-1?b.getLineEnd(e):i.getLineStart(d+1)-1;i.destroy()}else d=b.getLineEnd(e);a.extend(d)}c.select||a.collapse();this._setSelection(a,!0);return!0},_doEnter:function(c){var a=this._model,b=this._getSelection();this._doContent(a.getLineDelimiter());if(c&&c.noCursor)b.end=b.start,this._setSelection(b);return!0},_doHome:function(c){var a=
this._getSelection(),b=this._model;if(c.ctrl)a.extend(0);else{var d=a.getCaret(),e=b.getLineAtOffset(d);this._wrapMode?(b=this._getLine(e),d=b.getLineIndex(d),d=b.getLineStart(d),b.destroy()):d=b.getLineStart(e);a.extend(d)}c.select||a.collapse();this._setSelection(a,!0);return!0},_doLineDown:function(c){var a=this._model,b=this._getSelection(),d=b.getCaret(),e=a.getLineAtOffset(d),i=this._getLine(e),n=this._columnX,g=1,o=!1;if(n===-1||c.wholeLine||c.select&&f.isIE)n=c.wholeLine?a.getLineEnd(e+1):
d,n=i.getBoundingClientRect(n).left;(d=i.getLineIndex(d))<i.getLineCount()-1?g=i.getClientRects(d+1).top+1:(o=e===a.getLineCount()-1,e++);o?c.select&&(b.extend(a.getCharCount()),this._setSelection(b,!0,!0)):(i.lineIndex!==e&&(i.destroy(),i=this._getLine(e)),b.extend(i.getOffset(n,g)),c.select||b.collapse(),this._setSelection(b,!0,!0));this._columnX=n;i.destroy();return!0},_doLineUp:function(c){var a=this._model,b=this._getSelection(),d=b.getCaret(),e=a.getLineAtOffset(d),i=this._getLine(e),n=this._columnX,
g=!1,o;if(n===-1||c.wholeLine||c.select&&f.isIE)n=c.wholeLine?a.getLineStart(e-1):d,n=i.getBoundingClientRect(n).left;(d=i.getLineIndex(d))>0?o=i.getClientRects(d-1).top+1:(g=e===0,g||(e--,o=this._getLineHeight(e)-1));g?c.select&&(b.extend(0),this._setSelection(b,!0,!0)):(i.lineIndex!==e&&(i.destroy(),i=this._getLine(e)),b.extend(i.getOffset(n,o)),c.select||b.collapse(),this._setSelection(b,!0,!0));this._columnX=n;i.destroy();return!0},_doPageDown:function(c){var a=this._model,b=this._getSelection(),
d=b.getCaret(),e=a.getLineAtOffset(d),i=a.getLineCount(),n=this._getScroll(),g=this._getClientHeight(),o;if(this._lineHeight){a=this._columnX;n=this._getBoundsAtOffset(d);if(a===-1||c.select&&f.isIE)a=n.left;d=this._getLineIndex(n.top+g);o=this._getLine(d);e=this._getLinePixel(d);d=o.getOffset(a,n.top+g-e);g=o.getBoundingClientRect(d);o.destroy();b.extend(d);c.select||b.collapse();this._setSelection(b,!0,!0,g.top+e-n.top);this._columnX=a;return!0}if(e<i-1){var t=this._getLineHeight(),k=Math.min(i-
e-1,Math.floor(g/t)),k=Math.max(1,k),a=this._columnX;if(a===-1||c.select&&f.isIE)o=this._getLine(e),a=o.getBoundingClientRect(d).left,o.destroy();o=this._getLine(e+k);b.extend(o.getOffset(a,0));o.destroy();c.select||b.collapse();c=i*t;d=n.y+k*t;d+g>c&&(d=c-g);this._setSelection(b,!0,!0,d-n.y);this._columnX=a}return!0},_doPageUp:function(c){var a=this._model,b=this._getSelection(),d=b.getCaret(),e=a.getLineAtOffset(d),i=this._getScroll(),n=this._getClientHeight(),g;if(this._lineHeight){a=this._columnX;
i=this._getBoundsAtOffset(d);if(a===-1||c.select&&f.isIE)a=i.left;d=this._getLineIndex(i.bottom-n);g=this._getLine(d);e=this._getLinePixel(d);d=g.getOffset(a,i.bottom-n-e);n=g.getBoundingClientRect(d);g.destroy();b.extend(d);c.select||b.collapse();this._setSelection(b,!0,!0,n.top+e-i.top);this._columnX=a;return!0}if(e>0){var o=this._getLineHeight(),n=Math.max(1,Math.min(e,Math.floor(n/o))),a=this._columnX;if(a===-1||c.select&&f.isIE)g=this._getLine(e),a=g.getBoundingClientRect(d).left,g.destroy();
g=this._getLine(e-n);b.extend(g.getOffset(a,this._getLineHeight(e-n)-1));g.destroy();c.select||b.collapse();c=Math.max(0,i.y-n*o);this._setSelection(b,!0,!0,c-i.y);this._columnX=a}return!0},_doPaste:function(c){var a=this;return this._getClipboardText(c,function(c){c&&(f.isLinux&&a._lastMouseButton===2&&(new Date).getTime()-a._lastMouseTime<=a._clickTime&&a._setSelectionTo(a._lastMouseX,a._lastMouseY),a._doContent(c))})!==null},_doScroll:function(c){var a=c.type,b=this._model,d=b.getLineCount(),c=
this._getClientHeight(),e=this._getLineHeight();d*=e;var i=this._getScroll().y,n;switch(a){case "textStart":n=0;break;case "textEnd":n=d-c;break;case "pageDown":n=i+c;break;case "pageUp":n=i-c;break;case "centerLine":a=this._getSelection(),n=b.getLineAtOffset(a.start),b=(b.getLineAtOffset(a.end)-n+1)*e,n=n*e-c/2+b/2}n!==void 0&&(n=Math.min(Math.max(0,n),d-c),this._scrollView(0,n-i));return!0},_doSelectAll:function(){var c=this._model,a=this._getSelection();a.setCaret(0);a.extend(c.getCharCount());
this._setSelection(a,!1);return!0},_doTab:function(){if(this._tabMode&&!this._readonly){var c="\t";if(this._expandTab)var a=this._model,c=this._getSelection().getCaret(),b=a.getLineAtOffset(c),a=a.getLineStart(b),c=Array(this._tabSize-(c-a)%this._tabSize+1).join(" ");this._doContent(c);return!0}},_doShiftTab:function(){return!this._tabMode||this._readonly?void 0:!0},_doTabMode:function(){this._tabMode=!this._tabMode;return!0},_doWrapMode:function(){this.setOptions({wrapMode:!this.getOptions("wrapMode")});
return!0},_autoScroll:function(){var c=this._getSelection(),a=this.convert({x:this._autoScrollX,y:this._autoScrollY},"page","document"),b=c.getCaret(),d=this._model.getLineAtOffset(b),e;if(this._autoScrollDir==="up"||this._autoScrollDir==="down")b=this._autoScrollY/this._getLineHeight(),b=b<0?Math.floor(b):Math.ceil(b),e=d,e=Math.max(0,Math.min(this._model.getLineCount()-1,e+b));else if(this._autoScrollDir==="left"||this._autoScrollDir==="right")e=this._getLineIndex(a.y),d=this._getLine(d),a.x+=d.getBoundingClientRect(b,
!1).left,d.destroy();d=this._getLine(e);c.extend(d.getOffset(a.x,a.y-this._getLinePixel(e)));d.destroy();this._setSelection(c,!0)},_autoScrollTimer:function(){this._autoScroll();var c=this;this._autoScrollTimerID=this._getWindow().setTimeout(function(){c._autoScrollTimer()},this._AUTO_SCROLL_RATE)},_calculateLineHeightTimer:function(c){if(this._lineHeight&&!this._calculateLHTimer){var a=this._model.getLineCount(),b=0;if(c){for(var c=0,d=(new Date).getTime(),e=0;b<a;)if(this._lineHeight[b]||(c++,e||
(e=b),this._lineHeight[b]=this._calculateLineHeight(b)),b++,(new Date).getTime()-d>100)break;this.redrawRulers(0,a);this._queueUpdate()}c=this._getWindow();if(b!==a){var i=this;this._calculateLHTimer=c.setTimeout(function(){i._calculateLHTimer=null;i._calculateLineHeightTimer(!0)},0)}else if(this._calculateLHTimer)c.clearTimeout(this._calculateLHTimer),this._calculateLHTimer=void 0}},_calculateLineHeight:function(c){var c=this._getLine(c),a=c.getBoundingClientRect();c.destroy();return Math.max(1,
Math.ceil(a.bottom-a.top))},_calculateMetrics:function(){var c=this._clientDiv,j=c.ownerDocument,d=f.createElement(j,"div");d.style.lineHeight="normal";var e={type:"LineStyle",textView:this,0:0,lineText:this._model.getLine(0),lineStart:0};this.onLineStyle(e);l(e.style,d);d.style.position="fixed";d.style.left="-1000px";var i=f.createElement(j,"span");i.appendChild(j.createTextNode(" "));d.appendChild(i);var g=f.createElement(j,"span");g.style.fontStyle="italic";g.appendChild(j.createTextNode(" "));
d.appendChild(g);var n=f.createElement(j,"span");n.style.fontWeight="bold";n.appendChild(j.createTextNode(" "));d.appendChild(n);e=f.createElement(j,"span");e.style.fontWeight="bold";e.style.fontStyle="italic";e.appendChild(j.createTextNode(" "));d.appendChild(e);c.appendChild(d);var o=d.getBoundingClientRect(),i=i.getBoundingClientRect(),g=g.getBoundingClientRect(),n=n.getBoundingClientRect(),e=e.getBoundingClientRect(),i=i.bottom-i.top,g=g.bottom-g.top,n=n.bottom-n.top,k=e.bottom-e.top,t=0,e=o.bottom-
o.top<=0,o=Math.max(1,o.bottom-o.top);g>i&&(t=1);n>g&&(t=2);k>n&&(t=3);var h;if(t!==0){h={style:{}};if((t&1)!==0)h.style.fontStyle="italic";if((t&2)!==0)h.style.fontWeight="bold"}i=b(d);c.removeChild(d);g=a(this._viewDiv);d=f.createElement(j,"div");d.style.position="fixed";d.style.left="-1000px";d.style.paddingLeft=g.left+"px";d.style.paddingTop=g.top+"px";d.style.paddingRight=g.right+"px";d.style.paddingBottom=g.bottom+"px";d.style.width="100px";d.style.height="100px";n=f.createElement(j,"div");
n.style.width="100%";n.style.height="100%";d.appendChild(n);c.appendChild(d);j=d.getBoundingClientRect();g=n.getBoundingClientRect();d.style.overflow="hidden";n.style.height="200px";n=d.clientWidth;d.style.overflow="scroll";k=d.clientWidth;c.removeChild(d);g={left:g.left-j.left,top:g.top-j.top,right:j.right-g.right,bottom:j.bottom-g.bottom};return{lineHeight:o,largestFontStyle:h,lineTrim:i,viewPadding:g,scrollWidth:n-k,invalid:e}},_checkOverlayScroll:function(){if(f.isMac){var c=this,a=this._getWindow();
this._overlayScrollTimer&&a.clearTimeout(this._overlayScrollTimer);var b=function(){var d=c._isOverOverlayScroll();d.vertical||d.horizontal?c._overlayScrollTimer=a.setTimeout(b,200):(c._overlayScrollTimer=void 0,c._update())};this._overlayScrollTimer=a.setTimeout(b,200)}},_clearSelection:function(c){var a=this._getSelection();if(a.isEmpty())return!1;c==="next"?a.start=a.end:a.end=a.start;this._setSelection(a,!0);return!0},_commitIME:function(){if(this._imeOffset!==-1){this._scrollDiv.focus();this._clientDiv.focus();
var c=this._model,a=c.getLineAtOffset(this._imeOffset),b=c.getLineStart(a),d=this._getDOMText(this._getLineNode(a)).text,c=c.getLine(a),b=this._imeOffset-b,c=b+d.length-c.length;b!==c&&this._doContent(d.substring(b,c));this._imeOffset=-1}},_createActions:function(){var c=r.KeyBinding,a=this._keyBindings=[];a.push({actionID:"lineUp",keyBinding:new c(38),predefined:!0});a.push({actionID:"lineDown",keyBinding:new c(40),predefined:!0});a.push({actionID:"charPrevious",keyBinding:new c(37),predefined:!0});
a.push({actionID:"charNext",keyBinding:new c(39),predefined:!0});f.isMac?(a.push({actionID:"scrollPageUp",keyBinding:new c(33),predefined:!0}),a.push({actionID:"scrollPageDown",keyBinding:new c(34),predefined:!0}),a.push({actionID:"pageUp",keyBinding:new c(33,null,null,!0),predefined:!0}),a.push({actionID:"pageDown",keyBinding:new c(34,null,null,!0),predefined:!0}),a.push({actionID:"lineStart",keyBinding:new c(37,!0),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c(39,!0),predefined:!0}),
a.push({actionID:"wordPrevious",keyBinding:new c(37,null,null,!0),predefined:!0}),a.push({actionID:"wordNext",keyBinding:new c(39,null,null,!0),predefined:!0}),a.push({actionID:"scrollTextStart",keyBinding:new c(36),predefined:!0}),a.push({actionID:"scrollTextEnd",keyBinding:new c(35),predefined:!0}),a.push({actionID:"textStart",keyBinding:new c(38,!0),predefined:!0}),a.push({actionID:"textEnd",keyBinding:new c(40,!0),predefined:!0}),a.push({actionID:"scrollPageUp",keyBinding:new c(38,null,null,null,
!0),predefined:!0}),a.push({actionID:"scrollPageDown",keyBinding:new c(40,null,null,null,!0),predefined:!0}),a.push({actionID:"lineStart",keyBinding:new c(37,null,null,null,!0),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c(39,null,null,null,!0),predefined:!0}),a.push({actionID:"lineStart",keyBinding:new c(38,null,null,!0),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c(40,null,null,!0),predefined:!0})):(a.push({actionID:"pageUp",keyBinding:new c(33),predefined:!0}),a.push({actionID:"pageDown",
keyBinding:new c(34),predefined:!0}),a.push({actionID:"lineStart",keyBinding:new c(36),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c(35),predefined:!0}),a.push({actionID:"wordPrevious",keyBinding:new c(37,!0),predefined:!0}),a.push({actionID:"wordNext",keyBinding:new c(39,!0),predefined:!0}),a.push({actionID:"textStart",keyBinding:new c(36,!0),predefined:!0}),a.push({actionID:"textEnd",keyBinding:new c(35,!0),predefined:!0}));f.isFirefox&&f.isLinux&&(a.push({actionID:"lineUp",keyBinding:new c(38,
!0),predefined:!0}),a.push({actionID:"lineDown",keyBinding:new c(40,!0),predefined:!0}));a.push({actionID:"selectLineUp",keyBinding:new c(38,null,!0),predefined:!0});a.push({actionID:"selectLineDown",keyBinding:new c(40,null,!0),predefined:!0});a.push({actionID:"selectCharPrevious",keyBinding:new c(37,null,!0),predefined:!0});a.push({actionID:"selectCharNext",keyBinding:new c(39,null,!0),predefined:!0});a.push({actionID:"selectPageUp",keyBinding:new c(33,null,!0),predefined:!0});a.push({actionID:"selectPageDown",
keyBinding:new c(34,null,!0),predefined:!0});f.isMac?(a.push({actionID:"selectLineStart",keyBinding:new c(37,!0,!0),predefined:!0}),a.push({actionID:"selectLineEnd",keyBinding:new c(39,!0,!0),predefined:!0}),a.push({actionID:"selectWordPrevious",keyBinding:new c(37,null,!0,!0),predefined:!0}),a.push({actionID:"selectWordNext",keyBinding:new c(39,null,!0,!0),predefined:!0}),a.push({actionID:"selectTextStart",keyBinding:new c(36,null,!0),predefined:!0}),a.push({actionID:"selectTextEnd",keyBinding:new c(35,
null,!0),predefined:!0}),a.push({actionID:"selectTextStart",keyBinding:new c(38,!0,!0),predefined:!0}),a.push({actionID:"selectTextEnd",keyBinding:new c(40,!0,!0),predefined:!0}),a.push({actionID:"selectLineStart",keyBinding:new c(37,null,!0,null,!0),predefined:!0}),a.push({actionID:"selectLineEnd",keyBinding:new c(39,null,!0,null,!0),predefined:!0}),a.push({actionID:"selectLineStart",keyBinding:new c(38,null,!0,!0),predefined:!0}),a.push({actionID:"selectLineEnd",keyBinding:new c(40,null,!0,!0),
predefined:!0})):(f.isLinux&&(a.push({actionID:"selectWholeLineUp",keyBinding:new c(38,!0,!0),predefined:!0}),a.push({actionID:"selectWholeLineDown",keyBinding:new c(40,!0,!0),predefined:!0})),a.push({actionID:"selectLineStart",keyBinding:new c(36,null,!0),predefined:!0}),a.push({actionID:"selectLineEnd",keyBinding:new c(35,null,!0),predefined:!0}),a.push({actionID:"selectWordPrevious",keyBinding:new c(37,!0,!0),predefined:!0}),a.push({actionID:"selectWordNext",keyBinding:new c(39,!0,!0),predefined:!0}),
a.push({actionID:"selectTextStart",keyBinding:new c(36,!0,!0),predefined:!0}),a.push({actionID:"selectTextEnd",keyBinding:new c(35,!0,!0),predefined:!0}));a.push({actionID:"undo",keyBinding:new r.KeyBinding("z",!0),predefined:!0});f.isMac?a.push({actionID:"redo",keyBinding:new r.KeyBinding("z",!0,!0),predefined:!0}):a.push({actionID:"redo",keyBinding:new r.KeyBinding("y",!0),predefined:!0});a.push({actionID:"deletePrevious",keyBinding:new c(8),predefined:!0});a.push({actionID:"deletePrevious",keyBinding:new c(8,
null,!0),predefined:!0});a.push({actionID:"deleteNext",keyBinding:new c(46),predefined:!0});a.push({actionID:"deleteWordPrevious",keyBinding:new c(8,!0),predefined:!0});a.push({actionID:"deleteWordPrevious",keyBinding:new c(8,!0,!0),predefined:!0});a.push({actionID:"deleteWordNext",keyBinding:new c(46,!0),predefined:!0});a.push({actionID:"tab",keyBinding:new c(9),predefined:!0});a.push({actionID:"shiftTab",keyBinding:new c(9,null,!0),predefined:!0});a.push({actionID:"enter",keyBinding:new c(13),predefined:!0});
a.push({actionID:"enter",keyBinding:new c(13,null,!0),predefined:!0});a.push({actionID:"selectAll",keyBinding:new c("a",!0),predefined:!0});a.push({actionID:"toggleTabMode",keyBinding:new c("m",!0),predefined:!0});f.isMac&&(a.push({actionID:"deleteNext",keyBinding:new c(46,null,!0),predefined:!0}),a.push({actionID:"deleteWordPrevious",keyBinding:new c(8,null,null,!0),predefined:!0}),a.push({actionID:"deleteWordNext",keyBinding:new c(46,null,null,!0),predefined:!0}));if(!f.isFirefox){var b=f.isMac&&
f.isChrome;a.push({actionID:null,keyBinding:new c("u",!b,!1,!1,b),predefined:!0});a.push({actionID:null,keyBinding:new c("i",!b,!1,!1,b),predefined:!0});a.push({actionID:null,keyBinding:new c("b",!b,!1,!1,b),predefined:!0})}f.isFirefox&&(a.push({actionID:"copy",keyBinding:new c(45,!0),predefined:!0}),a.push({actionID:"paste",keyBinding:new c(45,null,!0),predefined:!0}),a.push({actionID:"cut",keyBinding:new c(46,null,!0),predefined:!0}));f.isMac&&(a.push({actionID:"lineStart",keyBinding:new c("a",
!1,!1,!1,!0),predefined:!0}),a.push({actionID:"lineEnd",keyBinding:new c("e",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"lineUp",keyBinding:new c("p",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"lineDown",keyBinding:new c("n",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"charPrevious",keyBinding:new c("b",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"charNext",keyBinding:new c("f",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"deletePrevious",keyBinding:new c("h",!1,!1,!1,!0),predefined:!0}),
a.push({actionID:"deleteNext",keyBinding:new c("d",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"deleteLineEnd",keyBinding:new c("k",!1,!1,!1,!0),predefined:!0}),f.isFirefox?(a.push({actionID:"scrollPageDown",keyBinding:new c("v",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"deleteLineStart",keyBinding:new c("u",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"deleteWordPrevious",keyBinding:new c("w",!1,!1,!1,!0),predefined:!0})):(a.push({actionID:"pageDown",keyBinding:new c("v",!1,!1,!1,!0),predefined:!0}),
a.push({actionID:"centerLine",keyBinding:new c("l",!1,!1,!1,!0),predefined:!0}),a.push({actionID:"enterNoCursor",keyBinding:new c("o",!1,!1,!1,!0),predefined:!0})));var d=this;this._actions={lineUp:{defaultHandler:function(){return d._doLineUp({select:!1})}},lineDown:{defaultHandler:function(){return d._doLineDown({select:!1})}},lineStart:{defaultHandler:function(){return d._doHome({select:!1,ctrl:!1})}},lineEnd:{defaultHandler:function(){return d._doEnd({select:!1,ctrl:!1})}},charPrevious:{defaultHandler:function(){return d._doCursorPrevious({select:!1,
unit:"character"})}},charNext:{defaultHandler:function(){return d._doCursorNext({select:!1,unit:"character"})}},pageUp:{defaultHandler:function(){return d._doPageUp({select:!1})}},pageDown:{defaultHandler:function(){return d._doPageDown({select:!1})}},scrollPageUp:{defaultHandler:function(){return d._doScroll({type:"pageUp"})}},scrollPageDown:{defaultHandler:function(){return d._doScroll({type:"pageDown"})}},wordPrevious:{defaultHandler:function(){return d._doCursorPrevious({select:!1,unit:"word"})}},
wordNext:{defaultHandler:function(){return d._doCursorNext({select:!1,unit:"word"})}},textStart:{defaultHandler:function(){return d._doHome({select:!1,ctrl:!0})}},textEnd:{defaultHandler:function(){return d._doEnd({select:!1,ctrl:!0})}},scrollTextStart:{defaultHandler:function(){return d._doScroll({type:"textStart"})}},scrollTextEnd:{defaultHandler:function(){return d._doScroll({type:"textEnd"})}},centerLine:{defaultHandler:function(){return d._doScroll({type:"centerLine"})}},selectLineUp:{defaultHandler:function(){return d._doLineUp({select:!0})}},
selectLineDown:{defaultHandler:function(){return d._doLineDown({select:!0})}},selectWholeLineUp:{defaultHandler:function(){return d._doLineUp({select:!0,wholeLine:!0})}},selectWholeLineDown:{defaultHandler:function(){return d._doLineDown({select:!0,wholeLine:!0})}},selectLineStart:{defaultHandler:function(){return d._doHome({select:!0,ctrl:!1})}},selectLineEnd:{defaultHandler:function(){return d._doEnd({select:!0,ctrl:!1})}},selectCharPrevious:{defaultHandler:function(){return d._doCursorPrevious({select:!0,
unit:"character"})}},selectCharNext:{defaultHandler:function(){return d._doCursorNext({select:!0,unit:"character"})}},selectPageUp:{defaultHandler:function(){return d._doPageUp({select:!0})}},selectPageDown:{defaultHandler:function(){return d._doPageDown({select:!0})}},selectWordPrevious:{defaultHandler:function(){return d._doCursorPrevious({select:!0,unit:"word"})}},selectWordNext:{defaultHandler:function(){return d._doCursorNext({select:!0,unit:"word"})}},selectTextStart:{defaultHandler:function(){return d._doHome({select:!0,
ctrl:!0})}},selectTextEnd:{defaultHandler:function(){return d._doEnd({select:!0,ctrl:!0})}},deletePrevious:{defaultHandler:function(){return d._doBackspace({unit:"character"})}},deleteNext:{defaultHandler:function(){return d._doDelete({unit:"character"})}},deleteWordPrevious:{defaultHandler:function(){return d._doBackspace({unit:"word"})}},deleteWordNext:{defaultHandler:function(){return d._doDelete({unit:"word"})}},deleteLineStart:{defaultHandler:function(){return d._doBackspace({unit:"line"})}},
deleteLineEnd:{defaultHandler:function(){return d._doDelete({unit:"line"})}},tab:{defaultHandler:function(){return d._doTab()}},shiftTab:{defaultHandler:function(){return d._doShiftTab()}},enter:{defaultHandler:function(){return d._doEnter()}},enterNoCursor:{defaultHandler:function(){return d._doEnter({noCursor:!0})}},selectAll:{defaultHandler:function(){return d._doSelectAll()}},copy:{defaultHandler:function(){return d._doCopy()}},cut:{defaultHandler:function(){return d._doCut()}},paste:{defaultHandler:function(){return d._doPaste()}},
toggleWrapMode:{defaultHandler:function(){return d._doWrapMode()}},toggleTabMode:{defaultHandler:function(){return d._doTabMode()}}}},_createRuler:function(c,a){if(this._clientDiv){var b=c.getLocation()==="left"?this._leftDiv:this._rightDiv;b.style.display="block";var d=f.createElement(b.ownerDocument,"div");d._ruler=c;d.rulerChanged=!0;d.style.position="relative";var b=b.firstChild.rows[0],e=b.cells.length,b=b.insertCell(a===void 0||a<0||a>e?e:a);b.vAlign="top";b.style.verticalAlign="top";b.style.borderWidth=
"0px";b.style.margin="0px";b.style.padding="0px";b.style.outline="none";b.appendChild(d)}},_createView:function(){if(!this._clientDiv){for(var c=this._parent;c.hasChildNodes();)c.removeChild(c.lastChild);var a=c.ownerDocument,b=f.createElement(a,"div");this._rootDiv=b;b.tabIndex=-1;b.style.position="relative";b.style.overflow="hidden";b.style.width="100%";b.style.height="100%";c.style.overflow="hidden";b.setAttribute("role","application");c.appendChild(b);c=f.createElement(a,"div");c.className="textviewLeftRuler";
this._leftDiv=c;c.tabIndex=-1;c.style.overflow="hidden";c.style.MozUserSelect="none";c.style.WebkitUserSelect="none";c.style.position="absolute";c.style.cursor="default";c.style.display="none";c.setAttribute("aria-hidden","true");var d=f.createElement(a,"table");c.appendChild(d);d.cellPadding="0px";d.cellSpacing="0px";d.border="0px";d.style.borderWidth="0px";d.style.margin="0px";d.style.padding="0px";d.style.outline="none";d.style.lineHeight="normal";d=d.insertRow(0);d.style.borderWidth="0px";d.style.margin=
"0px";d.style.padding="0px";d.style.outline="none";d.style.lineHeight="normal";b.appendChild(c);c=f.createElement(a,"div");c.className="textview";this._viewDiv=c;c.tabIndex=-1;c.style.overflow="auto";c.style.position="absolute";c.style.top="0px";c.style.bottom="0px";c.style.borderWidth="0px";c.style.margin="0px";c.style.outline="none";b.appendChild(c);var e=f.createElement(a,"div");e.className="textviewRightRuler";this._rightDiv=e;e.tabIndex=-1;e.style.display="none";e.style.overflow="hidden";e.style.MozUserSelect=
"none";e.style.WebkitUserSelect="none";e.style.position="absolute";e.style.cursor="default";e.style.right="0px";e.setAttribute("aria-hidden","true");d=f.createElement(a,"table");e.appendChild(d);d.cellPadding="0px";d.cellSpacing="0px";d.border="0px";d.style.borderWidth="0px";d.style.margin="0px";d.style.padding="0px";d.style.outline="none";d.style.lineHeight="normal";d=d.insertRow(0);d.style.borderWidth="0px";d.style.margin="0px";d.style.padding="0px";d.style.outline="none";d.style.lineHeight="normal";
b.appendChild(e);this._scrollDiv=d=f.createElement(a,"div");d.style.margin="0px";d.style.borderWidth="0px";d.style.padding="0px";c.appendChild(d);if(f.isFirefox)this._clipboardDiv=c=f.createElement(a,"div"),c.style.position="fixed",c.style.whiteSpace="pre",c.style.left="-1000px",b.appendChild(c);if(!f.isIE&&!f.isIOS)this._clipDiv=c=f.createElement(a,"div"),c.style.position="absolute",c.style.overflow="hidden",c.style.margin="0px",c.style.borderWidth="0px",c.style.padding="0px",b.appendChild(c),this._clipScrollDiv=
d=f.createElement(a,"div"),d.style.position="absolute",d.style.height="1px",d.style.top="-1000px",c.appendChild(d);this._setFullSelection(this._fullSelection,!0);c=f.createElement(a,"div");c.className="textviewContent";this._clientDiv=c;c.style.position="absolute";c.style.borderWidth="0px";c.style.margin="0px";c.style.padding="0px";c.style.outline="none";c.style.zIndex="1";c.style.WebkitUserSelect="text";c.setAttribute("spellcheck","false");if(f.isIOS||f.isAndroid)c.style.WebkitTapHighlightColor=
"transparent";(this._clipDiv||b).appendChild(c);if(f.isIOS||f.isAndroid)this._vScrollDiv=d=f.createElement(a,"div"),d.style.position="absolute",d.style.borderWidth="1px",d.style.borderColor="white",d.style.borderStyle="solid",d.style.borderRadius="4px",d.style.backgroundColor="black",d.style.opacity="0.5",d.style.margin="0px",d.style.padding="0px",d.style.outline="none",d.style.zIndex="3",d.style.width="8px",d.style.display="none",b.appendChild(d),this._hScrollDiv=d=f.createElement(a,"div"),d.style.position=
"absolute",d.style.borderWidth="1px",d.style.borderColor="white",d.style.borderStyle="solid",d.style.borderRadius="4px",d.style.backgroundColor="black",d.style.opacity="0.5",d.style.margin="0px",d.style.padding="0px",d.style.outline="none",d.style.zIndex="3",d.style.height="8px",d.style.display="none",b.appendChild(d);if(f.isFirefox&&!c.setCapture)this._overlayDiv=d=f.createElement(a,"div"),d.style.position=c.style.position,d.style.borderWidth=c.style.borderWidth,d.style.margin=c.style.margin,d.style.padding=
c.style.padding,d.style.cursor="text",d.style.zIndex="2",(this._clipDiv||b).appendChild(d);c.contentEditable="true";c.setAttribute("role","textbox");c.setAttribute("aria-multiline","true");this._setWrapMode(this._wrapMode,!0);this._setReadOnly(this._readonly);this._setThemeClass(this._themeClass,!0);this._setTabSize(this._tabSize,!0);if(!a.getElementById("_textviewStyle")&&(b="",f.isWebkit&&this._metrics.scrollWidth>0&&(b+="\n.textviewContainer ::-webkit-scrollbar-corner {background: #eeeeee;}"),
f.isFirefox&&f.isMac&&this._highlightRGB&&this._highlightRGB!=="Highlight"&&(b+="\n.textviewContainer ::-moz-selection {background: "+this._highlightRGB+";}"),b))c=f.createElement(a,"style"),c.id="_textviewStyle",d=a.getElementsByTagName("head")[0]||a.documentElement,c.appendChild(a.createTextNode(b)),d.insertBefore(c,d.firstChild);this._hookEvents();a=this._rulers;for(b=0;b<a.length;b++)this._createRuler(a[b]);this._update()}},_defaultOptions:function(){return{parent:{value:void 0,update:null},model:{value:void 0,
update:this.setModel},readonly:{value:!1,update:this._setReadOnly},fullSelection:{value:!0,update:this._setFullSelection},tabMode:{value:!0,update:null},tabSize:{value:8,update:this._setTabSize},expandTab:{value:!1,update:null},wrapMode:{value:!1,update:this._setWrapMode},themeClass:{value:void 0,update:this._setThemeClass}}},_destroyRuler:function(c){var a=c.getLocation()==="left"?this._leftDiv:this._rightDiv;if(a){for(var b=a.firstChild.rows[0],d=b.cells,e=0;e<d.length;e++)if(d[e].firstChild._ruler===
c)break;if(e!==d.length&&(b.cells[e]._ruler=void 0,b.deleteCell(e),d.length===0))a.style.display="none"}},_destroyView:function(){if(this._clientDiv){this._setGrab(null);this._unhookEvents();var c=this._getWindow();if(this._autoScrollTimerID)c.clearTimeout(this._autoScrollTimerID),this._autoScrollTimerID=null;if(this._updateTimer)c.clearTimeout(this._updateTimer),this._updateTimer=null;c=this._rootDiv;c.parentNode.removeChild(c);this._hScrollDiv=this._vScrollDiv=this._rightDiv=this._leftDiv=this._overlayDiv=
this._clientDiv=this._clipScrollDiv=this._clipDiv=this._viewDiv=this._scrollDiv=this._rootDiv=this._clipboardDiv=this._selDiv3=this._selDiv2=this._selDiv1=null}},_doAutoScroll:function(c,a,b){this._autoScrollDir=c;this._autoScrollX=a;this._autoScrollY=b;this._autoScrollTimerID||this._autoScrollTimer()},_endAutoScroll:function(){this._autoScrollTimerID&&this._getWindow().clearTimeout(this._autoScrollTimerID);this._autoScrollTimerID=this._autoScrollDir=void 0},_fixCaret:function(){var c=this._clientDiv;
if(c){var a=this._hasFocus;this._ignoreFocus=!0;a&&c.blur();c.contentEditable=!1;c.contentEditable=!0;a&&c.focus();this._ignoreFocus=!1}},_getBaseText:function(c,a){var b=this._model;b.getBaseModel&&(c=b.mapOffset(c),a=b.mapOffset(a),b=b.getBaseModel());return b.getText(c,a)},_getBottomIndex:function(c){var a=this._bottomChild;if(c&&this._getClientHeight()>this._getLineHeight()){var c=a.getBoundingClientRect(),b=this._clientDiv.getBoundingClientRect();c.bottom>b.bottom&&(a=this._getLinePrevious(a)||
a)}return a.lineIndex},_getBoundsAtOffset:function(c){var a=this._getLine(this._model.getLineAtOffset(c)),c=a.getBoundingClientRect(c),b=this._getLinePixel(a.lineIndex);c.top+=b;c.bottom+=b;a.destroy();return c},_getClientHeight:function(){var c=this._getViewPadding();return Math.max(0,this._viewDiv.clientHeight-c.top-c.bottom)},_getClientWidth:function(){var c=this._getViewPadding();return Math.max(0,this._viewDiv.clientWidth-c.left-c.right)},_getClipboardText:function(c,a){var b=this._model.getLineDelimiter(),
d,i,g=this._getWindow();if(g.clipboardData)return d=[],i=g.clipboardData.getData("Text"),e(i,function(c){d.push(c)},function(){d.push(b)}),i=d.join(""),a&&a(i),i;if(f.isFirefox){this._ignoreFocus=!0;var n=this._clipboardDiv;n.innerHTML="<pre contenteditable=''></pre>";n.firstChild.focus();var o=this,k=function(){var c=o._getTextFromElement(n);n.innerHTML="";d=[];e(c,function(c){d.push(c)},function(){d.push(b)});return d.join("")},t=!1;this._ignorePaste=!0;if(!f.isLinux||this._lastMouseButton!==2)try{t=
n.ownerDocument.execCommand("paste",!1,null)}catch(h){t=n.childNodes.length>1||n.firstChild&&n.firstChild.childNodes.length>0}this._ignorePaste=!1;if(!t)return c?(g.setTimeout(function(){o.focus();(i=k())&&a&&a(i);o._ignoreFocus=!1},0),null):(this.focus(),this._ignoreFocus=!1,"");this.focus();this._ignoreFocus=!1;(i=k())&&a&&a(i);return i}return c&&c.clipboardData?(d=[],i=c.clipboardData.getData("text/plain"),e(i,function(c){d.push(c)},function(){d.push(b)}),(i=d.join(""))&&a&&a(i),i):""},_getDOMText:function(c,
a){for(var b=c.firstChild,d="",e=0;b;){var i;if(b.ignoreChars){i=b.lastChild;for(var n=0,g=[],f=-1;i;){for(var o=i.data,k=o.length-1;k>=0;k--){var h=o.substring(k,k+1);n<b.ignoreChars&&(h===" "||h==="\u200c"||h==="\ufeff")?n++:g.push(h==="\u00a0"?"\t":h)}if(a===i)f=g.length;i=i.previousSibling}g=g.reverse().join("");f!==-1&&(e=d.length+g.length-f);d+=g}else for(i=b.firstChild;i;){if(a===i)e=d.length;d+=i.data;i=i.nextSibling}b=b.nextSibling}return{text:d,offset:e}},_getTextFromElement:function(c){var a=
c.ownerDocument,b=a.defaultView;if(!b.getSelection)return c.innerText||c.textContent;a=a.createRange();a.selectNode(c);var c=b.getSelection(),b=[],d;for(d=0;d<c.rangeCount;d++)b.push(c.getRangeAt(d));this._ignoreSelect=!0;c.removeAllRanges();c.addRange(a);a=c.toString();c.removeAllRanges();for(d=0;d<b.length;d++)c.addRange(b[d]);this._ignoreSelect=!1;return a},_getViewPadding:function(){return this._metrics.viewPadding},_getLine:function(c){var a=this._getLineNode(c);return a&&!a.lineChanged&&!a.lineRemoved?
a._line:new g(this,c)},_getLineHeight:function(c,a){if(c!==void 0&&this._lineHeight){var b=this._lineHeight[c];if(b)return b;if(a||a===void 0)return this._lineHeight[c]=this._calculateLineHeight(c)}return this._metrics.lineHeight},_getLineNode:function(c){for(var a=this._clientDiv.firstChild;a;){if(c===a.lineIndex)return a;a=a.nextSibling}},_getLineNext:function(c){for(c=c?c.nextSibling:this._clientDiv.firstChild;c&&c.lineIndex===-1;)c=c.nextSibling;return c},_getLinePrevious:function(c){for(c=c?
c.previousSibling:this._clientDiv.lastChild;c&&c.lineIndex===-1;)c=c.previousSibling;return c},_getLinePixel:function(c){c=Math.min(Math.max(0,c),this._model.getLineCount());if(this._lineHeight){var a=this._getTopIndex(),b=-this._topIndexY+this._getScroll().y;if(c>a)for(;a<c;a++)b+=this._getLineHeight(a);else for(a-=1;a>=c;a--)b-=this._getLineHeight(a);return b}return this._getLineHeight()*c},_getLineIndex:function(c){var a,b=0,d=this._model.getLineCount();if(this._lineHeight){var b=this._getTopIndex(),
e=-this._topIndexY+this._getScroll().y;if(c!==e)if(c<e)for(;c<e&&b>0;)c+=this._getLineHeight(--b);else for(a=this._getLineHeight(b);c-a>=e&&b<d-1;)c-=a,a=this._getLineHeight(++b)}else a=this._getLineHeight(),b=Math.floor(c/a);return Math.max(0,Math.min(d-1,b))},_getScroll:function(){var c=this._viewDiv;return{x:c.scrollLeft,y:c.scrollTop}},_getSelection:function(){return this._selection.clone()},_getTopIndex:function(c){var a=this._topChild;if(c&&this._getClientHeight()>this._getLineHeight()){var c=
a.getBoundingClientRect(),b=this._getViewPadding(),d=this._viewDiv.getBoundingClientRect();c.top<d.top+b.top&&(a=this._getLineNext(a)||a)}return a.lineIndex},_hookEvents:function(){var c=this;this._modelListener={onChanging:function(a){c._onModelChanging(a)},onChanged:function(a){c._onModelChanged(a)}};this._model.addEventListener("preChanging",this._modelListener.onChanging);this._model.addEventListener("postChanged",this._modelListener.onChanged);var a=this._handlers=[],b=this._clientDiv,d=this._viewDiv,
e=this._rootDiv,i=this._overlayDiv||b,n=b.ownerDocument,g=this._getWindow(),o=f.isIE?n:g;a.push({target:g,type:"resize",handler:function(a){return c._handleResize(a?a:g.event)}});a.push({target:b,type:"blur",handler:function(a){return c._handleBlur(a?a:g.event)}});a.push({target:b,type:"focus",handler:function(a){return c._handleFocus(a?a:g.event)}});a.push({target:d,type:"focus",handler:function(){b.focus()}});a.push({target:d,type:"scroll",handler:function(a){return c._handleScroll(a?a:g.event)}});
a.push({target:b,type:"textInput",handler:function(a){return c._handleTextInput(a?a:g.event)}});a.push({target:b,type:"keydown",handler:function(a){return c._handleKeyDown(a?a:g.event)}});a.push({target:b,type:"keypress",handler:function(a){return c._handleKeyPress(a?a:g.event)}});a.push({target:b,type:"keyup",handler:function(a){return c._handleKeyUp(a?a:g.event)}});a.push({target:b,type:"contextmenu",handler:function(a){return c._handleContextMenu(a?a:g.event)}});a.push({target:b,type:"copy",handler:function(a){return c._handleCopy(a?
a:g.event)}});a.push({target:b,type:"cut",handler:function(a){return c._handleCut(a?a:g.event)}});a.push({target:b,type:"paste",handler:function(a){return c._handlePaste(a?a:g.event)}});if(f.isIOS||f.isAndroid)a.push({target:n,type:"selectionchange",handler:function(a){return c._handleSelectionChange(a?a:g.event)}}),a.push({target:b,type:"touchstart",handler:function(a){return c._handleTouchStart(a?a:g.event)}}),a.push({target:b,type:"touchmove",handler:function(a){return c._handleTouchMove(a?a:g.event)}}),
a.push({target:b,type:"touchend",handler:function(a){return c._handleTouchEnd(a?a:g.event)}});else{a.push({target:b,type:"selectstart",handler:function(a){return c._handleSelectStart(a?a:g.event)}});a.push({target:b,type:"mousedown",handler:function(a){return c._handleMouseDown(a?a:g.event)}});a.push({target:b,type:"mouseover",handler:function(a){return c._handleMouseOver(a?a:g.event)}});a.push({target:b,type:"mouseout",handler:function(a){return c._handleMouseOut(a?a:g.event)}});a.push({target:o,
type:"mouseup",handler:function(a){return c._handleMouseUp(a?a:g.event)}});a.push({target:o,type:"mousemove",handler:function(a){return c._handleMouseMove(a?a:g.event)}});a.push({target:e,type:"mousedown",handler:function(a){return c._handleRootMouseDown(a?a:g.event)}});a.push({target:e,type:"mouseup",handler:function(a){return c._handleRootMouseUp(a?a:g.event)}});a.push({target:i,type:"dragstart",handler:function(a){return c._handleDragStart(a?a:g.event)}});a.push({target:i,type:"drag",handler:function(a){return c._handleDrag(a?
a:g.event)}});a.push({target:i,type:"dragend",handler:function(a){return c._handleDragEnd(a?a:g.event)}});a.push({target:i,type:"dragenter",handler:function(a){return c._handleDragEnter(a?a:g.event)}});a.push({target:i,type:"dragover",handler:function(a){return c._handleDragOver(a?a:g.event)}});a.push({target:i,type:"dragleave",handler:function(a){return c._handleDragLeave(a?a:g.event)}});a.push({target:i,type:"drop",handler:function(a){return c._handleDrop(a?a:g.event)}});a.push({target:this._clientDiv,
type:f.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(a){return c._handleMouseWheel(a?a:g.event)}});if(f.isFirefox&&(!f.isWindows||f.isFirefox>=15))(d=g.MutationObserver||g.MozMutationObserver)?(this._mutationObserver=new d(function(a){c._handleDataModified(a)}),this._mutationObserver.observe(b,{subtree:!0,characterData:!0})):a.push({target:this._clientDiv,type:"DOMCharacterDataModified",handler:function(a){return c._handleDataModified(a?a:g.event)}});this._overlayDiv&&(a.push({target:this._overlayDiv,
type:"mousedown",handler:function(a){return c._handleMouseDown(a?a:g.event)}}),a.push({target:this._overlayDiv,type:"mouseover",handler:function(a){return c._handleMouseOver(a?a:g.event)}}),a.push({target:this._overlayDiv,type:"mouseout",handler:function(a){return c._handleMouseOut(a?a:g.event)}}),a.push({target:this._overlayDiv,type:"contextmenu",handler:function(a){return c._handleContextMenu(a?a:g.event)}}));this._isW3CEvents||a.push({target:this._clientDiv,type:"dblclick",handler:function(a){return c._handleDblclick(a?
a:g.event)}})}d=this._leftDiv;e=this._rightDiv;f.isIE&&a.push({target:d,type:"selectstart",handler:function(){return!1}});a.push({target:d,type:f.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(a){return c._handleMouseWheel(a?a:g.event)}});a.push({target:d,type:"click",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:d,type:"dblclick",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:d,type:"mousemove",handler:function(a){c._handleRulerEvent(a?a:
g.event)}});a.push({target:d,type:"mouseover",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:d,type:"mouseout",handler:function(a){c._handleRulerEvent(a?a:g.event)}});f.isIE&&a.push({target:e,type:"selectstart",handler:function(){return!1}});a.push({target:e,type:f.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(a){return c._handleMouseWheel(a?a:g.event)}});a.push({target:e,type:"click",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:e,type:"dblclick",
handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:e,type:"mousemove",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:e,type:"mouseover",handler:function(a){c._handleRulerEvent(a?a:g.event)}});a.push({target:e,type:"mouseout",handler:function(a){c._handleRulerEvent(a?a:g.event)}});for(d=0;d<a.length;d++)e=a[d],h(e.target,e.type,e.handler,e.capture)},_getWindow:function(){return this._parent.ownerDocument.defaultView||this._parent.ownerDocument.parentWindow},
_init:function(a){var b=a.parent;typeof b==="string"&&(b=(a.document||document).getElementById(b));if(!b)throw"no parent";a.parent=b;a.model=a.model||new s.TextModel;var e=this._defaultOptions(),i;for(i in e)e.hasOwnProperty(i)&&(this["_"+i]=a[i]!==void 0?a[i]:e[i].value);this._rulers=[];this._selection=new d(0,0,!1);this._linksVisible=!1;this._maxLineWidth=this._redrawCount=0;this._maxLineIndex=-1;this._ignoreSelect=!0;this._hasFocus=this._ignoreFocus=!1;this._dragOffset=this._columnX=-1;this._isRangeRects=
(!f.isIE||f.isIE>=9)&&typeof b.ownerDocument.createRange().getBoundingClientRect==="function";this._isW3CEvents=b.addEventListener;this._autoScrollTimerID=this._autoScrollY=this._autoScrollX=null;this._AUTO_SCROLL_RATE=50;this._mouseUpClosure=this._moseMoveClosure=this._grabControl=null;this._clickCount=this._lastMouseTime=this._lastMouseY=this._lastMouseX=0;this._clickTime=250;this._clickDist=5;this._isMouseDown=!1;this._doubleClickSelection=null;this._vScroll=this._hScroll=0;this._imeOffset=-1;
this._createActions();this._createView()},_isOverOverlayScroll:function(){if(!f.isMac)return{};var a=this._viewDiv.getBoundingClientRect(),b=this._lastMouseMoveX,d=this._lastMouseMoveY;return{vertical:a.top<=d&&d<a.bottom&&a.right-15<=b&&b<a.right,horizontal:a.bottom-15<=d&&d<a.bottom&&a.left<=b&&b<a.right}},_modifyContent:function(a,b){if(!this._readonly||a._code)if(a.type="Verify",this.onVerify(a),!(a.text===null||a.text===void 0)){var d=this._model;try{if(a._ignoreDOMSelection)this._ignoreDOMSelection=
!0;d.setText(a.text,a.start,a.end)}finally{if(a._ignoreDOMSelection)this._ignoreDOMSelection=!1}b&&(d=this._getSelection(),d.setCaret(a.start+a.text.length),this._setSelection(d,!0));this.onModify({type:"Modify"})}},_onModelChanged:function(a){a.type="ModelChanged";this.onModelChanged(a);a.type="Changed";var b=a.start,d=a.addedCharCount,e=a.removedCharCount,i=a.addedLineCount,g=a.removedLineCount,n=this._getSelection();n.end>b&&(n.end>b&&n.start<b+e?n.setCaret(b+d):(n.start+=d-e,n.end+=d-e),this._setSelection(n,
!1,!1));b=this._model.getLineAtOffset(b);for(d=this._getLineNext();d;){e=d.lineIndex;if(b<=e&&e<=b+g)b===e&&!d.modelChangedEvent&&!d.lineRemoved?(d.modelChangedEvent=a,d.lineChanged=!0):(d.lineRemoved=!0,d.lineChanged=!1,d.modelChangedEvent=null);if(e>b+g)d.lineIndex=e+i-g,d._line.lineIndex=d.lineIndex;d=this._getLineNext(d)}if(!this._wrapMode&&b<=this._maxLineIndex&&this._maxLineIndex<=b+g)this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0;this._update()},_onModelChanging:function(a){a.type=
"ModelChanging";this.onModelChanging(a);a.type="Changing"},_queueUpdate:function(){if(!this._updateTimer&&!this._ignoreQueueUpdate){var a=this;this._updateTimer=this._getWindow().setTimeout(function(){a._updateTimer=null;a._update()},0)}},_resetLineHeight:function(a,b){if(this._wrapMode){if(a!==void 0&&b!==void 0)for(var d=a;d<b;d++)this._lineHeight[d]=void 0;else this._lineHeight=Array(this._model.getLineCount());this._calculateLineHeightTimer()}else this._lineHeight=null},_resetLineWidth:function(){var a=
this._clientDiv;if(a)for(a=a.firstChild;a;)a.lineWidth=void 0,a=a.nextSibling},_reset:function(){this._maxLineIndex=-1;this._maxLineWidth=0;this._columnX=-1;this._bottomChild=this._topChild=null;this._topIndexY=0;this._resetLineHeight();this._setSelection(new d(0,0,!1),!1,!1);if(this._viewDiv)this._viewDiv.scrollLeft=0,this._viewDiv.scrollTop=0;var a=this._clientDiv;if(a){for(var b=a.firstChild;b;)b.lineRemoved=!0,b=b.nextSibling;if(f.isFirefox)this._ignoreFocus=!1,(b=this._hasFocus)&&a.blur(),a.contentEditable=
!1,a.contentEditable=!0,b&&a.focus(),this._ignoreFocus=!1}},_scrollView:function(a,b){this._ensureCaretVisible=!1;var d=this._viewDiv;a&&(d.scrollLeft+=a);b&&(d.scrollTop+=b)},_setClipboardText:function(a,b){var d,i=this._parent.ownerDocument,g=this._getWindow();if(g.clipboardData)return d=[],e(a,function(a){d.push(a)},function(){d.push(f.platformDelimiter)}),g.clipboardData.setData("Text",d.join(""));if(b&&b.clipboardData&&(d=[],e(a,function(a){d.push(a)},function(){d.push(f.platformDelimiter)}),
b.clipboardData.setData("text/plain",d.join(""))))return!0;var o=f.createElement(i,"pre");o.style.position="fixed";o.style.left="-1000px";e(a,function(a){o.appendChild(i.createTextNode(a))},function(){o.appendChild(f.createElement(i,"br"))});o.appendChild(i.createTextNode(" "));this._clientDiv.appendChild(o);var n=i.createRange();n.setStart(o.firstChild,0);n.setEndBefore(o.lastChild);var k=g.getSelection();k.rangeCount>0&&k.removeAllRanges();k.addRange(n);var h=this,n=function(){o&&o.parentNode===
h._clientDiv&&h._clientDiv.removeChild(o);h._updateDOMSelection()},k=!1;this._ignoreCopy=!0;try{k=i.execCommand("copy",!1,null)}catch(l){}this._ignoreCopy=!1;if(!k&&b)return g.setTimeout(n,0),!1;n();return!0},_setDOMSelection:function(a,b,d,e){for(var i,g,n,o,k=0,h=a.firstChild,l,m,z=this._model.getLine(a.lineIndex).length;h;){l=h.firstChild;m=l.length;h.ignoreChars&&(m-=h.ignoreChars);if(k+m>b||k+m>=z){i=l;g=b-k;h.ignoreChars&&m>0&&g===m&&(g+=h.ignoreChars);break}k+=m;h=h.nextSibling}for(var k=0,
h=d.firstChild,p=this._model.getLine(d.lineIndex).length;h;){l=h.firstChild;m=l.length;h.ignoreChars&&(m-=h.ignoreChars);if(m+k>e||k+m>=p){n=l;o=e-k;h.ignoreChars&&m>0&&o===m&&(o+=h.ignoreChars);break}k+=m;h=h.nextSibling}this._setDOMFullSelection(a,b,z,d,e,p);if(this._hasFocus)if(b=this._getWindow(),a=this._parent.ownerDocument,b.getSelection){if(b=b.getSelection(),!(b.anchorNode===i&&b.anchorOffset===g&&b.focusNode===n&&b.focusOffset===o||b.anchorNode===n&&b.anchorOffset===o&&b.focusNode===i&&b.focusOffset===
g))a=a.createRange(),a.setStart(i,g),a.setEnd(n,o),this._ignoreSelect=!1,b.rangeCount>0&&b.removeAllRanges(),b.addRange(a),this._ignoreSelect=!0}else if(a.selection)b=a.body,a=f.createElement(a,"div"),b.appendChild(a),b.removeChild(a),a=b.createTextRange(),a.moveToElementText(i.parentNode),a.moveStart("character",g),i=b.createTextRange(),i.moveToElementText(n.parentNode),i.moveStart("character",o),a.setEndPoint("EndToStart",i),this._ignoreSelect=!1,a.select(),this._ignoreSelect=!0},_setDOMFullSelection:function(a,
b,d,e,i){if(this._selDiv1&&(d=this._selDiv1,d.style.width="0px",d.style.height="0px",d=this._selDiv2,d.style.width="0px",d.style.height="0px",d=this._selDiv3,d.style.width="0px",d.style.height="0px",!(a===e&&b===i))){var f=this._model,n=this._getViewPadding(),o=this._clientDiv.getBoundingClientRect(),k=this._viewDiv.getBoundingClientRect(),d=k.left+n.left,h=o.right,n=k.top+n.top,l=o.bottom,k=o=0;this._clipDiv?(k=this._clipDiv.getBoundingClientRect(),o=k.left-this._clipDiv.scrollLeft):(k=this._rootDiv.getBoundingClientRect(),
o=k.left);k=k.top;this._ignoreDOMSelection=!0;var a=(new g(this,a.lineIndex,a)).getBoundingClientRect(f.getLineStart(a.lineIndex)+b,!1),m=a.left,i=(new g(this,e.lineIndex,e)).getBoundingClientRect(f.getLineStart(e.lineIndex)+i,!1),b=i.left;this._ignoreDOMSelection=!1;var f=this._selDiv1,m=Math.min(h,Math.max(d,m)),z=Math.min(l,Math.max(n,a.top)),p=h,e=Math.min(l,Math.max(n,a.bottom));f.style.left=m-o+"px";f.style.top=z-k+"px";f.style.width=Math.max(0,p-m)+"px";f.style.height=Math.max(0,e-z)+"px";
if(a.top===i.top)p=Math.min(b,h),f.style.width=Math.max(0,p-m)+"px";else if(a=Math.min(l,Math.max(n,i.top)),b=Math.min(h,Math.max(d,b)),n=Math.min(l,Math.max(n,i.bottom)),l=this._selDiv3,l.style.left=d-o+"px",l.style.top=a-k+"px",l.style.width=Math.max(0,b-d)+"px",l.style.height=Math.max(0,n-a)+"px",a-e>0)n=this._selDiv2,n.style.left=d-o+"px",n.style.top=e-k+"px",n.style.width=Math.max(0,h-d)+"px",n.style.height=Math.max(0,a-e)+"px"}},_setGrab:function(a){if(a!==this._grabControl)a?(a.setCapture&&
a.setCapture(),this._grabControl=a):(this._grabControl.releaseCapture&&this._grabControl.releaseCapture(),this._grabControl=null)},_setLinksVisible:function(a){if(this._linksVisible!==a){this._linksVisible=a;if(f.isIE&&a)this._hadFocus=this._hasFocus;var b=this._clientDiv;b.contentEditable=!a;this._hadFocus&&!a&&b.focus();if(this._overlayDiv)this._overlayDiv.style.zIndex=a?"-1":"1";for(a=this._getLineNext();a;){if(a.hasLink)for(b=a.firstChild;b;){var d=b.nextSibling,e=b.viewStyle;e&&e.tagName==="A"&&
a.replaceChild(a._line._createSpan(a,b.firstChild.data,e),b);b=d}a=this._getLineNext(a)}}},_setSelection:function(a,b,d,e){if(a){this._columnX=-1;d===void 0&&(d=!0);var i=this._selection;this._selection=a;b&&this._showCaret(!1,e);d&&this._updateDOMSelection();if(!i.equals(a))this.onSelection({type:"Selection",oldValue:{start:i.start,end:i.end},newValue:{start:a.start,end:a.end}})}},_setSelectionTo:function(a,b,d,e){var i=this._model,g=this._getSelection(),b=this.convert({x:a,y:b},"page","document"),
a=this._getLineIndex(b.y);if(this._clickCount===1){i=this._getLine(a);a=i.getOffset(b.x,b.y-this._getLinePixel(a));i.destroy();if(e&&!d&&g.start<=a&&a<g.end)return this._dragOffset=a,!1;g.extend(a);d||g.collapse()}else(this._clickCount&1)===0?(i=this._getLine(a),a=i.getOffset(b.x,b.y-this._getLinePixel(a)),this._doubleClickSelection?a>=this._doubleClickSelection.start?(d=this._doubleClickSelection.start,e=i.getNextOffset(a,"wordend",1)):(d=i.getNextOffset(a,"word",-1),e=this._doubleClickSelection.end):
(d=i.getNextOffset(a,"word",-1),e=i.getNextOffset(d,"wordend",1)),i.destroy()):this._doubleClickSelection?(e=i.getLineAtOffset(this._doubleClickSelection.start),a>=e?(d=i.getLineStart(e),e=i.getLineEnd(a)):(d=i.getLineStart(a),e=i.getLineEnd(e))):(d=i.getLineStart(a),e=i.getLineEnd(a)),g.setCaret(d),g.extend(e);this._setSelection(g,!0,!0);return!0},_setFullSelection:function(a,b){this._fullSelection=a;if(f.isWebkit)this._fullSelection=!0;var d=this._clipDiv||this._rootDiv;if(d)if(this._fullSelection){if(!this._selDiv1&&
this._fullSelection&&!f.isIOS){var e=d.ownerDocument;this._highlightRGB=f.isWebkit?"transparent":"Highlight";var i=f.createElement(e,"div");this._selDiv1=i;i.style.position="absolute";i.style.borderWidth="0px";i.style.margin="0px";i.style.padding="0px";i.style.outline="none";i.style.background=this._highlightRGB;i.style.width="0px";i.style.height="0px";i.style.zIndex="0";d.appendChild(i);var g=f.createElement(e,"div");this._selDiv2=g;g.style.position="absolute";g.style.borderWidth="0px";g.style.margin=
"0px";g.style.padding="0px";g.style.outline="none";g.style.background=this._highlightRGB;g.style.width="0px";g.style.height="0px";g.style.zIndex="0";d.appendChild(g);this._selDiv3=e=f.createElement(e,"div");e.style.position="absolute";e.style.borderWidth="0px";e.style.margin="0px";e.style.padding="0px";e.style.outline="none";e.style.background=this._highlightRGB;e.style.width="0px";e.style.height="0px";e.style.zIndex="0";d.appendChild(e);if(f.isFirefox&&f.isMac){d=this._getWindow().getComputedStyle(e,
null).getPropertyValue("background-color");switch(d){case "rgb(119, 141, 168)":d="rgb(199, 208, 218)";break;case "rgb(127, 127, 127)":d="rgb(198, 198, 198)";break;case "rgb(255, 193, 31)":d="rgb(250, 236, 115)";break;case "rgb(243, 70, 72)":d="rgb(255, 176, 139)";break;case "rgb(255, 138, 34)":d="rgb(255, 209, 129)";break;case "rgb(102, 197, 71)":d="rgb(194, 249, 144)";break;case "rgb(140, 78, 184)":d="rgb(232, 184, 255)";break;default:d="rgb(180, 213, 255)"}this._highlightRGB=d;i.style.background=
d;g.style.background=d;e.style.background=d}b||this._updateDOMSelection()}}else{if(this._selDiv1)d.removeChild(this._selDiv1),this._selDiv1=null;if(this._selDiv2)d.removeChild(this._selDiv2),this._selDiv2=null;if(this._selDiv3)d.removeChild(this._selDiv3),this._selDiv3=null}},_setReadOnly:function(a){this._readonly=a;this._clientDiv.setAttribute("aria-readonly",a?"true":"false")},_setTabSize:function(a,b){this._tabSize=a;this._customTabSize=void 0;var d=this._clientDiv;if(f.isOpera){if(d)d.style.OTabSize=
this._tabSize+""}else if(f.isWebkit>=537.1){if(d)d.style.tabSize=this._tabSize+""}else if(f.isFirefox>=4){if(d)d.style.MozTabSize=this._tabSize+""}else if(this._tabSize!==8)this._customTabSize=this._tabSize;b||(this.redrawLines(),this._resetLineWidth())},_setThemeClass:function(a,b){this._themeClass=a;var d="textviewContainer";this._themeClass&&(d+=" "+this._themeClass);this._rootDiv.className=d;this._updateStyle(b)},_setWrapMode:function(a,b){this._wrapMode=a;var d=this._clientDiv,e=this._viewDiv;
a?(d.style.whiteSpace="pre-wrap",d.style.wordWrap="break-word",e.style.overflowX="hidden",e.style.overflowY="scroll"):(d.style.whiteSpace="pre",d.style.wordWrap="normal",e.style.overflowX="auto",e.style.overflowY="auto");b||(this.redraw(),this._resetLineWidth());this._resetLineHeight()},_showCaret:function(a,b){if(this._clientDiv){var d=this._model,e=this._getSelection(),i=this._getScroll(),g=e.getCaret(),n=e.start,f=e.end,o=d.getLineAtOffset(f),k=Math.max(Math.max(n,d.getLineStart(o)),f-1),d=this._getClientWidth(),
o=this._getClientHeight(),h=d/4,l=this._getBoundsAtOffset(g===n?n:k),m=l.left,p=l.right,w=l.top,r=l.bottom;a&&!e.isEmpty()&&(l=this._getBoundsAtOffset(g===f?n:k),l.top===w?g===n?p=m+Math.min(l.right-m,d):m=p-Math.min(p-l.left,d):g===n?r=w+Math.min(l.bottom-w,o):w=r-Math.min(r-l.top,o));e=0;m<i.x&&(e=Math.min(m-i.x,-h));p>i.x+d&&(e=Math.max(p-i.x-d,h));g=0;w<i.y?g=w-i.y:r>i.y+o&&(g=r-i.y-o);b&&(b>0?g>0&&(g=Math.max(g,b)):g<0&&(g=Math.min(g,b)));return e!==0||g!==0?(this._scrollView(e,g),o!==this._getClientHeight()||
d!==this._getClientWidth()?this._showCaret():this._ensureCaretVisible=!0,!0):!1}},_startIME:function(){if(this._imeOffset===-1){var a=this._getSelection();a.isEmpty()||this._modifyContent({text:"",start:a.start,end:a.end},!0);this._imeOffset=a.start}},_unhookEvents:function(){this._model.removeEventListener("preChanging",this._modelListener.onChanging);this._model.removeEventListener("postChanged",this._modelListener.onChanged);this._modelListener=null;for(var a=0;a<this._handlers.length;a++){var b=
this._handlers[a],d=b.target,e=b.type,b=b.handler;typeof d.removeEventListener==="function"?d.removeEventListener(e,b,!1):d.detachEvent("on"+e,b)}this._handlers=null;if(this._mutationObserver)this._mutationObserver.disconnect(),this._mutationObserver=null},_updateDOMSelection:function(){if(!this._ignoreDOMSelection&&this._clientDiv){var a=this._getSelection(),b=this._model,d=b.getLineAtOffset(a.start),e=b.getLineAtOffset(a.end),i=this._getLineNext();if(i){var g=this._getLinePrevious(),n;d<i.lineIndex?
(n=i,d=0):d>g.lineIndex?(n=g,d=0):(n=this._getLineNode(d),d=a.start-b.getLineStart(d));e<i.lineIndex?a=0:e>g.lineIndex?(i=g,a=0):(i=this._getLineNode(e),a=a.end-b.getLineStart(e));this._setDOMSelection(n,d,i,a)}}},_update:function(a){if(!(this._redrawCount>0)){if(this._updateTimer)this._getWindow().clearTimeout(this._updateTimer),this._updateTimer=null,a=!1;var b=this._clientDiv;if(b){if(this._metrics.invalid)this._ignoreQueueUpdate=!0,this._updateStyle(),this._ignoreQueueUpdate=!1;var d=this._model,
e=this._getScroll(),i=this._getViewPadding(),o=d.getLineCount(),n=this._getLineHeight(),k=this._getClientWidth();if(this._wrapMode)b.style.width=k+"px";var h,l,m,v,p=0,r=0;if(this._lineHeight){for(;r<o;){m=this._getLineHeight(r);if(p+m>e.y)break;p+=m;r++}h=r;l=Math.max(0,h-1);m=d=e.y-p;h>0&&(d+=this._getLineHeight(h-1))}else v=Math.max(0,e.y)/n,h=Math.floor(v),l=Math.max(0,h-1),d=Math.round((v-l)*n),m=Math.round((v-h)*n);this._topIndexY=m;v=this._parent;var w=v.clientWidth,s=v.clientHeight;v=this._getClientHeight();
if(a){l=0;this._leftDiv&&(h=this._leftDiv.getBoundingClientRect(),l=h.right-h.left);h=k;for(this._wrapMode||(h=Math.max(this._maxLineWidth,h));r<o;)m=this._getLineHeight(r,!1),p+=m,r++;o=p}else{for(var k=this._viewDiv,e=Math.min(h+Math.floor((v+m)/n),o-1),x=Math.min(e+1,o-1),n=b.firstChild;n;){m=n.lineIndex;var C=n.nextSibling;if(!(l<=m&&m<=x)||n.lineRemoved||n.lineIndex===-1)this._mouseWheelLine===n?(n.style.display="none",n.lineIndex=-1):b.removeChild(n);n=C}var n=this._getLineNext(),C=k.ownerDocument,
y=C.createDocumentFragment();for(m=l;m<=x;m++)if(!n||n.lineIndex>m)(new g(this,m)).create(y,null);else{y.firstChild&&(b.insertBefore(y,n),y=C.createDocumentFragment());if(n&&n.lineChanged)n=(new g(this,m)).create(y,n),n.lineChanged=!1;n=this._getLineNext(n)}y.firstChild&&b.insertBefore(y,n);if(f.isWebkit&&!this._wrapMode)b.style.width="0x7fffffffpx";n=this._getLineNext();m=v+d;for(C=!1;n;){l=n.lineWidth;if(l===void 0)x=n._line.getBoundingClientRect(),l=n.lineWidth=Math.ceil(x.right-x.left),this._lineHeight&&
(this._lineHeight[n.lineIndex]=Math.ceil(x.bottom-x.top));if(this._lineHeight&&!C&&(m-=this._lineHeight[n.lineIndex],m<0))e=n.lineIndex,C=!0;if(!this._wrapMode){if(l>=this._maxLineWidth)this._maxLineWidth=l,this._maxLineIndex=n.lineIndex;if(this._checkMaxLineIndex===n.lineIndex)this._checkMaxLineIndex=-1}if(n.lineIndex===h)this._topChild=n;if(n.lineIndex===e)this._bottomChild=n;n=this._getLineNext(n)}if(this._checkMaxLineIndex!==-1&&(m=this._checkMaxLineIndex,this._checkMaxLineIndex=-1,0<=m&&m<o)){n=
new g(this,m);x=n.getBoundingClientRect();l=x.right-x.left;if(l>=this._maxLineWidth)this._maxLineWidth=l,this._maxLineIndex=m;n.destroy()}for(;r<o;)m=this._getLineHeight(r,r<=e),p+=m,r++;o=p;this._updateRuler(this._leftDiv,h,e);this._updateRuler(this._rightDiv,h,e);l=0;this._leftDiv&&(h=this._leftDiv.getBoundingClientRect(),l=h.right-h.left);e=0;this._rightDiv&&(e=this._rightDiv.getBoundingClientRect(),e=e.right-e.left);k.style.left=l+"px";k.style.right=e+"px";e=this._scrollDiv;e.style.height=o+"px";
p=k=this._getClientWidth();this._wrapMode||(p=Math.max(this._maxLineWidth,p));h=p;if((!f.isIE||f.isIE>=9)&&this._maxLineWidth>k)p+=i.right+i.left;e.style.width=p+"px";if(this._clipScrollDiv)this._clipScrollDiv.style.width=p+"px";e=this._getScroll();p=v+i.top+i.bottom;this._updateRulerSize(this._leftDiv,p);this._updateRulerSize(this._rightDiv,p)}if(this._vScrollDiv)p=v-8,r=Math.max(15,Math.ceil(Math.min(1,p/(o+i.top+i.bottom))*p)),this._vScrollDiv.style.left=l+k-8+"px",this._vScrollDiv.style.top=Math.floor(Math.max(0,
e.y*p/o))+"px",this._vScrollDiv.style.height=r+"px";if(!this._wrapMode&&this._hScrollDiv)p=k-8,r=Math.max(15,Math.ceil(Math.min(1,p/(this._maxLineWidth+i.left+i.right))*p)),this._hScrollDiv.style.left=l+Math.floor(Math.max(0,Math.floor(e.x*p/this._maxLineWidth)))+"px",this._hScrollDiv.style.top=v-9+"px",this._hScrollDiv.style.width=r+"px";x=e.x;m=this._clipDiv;p=this._overlayDiv;if(m){m.scrollLeft=x;r=l+i.left;n=i.top;a=k;l=v;x=0;C=-d;if(e.x===0)r-=i.left,a+=i.left,x=i.left;e.x+k===h&&(a+=i.right);
e.y===0&&(n-=i.top,l+=i.top,C+=i.top);e.y+v===o&&(l+=i.bottom);m.style.left=r+"px";m.style.top=n+"px";i=this._isOverOverlayScroll();m.style.right=w-a-r+(this._overlayScrollTimer&&i.vertical?15:0)+"px";m.style.bottom=s-l-n+(this._overlayScrollTimer&&i.horizontal?15:0)+"px";b.style.left=x+"px";b.style.top=C+"px";b.style.width=h+"px";b.style.height=v+d+"px";if(p)p.style.left=b.style.left,p.style.top=b.style.top,p.style.width=b.style.width,p.style.height=b.style.height}else{r=x;n=d;w=x+k;s=d+v;r===0&&
(r-=i.left);n===0&&(n-=i.top);w===h&&(w+=i.right);e.y+v===o&&(s+=i.bottom);b.style.clip="rect("+n+"px,"+w+"px,"+s+"px,"+r+"px)";b.style.left=-x+l+i.left+"px";b.style.width=(f.isWebkit?h:k+x)+"px";if(!a)b.style.top=-d+i.top+"px",b.style.height=v+d+"px";if(p&&(p.style.clip=b.style.clip,p.style.left=b.style.left,p.style.width=b.style.width,!a))p.style.top=b.style.top,p.style.height=b.style.height}this._updateDOMSelection();b=this._ensureCaretVisible;this._ensureCaretVisible=!1;v!==this._getClientHeight()&&
(this._update(),b&&this._showCaret())}}},_updateRulerSize:function(a,b){if(a){for(var d=this._topIndexY,e=this._getLineHeight(),i=a.firstChild.rows[0].cells,g=0;g<i.length;g++){var n=i[g].firstChild,f=e;n._ruler.getOverview()==="page"&&(f+=d);n.style.top=-f+"px";n.style.height=b+f+"px"}a.style.height=b+"px"}},_updateRuler:function(a,b,d){if(a)for(var a=a.firstChild.rows[0].cells,e=this._parent.ownerDocument,i=this._getLineHeight(),g=this._getViewPadding(),n=0;n<a.length;n++){var o=a[n].firstChild,
k=o._ruler;o.rulerChanged&&l(k.getRulerStyle(),o);var h,m=o.firstChild;m?(h=m,m=m.nextSibling):(h=f.createElement(e,"div"),h.style.visibility="hidden",o.appendChild(h));var p,r;if(o.rulerChanged&&h){p=-1;if(r=k.getWidestAnnotation())if(l(r.style,h),r.html)h.innerHTML=r.html;h.lineIndex=p;h.style.height=i+g.top+"px"}var s,w;if(k.getOverview()==="page"){for(k=k.getAnnotations(b,d+1);m;)p=m.lineIndex,r=m.nextSibling,(!(b<=p&&p<=d)||m.lineChanged)&&o.removeChild(m),m=r;m=o.firstChild.nextSibling;w=e.createDocumentFragment();
for(p=b;p<=d;p++)if(!m||m.lineIndex>p){s=f.createElement(e,"div");if(r=k[p]){l(r.style,s);if(r.html)s.innerHTML=r.html;s.annotation=r}s.lineIndex=p;s.style.height=this._getLineHeight(p)+"px";w.appendChild(s)}else if(w.firstChild&&(o.insertBefore(w,m),w=e.createDocumentFragment()),m)m=m.nextSibling;w.firstChild&&o.insertBefore(w,m)}else{r=this._getClientHeight();p=this._model.getLineCount();m=r+g.top+g.bottom-2*this._metrics.scrollWidth;h=i*p<m?i:m/p;if(o.rulerChanged){for(r=o.childNodes.length;r>
1;)o.removeChild(o.lastChild),r--;k=k.getAnnotations(0,p);w=e.createDocumentFragment();for(var K in k)if(p=K>>>0,!(p<0)){s=f.createElement(e,"div");r=k[K];l(r.style,s);s.style.position="absolute";s.style.top=this._metrics.scrollWidth+i+Math.floor(p*h)+"px";if(r.html)s.innerHTML=r.html;s.annotation=r;s.lineIndex=p;w.appendChild(s)}o.appendChild(w)}else if(o._oldTrackHeight!==m)for(s=o.firstChild?o.firstChild.nextSibling:null;s;)s.style.top=this._metrics.scrollWidth+i+Math.floor(s.lineIndex*h)+"px",
s=s.nextSibling;o._oldTrackHeight=m}o.rulerChanged=!1}},_updateStyle:function(a){if(!a&&f.isIE)this._rootDiv.style.lineHeight="normal";var b=this._metrics=this._calculateMetrics();this._rootDiv.style.lineHeight=f.isIE?b.lineHeight-(b.lineTrim.top+b.lineTrim.bottom)+"px":"normal";a||(this.redraw(),this._resetLineWidth())}};p.EventTarget.addMixin(o.prototype);return{TextView:o}});
define("orion/editor/projectionTextModel",["orion/editor/textModel","orion/editor/eventTarget"],function(s,r){function p(f){this._model=f;this._projections=[]}p.prototype={addProjection:function(f){if(f){var h=this._model,l=this._projections;f._lineIndex=h.getLineAtOffset(f.start);f._lineCount=h.getLineAtOffset(f.end)-f._lineIndex;var k=f.text;k||(k="");f._model=typeof k==="string"?new s.TextModel(k,h.getLineDelimiter()):k;var h=this.mapOffset(f.start,!0),k=f.end-f.start,m=f._lineCount,e=f._model.getCharCount(),
a=f._model.getLineCount()-1;this.onChanging({type:"Changing",text:f._model.getText(),start:h,removedCharCount:k,addedCharCount:e,removedLineCount:m,addedLineCount:a});var b=this._binarySearch(l,f.start);l.splice(b,0,f);this.onChanged({type:"Changed",start:h,removedCharCount:k,addedCharCount:e,removedLineCount:m,addedLineCount:a})}},getProjections:function(){return this._projections.slice(0)},getBaseModel:function(){return this._model},mapOffset:function(f,h){var l=this._projections,k=0,m,e;if(h){for(m=
0;m<l.length;m++){e=l[m];if(e.start>f)break;if(e.end>f)return-1;k+=e._model.getCharCount()-(e.end-e.start)}return f+k}for(m=0;m<l.length;m++){e=l[m];if(e.start>f-k)break;var a=e._model.getCharCount();if(e.start+a>f-k)return-1;k+=a-(e.end-e.start)}return f-k},removeProjection:function(f){var h,l=0;for(h=0;h<this._projections.length;h++){var k=this._projections[h];if(k===f){f=k;break}l+=k._model.getCharCount()-(k.end-k.start)}if(h<this._projections.length){var k=this._model,l=f.start+l,m=f.end-f.start,
e=f._lineCount,a=f._model.getCharCount(),b=f._model.getLineCount()-1;this.onChanging({type:"Changing",text:k.getText(f.start,f.end),start:l,removedCharCount:a,addedCharCount:m,removedLineCount:b,addedLineCount:e});this._projections.splice(h,1);this.onChanged({type:"Changed",start:l,removedCharCount:a,addedCharCount:m,removedLineCount:b,addedLineCount:e})}},_binarySearch:function(f,h){for(var l=f.length,k=-1,m;l-k>1;)m=Math.floor((l+k)/2),h<=f[m].start?l=m:k=m;return l},getCharCount:function(){for(var f=
this._model.getCharCount(),h=this._projections,l=0;l<h.length;l++){var k=h[l];f+=k._model.getCharCount()-(k.end-k.start)}return f},getLine:function(f,h){if(f<0)return null;var l=this._model,k=this._projections,m=0,e=[],a=0,b,d,i;for(b=0;b<k.length;b++){i=k[b];if(i._lineIndex>=f-m)break;d=i._model.getLineCount()-1;if(i._lineIndex+d>=f-m)if(a=f-(i._lineIndex+m),a<d)return i._model.getLine(a,h);else e.push(i._model.getLine(d));a=i.end;m+=d-i._lineCount}for(a=Math.max(a,l.getLineStart(f-m));b<k.length;b++){i=
k[b];if(i._lineIndex>f-m)break;e.push(l.getText(a,i.start));d=i._model.getLineCount()-1;if(i._lineIndex+d>f-m)return e.push(i._model.getLine(0,h)),e.join("");e.push(i._model.getText());a=i.end;m+=d-i._lineCount}k=l.getLineEnd(f-m,h);a<k&&e.push(l.getText(a,k));return e.join("")},getLineAtOffset:function(f){for(var h=this._model,l=this._projections,k=0,m=0,e=0;e<l.length;e++){var a=l[e];if(a.start>f-k)break;var b=a._model.getCharCount();if(a.start+b>f-k){l=f-(a.start+k);m+=a._model.getLineAtOffset(l);
k+=l;break}m+=a._model.getLineCount()-1-a._lineCount;k+=b-(a.end-a.start)}return h.getLineAtOffset(f-k)+m},getLineCount:function(){for(var f=this._projections,h=this._model.getLineCount(),l=0;l<f.length;l++){var k=f[l];h+=k._model.getLineCount()-1-k._lineCount}return h},getLineDelimiter:function(){return this._model.getLineDelimiter()},getLineEnd:function(f,h){if(f<0)return-1;for(var l=this._model,k=this._projections,m=0,e=0,a=0;a<k.length;a++){var b=k[a];if(b._lineIndex>f-m)break;var d=b._model.getLineCount()-
1;if(b._lineIndex+d>f-m)return b._model.getLineEnd(f-(b._lineIndex+m),h)+b.start+e;e+=b._model.getCharCount()-(b.end-b.start);m+=d-b._lineCount}return l.getLineEnd(f-m,h)+e},getLineStart:function(f){if(f<0)return-1;for(var h=this._model,l=this._projections,k=0,m=0,e=0;e<l.length;e++){var a=l[e];if(a._lineIndex>=f-k)break;var b=a._model.getLineCount()-1;if(a._lineIndex+b>=f-k)return a._model.getLineStart(f-(a._lineIndex+k))+a.start+m;m+=a._model.getCharCount()-(a.end-a.start);k+=b-a._lineCount}return h.getLineStart(f-
k)+m},getText:function(f,h){f===void 0&&(f=0);var l=this._model,k=this._projections,m=0,e=[],a,b,d;for(a=0;a<k.length;a++){b=k[a];if(b.start>f-m)break;d=b._model.getCharCount();if(b.start+d>f-m)if(h!==void 0&&b.start+d>h-m)return b._model.getText(f-(b.start+m),h-(b.start+m));else e.push(b._model.getText(f-(b.start+m))),f=b.end+m+d-(b.end-b.start);m+=d-(b.end-b.start)}var i=f-m;if(h!==void 0){for(;a<k.length;a++){b=k[a];if(b.start>h-m)break;e.push(l.getText(i,b.start));d=b._model.getCharCount();if(b.start+
d>h-m)return e.push(b._model.getText(0,h-(b.start+m))),e.join("");e.push(b._model.getText());i=b.end;m+=d-(b.end-b.start)}e.push(l.getText(i,h-m))}else{for(;a<k.length;a++)b=k[a],e.push(l.getText(i,b.start)),e.push(b._model.getText()),i=b.end;e.push(l.getText(i))}return e.join("")},_onChanging:function(f,h,l,k,m,e){for(var a=this._model,b=this._projections,d,i=0,g,o=h+l;d<b.length;d++){l=b[d];if(l.start>h)break;i+=l._model.getCharCount()-(l.end-l.start)}h+=i;for(var c=d;d<b.length;d++){l=b[d];if(l.start>
o)break;i+=l._model.getCharCount()-(l.end-l.start);g+=l._model.getLineCount()-1-l._lineCount}l=o+i;i=d;this.onChanging(h,l-h,k,m+g,e);b.splice(b,i-c);for(f=f.length-(l-h);d<b.length;d++)l=b[d],l.start+=f,l.end+=f,l._lineIndex=a.getLineAtOffset(l.start)},onChanging:function(f){return this.dispatchEvent(f)},onChanged:function(f){return this.dispatchEvent(f)},setLineDelimiter:function(f){this._model.setLineDelimiter(f)},setText:function(f,h,l){f===void 0&&(f="");h===void 0&&(h=0);var k=h,m=l,e=this._model,
a=this._projections,b=0,d=0,i,g,o,c,j,q=0;for(i=0;i<a.length;i++){g=a[i];if(g.start>h-b)break;o=g._model.getCharCount();if(g.start+o>h-b)if(l!==void 0&&g.start+o>l-b){g._model.setText(f,h-(g.start+b),l-(g.start+b));return}else q=g._model.getLineCount()-1-g._model.getLineAtOffset(h-(g.start+b)),c={projection:g,start:h-(g.start+b)},h=g.end+b+o-(g.end-g.start);d+=g._model.getLineCount()-1-g._lineCount;b+=o-(g.end-g.start)}h-=b;var u=i,q=e.getLineAtOffset(h)+d-q;if(l!==void 0)for(;i<a.length;i++){g=a[i];
if(g.start>l-b)break;o=g._model.getCharCount();if(g.start+o>l-b){d+=g._model.getLineAtOffset(l-(g.start+b));o=l-(g.start+b);l=g.end+b;j={projection:g,end:o};break}d+=g._model.getLineCount()-1-g._lineCount;b+=o-(g.end-g.start)}else{for(;i<a.length;i++)g=a[i],d+=g._model.getLineCount()-1-g._lineCount,b+=g._model.getCharCount()-(g.end-g.start);l=m=e.getCharCount()+b}l-=b;g=e.getLineAtOffset(l)+d;m-=k;for(var d=g-q,q=f.length,A=o=g=b=0;;){g!==-1&&g<=A&&(g=f.indexOf("\r",A));o!==-1&&o<=A&&(o=f.indexOf("\n",
A));if(o===-1&&g===-1)break;A=g!==-1&&o!==-1?g+1===o?o+1:(g<o?g:o)+1:g!==-1?g+1:o+1;b++}this.onChanging({type:"Changing",text:f,start:k,removedCharCount:m,addedCharCount:q,removedLineCount:d,addedLineCount:b});e.setText(f,h,l);if(c)g=c.projection,g._model.setText("",c.start);if(j)g=j.projection,g._model.setText("",0,j.end),g.start=g.end,g._lineCount=0;a.splice(u,i-u);for(f=f.length-(l-h);i<a.length;i++)g=a[i],g.start+=f,g.end+=f,g._lineIndex=e.getLineAtOffset(g.start);this.onChanged({type:"Changed",
start:k,removedCharCount:m,addedCharCount:q,removedLineCount:d,addedLineCount:b})}};r.EventTarget.addMixin(p.prototype);return{ProjectionTextModel:p}});
(function(){function s(f,l,k,m,e,a){l[f]&&(k.push(f),(l[f]===!0||l[f]===1)&&m.push(e+f+"/"+a))}function r(f,l,k,m,e){l=m+l+"/"+e;require._fileExists(f.toUrl(l))&&k.push(l)}var p=/(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/,f={};define("i18n",{version:"1.0.0",load:function(h,l,k,m){var m=m||{},e=p.exec(h),a=e[1],b=e[4],d=e[5],i=b.split("-"),g=[],o={},c,j,q="";e[5]?(a=e[1],h=a+d):(d=e[4],b=m.locale||(m.locale=typeof navigator==="undefined"?"root":(navigator.language||navigator.userLanguage||"root").toLowerCase()),
i=b.split("-"));if(m.isBuild){g.push(h);r(l,"root",g,a,d);for(c=0;j=i[c];c++)q+=(q?"-":"")+j,r(l,q,g,a,d);l(g,function(){k()})}else l([h],function(b){var e=[];s("root",b,e,g,a,d);for(c=0;j=i[c];c++)q+=(q?"-":"")+j,s(q,b,e,g,a,d);l(g,function(){var c,i;for(c=e.length-1;c>-1&&(j=e[c]);c--){i=b[j];if(i===!0||i===1)i=l(a+j+"/"+d);var g=o,q=void 0;for(q in i)!(q in f)&&!(q in g)&&(g[q]=i[q])}k(o)})})}})})();
define("orion/editor/i18n",{load:function(s,r,p){r.specified&&r.specified("orion/bootstrap")?r(["orion/i18n!"+s],function(f){p(f)}):p({})}});
define("orion/editor/nls/root/messages",{multipleAnnotations:"Multiple annotations:",line:"Line: ${0}",breakpoint:"Breakpoint",bookmark:"Bookmark",task:"Task",error:"Error",warning:"Warning",matchingSearch:"Matching Search",currentSearch:"Current Search",currentLine:"Current Line",matchingBracket:"Matching Bracket",currentBracket:"Current Bracket",Comment:"Comment","Flat outline":"Flat outline",incrementalFind:"Incremental find: ${0}",incrementalFindNotFound:"Incremental find: ${0} (not found)",find:"Find...",
undo:"Undo",redo:"Redo",cancelMode:"Cancel Current Mode",findNext:"Find Next Occurrence",findPrevious:"Find Previous Occurrence",incrementalFindKey:"Incremental Find",indentLines:"Indent Lines",unindentLines:"Unindent Lines",moveLinesUp:"Move Lines Up",moveLinesDown:"Move Lines Down",copyLinesUp:"Copy Lines Up",copyLinesDown:"Copy Lines Down",deleteLines:"Delete Lines",gotoLine:"Goto Line...",gotoLinePrompty:"Goto Line:",nextAnnotation:"Next Annotation",prevAnnotation:"Previous Annotation",expand:"Expand",
collapse:"Collapse",expandAll:"Expand All",collapseAll:"Collapse All",lastEdit:"Last Edit Location",toggleLineComment:"Toggle Line Comment",addBlockComment:"Add Block Comment",removeBlockComment:"Remove Block Comment",linkedModeEntered:"Linked Mode entered",linkedModeExited:"Linked Mode exited",syntaxError:"Syntax Error",contentAssist:"Content Assist",lineColumn:"Line ${0} : Col ${1}"});
define("orion/editor/nls/messages",["orion/editor/i18n!orion/editor/nls/messages","orion/editor/nls/root/messages"],function(s,r){var p={root:r},f;for(f in s)s.hasOwnProperty(f)&&typeof p[f]==="undefined"&&(p[f]=s[f]);return p});
define("orion/editor/annotations",["i18n!orion/editor/nls/messages","orion/editor/eventTarget"],function(s,r){function p(a,b,d){this.start=a;this.end=b;this._projectionModel=d;this.html=this._expandedHTML;this.style=this._expandedStyle;this.expanded=!0}function f(){}function h(a,b){var d=a.lastIndexOf("."),d=a.substring(d+1),e={title:s[d],style:{styleClass:"annotation "+d},html:"<div class='annotationHTML "+d+"'></div>",overviewStyle:{styleClass:"annotationOverview "+d}};b?e.lineStyle={styleClass:"annotationLine "+
d}:e.rangeStyle={styleClass:"annotationRange "+d};f.registerType(a,e)}function l(){}function k(a){this._annotations=[];var b=this;this._listener={onChanged:function(a){b._onChanged(a)}};this.setTextModel(a)}function m(a,b){this._view=a;this._annotationModel=b;var d=this;this._listener={onDestroy:function(a){d._onDestroy(a)},onLineStyle:function(a){d._onLineStyle(a)},onChanged:function(a){d._onAnnotationModelChanged(a)}};a.addEventListener("Destroy",this._listener.onDestroy);a.addEventListener("postLineStyle",
this._listener.onLineStyle);b.addEventListener("Changed",this._listener.onChanged)}p.prototype={_expandedHTML:"<div class='annotationHTML expanded'></div>",_expandedStyle:{styleClass:"annotation expanded"},_collapsedHTML:"<div class='annotationHTML collapsed'></div>",_collapsedStyle:{styleClass:"annotation collapsed"},collapse:function(){if(this.expanded){this.expanded=!1;this.html=this._collapsedHTML;this.style=this._collapsedStyle;var a=this._projectionModel,b=a.getBaseModel();this._projection=
{start:b.getLineStart(b.getLineAtOffset(this.start)+1),end:b.getLineEnd(b.getLineAtOffset(this.end),!0)};a.addProjection(this._projection)}},expand:function(){if(!this.expanded)this.expanded=!0,this.html=this._expandedHTML,this.style=this._expandedStyle,this._projectionModel.removeProjection(this._projection)}};f.ANNOTATION_ERROR="orion.annotation.error";f.ANNOTATION_WARNING="orion.annotation.warning";f.ANNOTATION_TASK="orion.annotation.task";f.ANNOTATION_BREAKPOINT="orion.annotation.breakpoint";
f.ANNOTATION_BOOKMARK="orion.annotation.bookmark";f.ANNOTATION_FOLDING="orion.annotation.folding";f.ANNOTATION_CURRENT_BRACKET="orion.annotation.currentBracket";f.ANNOTATION_MATCHING_BRACKET="orion.annotation.matchingBracket";f.ANNOTATION_CURRENT_LINE="orion.annotation.currentLine";f.ANNOTATION_CURRENT_SEARCH="orion.annotation.currentSearch";f.ANNOTATION_MATCHING_SEARCH="orion.annotation.matchingSearch";f.ANNOTATION_READ_OCCURRENCE="orion.annotation.readOccurrence";f.ANNOTATION_WRITE_OCCURRENCE="orion.annotation.writeOccurrence";
var e={};f.registerType=function(a,b){var d=b;if(typeof d!=="function")d=function(a,b,d){this.start=a;this.end=b;if(d)this.title=d},d.prototype=b;d.prototype.type=a;e[a]=d;return a};f.createAnnotation=function(a,b,d,e){return new (this.getType(a))(b,d,e)};f.getType=function(a){return e[a]};h(f.ANNOTATION_ERROR);h(f.ANNOTATION_WARNING);h(f.ANNOTATION_TASK);h(f.ANNOTATION_BREAKPOINT);h(f.ANNOTATION_BOOKMARK);h(f.ANNOTATION_CURRENT_BRACKET);h(f.ANNOTATION_MATCHING_BRACKET);h(f.ANNOTATION_CURRENT_SEARCH);
h(f.ANNOTATION_MATCHING_SEARCH);h(f.ANNOTATION_READ_OCCURRENCE);h(f.ANNOTATION_WRITE_OCCURRENCE);h(f.ANNOTATION_CURRENT_LINE,!0);f.registerType(f.ANNOTATION_FOLDING,p);l.addMixin=function(a){var b=l.prototype,d;for(d in b)b.hasOwnProperty(d)&&(a[d]=b[d])};l.prototype={addAnnotationType:function(a){if(!this._annotationTypes)this._annotationTypes=[];this._annotationTypes.push(a)},getAnnotationTypePriority:function(a){if(this._annotationTypes)for(var b=0;b<this._annotationTypes.length;b++)if(this._annotationTypes[b]===
a)return b+1;return 0},getAnnotationsByType:function(a,b,d){a=a.getAnnotations(b,d);for(d=[];a.hasNext();)b=a.next(),this.getAnnotationTypePriority(b.type)!==0&&d.push(b);var e=this;d.sort(function(a,b){return e.getAnnotationTypePriority(a.type)-e.getAnnotationTypePriority(b.type)});return d},isAnnotationTypeVisible:function(a){return this.getAnnotationTypePriority(a)!==0},removeAnnotationType:function(a){if(this._annotationTypes)for(var b=0;b<this._annotationTypes.length;b++)if(this._annotationTypes[b]===
a){this._annotationTypes.splice(b,1);break}}};k.prototype={addAnnotation:function(a){if(a){var b=this._annotations,d=this._binarySearch(b,a.start);b.splice(d,0,a);this.onChanged({type:"Changed",added:[a],removed:[],changed:[]})}},getTextModel:function(){return this._model},getAnnotations:function(a,b){var d=this._annotations,e,g=0,f=function(){for(;g<d.length;){var c=d[g++];if(a===c.start||(a>c.start?a<c.end:c.start<b))return c;if(c.start>=b)break}return null};e=f();return{next:function(){var a=e;
a&&(e=f());return a},hasNext:function(){return e!==null}}},modifyAnnotation:function(a){if(a&&!(this._getAnnotationIndex(a)<0))this.onChanged({type:"Changed",added:[],removed:[],changed:[a]})},onChanged:function(a){return this.dispatchEvent(a)},removeAnnotations:function(a){var b=this._annotations,d,e;if(a){d=[];for(e=b.length-1;e>=0;e--){var g=b[e];g.type===a&&b.splice(e,1);d.splice(0,0,g)}}else d=b;this.onChanged({type:"Changed",removed:d,added:[],changed:[]})},removeAnnotation:function(a){if(a&&
(a=this._getAnnotationIndex(a),!(a<0)))this.onChanged({type:"Changed",removed:this._annotations.splice(a,1),added:[],changed:[]})},replaceAnnotations:function(a,b){var d=this._annotations,e,g,f,c=[];if(a)for(e=a.length-1;e>=0;e--)f=a[e],g=this._getAnnotationIndex(f),g<0||(d.splice(g,1),c.splice(0,0,f));b||(b=[]);for(e=0;e<b.length;e++)f=b[e],g=this._binarySearch(d,f.start),d.splice(g,0,f);this.onChanged({type:"Changed",removed:c,added:b,changed:[]})},setTextModel:function(a){this._model&&this._model.removeEventListener("Changed",
this._listener.onChanged);(this._model=a)&&this._model.addEventListener("Changed",this._listener.onChanged)},_binarySearch:function(a,b){for(var d=a.length,e=-1,g;d-e>1;)g=Math.floor((d+e)/2),b<=a[g].start?d=g:e=g;return d},_getAnnotationIndex:function(a){for(var b=this._annotations,d=this._binarySearch(b,a.start);d<b.length&&b[d].start===a.start;){if(b[d]===a)return d;d++}return-1},_onChanged:function(a){var b=a.start,d=a.removedCharCount,e=this._annotations,g=b+d;if(0<e.length){for(var f={type:"Changed",
added:[],removed:[],changed:[],textModelChangedEvent:a},a=a.addedCharCount-d,d=0;d<e.length;d++){var c=e[d];c.start>=g?(c.start+=a,c.end+=a,f.changed.push(c)):c.end<=b||(c.start<b&&g<c.end?(c.end+=a,f.changed.push(c)):(e.splice(d,1),f.removed.push(c),d--))}if(f.added.length>0||f.removed.length>0||f.changed.length>0)this.onChanged(f)}}};r.EventTarget.addMixin(k.prototype);m.prototype={destroy:function(){var a=this._view;if(a)a.removeEventListener("Destroy",this._listener.onDestroy),a.removeEventListener("LineStyle",
this._listener.onLineStyle),this.view=null;(a=this._annotationModel)&&a.removeEventListener("Changed",this._listener.onChanged)},_mergeStyle:function(a,b){if(b){a||(a={});a.styleClass&&b.styleClass&&a.styleClass!==b.styleClass?a.styleClass+=" "+b.styleClass:a.styleClass=b.styleClass;var d;if(b.style){if(!a.style)a.style={};for(d in b.style)a.style[d]||(a.style[d]=b.style[d])}if(b.attributes){if(!a.attributes)a.attributes={};for(d in b.attributes)a.attributes[d]||(a.attributes[d]=b.attributes[d])}}return a},
_mergeStyleRanges:function(a,b){a||(a=[]);var d,e;for(e=0;e<a.length&&b;e++){var g=a[e];if(b.end<=g.start)break;if(!(b.start>=g.end)){d=this._mergeStyle({},g.style);d=this._mergeStyle(d,b.style);var f=[];f.push(e,1);b.start<g.start&&f.push({start:b.start,end:g.start,style:b.style});b.start>g.start&&f.push({start:g.start,end:b.start,style:g.style});f.push({start:Math.max(g.start,b.start),end:Math.min(g.end,b.end),style:d});b.end<g.end&&f.push({start:b.end,end:g.end,style:g.style});b=b.end>g.end?{start:g.end,
end:b.end,style:b.style}:null;Array.prototype.splice.apply(a,f)}}b&&(d=this._mergeStyle({},b.style),a.splice(e,0,{start:b.start,end:b.end,style:d}));return a},_onAnnotationModelChanged:function(a){function b(a){for(var b=0;b<a.length;b++)if(e.isAnnotationTypeVisible(a[b].type)){var f=a[b].start,k=a[b].end;g.getBaseModel&&(f=g.mapOffset(f,!0),k=g.mapOffset(k,!0));f!==-1&&k!==-1&&d.redrawRange(f,k)}}if(!a.textModelChangedEvent){var d=this._view;if(d){var e=this,g=d.getModel();b(a.added);b(a.removed);
b(a.changed)}}},_onDestroy:function(){this.destroy()},_onLineStyle:function(a){var b=this._annotationModel,d=a.textView.getModel(),e=b.getTextModel(),g=a.lineStart,f=a.lineStart+a.lineText.length;e!==d&&(g=d.mapOffset(g),f=d.mapOffset(f));for(b=b.getAnnotations(g,f);b.hasNext();)if(g=b.next(),this.isAnnotationTypeVisible(g.type)){if(g.rangeStyle){var f=g.start,c=g.end;e!==d&&(f=d.mapOffset(f,!0),c=d.mapOffset(c,!0));a.ranges=this._mergeStyleRanges(a.ranges,{start:f,end:c,style:g.rangeStyle})}if(g.lineStyle)a.style=
this._mergeStyle({},a.style),a.style=this._mergeStyle(a.style,g.lineStyle)}}};l.addMixin(m.prototype);return{FoldingAnnotation:p,AnnotationType:f,AnnotationTypeList:l,AnnotationModel:k,AnnotationStyler:m}});
define("orion/editor/tooltip",["i18n!orion/editor/nls/messages","orion/editor/textView","orion/editor/textModel","orion/editor/projectionTextModel","orion/editor/util"],function(s,r,p,f,h){function l(f){this._view=f;this._create(f.getOptions("parent").ownerDocument);f.addEventListener("Destroy",this,this.destroy)}l.getTooltip=function(f){if(!f._tooltip)f._tooltip=new l(f);return f._tooltip};l.prototype={_create:function(f){if(!this._tooltipDiv){var m=this._tooltipDiv=h.createElement(f,"div");m.className=
"textviewTooltip";m.setAttribute("aria-live","assertive");m.setAttribute("aria-atomic","true");var e=this._tooltipContents=h.createElement(f,"div");m.appendChild(e);f.body.appendChild(m);this.hide()}},_getWindow:function(){var f=this._tooltipDiv.ownerDocument;return f.defaultView||f.parentWindow},destroy:function(){if(this._tooltipDiv){this.hide();var f=this._tooltipDiv.parentNode;f&&f.removeChild(this._tooltipDiv);this._tooltipDiv=null}},hide:function(){if(this._contentsView)this._contentsView.destroy(),
this._contentsView=null;if(this._tooltipContents)this._tooltipContents.innerHTML="";if(this._tooltipDiv)this._tooltipDiv.style.visibility="hidden";var f=this._getWindow();if(this._showTimeout)f.clearTimeout(this._showTimeout),this._showTimeout=null;if(this._hideTimeout)f.clearTimeout(this._hideTimeout),this._hideTimeout=null;if(this._fadeTimeout)f.clearInterval(this._fadeTimeout),this._fadeTimeout=null},isVisible:function(){return this._tooltipDiv&&this._tooltipDiv.style.visibility==="visible"},setTarget:function(f,
h){if(this.target!==f&&(this._target=f,this.hide(),f)){var e=this;if(h===0)e.show(!0);else{var a=this._getWindow();e._showTimeout=a.setTimeout(function(){e.show(!0)},h?h:500)}}},show:function(k){if(this._target){var h=this._target.getTooltipInfo();if(h){var e=this._tooltipDiv,a=this._tooltipContents;e.style.left=e.style.right=e.style.width=e.style.height=a.style.width=a.style.height="auto";var b=h.contents;b instanceof Array&&(b=this._getAnnotationContents(b));if(typeof b==="string")a.innerHTML=b;
else if(this._isNode(b))a.appendChild(b);else if(b instanceof f.ProjectionTextModel){var d=this._view,i=d.getOptions();i.wrapMode=!1;i.parent=a;var g=i.themeClass;g?((g=g.replace("tooltip",""))&&(g=" "+g),g="tooltip"+g):g="tooltip";i.themeClass=g;i=this._contentsView=new r.TextView(i);i._clientDiv.contentEditable=!1;i.addEventListener("LineStyle",function(a){d.onLineStyle(a)});i.setModel(b);b=i.computeSize();a.style.width=b.width+20+"px";a.style.height=b.height+"px";i.resize()}else return;a=e.ownerDocument.documentElement;
h.anchor==="right"?(b=a.clientWidth-h.x,e.style.right=b+"px"):(b=parseInt(this._getNodeStyle(e,"padding-left","0"),10),b+=parseInt(this._getNodeStyle(e,"border-left-width","0"),10),b=h.x-b,e.style.left=b+"px");e.style.maxWidth=a.clientWidth-b-10+"px";b=parseInt(this._getNodeStyle(e,"padding-top","0"),10);b+=parseInt(this._getNodeStyle(e,"border-top-width","0"),10);b=h.y-b;e.style.top=b+"px";e.style.maxHeight=a.clientHeight-b-10+"px";e.style.opacity="1";e.style.visibility="visible";if(k){var o=this,
c=this._getWindow();o._hideTimeout=c.setTimeout(function(){var a=parseFloat(o._getNodeStyle(e,"opacity","1"));o._fadeTimeout=c.setInterval(function(){e.style.visibility==="visible"&&a>0?(a-=0.1,e.style.opacity=a):o.hide()},50)},5E3)}}}},_getAnnotationContents:function(k){function h(b){var d=b.title;if(d==="")return null;var e="<div>";b.html&&(e+=b.html+"&nbsp;");if(!d)d=b.end,b=a.getLineStart(a.getLineAtOffset(b.start)),d=a.getLineEnd(a.getLineAtOffset(d),!0),d=a.getText(b,d);d=d.replace(/</g,"&lt;").replace(/>/g,
"&gt;");e+="<span style='vertical-align:middle;'>"+d+"</span><div>";return e}if(k.length===0)return null;var e=this._view.getModel(),a=e.getBaseModel?e.getBaseModel():e;if(k.length===1)if(e=k[0],e.title!==void 0)return h(e);else{var k=new f.ProjectionTextModel(a),b=a.getLineStart(a.getLineAtOffset(e.start)),d=a.getCharCount();e.end!==d&&k.addProjection({start:e.end,end:d});b>0&&k.addProjection({start:0,end:b});return k}else{b="<div><em>"+s.multipleAnnotations+"</em></div>";for(d=0;d<k.length;d++)e=
k[d],(e=h(e))&&(b+=e);return b}},_getNodeStyle:function(f,h,e){var a;if(f&&(a=f.style[h],!a))if(f.currentStyle){for(a=0;(a=h.indexOf("-",a))!==-1;)h=h.substring(0,a)+h.substring(a+1,a+2).toUpperCase()+h.substring(a+2);a=f.currentStyle[h]}else a=(f=f.ownerDocument.defaultView.getComputedStyle(f,null))?f.getPropertyValue(h):null;return a||e},_isNode:function(f){return typeof Node==="object"?f instanceof Node:f&&typeof f==="object"&&typeof f.nodeType==="number"&&typeof f.nodeName==="string"}};return{Tooltip:l}});
define("orion/editor/rulers",["i18n!orion/editor/nls/messages","orion/editor/annotations","orion/editor/tooltip","orion/editor/util"],function(s,r,p,f){function h(a,b,d,e){this._location=b||"left";this._overview=d||"page";this._rulerStyle=e;this._view=null;var g=this;this._listener={onTextModelChanged:function(a){g._onTextModelChanged(a)},onAnnotationModelChanged:function(a){g._onAnnotationModelChanged(a)}};this.setAnnotationModel(a)}function l(a,b,d,e,g){h.call(this,a,b,"page",d);this._oddStyle=
e||{style:{backgroundColor:"white"}};this._evenStyle=g||{style:{backgroundColor:"white"}};this._numOfDigits=0}function k(a,b,d){h.call(this,a,b,"page",d)}function m(a,b,d){h.call(this,a,b,"document",d)}function e(a,b,d){k.call(this,a,b,d)}h.prototype={getAnnotations:function(a,b){var d=this._annotationModel;if(!d)return[];var e=this._view.getModel(),g=e.getLineStart(a),f=e.getLineEnd(b-1),c=e;e.getBaseModel&&(c=e.getBaseModel(),g=e.mapOffset(g),f=e.mapOffset(f));for(var j=[],d=this.getAnnotationsByType(d,
g,f),g=0;g<d.length;g++)for(var f=d[g],k=c.getLineAtOffset(f.start),h=c.getLineAtOffset(Math.max(f.start,f.end-1)),l=k;l<=h;l++){var m=l;if(e!==c){m=c.getLineStart(l);m=e.mapOffset(m,!0);if(m===-1)continue;m=e.getLineAtOffset(m)}if(a<=m&&m<b){var n=this._mergeAnnotation(j[m],f,l-k,h-k+1);n&&(j[m]=n)}}if(!this._multiAnnotation&&this._multiAnnotationOverlay)for(var B in j)j[B]._multiple&&(j[B].html+=this._multiAnnotationOverlay.html);return j},getAnnotationModel:function(){return this._annotationModel},
getLocation:function(){return this._location},getOverview:function(){return this._overview},getRulerStyle:function(){return this._rulerStyle},getView:function(){return this._view},getWidestAnnotation:function(){return null},setAnnotationModel:function(a){this._annotationModel&&this._annotationModel.removEventListener("Changed",this._listener.onAnnotationModelChanged);(this._annotationModel=a)&&this._annotationModel.addEventListener("Changed",this._listener.onAnnotationModelChanged)},setMultiAnnotation:function(a){this._multiAnnotation=
a},setMultiAnnotationOverlay:function(a){this._multiAnnotationOverlay=a},setView:function(a){this._onTextModelChanged&&this._view&&this._view.removeEventListener("ModelChanged",this._listener.onTextModelChanged);this._view=a;this._onTextModelChanged&&this._view&&this._view.addEventListener("ModelChanged",this._listener.onTextModelChanged)},onClick:function(){},onDblClick:function(){},onMouseMove:function(a,b){var d=p.Tooltip.getTooltip(this._view);if(d&&!(d.isVisible()&&this._tooltipLineIndex===a)){this._tooltipLineIndex=
a;var e=this;d.setTarget({y:b.clientY,getTooltipInfo:function(){return e._getTooltipInfo(e._tooltipLineIndex,this.y)}})}},onMouseOver:function(a,b){this.onMouseMove(a,b)},onMouseOut:function(){var a=p.Tooltip.getTooltip(this._view);a&&a.setTarget(null)},_getTooltipInfo:function(a,b){if(a!==void 0){var d=this._view,e=d.getModel(),g=this._annotationModel,f=[];if(g){var f=e.getLineStart(a),c=e.getLineEnd(a);e.getBaseModel&&(f=e.mapOffset(f),c=e.mapOffset(c));f=this.getAnnotationsByType(g,f,c)}g=this._getTooltipContents(a,
f);if(!g)return null;g={contents:g,anchor:this.getLocation()};f=d.getClientArea();f.y=this.getOverview()==="document"?d.convert({y:b},"view","document").y:d.getLocationAtOffset(e.getLineStart(a)).y;d.convert(f,"document","page");g.x=f.x;g.y=f.y;g.anchor==="right"&&(g.x+=f.width);return g}},_getTooltipContents:function(a,b){return b},_onAnnotationModelChanged:function(a){function b(a){for(var b=0;b<a.length;b++)if(g.isAnnotationTypeVisible(a[b].type)){var f=a[b].start,o=a[b].end;e.getBaseModel&&(f=
e.mapOffset(f,!0),o=e.mapOffset(o,!0));f!==-1&&o!==-1&&d.redrawLines(e.getLineAtOffset(f),e.getLineAtOffset(Math.max(f,o-1))+1,g)}}var d=this._view;if(d){var e=d.getModel(),g=this,f=e.getLineCount();a.textModelChangedEvent?(a=a.textModelChangedEvent.start,e.getBaseModel&&(a=e.mapOffset(a,!0)),a=e.getLineAtOffset(a),d.redrawLines(a,f,g)):(b(a.added),b(a.removed),b(a.changed))}},_mergeAnnotation:function(a,b,d){a||(a={});if(d===0)if(a.html&&b.html){if(b.html!==a.html&&!a._multiple&&this._multiAnnotation)a.html=
this._multiAnnotation.html;a._multiple=!0}else a.html=b.html;a.style=this._mergeStyle(a.style,b.style);return a},_mergeStyle:function(a,b){if(b){a||(a={});a.styleClass&&b.styleClass&&a.styleClass!==b.styleClass?a.styleClass+=" "+b.styleClass:a.styleClass=b.styleClass;var d;if(b.style){if(!a.style)a.style={};for(d in b.style)a.style[d]||(a.style[d]=b.style[d])}if(b.attributes){if(!a.attributes)a.attributes={};for(d in b.attributes)a.attributes[d]||(a.attributes[d]=b.attributes[d])}}return a}};r.AnnotationTypeList.addMixin(h.prototype);
l.prototype=new h;l.prototype.getAnnotations=function(a,b){for(var d=h.prototype.getAnnotations.call(this,a,b),e=this._view.getModel(),f=a;f<b;f++){var o=f&1?this._oddStyle:this._evenStyle,c=f;e.getBaseModel&&(c=e.getLineStart(c),c=e.getBaseModel().getLineAtOffset(e.mapOffset(c)));d[f]||(d[f]={});d[f].html=c+1+"";if(!d[f].style)d[f].style=o}return d};l.prototype.getWidestAnnotation=function(){var a=this._view.getModel().getLineCount();return this.getAnnotations(a-1,a)[a-1]};l.prototype._onTextModelChanged=
function(a){var a=a.start,b=this._view.getModel(),d=((b.getBaseModel?b.getBaseModel().getLineCount():b.getLineCount())+"").length;if(this._numOfDigits!==d)this._numOfDigits=d,this._view.redrawLines(b.getLineAtOffset(a),b.getLineCount(),this)};k.prototype=new h;m.prototype=new h;m.prototype.getRulerStyle=function(){var a={style:{lineHeight:"1px",fontSize:"1px"}};return a=this._mergeStyle(a,this._rulerStyle)};m.prototype.onClick=function(a){a!==void 0&&this._view.setTopIndex(a)};m.prototype._getTooltipContents=
function(a,b){if(b.length===0){var d=this._view.getModel(),e=a;d.getBaseModel&&(e=d.getLineStart(e),e=d.getBaseModel().getLineAtOffset(d.mapOffset(e)));return f.formatMessage(s.line,e+1)}return h.prototype._getTooltipContents.call(this,a,b)};m.prototype._mergeAnnotation=function(a,b,d,e){if(d===0){if(!a)a={html:"&nbsp;",style:{style:{height:3*e+"px"}}},a.style=this._mergeStyle(a.style,b.overviewStyle);return a}};e.prototype=new k;e.prototype.onClick=function(a){if(a!==void 0){var b=this._annotationModel;
if(b){var d=this._view.getModel(),e=d.getLineStart(a),a=d.getLineEnd(a,!0);d.getBaseModel&&(e=d.mapOffset(e),a=d.mapOffset(a),d=d.getBaseModel());for(var f,b=b.getAnnotations(e,a);!f&&b.hasNext();)a=b.next(),this.isAnnotationTypeVisible(a.type)&&(f=a);f&&d.getLineAtOffset(f.start)===d.getLineAtOffset(e)&&((d=p.Tooltip.getTooltip(this._view))&&d.setTarget(null),f.expanded?f.collapse():f.expand(),this._annotationModel.modifyAnnotation(f))}}};e.prototype._getTooltipContents=function(a,b){return b.length===
1&&b[0].expanded?null:k.prototype._getTooltipContents.call(this,a,b)};e.prototype._onAnnotationModelChanged=function(a){function b(a){for(o=0;o<a.length;o++)if(f.isAnnotationTypeVisible(a[o].type)){var b=a[o].start;e.getBaseModel&&(b=e.mapOffset(b,!0));b!==-1&&(j=Math.min(j,e.getLineAtOffset(b)))}}if(a.textModelChangedEvent)k.prototype._onAnnotationModelChanged.call(this,a);else{var d=this._view;if(d){var e=d.getModel(),f=this,o,c=e.getLineCount(),j=c;b(a.added);b(a.removed);b(a.changed);a=d.getRulers();
for(o=0;o<a.length;o++)d.redrawLines(j,c,a[o])}}};return{Ruler:h,AnnotationRuler:k,LineNumberRuler:l,OverviewRuler:m,FoldingRuler:e}});
define("orion/editor/undoStack",[],function(){function s(f,h,l){this.offset=f;this.text=h;this.previousText=l}function r(){this.changes=[]}function p(f,h){this.view=f;this.size=h!==void 0?h:100;this.reset();var l=f.getModel();l.getBaseModel&&(l=l.getBaseModel());this.model=l;var k=this;this._listener={onChanging:function(f){k._onChanging(f)},onDestroy:function(f){k._onDestroy(f)}};l.addEventListener("Changing",this._listener.onChanging);f.addEventListener("Destroy",this._listener.onDestroy)}s.prototype=
{undo:function(f,h){this._doUndoRedo(this.offset,this.previousText,this.text,f,h)},redo:function(f,h){this._doUndoRedo(this.offset,this.text,this.previousText,f,h)},_doUndoRedo:function(f,h,l,k,m){var e=k.getModel();if(e.mapOffset&&k.annotationModel){var a=e.mapOffset(f,!0);if(a<0)for(var b=k.annotationModel.getAnnotations(f,f+1);b.hasNext();){var d=b.next();if(d.type==="orion.annotation.folding"){d.expand();a=e.mapOffset(f,!0);break}}if(a<0)return;f=a}k.setText(h,f,f+l.length);m&&k.setSelection(f,
f+h.length)}};r.prototype={add:function(f){this.changes.push(f)},end:function(f){this.endSelection=f.getSelection();this.endCaret=f.getCaretOffset()},undo:function(f,h){for(var l=this.changes.length-1;l>=0;l--)this.changes[l].undo(f,!1);if(h){var l=this.startSelection.start,k=this.startSelection.end;f.setSelection(this.startCaret?l:k,this.startCaret?k:l)}},redo:function(f,h){for(var l=0;l<this.changes.length;l++)this.changes[l].redo(f,!1);if(h){var l=this.endSelection.start,k=this.endSelection.end;
f.setSelection(this.endCaret?l:k,this.endCaret?k:l)}},start:function(f){this.startSelection=f.getSelection();this.startCaret=f.getCaretOffset()}};p.prototype={add:function(f){this.compoundChange?this.compoundChange.add(f):(this.stack.splice(this.index,this.stack.length-this.index,f),this.index++,this.stack.length>this.size&&(this.stack.shift(),this.index--,this.cleanIndex--))},markClean:function(){this.endCompoundChange();this._commitUndo();this.cleanIndex=this.index},isClean:function(){return this.cleanIndex===
this.getSize().undo},canUndo:function(){return this.getSize().undo>0},canRedo:function(){return this.getSize().redo>0},endCompoundChange:function(){this.compoundChange&&this.compoundChange.end(this.view);this.compoundChange=void 0},getSize:function(){var f=this.index,h=this.stack.length;this._undoStart!==void 0&&f++;return{undo:f,redo:h-f}},undo:function(){this._commitUndo();if(this.index<=0)return!1;var f=this.stack[--this.index];this._ignoreUndo=!0;f.undo(this.view,!0);this._ignoreUndo=!1;return!0},
redo:function(){this._commitUndo();if(this.index>=this.stack.length)return!1;var f=this.stack[this.index++];this._ignoreUndo=!0;f.redo(this.view,!0);this._ignoreUndo=!1;return!0},reset:function(){this.index=this.cleanIndex=0;this.stack=[];this._undoStart=void 0;this._undoText="";this._undoType=0;this._ignoreUndo=!1;this._compoundChange=void 0},startCompoundChange:function(){this._commitUndo();var f=new r;this.add(f);this.compoundChange=f;this.compoundChange.start(this.view)},_commitUndo:function(){if(this._undoStart!==
void 0)this._undoType===-1?this.add(new s(this._undoStart,"",this._undoText)):this.add(new s(this._undoStart,this._undoText,"")),this._undoStart=void 0,this._undoText="",this._undoType=0},_onDestroy:function(){this.model.removeEventListener("Changing",this._listener.onChanging);this.view.removeEventListener("Destroy",this._listener.onDestroy)},_onChanging:function(f){var h=f.text,l=f.start,k=f.removedCharCount,f=f.addedCharCount;if(!this._ignoreUndo){this._undoStart!==void 0&&!(f===1&&k===0&&this._undoType===
1&&l===this._undoStart+this._undoText.length||f===0&&k===1&&this._undoType===-1&&(l+1===this._undoStart||l===this._undoStart))&&this._commitUndo();if(!this.compoundChange)if(f===1&&k===0){if(this._undoStart===void 0)this._undoStart=l;this._undoText+=h;this._undoType=1;return}else if(f===0&&k===1){h=this._undoText.length>0&&this._undoStart===l;this._undoStart=l;this._undoType=-1;h?this._undoText+=this.model.getText(l,l+k):this._undoText=this.model.getText(l,l+k)+this._undoText;return}this.add(new s(l,
h,this.model.getText(l,l+k)))}}};return{UndoStack:p}});
define("orion/editor/textDND",[],function(){function s(r,p){this._view=r;this._undoStack=p;this._dragSelection=null;this._dropOffset=-1;this._dropText=null;var f=this;this._listener={onDragStart:function(h){f._onDragStart(h)},onDragEnd:function(h){f._onDragEnd(h)},onDragEnter:function(h){f._onDragEnter(h)},onDragOver:function(h){f._onDragOver(h)},onDrop:function(h){f._onDrop(h)},onDestroy:function(h){f._onDestroy(h)}};r.addEventListener("DragStart",this._listener.onDragStart);r.addEventListener("DragEnd",
this._listener.onDragEnd);r.addEventListener("DragEnter",this._listener.onDragEnter);r.addEventListener("DragOver",this._listener.onDragOver);r.addEventListener("Drop",this._listener.onDrop);r.addEventListener("Destroy",this._listener.onDestroy)}s.prototype={destroy:function(){var r=this._view;if(r)r.removeEventListener("DragStart",this._listener.onDragStart),r.removeEventListener("DragEnd",this._listener.onDragEnd),r.removeEventListener("DragEnter",this._listener.onDragEnter),r.removeEventListener("DragOver",
this._listener.onDragOver),r.removeEventListener("Drop",this._listener.onDrop),r.removeEventListener("Destroy",this._listener.onDestroy),this._view=null},_onDestroy:function(){this.destroy()},_onDragStart:function(r){var p=this._view,f=p.getSelection(),p=p.getModel();if(p.getBaseModel)f.start=p.mapOffset(f.start),f.end=p.mapOffset(f.end),p=p.getBaseModel();if(p=p.getText(f.start,f.end))this._dragSelection=f,r.event.dataTransfer.effectAllowed="copyMove",r.event.dataTransfer.setData("Text",p)},_onDragEnd:function(r){var p=
this._view;if(this._dragSelection){this._undoStack&&this._undoStack.startCompoundChange();(r=r.event.dataTransfer.dropEffect==="move")&&p.setText("",this._dragSelection.start,this._dragSelection.end);if(this._dropText){var f=this._dropText,h=this._dropOffset;if(r)if(h>=this._dragSelection.end)h-=this._dragSelection.end-this._dragSelection.start;else if(h>=this._dragSelection.start)h=this._dragSelection.start;p.setText(f,h,h);p.setSelection(h,h+f.length);this._dropText=null;this._dropOffset=-1}this._undoStack&&
this._undoStack.endCompoundChange()}this._dragSelection=null},_onDragEnter:function(r){this._onDragOver(r)},_onDragOver:function(r){var p=r.event.dataTransfer.types;if(p){var f=!this._view.getOptions("readonly");f&&(f=p.contains?p.contains("text/plain"):p.indexOf("text/plain")!==-1);if(!f)r.event.dataTransfer.dropEffect="none"}},_onDrop:function(r){var p=this._view,f=r.event.dataTransfer.getData("Text");if(f)r=p.getOffsetAtLocation(r.x,r.y),this._dragSelection?(this._dropOffset=r,this._dropText=f):
(p.setText(f,r,r),p.setSelection(r,r+f.length))}};return{TextDND:s}});
define("orion/editor/editor","i18n!orion/editor/nls/messages,orion/editor/keyBinding,orion/editor/eventTarget,orion/editor/tooltip,orion/editor/annotations,orion/editor/util".split(","),function(s,r,p,f,h,l){function k(a){this._textViewFactory=a.textViewFactory;this._undoStackFactory=a.undoStackFactory;this._textDNDFactory=a.textDNDFactory;this._annotationFactory=a.annotationFactory;this._foldingRulerFactory=a.foldingRulerFactory;this._lineNumberRulerFactory=a.lineNumberRulerFactory;this._contentAssistFactory=
a.contentAssistFactory;this._keyBindingFactory=a.keyBindingFactory;this._statusReporter=a.statusReporter;this._domNode=a.domNode;this._foldingRuler=this._overviewRuler=this._lineNumberRuler=this._annotationRuler=this._annotationModel=this._annotationStyler=null;this._dirty=!1;this._title=this._contentAssist=null;this._keyModes=[]}function m(a){var b=this,d=Array.prototype.slice.call(arguments,1);return d.length?function(){return arguments.length?b.apply(a,d.concat(Array.prototype.slice.call(arguments))):
b.apply(a,d)}:function(){return arguments.length?b.apply(a,arguments):b.call(a)}}var e;k.prototype={destroy:function(){this.uninstallTextView();this._textViewFactory=this._undoStackFactory=this._textDNDFactory=this._annotationFactory=this._foldingRulerFactory=this._lineNumberRulerFactory=this._contentAssistFactory=this._keyBindingFactory=this._statusReporter=this._domNode=null},getAnnotationModel:function(){return this._annotationModel},getAnnotationRuler:function(){return this._annotationRuler},
getAnnotationStyler:function(){return this._annotationStyler},getFoldingRuler:function(){return this._foldingRuler},getLineNumberRuler:function(){return this._lineNumberRuler},getModel:function(){var a=this._textView.getModel();a.getBaseModel&&(a=a.getBaseModel());return a},getOverviewRuler:function(){return this._overviewRuler},getTextView:function(){return this._textView},getTitle:function(){return this._title},getKeyModes:function(){return this._keyModes},isDirty:function(){return this._dirty},
setAnnotationRulerVisible:function(a){if(this._annotationRulerVisible!==a&&(this._annotationRulerVisible=a,this._annotationRuler)){var b=this._textView;a?b.addRuler(this._annotationRuler,0):b.removeRuler(this._annotationRuler)}},setFoldingRulerVisible:function(a){if(this._foldingRulerVisible!==a&&(this._foldingRulerVisible=a,this._foldingRuler)){var b=this._textView;b.getModel().getBaseModel&&(a?b.addRuler(this._foldingRuler,100):b.removeRuler(this._foldingRuler))}},setDirty:function(a){if(this._dirty!==
a)this._dirty=a,this.onDirtyChanged({type:"DirtyChanged"})},setLineNumberRulerVisible:function(a){if(this._lineNumberRulerVisible!==a&&(this._lineNumberRulerVisible=a,this._lineNumberRuler)){var b=this._textView;a?b.addRuler(this._lineNumberRuler,1):b.removeRuler(this._lineNumberRuler)}},setOverviewRulerVisible:function(a){if(this._overviewRulerVisible!==a&&(this._overviewRulerVisible=a,this._overviewRuler)){var b=this._textView;a?b.addRuler(this._overviewRuler):b.removeRuler(this._overviewRuler)}},
mapOffset:function(a,b){var d=this._textView.getModel();d.getBaseModel&&(a=d.mapOffset(a,b));return a},getCaretOffset:function(){return this.mapOffset(this._textView.getCaretOffset())},getSelection:function(){var a=this._textView,b=a.getSelection(),a=a.getModel();if(a.getBaseModel)b.start=a.mapOffset(b.start),b.end=a.mapOffset(b.end);return b},getText:function(a,b){var d=this._textView.getModel();d.getBaseModel&&(d=d.getBaseModel());return d.getText(a,b)},_expandOffset:function(a){var b=this._textView.getModel(),
d=this._annotationModel;if(d&&b.getBaseModel)for(a=d.getAnnotations(a,a+1);a.hasNext();)b=a.next(),b.type===h.AnnotationType.ANNOTATION_FOLDING&&b.expand&&(b.expand(),d.modifyAnnotation(b))},setCaretOffset:function(a){var b=this._textView,d=b.getModel();d.getBaseModel&&(this._expandOffset(a),a=d.mapOffset(a,!0));b.setCaretOffset(a)},setText:function(a,b,d){var e=this._textView,f=e.getModel();f.getBaseModel&&(b!==void 0&&(this._expandOffset(b),b=f.mapOffset(b,!0)),d!==void 0&&(this._expandOffset(d),
d=f.mapOffset(d,!0)));e.setText(a,b,d)},setFoldingEnabled:function(a){this.setFoldingRulerVisible(a)},setSelection:function(a,b,d){var e=this._textView,f=e.getModel();f.getBaseModel&&(this._expandOffset(a),this._expandOffset(b),a=f.mapOffset(a,!0),b=f.mapOffset(b,!0));e.setSelection(a,b,d)},moveSelection:function(a,b,d,i){var f=this._textView;this.setSelection(a,b||a,!1);var b=f.getTopPixel(),o=f.getBottomPixel(),a=this.getModel().getLineAtOffset(a),a=f.getLinePixel(a);a<b||a>o?(o=Math.max(0,a-Math.floor((a<
b?3:1)*(o-b)/4)),(new e({node:f,duration:300,curve:[b,o],onAnimate:function(a){f.setTopPixel(Math.floor(a))},onEnd:function(){f.showSelection();(i===void 0||i)&&f.focus();d&&d()}})).play()):(f.showSelection(),(i===void 0||i)&&f.focus(),d&&d())},checkDirty:function(){this.setDirty(!this._undoStack.isClean())},reportStatus:function(a,b,d){this._statusReporter&&this._statusReporter(a,b,d)},_getTooltipInfo:function(a,b){var d=this._textView,e=this.getAnnotationModel();if(!e)return null;var f=this._annotationStyler;
if(!f)return null;var o=d.getOffsetAtLocation(a,b);if(o===-1)return null;o=this.mapOffset(o);f=f.getAnnotationsByType(e,o,o+1);e=[];for(o=0;o<f.length;o++)f[o].rangeStyle&&e.push(f[o]);if(e.length===0)return null;d=d.convert({x:a,y:b},"document","page");return{contents:e,anchor:"left",x:d.x+10,y:d.y+20}},_highlightCurrentLine:function(a,b){var d=this._annotationModel;if(d){var e=this._textView.getModel(),f=b?e.getLineAtOffset(b.start):-1,o=e.getLineAtOffset(a.start),c=a.start===a.end,j=!b||b.start===
b.end,k=e.getLineStart(o),l=e.getLineEnd(o);e.getBaseModel&&(k=e.mapOffset(k),l=e.mapOffset(l));e=this._currentLineAnnotation;if(!(f===o&&j&&c&&e&&e.start===k&&e.end===l)){var f=e?[e]:null,m;c&&(e=h.AnnotationType.createAnnotation(h.AnnotationType.ANNOTATION_CURRENT_LINE,k,l),m=[e]);this._currentLineAnnotation=e;d.replaceAnnotations(f,m)}}},installTextView:function(){this._textView=this._textViewFactory();if(this._undoStackFactory)this._undoStack=this._undoStackFactory.createUndoStack(this);if(this._textDNDFactory)this._textDND=
this._textDNDFactory.createTextDND(this,this._undoStack);if(this._contentAssistFactory){var a=this._contentAssistFactory.createContentAssistMode(this);this._keyModes.push(a);this._contentAssist=a.getContentAssist()}var b=this,d=this._textView,e=this;this._listener={onModelChanged:function(){e.checkDirty()},onMouseOver:function(a){e._listener.onMouseMove(a)},onMouseMove:function(a){var b=f.Tooltip.getTooltip(d);b&&b.setTarget({x:a.x,y:a.y,getTooltipInfo:function(){return e._getTooltipInfo(this.x,this.y)}})},
onMouseOut:function(){var a=f.Tooltip.getTooltip(d);a&&a.setTarget(null)},onSelection:function(a){e._updateCursorStatus();e._highlightCurrentLine(a.newValue,a.oldValue)}};d.addEventListener("ModelChanged",this._listener.onModelChanged);d.addEventListener("Selection",this._listener.onSelection);d.addEventListener("MouseOver",this._listener.onMouseOver);d.addEventListener("MouseOut",this._listener.onMouseOut);d.addEventListener("MouseMove",this._listener.onMouseMove);this._keyBindingFactory&&this._keyBindingFactory(this,
this._keyModes,this._undoStack,this._contentAssist);d.setKeyBinding(new r.KeyBinding(27),"cancelMode");d.setAction("cancelMode",function(){for(var a=!1,b=0;b<this._keyModes.length;b++)this._keyModes[b].isActive()&&(a=this._keyModes[b].cancel()||a);return a}.bind(this),{name:s.cancelMode});d.setAction("lineUp",function(){for(var a=0;a<this._keyModes.length;a++)if(this._keyModes[a].isActive())return this._keyModes[a].lineUp();return!1}.bind(this));d.setAction("lineDown",function(){for(var a=0;a<this._keyModes.length;a++)if(this._keyModes[a].isActive())return this._keyModes[a].lineDown();
return!1}.bind(this));d.setAction("enter",function(){for(var a=0;a<this._keyModes.length;a++)if(this._keyModes[a].isActive())return this._keyModes[a].enter();return!1}.bind(this));a=function(a){if(a!==void 0&&a!==-1){for(var d=this.getView().getModel(),e=this.getAnnotationModel(),f=b.mapOffset(d.getLineStart(a)),a=b.mapOffset(d.getLineEnd(a)),d=e.getAnnotations(f,a),i=null;d.hasNext();){var g=d.next();if(g.type===h.AnnotationType.ANNOTATION_BOOKMARK){i=g;break}}i?e.removeAnnotation(i):(i=h.AnnotationType.createAnnotation(h.AnnotationType.ANNOTATION_BOOKMARK,
f,a),i.title=void 0,e.addAnnotation(i))}};if(this._annotationFactory){var g=d.getModel();g.getBaseModel&&(g=g.getBaseModel());if(this._annotationModel=this._annotationFactory.createAnnotationModel(g))if(g=this._annotationStyler=this._annotationFactory.createAnnotationStyler(d,this._annotationModel))g.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_SEARCH),g.addAnnotationType(h.AnnotationType.ANNOTATION_MATCHING_SEARCH),g.addAnnotationType(h.AnnotationType.ANNOTATION_ERROR),g.addAnnotationType(h.AnnotationType.ANNOTATION_WARNING),
g.addAnnotationType(h.AnnotationType.ANNOTATION_MATCHING_BRACKET),g.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_BRACKET),g.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_LINE),g.addAnnotationType(h.AnnotationType.ANNOTATION_READ_OCCURRENCE),g.addAnnotationType(h.AnnotationType.ANNOTATION_WRITE_OCCURRENCE),g.addAnnotationType("orion.annotation.highlightError");d.annotationModel=this._annotationModel;var g=this._annotationFactory.createAnnotationRulers(this._annotationModel),o=this._annotationRuler=
g.annotationRuler;if(o)o.onClick=function(a){if(a!==void 0&&a!==-1)for(var d=this.getView().getModel(),e=this.getAnnotationModel(),f=b.mapOffset(d.getLineStart(a)),a=b.mapOffset(d.getLineEnd(a)),a=e.getAnnotations(f,a);a.hasNext();)if(e=a.next(),this.isAnnotationTypeVisible(e.type)){a=b.getModel();b.onGotoLine(a.getLineAtOffset(f),e.start-f,e.end-f);break}},o.onDblClick=a,o.setMultiAnnotationOverlay({html:"<div class='annotationHTML overlay'></div>"}),o.addAnnotationType(h.AnnotationType.ANNOTATION_ERROR),
o.addAnnotationType(h.AnnotationType.ANNOTATION_WARNING),o.addAnnotationType(h.AnnotationType.ANNOTATION_TASK),o.addAnnotationType(h.AnnotationType.ANNOTATION_BOOKMARK);this.setAnnotationRulerVisible(!0);if(o=this._overviewRuler=g.overviewRuler)o.onClick=function(a){a!==void 0&&(a=d.getModel().getLineStart(a),b.moveSelection(b.mapOffset(a)))},o.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_SEARCH),o.addAnnotationType(h.AnnotationType.ANNOTATION_MATCHING_SEARCH),o.addAnnotationType(h.AnnotationType.ANNOTATION_ERROR),
o.addAnnotationType(h.AnnotationType.ANNOTATION_WARNING),o.addAnnotationType(h.AnnotationType.ANNOTATION_TASK),o.addAnnotationType(h.AnnotationType.ANNOTATION_BOOKMARK),o.addAnnotationType(h.AnnotationType.ANNOTATION_MATCHING_BRACKET),o.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_BRACKET),o.addAnnotationType(h.AnnotationType.ANNOTATION_CURRENT_LINE),o.addAnnotationType(h.AnnotationType.ANNOTATION_READ_OCCURRENCE),o.addAnnotationType(h.AnnotationType.ANNOTATION_WRITE_OCCURRENCE);this.setOverviewRulerVisible(!0)}if(this._lineNumberRulerFactory)this._lineNumberRuler=
this._lineNumberRulerFactory.createLineNumberRuler(this._annotationModel),this._lineNumberRuler.onDblClick=a,this.setLineNumberRulerVisible(!0);if(this._foldingRulerFactory)this._foldingRuler=this._foldingRulerFactory.createFoldingRuler(this._annotationModel),this._foldingRuler.addAnnotationType(h.AnnotationType.ANNOTATION_FOLDING),this.setFoldingRulerVisible(!1);this.dispatchEvent({type:"TextViewInstalled",textView:d})},uninstallTextView:function(){var a=this._textView;if(a)a.destroy(),this._textView=
this._undoStack=this._textDND=this._contentAssist=this._listener=this._annotationModel=this._annotationStyler=this._annotationRuler=this._overviewRuler=this._lineNumberRuler=this._foldingRuler=this._currentLineAnnotation=this._title=null,this._dirty=!1,this._keyModes=[],this.dispatchEvent({type:"TextViewUninstalled",textView:a})},_updateCursorStatus:function(){var a=this.getModel(),b=this.getCaretOffset(),d=a.getLineAtOffset(b),a=a.getLineStart(d);b-=a;for(a=0;a<this._keyModes.length;a++){var e=this._keyModes[a];
if(e.isActive()&&e.isStatusActive&&e.isStatusActive())return}this.reportStatus(l.formatMessage(s.lineColumn,d+1,b+1))},showProblems:function(a){var b=this._annotationModel;if(b){for(var d=[],e=[],f=b.getTextModel(),o=b.getAnnotations(0,f.getCharCount()),c;o.hasNext();)c=o.next(),(c.type===h.AnnotationType.ANNOTATION_ERROR||c.type===h.AnnotationType.ANNOTATION_WARNING)&&d.push(c);if(a)for(o=0;o<a.length;o++)if(c=a[o]){var j=c.description.replace(/'/g,"&#39;").replace(/"/g,"&#34;"),k=f.getLineStart(c.line-
1);c=h.AnnotationType.createAnnotation(c.severity==="error"?h.AnnotationType.ANNOTATION_ERROR:h.AnnotationType.ANNOTATION_WARNING,k+c.start-1,k+c.end,j);e.push(c)}b.replaceAnnotations(d,e)}},showOccurrences:function(a){var b=this._annotationModel;if(b){for(var d=[],e=[],f=b.getTextModel(),o=b.getAnnotations(0,f.getCharCount()),c;o.hasNext();)c=o.next(),(c.type===h.AnnotationType.ANNOTATION_READ_OCCURRENCE||c.type===h.AnnotationType.ANNOTATION_WRITE_OCCURRENCE)&&d.push(c);if(a)for(o=0;o<a.length;o++)if(c=
a[o]){var j=f.getLineStart(c.line-1);c=h.AnnotationType.createAnnotation(c.readAccess===!0?h.AnnotationType.ANNOTATION_READ_OCCURRENCE:h.AnnotationType.ANNOTATION_WRITE_OCCURRENCE,j+c.start-1,j+c.end,c.description);e.push(c)}b.replaceAnnotations(d,e)}},showSelection:function(a,b,d,e,f){typeof a==="number"?(typeof b!=="number"&&(b=a),this.moveSelection(a,b)):typeof d==="number"&&(a=this.getModel().getLineStart(d-1),typeof e==="number"&&(a+=e),typeof f!=="number"&&(f=0),this.moveSelection(a,a+f))},
setInput:function(a,b,d,e){this._title=a;this._textView&&(e?(this._undoStack.markClean(),this.checkDirty()):(b?this._textView.setText(b):d!==null&&d!==void 0&&(this._textView.setText(d),this._textView.getModel().setLineDelimiter("auto"),this._highlightCurrentLine(this._textView.getSelection())),this._undoStack.reset(),this.checkDirty(),this._textView.focus()));this.onInputChanged({type:"InputChanged",title:a,message:b,contents:d,contentsSaved:e})},onInputChanged:function(a){return this.dispatchEvent(a)},
onGotoLine:function(a,b,d){if(this._textView){var e=this.getModel(),f=e.getLineStart(a),o=0;d===void 0&&(d=0);typeof b==="string"?(a=e.getLine(a).indexOf(b),a!==-1&&(o=a,d=o+b.length)):(o=b,b=e.getLineEnd(a)-f,o=Math.min(o,b),d=Math.min(d,b));this.moveSelection(f+o,f+d)}},onDirtyChanged:function(a){return this.dispatchEvent(a)}};p.EventTarget.addMixin(k.prototype);e=function(){function a(a){this.options=a}a.prototype.play=function(){var a=typeof this.options.duration==="number"?this.options.duration:
350,d=this.options.easing||this.defaultEasing,e=this.options.onAnimate||function(){},f=this.options.onEnd||function(){},o=this.options.curve[0],c=this.options.curve[1]-o,j,k,h=-1;k=setInterval(function(){h=h===-1?(new Date).getTime():h;var l=((new Date).getTime()-h)/a;l<1?(l=d(l),j=o+l*c,e(j)):(clearInterval(k),f())},typeof this.options.rate==="number"?this.options.rate:20)};a.prototype.defaultEasing=function(a){return Math.sin(a*(Math.PI/2))};return a}();if(!Function.prototype.bind)Function.prototype.bind=
m;return{Editor:k,util:{bind:m}}});define("orion/editor/regex",[],function(){return{escape:function(s){return s.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&")},parse:function(s){return(s=/^\s*\/(.+)\/([gim]{0,3})\s*$/.exec(s))?{pattern:s[1],flags:s[2]}:null}}});
define("orion/editor/editorFeatures","i18n!orion/editor/nls/messages,orion/editor/undoStack,orion/editor/keyBinding,orion/editor/rulers,orion/editor/annotations,orion/editor/tooltip,orion/editor/textDND,orion/editor/regex,orion/editor/util".split(","),function(s,r,p,f,h,l,k,m,e){function a(){}function b(){}function d(){}function i(){}function g(){}function o(a,b,c){this.editor=a;this.textView=a.getTextView();this.undoStack=b;this._incrementalFindActive=!1;this._incrementalFindSuccess=!0;this._incrementalFindIgnoreSelection=
!1;this._incrementalFindPrefix="";this._searcher=c;this._lastEditLocation=null;this.init()}function c(a,b,c,d){this.editor=a;this.textView=a.getTextView();this.undoStack=b;this.contentAssist=c;this.linkedMode=d;this.contentAssist&&this.contentAssist.addEventListener("ProposalApplied",this.contentAssistProposalApplied.bind(this));this.init()}function j(a){this.editor=a;this.textView=a.getTextView();this.linkedModeActive=!1;this.linkedModePositions=[];this.linkedModeEscapePosition=this.linkedModeCurrentPositionIndex=
0;this.linkedModeListener={onVerify:function(a){for(var b=!1,c=0,d=0;d<this.linkedModePositions.length;++d){var e=this.linkedModePositions[d];if(b)e.offset+=c;else if(a.start>=e.offset&&a.end<=e.offset+e.length)b=e.length,e.length=a.start-e.offset+a.text.length+(e.offset+e.length-a.end),c=e.length-b,b=!0}b?this.linkedModeEscapePosition+=c:this.cancel()}.bind(this)}}a.prototype={createUndoStack:function(a){var a=a.getTextView(),b=new r.UndoStack(a,200);a.setAction("undo",function(){b.undo();return!0},
{name:s.undo});a.setAction("redo",function(){b.redo();return!0},{name:s.redo});return b}};b.prototype={createLineNumberRuler:function(a){return new f.LineNumberRuler(a,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"})}};d.prototype={createFoldingRuler:function(a){return new f.FoldingRuler(a,"left",{styleClass:"ruler folding"})}};i.prototype={createAnnotationModel:function(a){return new h.AnnotationModel(a)},createAnnotationStyler:function(a,b){return new h.AnnotationStyler(a,
b)},createAnnotationRulers:function(a){var b=new f.AnnotationRuler(a,"left",{styleClass:"ruler annotations"}),a=new f.OverviewRuler(a,"right",{styleClass:"ruler overview"});return{annotationRuler:b,overviewRuler:a}}};g.prototype={createTextDND:function(a,b){return new k.TextDND(a.getTextView(),b)}};o.prototype={init:function(){var a=this;this._incrementalFindListener={onVerify:function(b){var c=a.editor,d=c.getModel(),f=c.mapOffset(b.start),i=c.mapOffset(b.end),f=d.getText(f,i),d=a._incrementalFindPrefix;
if((d=d.match(RegExp("^"+m.escape(f),"i")))&&d.length>0)d=a._incrementalFindPrefix+=b.text,a.editor.reportStatus(e.formatMessage(s.incrementalFind,d)),f=c.getSelection().start,(f=c.getModel().find({string:d,start:f,caseInsensitive:d.toLowerCase()===d}).next())?(a._incrementalFindSuccess=!0,a._incrementalFindIgnoreSelection=!0,c.moveSelection(f.start,f.end),a._incrementalFindIgnoreSelection=!1):(c.reportStatus(e.formatMessage(s.incrementalFindNotFound,d),"error"),a._incrementalFindSuccess=!1),b.text=
null},onSelection:function(){a._incrementalFindIgnoreSelection||a.toggleIncrementalFind()}};this._lastEditListener={onModelChanged:function(b){if(a.editor.isDirty())a._lastEditLocation=b.start+b.addedCharCount}};this.textView.addEventListener("ModelChanged",this._lastEditListener.onModelChanged);this.textView.setKeyBinding(new p.KeyBinding("k",!0),"findNext");this.textView.setAction("findNext",function(){if(this._searcher){var a=this.textView.getSelection();a.start<a.end?this._searcher.findNext(!0,
this.textView.getText(a.start,a.end)):this._searcher.findNext(!0);return!0}return!1}.bind(this),{name:s.findNext});this.textView.setKeyBinding(new p.KeyBinding("k",!0,!0),"findPrevious");this.textView.setAction("findPrevious",function(){if(this._searcher){var a=this.textView.getSelection();a.start<a.end?this._searcher.findNext(!1,this.textView.getText(a.start,a.end)):this._searcher.findNext(!1);return!0}return!1}.bind(this),{name:s.findPrevious});this.textView.setKeyBinding(new p.KeyBinding("j",!0),
"incrementalFind");this.textView.setAction("incrementalFind",function(){if(this._searcher&&this._searcher.visible())return!0;var a=this.editor;if(this._incrementalFindActive){var b=this._incrementalFindPrefix;if(b.length!==0){var c;c=0;this._incrementalFindSuccess&&(c=a.getSelection().start+1);(c=a.getModel().find({string:b,start:c,caseInsensitive:b.toLowerCase()===b}).next())?(this._incrementalFindIgnoreSelection=this._incrementalFindSuccess=!0,a.moveSelection(c.start,c.end),this._incrementalFindIgnoreSelection=
!1,a.reportStatus(e.formatMessage(s.incrementalFind,b))):(a.reportStatus(e.formatMessage(s.incrementalFindNotFound,b),"error"),this._incrementalFindSuccess=!1)}}else a.setCaretOffset(a.getCaretOffset()),this.toggleIncrementalFind();return!0}.bind(this),{name:s.incrementalFindKey});this.textView.setAction("deletePrevious",function(){if(this._incrementalFindActive){var a=this.editor,b=this._incrementalFindPrefix,b=this._incrementalFindPrefix=b.substring(0,b.length-1);if(b.length===0)return this._incrementalFindIgnoreSelection=
this._incrementalFindSuccess=!0,a.setCaretOffset(a.getSelection().start),this._incrementalFindIgnoreSelection=!1,this.toggleIncrementalFind(),!0;a.reportStatus(e.formatMessage(s.incrementalFind,b));var c=a.getModel().find({string:b,start:a.getCaretOffset()-b.length-1,reverse:!0,caseInsensitive:b.toLowerCase()===b}).next();c?(this._incrementalFindIgnoreSelection=this._incrementalFindSuccess=!0,a.moveSelection(c.start,c.end),this._incrementalFindIgnoreSelection=!1):a.reportStatus(e.formatMessage(s.incrementalFindNotFound,
b),"error");return!0}return!1}.bind(this));this.textView.setAction("tab",function(){if(this.textView.getOptions("readonly"))return!1;if(this.textView.getOptions("tabMode")){var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),e=b.getLineAtOffset(c.end>c.start?c.end-1:c.end);if(d!==e){var f=[];f.push("");for(var i=d;i<=e;i++)f.push(b.getLine(i,!0));var i=b.getLineStart(d),b=b.getLineEnd(e,!0),g=this.textView.getOptions("tabSize","expandTab"),g=g.expandTab?Array(g.tabSize+
1).join(" "):"\t";a.setText(f.join(g),i,b);a.setSelection(i===c.start?c.start:c.start+g.length,c.end+(e-d+1)*g.length);return!0}a=a.getKeyModes();for(c=0;c<a.length;c++)if(a[c].isActive())return a[c].tab();return!1}}.bind(this));this.textView.setAction("shiftTab",function(){if(this.textView.getOptions("readonly"))return!1;if(this.textView.getOptions("tabMode")){for(var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),e=b.getLineAtOffset(c.end>c.start?c.end-1:c.end),f=this.textView.getOptions("tabSize"),
i=Array(f+1).join(" "),g=[],j=0,o=0,k=d;k<=e;k++){var h=b.getLine(k,!0);if(b.getLineStart(k)!==b.getLineEnd(k))if(h.indexOf("\t")===0)h=h.substring(1),j++;else if(h.indexOf(i)===0)h=h.substring(f),j+=f;else return!0;k===d&&(o=j);g.push(h)}d=b.getLineStart(d);f=b.getLineEnd(e,!0);b=b.getLineStart(e);a.setText(g.join(""),d,f);g=d===c.start?c.start:c.start-o;c=Math.max(g,c.end-j+(c.end===b+1&&c.start!==c.end?1:0));a.setSelection(g,c);return!0}}.bind(this),{name:s.unindentLines});this.textView.setKeyBinding(new p.KeyBinding(38,
!1,!1,!0),"moveLinesUp");this.textView.setAction("moveLinesUp",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start);if(d===0)return!0;var e=b.getLineAtOffset(c.end>c.start?c.end-1:c.end),f=b.getLineCount(),c=b.getLineStart(d-1),i=b.getLineStart(d),g=b.getLineEnd(e,!0),j=b.getText(i,g),k=0;e===f-1&&(e=b.getLineEnd(d-1),d=b.getLineEnd(d-1,!0),j+=b.getText(e,d),i=e,k=d-e);this.startUndo();a.setText("",i,g);a.setText(j,
c,c);a.setSelection(c,c+j.length-k);this.endUndo();return!0}.bind(this),{name:s.moveLinesUp});this.textView.setKeyBinding(new p.KeyBinding(40,!1,!1,!0),"moveLinesDown");this.textView.setAction("moveLinesDown",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),e=b.getLineAtOffset(c.end>c.start?c.end-1:c.end),f=b.getLineCount();if(e===f-1)return!0;var d=b.getLineStart(d),c=b.getLineEnd(e,!0),i=b.getLineEnd(e+1,
!0)-(c-d),g=0;e!==f-2?b=b.getText(d,c):(e=b.getLineEnd(e),b=b.getText(e,c)+b.getText(d,e),g+=c-e);this.startUndo();a.setText("",d,c);a.setText(b,i,i);a.setSelection(i+g,i+g+b.length);this.endUndo();return!0}.bind(this),{name:s.moveLinesDown});this.textView.setKeyBinding(new p.KeyBinding(38,!0,!1,!0),"copyLinesUp");this.textView.setAction("copyLinesUp",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),c=b.getLineAtOffset(c.end>
c.start?c.end-1:c.end),d=b.getLineStart(d),e=b.getLineEnd(c,!0),f=b.getLineCount(),i="",e=b.getText(d,e);c===f-1&&(e+=i=b.getLineDelimiter());a.setText(e,d,d);a.setSelection(d,d+e.length-i.length);return!0}.bind(this),{name:s.copyLinesUp});this.textView.setKeyBinding(new p.KeyBinding(40,!0,!1,!0),"copyLinesDown");this.textView.setAction("copyLinesDown",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),c=b.getLineAtOffset(c.end>
c.start?c.end-1:c.end),e=b.getLineStart(d),d=b.getLineEnd(c,!0),f=b.getLineCount(),i="",e=b.getText(e,d);c===f-1&&(e=(i=b.getLineDelimiter())+e);a.setText(e,d,d);a.setSelection(d+i.length,d+e.length);return!0}.bind(this),{name:s.copyLinesDown});this.textView.setKeyBinding(new p.KeyBinding("d",!0,!1,!1),"deleteLines");this.textView.setAction("deleteLines",function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getSelection(),c=a.getModel(),d=c.getLineAtOffset(b.start),b=c.getLineAtOffset(b.end>
b.start?b.end-1:b.end),d=c.getLineStart(d),c=c.getLineEnd(b,!0);a.setText("",d,c);return!0}.bind(this),{name:s.deleteLines});this.textView.setKeyBinding(new p.KeyBinding("l",!0),"gotoLine");this.textView.setAction("gotoLine",function(){var a=this.editor,b=a.getModel().getLineAtOffset(a.getCaretOffset());if(b=prompt(s.gotoLinePrompty,b+1))b=parseInt(b,10),a.onGotoLine(b-1,0);return!0}.bind(this),{name:s.gotoLine});this.textView.setKeyBinding(new p.KeyBinding(190,!0),"nextAnnotation");this.textView.setAction("nextAnnotation",
function(){var a=this.editor,b=a.getAnnotationModel();if(!b)return!0;for(var c=a.getModel(),d=a.getCaretOffset(),b=b.getAnnotations(d,c.getCharCount());b.hasNext();){var e=b.next();if(!(e.start<=d)&&!(e.type!==h.AnnotationType.ANNOTATION_ERROR&&e.type!==h.AnnotationType.ANNOTATION_WARNING&&e.type!==h.AnnotationType.ANNOTATION_TASK&&e.type!==h.AnnotationType.ANNOTATION_BOOKMARK)){var f=l.Tooltip.getTooltip(this.textView);if(!f){a.moveSelection(e.start);break}var i=c.getLineAtOffset(e.start),g=this.textView;
a.moveSelection(e.start,e.start,function(){setTimeout(function(){f.setTarget({getTooltipInfo:function(){var a=g.convert({x:g.getLocationAtOffset(e.start).x,y:g.getLocationAtOffset(c.getLineStart(i)).y},"document","page");return{contents:[e],x:a.x,y:a.y+Math.floor(g.getLineHeight(i)*1.33)}}},0)},0)});break}}return!0}.bind(this),{name:s.nextAnnotation});this.textView.setKeyBinding(new p.KeyBinding(188,!0),"previousAnnotation");this.textView.setAction("previousAnnotation",function(){var a=this.editor,
b=a.getAnnotationModel();if(!b)return!0;for(var c=a.getModel(),d=a.getCaretOffset(),b=b.getAnnotations(0,d),e=null;b.hasNext();){var f=b.next();f.start>=d||f.type!==h.AnnotationType.ANNOTATION_ERROR&&f.type!==h.AnnotationType.ANNOTATION_WARNING&&f.type!==h.AnnotationType.ANNOTATION_TASK&&f.type!==h.AnnotationType.ANNOTATION_BOOKMARK||(e=f)}if(e){var i=c.getLineAtOffset(e.start),g=l.Tooltip.getTooltip(this.textView);if(!g)return a.moveSelection(e.start),!0;var j=this.textView;a.moveSelection(e.start,
e.start,function(){setTimeout(function(){g.setTarget({getTooltipInfo:function(){var a=j.convert({x:j.getLocationAtOffset(e.start).x,y:j.getLocationAtOffset(c.getLineStart(i)).y},"document","page");return{contents:[e],x:a.x,y:a.y+Math.floor(j.getLineHeight(i)*1.33)}}},0)},0)})}return!0}.bind(this),{name:s.prevAnnotation});this.textView.setKeyBinding(new p.KeyBinding("e",!0,!1,!0,!1),"expand");this.textView.setAction("expand",function(){var a=this.editor,b=a.getAnnotationModel();if(!b)return!0;var c=
a.getModel(),a=a.getCaretOffset(),d=c.getLineAtOffset(a),a=c.getLineStart(d),d=c.getLineEnd(d,!0);c.getBaseModel&&(a=c.mapOffset(a),d=c.mapOffset(d),c.getBaseModel());for(var e,c=b.getAnnotations(a,d);!e&&c.hasNext();)a=c.next(),a.type===h.AnnotationType.ANNOTATION_FOLDING&&(a.expanded||(e=a));e&&!e.expanded&&(e.expand(),b.modifyAnnotation(e));return!0}.bind(this),{name:s.expand});this.textView.setKeyBinding(new p.KeyBinding("c",!0,!1,!0,!1),"collapse");this.textView.setAction("collapse",function(){var a=
this.editor,b=a.getAnnotationModel();if(!b)return!0;var c=a.getModel(),d=a.getCaretOffset(),e=c.getLineAtOffset(d),d=c.getLineStart(e),e=c.getLineEnd(e,!0);c.getBaseModel&&(d=c.mapOffset(d),e=c.mapOffset(e),c.getBaseModel());for(var f,c=b.getAnnotations(d,e);!f&&c.hasNext();)d=c.next(),d.type===h.AnnotationType.ANNOTATION_FOLDING&&(f=d);f&&f.expanded&&(a.setCaretOffset(f.start),f.collapse(),b.modifyAnnotation(f));return!0}.bind(this),{name:s.collapse});this.textView.setKeyBinding(new p.KeyBinding("e",
!0,!0,!0,!1),"expandAll");this.textView.setAction("expandAll",function(){var a=this.editor,b=a.getAnnotationModel();if(!b)return!0;var a=a.getModel(),c=b.getAnnotations(0,a.getCharCount());for(this.textView.setRedraw(!1);c.hasNext();)a=c.next(),a.type===h.AnnotationType.ANNOTATION_FOLDING&&!a.expanded&&(a.expand(),b.modifyAnnotation(a));this.textView.setRedraw(!0);return!0}.bind(this),{name:s.expandAll});this.textView.setKeyBinding(new p.KeyBinding("c",!0,!0,!0,!1),"collapseAll");this.textView.setAction("collapseAll",
function(){var a=this.editor,b=a.getAnnotationModel();if(!b)return!0;var a=a.getModel(),c=b.getAnnotations(0,a.getCharCount());for(this.textView.setRedraw(!1);c.hasNext();)a=c.next(),a.type===h.AnnotationType.ANNOTATION_FOLDING&&a.expanded&&(a.collapse(),b.modifyAnnotation(a));this.textView.setRedraw(!0);return!0}.bind(this),{name:s.collapseAll});this.textView.setKeyBinding(new p.KeyBinding("q",!e.isMac,!1,!1,e.isMac),"lastEdit");this.textView.setAction("lastEdit",function(){typeof this._lastEditLocation===
"number"&&this.editor.showSelection(this._lastEditLocation);return!0}.bind(this),{name:s.lastEdit})},toggleIncrementalFind:function(){(this._incrementalFindActive=!this._incrementalFindActive)?(this.editor.reportStatus(e.formatMessage(s.incrementalFind,this._incrementalFindPrefix)),this.textView.addEventListener("Verify",this._incrementalFindListener.onVerify),this.textView.addEventListener("Selection",this._incrementalFindListener.onSelection)):(this._incrementalFindPrefix="",this.editor.reportStatus(""),
this.textView.removeEventListener("Verify",this._incrementalFindListener.onVerify),this.textView.removeEventListener("Selection",this._incrementalFindListener.onSelection),this.textView.setCaretOffset(this.textView.getCaretOffset()))},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},cancel:function(){this.toggleIncrementalFind()},isActive:function(){return this._incrementalFindActive},isStatusActive:function(){return this._incrementalFindActive},
lineUp:function(){if(this._incrementalFindActive){var a=this._incrementalFindPrefix;if(a.length===0)return!1;var b=this.editor,c=b.getModel(),c=this._incrementalFindSuccess?b.getCaretOffset()-a.length-1:c.getCharCount()-1;(c=b.getModel().find({string:a,start:c,reverse:!0,caseInsensitive:a.toLowerCase()===a}).next())?(this._incrementalFindIgnoreSelection=this._incrementalFindSuccess=!0,b.moveSelection(c.start,c.end),this._incrementalFindIgnoreSelection=!1,b.reportStatus(e.formatMessage(s.incrementalFind,
a))):(b.reportStatus(e.formatMessage(s.incrementalFindNotFound,a),"error"),this._incrementalFindSuccess=!1);return!0}return!1},lineDown:function(){if(this._incrementalFindActive){var a=this._incrementalFindPrefix;if(a.length===0)return!1;var b=this.editor,c=0;this._incrementalFindSuccess&&(c=b.getSelection().start+1);(c=b.getModel().find({string:a,start:c,caseInsensitive:a.toLowerCase()===a}).next())?(this._incrementalFindIgnoreSelection=this._incrementalFindSuccess=!0,b.moveSelection(c.start,c.end),
this._incrementalFindIgnoreSelection=!1,b.reportStatus(e.formatMessage(s.incrementalFind,a))):(b.reportStatus(e.formatMessage(s.incrementalFindNotFound,a),"error"),this._incrementalFindSuccess=!1);return!0}return!1},enter:function(){return!1}};c.prototype={startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},init:function(){function a(b,c,d){var e=b.getLineAtOffset(c),f=b.getLineAtOffset(d),i,g,j,k,o,h;for(i=
e;i>=0;i--)if(g=b.getLine(i),j=i===e?c-b.getLineStart(e):g.length,k=g.lastIndexOf("/*",j),g=g.lastIndexOf("*/",j),g>k)break;else if(k!==-1){o=b.getLineStart(i)+k;break}for(i=f;i<b.getLineCount();i++)if(g=b.getLine(i),j=i===f?d-b.getLineStart(f):0,k=g.indexOf("/*",j),g=g.indexOf("*/",j),k!==-1&&k<g)break;else if(g!==-1){h=b.getLineStart(i)+g;break}return{commentStart:o,commentEnd:h}}this.textView.setAction("lineStart",function(){for(var a=this.editor,b=a.getModel(),c=a.getCaretOffset(),d=b.getLineAtOffset(c),
e=b.getLineStart(d),b=b.getLine(d),d=0;d<b.length;d++){var f=b.charCodeAt(d);if(!(f===32||f===9))break}d+=e;return c!==d?(a.setSelection(d,d),!0):!1}.bind(this));this.textView.setKeyBinding(new p.KeyBinding(191,!0),"toggleLineComment");this.textView.setAction("toggleLineComment",function(){if(this.textView.getOptions("readonly"))return!1;for(var a=this.editor,b=a.getModel(),c=a.getSelection(),d=b.getLineAtOffset(c.start),e=b.getLineAtOffset(c.end>c.start?c.end-1:c.end),f=!0,i=[],g,j,k=d;k<=e;k++)if(g=
b.getLine(k,!0),i.push(g),!f||(j=g.indexOf("//"))===-1)f=!1;else if(j!==0){var o;for(o=0;o<j;o++)if(f=g.charCodeAt(o),!(f===32||f===9))break;f=o===j}k=b.getLineStart(d);o=b.getLineEnd(e,!0);if(f){for(f=0;f<i.length;f++)g=i[f],j=g.indexOf("//"),i[f]=g.substring(0,j)+g.substring(j+2);i=i.join("");g=b.getLineStart(e);b=k===c.start?c.start:c.start-2;c=c.end-2*(e-d+1)+(c.end===g+1?2:0)}else i.splice(0,0,""),i=i.join("//"),b=k===c.start?c.start:c.start+2,c=c.end+2*(e-d+1);a.setText(i,k,o);a.setSelection(b,
c);return!0}.bind(this),{name:s.toggleLineComment});this.textView.setKeyBinding(new p.KeyBinding(191,!0,!e.isMac,!1,e.isMac),"addBlockComment");this.textView.setAction("addBlockComment",function(){if(this.textView.getOptions("readonly"))return!1;var b=this.editor,c=b.getModel(),d=b.getSelection(),e=RegExp("/\\*|\\*/","g"),f=a(c,d.start,d.end);if(f.commentStart!==void 0&&f.commentEnd!==void 0)return!0;c=c.getText(d.start,d.end);if(c.length===0)return!0;f=c.length;c=c.replace(e,"");e=c.length;b.setText("/*"+
c+"*/",d.start,d.end);b.setSelection(d.start+2,d.end+2+(e-f));return!0}.bind(this),{name:s.addBlockComment});this.textView.setKeyBinding(new p.KeyBinding(220,!0,!e.isMac,!1,e.isMac),"removeBlockComment");this.textView.setAction("removeBlockComment",function(){if(this.textView.getOptions("readonly"))return!1;var b=this.editor,c=b.getModel(),d=b.getSelection(),e=c.getText(d.start,d.end),f,i,g;for(g=0;g<e.length;g++)if(e.substring(g,g+2)==="/*"){f=d.start+g;break}for(;g<e.length;g++)if(e.substring(g,
g+2)==="*/"){i=d.start+g;break}if(f!==void 0&&i!==void 0)b.setText(c.getText(f+2,i),f,i+2),b.setSelection(f,i);else{e=a(c,d.start,d.end);if(e.commentStart===void 0||e.commentEnd===void 0)return!0;c=c.getText(e.commentStart+2,e.commentEnd);b.setText(c,e.commentStart,e.commentEnd+2);b.setSelection(d.start-2,d.end-2)}return!0}.bind(this),{name:s.removeBlockComment})},contentAssistProposalApplied:function(a){a=a.data.proposal;if(a.positions&&this.linkedMode){for(var b=[],c=0;c<a.positions.length;++c)b[c]=
{positions:[{offset:a.positions[c].offset,length:a.positions[c].length}]};this.linkedMode.enterLinkedMode({groups:b,escapePosition:a.escapePosition})}else a.escapePosition&&this.textView.setCaretOffset(a.escapePosition);return!0},cancel:function(){return!1},isActive:function(){return!0},isStatusActive:function(){return!1},lineUp:function(){return!1},lineDown:function(){return!1},enter:function(){if(this.textView.getOptions("readonly"))return!1;var a=this.editor,b=a.getSelection();if(b.start===b.end){for(var c=
a.getModel(),d=c.getLineAtOffset(b.start),e=c.getLine(d,!0),f=c.getLineStart(d),d=0,f=b.start-f,i;d<f&&((i=e.charCodeAt(d))===32||i===9);)d++;if(d>0){for(var g=e.substring(0,d),d=f;d<e.length&&((i=e.charCodeAt(d++))===32||i===9);)b.end++;a.setText(c.getLineDelimiter()+g,b.start,b.end);return!0}}return!1},tab:function(){return!1}};j.prototype={enterLinkedMode:function(a){if(!this.linkedModeActive){this.linkedModeActive=!0;this.linkedModePositions=[];for(var b=0;b<a.groups.length;++b){var c=a.groups[b];
this.linkedModePositions[b]={offset:c.positions[0].offset,length:c.positions[0].length}}this.linkedModeEscapePosition=a.escapePosition;this.linkedModeCurrentPositionIndex=0;this.selectTextForLinkedModePosition(this.linkedModePositions[this.linkedModeCurrentPositionIndex]);this.textView.addEventListener("Verify",this.linkedModeListener.onVerify);this.textView.setKeyBinding(new p.KeyBinding(9),"nextLinkedModePosition");this.textView.setAction("nextLinkedModePosition",function(){this.linkedModeCurrentPositionIndex=
++this.linkedModeCurrentPositionIndex%this.linkedModePositions.length;this.selectTextForLinkedModePosition(this.linkedModePositions[this.linkedModeCurrentPositionIndex]);return!0}.bind(this));this.textView.setKeyBinding(new p.KeyBinding(9,!1,!0),"previousLinkedModePosition");this.textView.setAction("previousLinkedModePosition",function(){this.linkedModeCurrentPositionIndex=this.linkedModeCurrentPositionIndex>0?this.linkedModeCurrentPositionIndex-1:this.linkedModePositions.length-1;this.selectTextForLinkedModePosition(this.linkedModePositions[this.linkedModeCurrentPositionIndex]);
return!0}.bind(this));this.editor.reportStatus(s.linkedModeEntered,null,!0)}},isActive:function(){return this.linkedModeActive},isStatusActive:function(){return this.linkedModeActive},enter:function(){this.cancel();return!0},cancel:function(a){if(this.linkedModeActive)this.linkedModeActive=!1,this.textView.removeEventListener("Verify",this.linkedModeListener.onVerify),this.textView.setKeyBinding(new p.KeyBinding(9),"tab"),this.textView.setKeyBinding(new p.KeyBinding(9,!1,!0),"shiftTab"),a||this.textView.setCaretOffset(this.linkedModeEscapePosition,
!1),this.editor.reportStatus(s.linkedModeExited,null,!0)},lineUp:function(){this.cancel(!0);return!1},lineDown:function(){this.cancel(!0);return!1},selectTextForLinkedModePosition:function(a){this.textView.setSelection(a.offset,a.offset+a.length)}};return{UndoFactory:a,LineNumberRulerFactory:b,FoldingRulerFactory:d,AnnotationFactory:i,TextDNDFactory:g,TextActions:o,SourceCodeActions:c,LinkedMode:j}});
(function(s,r){typeof define==="function"&&define.amd?define("orion/Deferred",r):typeof exports==="object"?module.exports=r():(s.orion=s.orion||{},s.orion.Deferred=r())})(this,function(){function s(){for(var a;a=k.shift()||m.shift();)a();e=!1}function r(a,b){(b?m:k).push(a);e||(e=!0,b?setTimeout(s,0):s())}function p(a){return function(){a.apply(null,arguments)}}function f(){}function h(){var a=Error("Cancel");a.name="Cancel";return a}function l(){function a(){for(var a;a=e.shift();){var c=a.deferred,
g=d==="resolved"?"resolve":"reject";if(typeof a[g]==="function")try{var k=a[g](b);k&&typeof k.then==="function"?(c.cancel=k.cancel||f,k.then(p(c.resolve),p(c.reject),c.progress)):c.resolve(k)}catch(h){c.reject(h)}else c[g](b)}}var b,d,e=[],g=this;this.reject=function(f){d||(d="rejected",b=f,e.length&&r(a));return g.promise};this.resolve=function(f){d||(d="resolved",b=f,e.length&&r(a));return g.promise};this.progress=function(a){d||e.forEach(function(b){b.progress&&b.progress(a)});return g.promise};
this.cancel=function(){d||g.reject(h())};this.then=function(b,c,f){var b={resolve:b,reject:c,progress:f,deferred:new l},g=b.deferred,k=this.cancel.bind(this),h=function(){r(function(){(g.cancel===h?k:g.cancel)()},!0)};g.cancel=h;c=g.promise;c.cancel=function(){g.cancel()};e.push(b);d&&r(a,!0);return c};this.promise={then:this.then,cancel:this.cancel}}var k=[],m=[],e=!1;l.all=function(a,b){function d(a,b){c||(k[a]=b,--f===0&&j.resolve(k))}function e(a,f){if(!c){if(b)try{d(a,b(f));return}catch(i){f=
i}j.reject(f)}}var f=a.length,k=[],c=!1,j=new l;j.then(null,function(){c=!0;a.forEach(function(a){a.cancel&&a.cancel()})});f===0?j.resolve(k):a.forEach(function(a,b){a.then(d.bind(null,b),e.bind(null,b))});return j.promise};l.when=function(a,b,d,e){var f;if(!(a&&typeof a.then==="function"))f=new l,f.resolve(a),a=f.promise;return a.then(b,d,e)};return l});
define("orion/editor/contentAssist",["i18n!orion/editor/nls/messages","orion/editor/keyBinding","orion/editor/eventTarget","orion/Deferred","orion/editor/util"],function(s,r,p,f,h){var l,k,m;function e(a){this.textView=a;this.state=l;this.providers=[];var b=this;this.contentAssistListener={onModelChanging:function(a){b.isDeactivatingChange(a)?b.setState(l):b.state===k&&b.setState(m)},onScroll:function(){b.setState(l)},onSelection:function(){var a=b.state;if(a===k||a===m)b.computeProposals(),b.setState(m)}};
a.setKeyBinding(h.isMac?new r.KeyBinding(" ",!1,!1,!1,!0):new r.KeyBinding(" ",!0),"contentAssist");a.setAction("contentAssist",function(){b.activate();return!0},{name:s.contentAssist})}function a(a,b){this.contentAssist=a;this.widget=b;this.proposals=[];var d=this;this.contentAssist.addEventListener("ProposalsComputed",function(a){d.proposals=a.data.proposals;d.selectedIndex=d.proposals.length?0:-1})}function b(a,b){this.contentAssist=a;this.textView=this.contentAssist.getTextView();this.isShowing=
this.textViewListenerAdded=!1;var d=this.textView.getOptions("parent").ownerDocument;this.parentNode=typeof b==="string"?d.getElementById(b):b;if(!this.parentNode){this.parentNode=h.createElement(d,"div");this.parentNode.className="contentassist";var c=d.getElementsByTagName("body")[0];if(c)c.appendChild(this.parentNode);else throw Error("parentNode is required");}var e=this;this.textViewListener={onMouseDown:function(a){a.event.target.parentElement!==e.parentNode&&e.contentAssist.deactivate()}};
this.contentAssist.addEventListener("ProposalsComputed",function(a){e.setProposals(a.data.proposals);e.show();if(!e.textViewListenerAdded)e.textView.addEventListener("MouseDown",e.textViewListener.onMouseDown),e.textViewListenerAdded=!0});this.contentAssist.addEventListener("Deactivating",function(){e.setProposals([]);e.hide();if(e.textViewListenerAdded)e.textView.removeEventListener("MouseDown",e.textViewListener.onMouseDown),e.textViewListenerAdded=!1;e.textViewListenerAdded=!1});this.scrollListener=
function(){e.isShowing&&e.position()};d.addEventListener("scroll",this.scrollListener)}l=1;k=2;m=3;var d={selected:" selected",hr:"proposal-hr",emphasis:"proposal-emphasis",noemphasis:"proposal-noemphasis",dfault:"proposal-default"};e.prototype={apply:function(a){if(!a)return!1;var b=this.textView.getCaretOffset(),d={proposal:a,start:b,end:b};this.setState(l);this.textView.setText(a.proposal||a,b,b);this.dispatchEvent({type:"ProposalApplied",data:d});return!0},activate:function(){this.state===l&&
this.setState(k)},deactivate:function(){this.setState(l)},getTextView:function(){return this.textView},isActive:function(){return this.state===k||this.state===m},isDeactivatingChange:function(a){var b=a.removedCharCount>0&&a.addedCharCount===0,d=this.textView,d=a.start+1<=d.getModel().getCharCount()&&/^\s*$/.test(d.getText(a.start,a.start+1));return a.removedLineCount>0||a.addedLineCount>0||b&&d},setState:function(a){var b;a===k?b="Activating":a===l&&(b="Deactivating");b&&this.dispatchEvent({type:b});
this.state=a;this.onStateChange(a)},onStateChange:function(a){if(a===l){if(this.listenerAdded)this.textView.removeEventListener("ModelChanging",this.contentAssistListener.onModelChanging),this.textView.removeEventListener("Scroll",this.contentAssistListener.onScroll),this.textView.removeEventListener("Selection",this.contentAssistListener.onSelection),this.listenerAdded=!1}else if(a===k){if(!this.listenerAdded)this.textView.addEventListener("ModelChanging",this.contentAssistListener.onModelChanging),
this.textView.addEventListener("Scroll",this.contentAssistListener.onScroll),this.textView.addEventListener("Selection",this.contentAssistListener.onSelection),this.listenerAdded=!0;this.computeProposals()}},computeProposals:function(){var a=this;this._computeProposals(this.textView.getCaretOffset()).then(function(b){a.dispatchEvent({type:"ProposalsComputed",data:{proposals:b}})})},getPrefixStart:function(a){for(;a>0&&/[A-Za-z0-9_]/.test(this.textView.getText(a-1,a));)a--;return a},handleError:function(a){typeof console!==
"undefined"&&(console.log("Error retrieving content assist proposals"),console.log(a))},_computeProposals:function(a){var b=this.providers,d=this.textView,c=d.getModel(),e=d.getText(),k={line:c.getLine(c.getLineAtOffset(a)),prefix:d.getText(this.getPrefixStart(a),a),selection:d.getSelection()},h=this,b=b.map(function(b){var c=b.computeProposals||b.getProposals,d;try{typeof c==="function"&&(d=h.progress?h.progress.progress(c.apply(b,[e,a,k]),"Generating content assist proposal"):c.apply(b,[e,a,k]))}catch(g){h.handleError(g)}return f.when(d)});
return f.all(b,this.handleError).then(function(a){return a.reduce(function(a,b){return b instanceof Array?a.concat(b):a},[])})},setProviders:function(a){this.providers=a.slice(0)},setProgress:function(a){this.progress=a}};p.EventTarget.addMixin(e.prototype);a.prototype={cancel:function(){this.getContentAssist().deactivate()},getContentAssist:function(){return this.contentAssist},isActive:function(){return this.getContentAssist().isActive()},lineUp:function(){for(var a=this.selectedIndex===0?this.proposals.length-
1:this.selectedIndex-1;this.proposals[a].unselectable&&a>0;)a--;this.selectedIndex=a;this.widget&&this.widget.setSelectedIndex(this.selectedIndex);return!0},lineDown:function(){for(var a=this.selectedIndex===this.proposals.length-1?0:this.selectedIndex+1;this.proposals[a].unselectable&&a<this.proposals.length-1;)a++;this.selectedIndex=a;this.widget&&this.widget.setSelectedIndex(this.selectedIndex);return!0},enter:function(){return this.contentAssist.apply(this.proposals[this.selectedIndex]||null)},
tab:function(){return this.widget?(this.widget.createAccessible(this),this.widget.parentNode.focus(),!0):!1}};b.prototype={onClick:function(a){this.contentAssist.apply(this.getProposal(a.target));this.textView.focus()},createDiv:function(a,b,d,c){var e=d.ownerDocument,f=h.createElement(e,"div");f.id="contentoption"+c;f.setAttribute("role","option");a.style==="hr"?a=h.createElement(e,"hr"):(f.className=this.calculateClasses(a.style,b),a=e.createTextNode(this.getDisplayString(a)),b&&this.parentNode.setAttribute("aria-activedescendant",
f.id));f.appendChild(a,f);d.appendChild(f)},createAccessible:function(a){this._isAccessible||this.parentNode.addEventListener("keydown",function(b){b.preventDefault();if(b.keyCode===27)return a.cancel();else if(b.keyCode===38)return a.lineUp();else if(b.keyCode===40)return a.lineDown();else if(b.keyCode===13)return a.enter();return!1});this._isAccessible=!0},calculateClasses:function(a,b){var e=d[a];if(!e)e=d.dfault;return b?e+d.selected:e},getDisplayString:function(a){return typeof a==="string"?
a:a.description&&typeof a.description==="string"?a.description:a.proposal},getProposal:function(a){for(var b=0,d=this.parentNode.firstChild;d!==null;d=d.nextSibling){if(d===a)return this.proposals[b]||null;b++}return null},setSelectedIndex:function(a){this.selectedIndex=a;this.selectNode(this.parentNode.childNodes[this.selectedIndex])},selectNode:function(a){for(var b=this.parentNode.childNodes,e=0;e<b.length;e++){var c=b[e],f=c.className.indexOf(d.selected);if(f>=0)c.className=c.className.substring(0,
f)+c.className.substring(f+d.selected.length);c===a&&(c.className+=d.selected,this.parentNode.setAttribute("aria-activedescendant",c.id),c.focus(),c.offsetTop<this.parentNode.scrollTop?c.scrollIntoView(!0):c.offsetTop+c.offsetHeight>this.parentNode.scrollTop+this.parentNode.clientHeight&&c.scrollIntoView(!1))}},setProposals:function(a){this.proposals=a},show:function(){if(this.proposals.length===0)this.hide();else{this.parentNode.innerHTML="";for(var a=0;a<this.proposals.length;a++)this.createDiv(this.proposals[a],
a===0,this.parentNode,a);this.position();this.parentNode.onclick=this.onClick.bind(this);this.isShowing=!0}},hide:function(){this.parentNode.ownerDocument.activeElement===this.parentNode&&this.textView.focus();this.parentNode.style.display="none";this.parentNode.onclick=null;this.isShowing=!1},position:function(){var a=this.textView.getLocationAtOffset(this.textView.getCaretOffset());a.y+=this.textView.getLineHeight();this.textView.convert(a,"document","page");this.parentNode.style.position="fixed";
this.parentNode.style.left=a.x+"px";this.parentNode.style.top=a.y+"px";this.parentNode.style.display="block";this.parentNode.scrollTop=0;var b=this.parentNode.ownerDocument,d=b.documentElement.clientWidth;if(a.y+this.parentNode.offsetHeight>b.documentElement.clientHeight)this.parentNode.style.top=a.y-this.parentNode.offsetHeight-this.textView.getLineHeight()+"px";if(a.x+this.parentNode.offsetWidth>d)this.parentNode.style.left=d-this.parentNode.offsetWidth+"px"}};return{ContentAssist:e,ContentAssistMode:a,
ContentAssistWidget:b}});
define("orion/editor/cssContentAssist",[],function(){function s(){}var r="alignment-adjust,alignment-baseline,animation,animation-delay,animation-direction,animation-duration,animation-iteration-count,animation-name,animation-play-state,animation-timing-function,appearance,azimuth,backface-visibility,background,background-attachment,background-clip,background-color,background-image,background-origin,background-position,background-repeat,background-size,baseline-shift,binding,bleed,bookmark-label,bookmark-level,bookmark-state,bookmark-target,border,border-bottom,border-bottom-color,border-bottom-left-radius,border-bottom-right-radius,border-bottom-style,border-bottom-width,border-collapse,border-color,border-image,border-image-outset,border-image-repeat,border-image-slice,border-image-source,border-image-width,border-left,border-left-color,border-left-style,border-left-width,border-radius,border-right,border-right-color,border-right-style,border-right-width,border-spacing,border-style,border-top,border-top-color,border-top-left-radius,border-top-right-radius,border-top-style,border-top-width,border-width,bottom,box-align,box-decoration-break,box-direction,box-flex,box-flex-group,box-lines,box-ordinal-group,box-orient,box-pack,box-shadow,box-sizing,break-after,break-before,break-inside,caption-side,clear,clip,color,color-profile,column-count,column-fill,column-gap,column-rule,column-rule-color,column-rule-style,column-rule-width,column-span,column-width,columns,content,counter-increment,counter-reset,crop,cue,cue-after,cue-before,cursor,direction,display,dominant-baseline,drop-initial-after-adjust,drop-initial-after-align,drop-initial-before-adjust,drop-initial-before-align,drop-initial-size,drop-initial-value,elevation,empty-cells,fit,fit-position,flex-align,flex-flow,flex-inline-pack,flex-order,flex-pack,float,float-offset,font,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,grid-columns,grid-rows,hanging-punctuation,height,hyphenate-after,hyphenate-before,hyphenate-character,hyphenate-lines,hyphenate-resource,hyphens,icon,image-orientation,image-rendering,image-resolution,inline-box-align,left,letter-spacing,line-height,line-stacking,line-stacking-ruby,line-stacking-shift,line-stacking-strategy,list-style,list-style-image,list-style-position,list-style-type,margin,margin-bottom,margin-left,margin-right,margin-top,mark,mark-after,mark-before,marker-offset,marks,marquee-direction,marquee-loop,marquee-play-count,marquee-speed,marquee-style,max-height,max-width,min-height,min-width,move-to,nav-down,nav-index,nav-left,nav-right,nav-up,opacity,orphans,outline,outline-color,outline-offset,outline-style,outline-width,overflow,overflow-style,overflow-x,overflow-y,padding,padding-bottom,padding-left,padding-right,padding-top,page,page-break-after,page-break-before,page-break-inside,page-policy,pause,pause-after,pause-before,perspective,perspective-origin,phonemes,pitch,pitch-range,play-during,position,presentation-level,punctuation-trim,quotes,rendering-intent,resize,rest,rest-after,rest-before,richness,right,rotation,rotation-point,ruby-align,ruby-overhang,ruby-position,ruby-span,size,speak,speak-header,speak-numeral,speak-punctuation,speech-rate,stress,string-set,table-layout,target,target-name,target-new,target-position,text-align,text-align-last,text-decoration,text-emphasis,text-height,text-indent,text-justify,text-outline,text-shadow,text-transform,text-wrap,top,transform,transform-origin,transform-style,transition,transition-delay,transition-duration,transition-property,transition-timing-function,unicode-bidi,vertical-align,visibility,voice-balance,voice-duration,voice-family,voice-pitch,voice-pitch-range,voice-rate,voice-stress,voice-volume,volume,white-space,white-space-collapse,widows,width,word-break,word-spacing,word-wrap,z-index".split(",");s.prototype=
{computeProposals:function(p,f){var h;for(h=f;h&&/[A-Za-z\-]/.test(p.charAt(h-1));)h--;h=h?p.substring(h,f):"";for(var l=[],k=0;k<r.length;k++){var m=r[k];m.indexOf(h)===0&&l.push({proposal:m.substring(h.length),description:m})}return l}};return{CssContentAssistProvider:s}});
define("orion/editor/htmlContentAssist",[],function(){function s(){}s.prototype={leadingWhitespace:function(r,p){var f="";for(p-=1;p>0;){var h=r.charAt(p--);if(h==="\n"||h==="\r")break;f=/\s/.test(h)?h.concat(f):""}return f},computeProposals:function(r,p,f){function h(a){return a.substring(f.prefix.length)}var l=[];if(r.length===0)return l.push({proposal:'<!DOCTYPE html>\n<html lang="en">\n\t<head>\n\t\t<meta charset=utf-8>\n\t\t<title>My Document</title>\n\t</head>\n\t<body>\n\t\t<h1>A basic HTML document</h1>\n\t\t<p>\n\t\t\t\n\t\t</p>\n\t</body>\n</html>',
description:"Simple HTML document",escapePosition:p+152}),l;var k=f.prefix;if(r.charAt(p-k.length-1)!=="<")return l;for(var m,e,a="abbr,b,button,canvas,cite,command,dd,del,dfn,dt,em,embed,font,h1,h2,h3,h4,h5,h6,i,ins,kbd,label,li,mark,meter,object,option,output,progress,q,rp,rt,samp,small,strong,sub,sup,td,time,title,tt,u,var".split(","),b=0;b<a.length;b++)m=a[b],m.indexOf(k)===0&&(e=m+"></"+m+">",m=p+m.length-k.length+1,l.push({proposal:h(e),description:"<"+e,escapePosition:m}));a="address,article,aside,audio,bdo,blockquote,body,caption,code,colgroup,datalist,details,div,fieldset,figure,footer,form,head,header,hgroup,iframe,legend,map,menu,nav,noframes,noscript,optgroup,p,pre,ruby,script,section,select,span,style,tbody,textarea,tfoot,th,thead,tr,video".split(",");
r=this.leadingWhitespace(r,p);for(b=0;b<a.length;b++)m=a[b],m.indexOf(k)===0&&(e=m+">\n"+r+"\t\n"+r+"</"+m+">",m=p+m.length-k.length+r.length+3,l.push({proposal:h(e),description:"<"+e,escapePosition:m}));a="area,base,br,col,hr,input,link,meta,param,keygen,source".split(",");for(b=0;b<a.length;b++)m=a[b],m.indexOf(k)===0&&(e=m+"/>",m=p+m.length-k.length+2,l.push({proposal:h(e),description:"<"+e,escapePosition:m}));"img".indexOf(k)===0&&(e='img src="" alt="Image"/>',l.push({proposal:h(e),description:"<"+
e,escapePosition:p+9-k.length}));k==="a"&&l.push({proposal:h('a href=""></a>'),description:"<a></a> - HTML anchor element",escapePosition:p+7});"ul".indexOf(k)===0&&(e="<ul> - unordered list",m=p-k.length+r.length+9,l.push({proposal:h("ul>\n"+r+"\t<li></li>\n"+r+"</ul>"),description:e,escapePosition:m}));"ol".indexOf(k)===0&&(e="<ol> - ordered list",m=p-k.length+r.length+9,l.push({proposal:h("ol>\n"+r+"\t<li></li>\n"+r+"</ol>"),description:e,escapePosition:m}));"dl".indexOf(k)===0&&(e="<dl> - definition list",
m=p-k.length+r.length+9,l.push({proposal:h("dl>\n"+r+"\t<dt></dt>\n"+r+"\t<dd></dd>\n"+r+"</dl>"),description:e,escapePosition:m}));"table".indexOf(k)===0&&(e="<table> - basic HTML table",m=p-k.length+r.length*2+19,l.push({proposal:h("table>\n"+r+"\t<tr>\n"+r+"\t\t<td></td>\n"+r+"\t</tr>\n"+r+"</table>"),description:e,escapePosition:m}));return l}};return{HTMLContentAssistProvider:s}});
define("orion/editor/jsTemplateContentAssist",[],function(){function s(f,l,k){var m=k-f.length,e=[],a="";for(k-=1;k>0;){var b=l.charAt(k--);if(b==="\n"||b==="\r")break;a=/\s/.test(b)?b.concat(a):""}l=a;"if".indexOf(f)===0&&(k="if - if statement",a=[{offset:m+4,length:9}],b=m+l.length+18,e.push({proposal:("if (condition) {\n"+l+"\t\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}),k="if - if else statement",a=[{offset:m+4,length:9}],b=m+l.length+18,e.push({proposal:("if (condition) {\n"+
l+"\t\n"+l+"} else {\n"+l+"\t\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}));"for".indexOf(f)===0&&(k="for - iterate over array",a=[{offset:m+9,length:1},{offset:m+20,length:5}],b=m+l.length+42,e.push({proposal:("for (var i = 0; i < array.length; i++) {\n"+l+"\t\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}),k="for..in - iterate over properties of an object",a=[{offset:m+9,length:8},{offset:m+21,length:6}],b=m+2*l.length+73,e.push({proposal:("for (var property in object) {\n"+
l+"\tif (object.hasOwnProperty(property)) {\n"+l+"\t\t\n"+l+"\t}\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}));"while".indexOf(f)===0&&(k="while - while loop with condition",a=[{offset:m+7,length:9}],b=m+l.length+21,e.push({proposal:("while (condition) {\n"+l+"\t\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}));"do".indexOf(f)===0&&(k="do - do while loop with condition",a=[{offset:m+16,length:9}],b=m+l.length+6,e.push({proposal:("do {\n"+l+
"\t\n"+l+"} while (condition);").substring(f.length),description:k,positions:a,escapePosition:b}));"switch".indexOf(f)===0&&(k="switch - switch case statement",a=[{offset:m+8,length:10},{offset:m+28,length:6}],b=m+2*l.length+38,e.push({proposal:("switch (expression) {\n"+l+"\tcase value1:\n"+l+"\t\t\n"+l+"\t\tbreak;\n"+l+"\tdefault:\n"+l+"}").substring(f.length),description:k,positions:a,escapePosition:b}));"try".indexOf(f)===0&&(k="try - try..catch statement",b=m+l.length+7,e.push({proposal:("try {\n"+
l+"\t\n"+l+"} catch (err) {\n"+l+"}").substring(f.length),description:k,escapePosition:b}),k="try - try..catch statement with finally block",b=m+l.length+7,e.push({proposal:("try {\n"+l+"\t\n"+l+"} catch (err) {\n"+l+"} finally {\n"+l+"}").substring(f.length),description:k,escapePosition:b}));return e}function r(f){for(var l="break,case,catch,continue,debugger,default,delete,do,else,finally,for,function,if,in,instanceof,new,return,switch,this,throw,try,typeof,var,void,while,with".split(","),k=[],
m=0;m<l.length;m++)l[m].indexOf(f)===0&&k.push({proposal:l[m].substring(f.length),description:l[m]});return k}function p(){}var f={":":":","!":"!","@":"@","#":"#",$:"$","^":"^","&":"&","*":"*",".":".","?":"?","<":"<",">":">"};p.prototype={computeProposals:function(h,l,k){for(var k=k.prefix,m=[],e=l-k.length-1,a="";e>=0;)if(a=h[e],a==="\n"||a==="\r")break;else if(/\s/.test(a))e--;else break;if(f[a])return m;m=m.concat(s(k,h,l));return m=m.concat(r(k,h,l))}};return{JSTemplateContentAssistProvider:p}});
define("orion/editor/AsyncStyler",["i18n!orion/editor/nls/messages","orion/editor/annotations"],function(s,r){function p(f){return f.getProperty("objectClass").indexOf(h)!==-1&&f.getProperty("type")==="highlighter"}function f(f,h,e){this.initialize(f,h,e);this.lineStyles=[]}var h="orion.edit.highlighter",l=h+" service must be an event emitter";r.AnnotationType.registerType("orion.annotation.highlightError",{title:s.syntaxError,html:"<div class='annotationHTML error'></div>",rangeStyle:{styleClass:"annotationRange error"}});
f.prototype={initialize:function(f,l,e){this.textView=f;this.serviceRegistry=l;this.annotationModel=e;this.services=[];var a=this;this.listener={onModelChanging:function(b){a.onModelChanging(b)},onModelChanged:function(b){a.onModelChanged(b)},onDestroy:function(b){a.onDestroy(b)},onLineStyle:function(b){a.onLineStyle(b)},onStyleReady:function(b){a.onStyleReady(b)},onServiceAdded:function(b){a.onServiceAdded(b.serviceReference,a.serviceRegistry.getService(b.serviceReference))},onServiceRemoved:function(b){a.onServiceRemoved(b.serviceReference,
a.serviceRegistry.getService(b.serviceReference))}};f.addEventListener("ModelChanging",this.listener.onModelChanging);f.addEventListener("ModelChanged",this.listener.onModelChanged);f.addEventListener("Destroy",this.listener.onDestroy);f.addEventListener("LineStyle",this.listener.onLineStyle);l.addEventListener("registered",this.listener.onServiceAdded);l.addEventListener("unregistering",this.listener.onServiceRemoved);f=l.getServiceReferences(h);for(e=0;e<f.length;e++){var b=f[e];p(b)&&this.addServiceListener(l.getService(b))}},
onDestroy:function(){this.destroy()},destroy:function(){if(this.textView)this.textView.removeEventListener("ModelChanging",this.listener.onModelChanging),this.textView.removeEventListener("ModelChanged",this.listener.onModelChanged),this.textView.removeEventListener("Destroy",this.listener.onDestroy),this.textView.removeEventListener("LineStyle",this.listener.onLineStyle),this.textView=null;if(this.services){for(var f=0;f<this.services.length;f++)this.removeServiceListener(this.services[f]);this.services=
null}if(this.serviceRegistry)this.serviceRegistry.removeEventListener("registered",this.listener.onServiceAdded),this.serviceRegistry.removeEventListener("unregistering",this.listener.onServiceRemoved),this.serviceRegistry=null;this.lineStyles=this.listener=null},onModelChanging:function(f){this.startLine=this.textView.getModel().getLineAtOffset(f.start)},onModelChanged:function(f){var h=this.startLine;(f.addedLineCount||f.removedLineCount)&&Array.prototype.splice.apply(this.lineStyles,[h,f.removedLineCount].concat(this._getEmptyStyle(f.addedLineCount)))},
onStyleReady:function(f){var h=f.lineStyles||f.style,f=Number.MAX_VALUE,e=-1,a=this.textView.getModel(),b;for(b in h)h.hasOwnProperty(b)&&(this.lineStyles[b]=h[b],f=Math.min(f,b),e=Math.max(e,b));f=Math.max(f,0);e=Math.min(e,a.getLineCount());if(h=this.annotationModel){for(var d=h.getAnnotations(a.getLineStart(f),a.getLineEnd(e)),i=[];d.hasNext();){var g=d.next();g.type==="orion.annotation.highlightError"&&i.push(g)}d=[];for(g=f;g<=e;g++){b=g;var l=this.lineStyles[b],l=l&&l.errors;b=a.getLineStart(b);
if(l)for(var c=0;c<l.length;c++){var j=l[c];d.push(r.AnnotationType.createAnnotation("orion.annotation.highlightError",j.start+b,j.end+b))}}h.replaceAnnotations(i,d)}this.textView.redrawLines(f,e+1)},onLineStyle:function(f){function h(a,b){for(var d=a.length,e=[],f=0;f<d;f++){var k=a[f];e.push({start:k.start+b,end:k.end+b,style:k.style})}return e}var e=this.lineStyles[f.lineIndex];if(e)if(e.ranges)f.ranges=h(e.ranges,f.lineStart);else if(e.style)f.style=e.style},_getEmptyStyle:function(f){for(var h=
[],e=0;e<f;e++)h.push(null);return h},setContentType:function(f){this.contentType=f;if(this.services)for(f=0;f<this.services.length;f++){var h=this.services[f];if(h.setContentType){var e=this.serviceRegistry.getService("orion.page.progress");e?e.progress(h.setContentType(this.contentType),"Styling content type: "+this.contentType.id?this.contentType.id:this.contentType):h.setContentType(this.contentType)}}},onServiceAdded:function(f,h){p(f)&&this.addServiceListener(h)},onServiceRemoved:function(f,
h){this.services.indexOf(h)!==-1&&this.removeServiceListener(h)},addServiceListener:function(f){if(typeof f.addEventListener==="function"){if(f.addEventListener("orion.edit.highlighter.styleReady",this.listener.onStyleReady),this.services.push(f),f.setContentType&&this.contentType){var h=this.serviceRegistry.getService("orion.page.progress");h?h.progress(f.setContentType(this.contentType),"Styling content type: "+this.contentType.id?this.contentType.id:this.contentType):f.setContentType(this.contentType)}}else typeof console!==
"undefined"&&console.log(Error(l))},removeServiceListener:function(f){typeof f.removeEventListener==="function"?(f.removeEventListener("orion.edit.highlighter.styleReady",this.listener.onStyleReady),f=this.services.indexOf(f),f!==-1&&this.services.splice(f,1)):typeof console!=="undefined"&&console.log(Error(l))}};return f});
define("orion/editor/mirror",["i18n!orion/editor/nls/messages","orion/editor/eventTarget","orion/editor/annotations"],function(s,r,p){function f(e){this.string=e;this.tokenStart=this.pos=0}function h(){this._modes={};this.mimeModes={};this.options={};this.StringStream=f}function l(e){var a=[],b;for(b in e)Object.prototype.hasOwnProperty.call(e,b)&&a.push(b);return a}function k(e,a,b){b=b||{};this.model=e;this.codeMirror=a;this.isWhitespaceVisible=typeof b.whitespacesVisible==="undefined"?!1:b.whitespacesVisible;
this.mode=null;this.isModeLoaded=!1;this.lines=[];this.dirtyLines=[];this.startLine=Number.MAX_VALUE;this.endLine=-1;this.timer=null;this.initialize(e)}function m(e,a,b){this.init(e,a,b)}f.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos===0},peek:function(){return this.string[this.pos]},next:function(){return this.string[this.pos++]},eat:function(e){var a=this.string[this.pos];return typeof a==="string"&&(a===e||e.test&&e.test(a)||typeof e==="function"&&
e(a))?this.string[this.pos++]:void 0},eatWhile:function(e){for(var a=!1;this.eat(e)!==void 0;)a=!0;return a},eatSpace:function(){return this.eatWhile(/\s/)},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){e=this.string.indexOf(e,this.pos);return e!==-1?(this.pos=e,!0):!1},match:function(e,a,b){a=a===!0||typeof a==="undefined";if(typeof e==="string"){var d=b?this.string.toLowerCase():this.string,e=b?e.toLowerCase():e,b=d.indexOf(e,this.pos);if(b!==-1&&a)this.pos=b+e.length;return b!==
-1}else return(e=this.string.substring(this.pos).match(e))&&a&&typeof e[0]==="string"&&(this.pos+=e.index+e[0].length),e},backUp:function(e){this.pos-=e},column:function(){for(var e=0,a=0;a<this.tokenStart;)e+=this.string[a++]==="\t"?4:1;return e},indentation:function(){for(var e=this.string.search(/\S/),a=0,b=0;b<e;)a+=this.string[b++]==="\t"?4:1;return a},current:function(){return this.string.substring(this.tokenStart,this.pos)},advance:function(){this.tokenStart=this.pos}};h.prototype={options:{},
setOption:function(e,a){this.options[e]=a},getOption:function(e){return this.options[e]},copyState:function(e,a){if(typeof e.copyState==="function")return e.copyState(a);var b={},d;for(d in a){var f=a[d];b[d]=f instanceof Array?f.slice():f}return b},defineMode:function(e,a){this._modes[e]=a},defineMIME:function(e,a){this.mimeModes[e]=a},getMode:function(e,a){var b={},d;typeof a==="string"&&this.mimeModes[a]&&(a=this.mimeModes[a]);typeof a==="object"&&(b=a,d=this._modes[a.name]);d=d||this._modes[a];
if(typeof d!=="function")throw"Mode not found "+a;return d(e,b)},listModes:function(){return l(this._modes)},listMIMEs:function(){return l(this.mimeModes)},_getModeName:function(e){e=this.mimeModes[e];if(typeof e==="object")e=e.name;return e}};k.prototype={initialize:function(){var e=this;this.listener={onModelChanging:function(a){e._onModelChanging(a)},onModelChanged:function(a){e._onModelChanged(a)},onDestroy:function(a){e._onDestroy(a)}};this.model.addEventListener("Changing",this.listener.onModelChanging);
this.model.addEventListener("Changed",this.listener.onModelChanged);this.model.addEventListener("Destroy",this.listener.onDestroy)},destroy:function(){this.model&&(this.model.removeEventListener("Changing",this.listener.onModelChanging),this.model.removeEventListener("Changed",this.listener.onModelChanged),this.model.removeEventListener("Destroy",this.listener.onDestroy));this.dirtyLines=this.lines=this.mode=this.codeMirror=this.model=null;clearTimeout(this.timer);this.timer=null},_onModelChanging:function(e){this.startLine=
this.model.getLineAtOffset(e.start)},_onModelChanged:function(e){this._dbgEvent(e);var a=this.startLine;(e.removedLineCount||e.addedLineCount)&&Array.prototype.splice.apply(this.lines,[a+1,e.removedLineCount].concat(this._newLines(e.addedLineCount)));this.mode&&(e=Math.max(e.addedLineCount,e.removedLineCount),e=a+Math.min(e,500),this.highlight(a,e),this.highlightLater(e+1))},_onDestroy:function(){this.destroy()},setViewportIndex:function(e){this.viewportIndex=e},_dbgEvent:function(){},_dbgStyle:function(){},
_newLines:function(e){for(var a=[],b=0;b<e;b++)a.push({style:null,eolState:null});return a},setMode:function(e,a){if(e)this.mode=this.codeMirror.getMode(this.codeMirror.options,e),this.lines=this._newLines(this.model.getLineCount()),a&&this.highlight()},highlight:function(e,a,b){if(this.mode){for(var d=this.model.getLineCount(),e=typeof e==="undefined"?0:e,a=typeof a==="undefined"?d-1:Math.min(a,d-1),d=this.mode,f=this.getState(e),g=e;g<=a;g++){var h=this.lines[g];this.highlightLine(g,h,f);h.eolState=
this.codeMirror.copyState(d,f)}this._expandRange(e,a);if(!b)this.onHighlightDone()}},highlightLater:function(e){this.dirtyLines.push(e);var a=this;this.timer=setTimeout(function(){a._highlightJob()},50)},_highlightJob:function(){for(var e=+new Date+30,a=this.mode.compareStates,b=this.model.getLineCount();this.dirtyLines.length;){var d=this.viewportIndex,f=this.lines[d],d=f&&!f.eolState?d:this.dirtyLines.pop();if(d>=b)break;this._expandRange(d,d);for(var f=this._getResumeLineIndex(d),d=f+1,f=(f=f>=
0&&this.lines[f].eolState)?this.codeMirror.copyState(this.mode,f):this.mode.startState(),g=0,h=d;h<b;h++){var c=this.lines[h],j=c.eolState,k=this.highlightLine(h,c,f);c.eolState=this.codeMirror.copyState(this.mode,f);k&&this._expandRange(d,h+1);var c=a&&j&&a(j,c.eolState),l=!a&&!k&&g++>3;if(c||l)break;else if(!j||k)g=0;j=h<b||this.dirtyLines.length;if(+new Date>e&&j){this.highlightLater(h+1);this.onHighlightDone();return}}}this.onHighlightDone()},onHighlightDone:function(){this.startLine!==Number.MAX_VALUE&&
this.endLine!==-1&&this.dispatchEvent({type:"Highlight",start:this.startLine,end:this.endLine});this.startLine=Number.MAX_VALUE;this.endLine=-1},_getResumeLineIndex:function(e){for(var a=this.lines,b=e-1;b>=0;b--)if(a[b].eolState||e-b>40)return b;return-1},getState:function(e){var a=this.mode,b=this.lines,d,f;for(d=e-1;d>=0;d--)if(f=b[d],f.eolState||e-d>40)break;var g=d>=0&&b[d].eolState;if(g){g=this.codeMirror.copyState(a,g);for(d=Math.max(0,d);d<e-1;d++)f=b[d],this.highlightLine(d,f,g),f.eolState=
this.codeMirror.copyState(a,g);return g}else return a.startState()},highlightLine:function(e,a,b){if(this.mode){var d=this.model;d.getLineStart(e)===d.getLineEnd(e)&&this.mode.blankLine&&this.mode.blankLine(b);for(var i=a.style||[],e=d.getLine(e),e=new f(e),d=!a.style,g=[],h=0;!e.eol();h++){var c=this.mode.token(e,b)||null,j=e.current();this._whitespaceStyle(c,j,e.tokenStart);c=[e.tokenStart,e.pos,c];j=i[h];g.push(c);d=d||!j||j[0]!==c[0]||j[1]!==c[1]||j[2]!==c[2];e.advance()}if(d=d||g.length!==i.length)a.style=
g.length?g:null;return d}},_whitespaceStyle:function(e,a,b){if(!e&&this.isWhitespaceVisible&&/\s+/.test(a)){for(var e=[],d,f,g=0;g<a.length;g++){var h=a[g];h!==f&&(f&&e.push([b+d,b+g,f==="\t"?"token_tab":"token_space"]),d=g,f=h)}e.push([b+d,b+g,f==="\t"?"token_tab":"token_space"]);return e}return null},_expandRange:function(e,a){this.startLine=Math.min(this.startLine,e);this.endLine=Math.max(this.endLine,a)},toStyleRangesAndErrors:function(e,a){var b=e.style;if(!b)return null;for(var d=[],f=[],g=
typeof a==="undefined"?0:this.model.getLineStart(a),h=0;h<b.length;h++){var c=b[h],j=!c[2]?null:c[2]==="token_tab"||c[2]==="token_space"?c[2]:"cm-"+c[2];j&&(c={start:g+c[0],end:g+c[1],style:{styleClass:j}},d.push(c),j==="cm-error"&&f.push(c))}return[d,f]},getLineStyle:function(e){return this.lines[e]},getLineStyles:function(){return this.lines}};r.EventTarget.addMixin(k.prototype);p.AnnotationType.registerType("orion.annotation.highlightError",{title:s.syntaxError,html:"<div class='annotationHTML error'></div>",
rangeStyle:{styleClass:"annotationRange error"}});m.prototype={init:function(e,a,b){this.textView=e;this.annotationModel=b;this.modeApplier=new k(e.getModel(),a);var d=this;this.listener={onLineStyle:function(a){d.onLineStyle(a)},onDestroy:function(a){d.onDestroy(a)},onHighlight:function(a){d.onHighlight(a)}};e.addEventListener("LineStyle",this.listener.onLineStyle);e.addEventListener("Destroy",this.listener.onDestroy);this.modeApplier.addEventListener("Highlight",this.listener.onHighlight)},destroy:function(){this.modeApplier&&
(this.modeApplier.removeEventListener("Highlight",this.listener.onHighlight),this.modeApplier.destroy());this.textView&&(this.textView.removeEventListener("LineStyle",this.listener.onLineStyle),this.textView.removeEventListener("Destroy",this.listener.onDestroy));this.listener=this.modeApplier=this.annotationModel=this.textView=null},setMode:function(e){this.modeApplier.setMode(e)},onLineStyle:function(e){var a=e.lineIndex,b=this.modeApplier,d=b.getLineStyle(a);if(!d||!d.eolState){var f=this.textView.getModel().getLineCount();
b.highlight(a,Math.min(a+20,f-1),!0);d=b.getLineStyle(a)}f=this.textView.getModel();if(d){var g=b.toStyleRangesAndErrors(d,a);if(g&&(e.ranges=g[0],e=this.annotationModel)){b=[];d=[];if(g=g[1])for(var h=0;h<g.length;h++){var c=g[h];c.style.styleClass==="cm-error"&&d.push(p.AnnotationType.createAnnotation("orion.annotation.highlightError",c.start,c.end))}for(a=e.getAnnotations(f.getLineStart(a),f.getLineEnd(a));a.hasNext();)f=a.next(),f.type==="orion.annotation.highlightError"&&b.push(f);e.replaceAnnotations(b,
d)}}},onHighlight:function(e){this.textView.redrawLines(e.start,e.end)},onDestroy:function(){this.destroy()}};return{Mirror:h,ModeApplier:k,CodeMirrorStyler:m}});
define("orion/editor/textMateStyler",["orion/editor/regex"],function(s){function r(e,a){var b=a.textView._parent.ownerDocument,d=a._stylesheet=a.util.createElement(b,"style");d.appendChild(b.createTextNode(a._styleSheet(e,"",a.util)));(b.getElementsByTagName("head")[0]||b.documentElement).appendChild(d);a.textView.update(!0)}function p(e,a){var b,d=this;e.getPreferences("/settings",2).then(function(e){if(e.get("JavaScript Editor")!==void 0&&(b=JSON.parse(e.get("JavaScript Editor")))){if(d._stylesheet)d._stylesheet.parentNode.removeChild(d._stylesheet),
d._stylesheet=null;d._update(b,d,a)}})}function f(e,a){for(var b=[],d=0;d<e.length;d++)b[e[d].element]=e[d].value;d=[];d.push("");var f=b.fontFamily,f=f==="sans serif"?'"Menlo", "Consolas", "Vera Mono", "monospace"':"monospace";d.push(a+" .textviewContainer {");d.push("\u0008ackground-color:"+b.background+";");d.push("\tfont-family: "+f+";");d.push("\tfont-size: "+b.fontSize+";");d.push("\tmin-width: 50px;");d.push("\tmin-height: 50px;");d.push("\tcolor: "+b.text+";");d.push("}");d.push(a+" {");d.push("\tfont-family: "+
f+";");d.push("\tfont-size: "+b.fontSize+";");d.push("\tcolor: "+b.text+";");d.push("}");d.push(a+" .textview {");d.push("\tbackground-color: "+b.background+";");d.push("}");d.push(a+".ruler.annotations{");d.push("\tbackground-color: white;");d.push("}");d.push(a+" .ruler {");d.push("\tbackground-color: "+b.annotationRuler+";");d.push("}");d.push(a+" .rulerLines {");d.push("\tcolor: "+b.lineNumber+";");d.push("\tbackground-color: "+b.annotationRuler+";");d.push("}");d.push(a+" .rulerLines.even {");
d.push("\tcolor: "+b.lineNumber+";");d.push("\tbackground-color: "+b.annotationRuler+";");d.push("}");d.push(a+" .rulerLines.odd {");d.push("\tcolor: "+b.lineNumber+";");d.push("\tbackground-color: "+b.annotationRuler+";");d.push("}");d.push(a+" .annotationLine.currentLine {");d.push("\tbackground-color: "+b.currentLine+";");d.push("}");d.push(a+" .entity-name-tag {");d.push("color: "+b.keyword+";");d.push("}");return d.join("\n")}function h(e){var a;if(e instanceof Array){a=Array(e.length);for(var b=
0;b<e.length;b++)a[b]=h(e[b])}else for(b in a={},e)if(Object.prototype.hasOwnProperty.call(e,b)){var d=e[b];a[b]=typeof d==="object"&&d!==null?h(d):d}return a}function l(e,a,b,d,i){this.initialize(e,d);this.grammar=h(a);this.externalGrammars=b?h(b):[];this._styles={};this._tree=null;this._allGrammars={};this.preprocess(this.grammar);this._updateStylesheet=p;this._update=r;this._styleSheet=f;this.util=i}var k,m={unsupported:[{regex:/\(\?[ims\-]:/,func:function(){return"option on/off for subexp"}},
{regex:/\(\?<([=!])/,func:function(e){return e[1]==="="?"lookbehind":"negative lookbehind"}},{regex:/\(\?>/,func:function(){return"atomic group"}}],toRegExp:function(e){function a(a,b){throw Error('Unsupported regex feature "'+a+'": "'+b[0]+'" at index: '+b.index+" in "+b.input);}var b="",d,e=m.processGlobalFlag("x",e,function(a){for(var b="",c=!1,d=a.length,e=0;e<d;){var f=a.charAt(e);if(!c&&f==="#")for(;e<d&&f!=="\r"&&f!=="\n";)f=a.charAt(++e);else if(!c&&/\s/.test(f))for(;e<d&&/\s/.test(f);)f=
a.charAt(++e);else f==="\\"?(b+=f,/\s/.test(a.charAt(e+1))||(b+=a.charAt(e+1),e+=1)):(f==="["?c=!0:f==="]"&&(c=!1),b+=f),e+=1}return b}),e=m.processGlobalFlag("i",e,function(a){b+="i";return a});for(d=0;d<this.unsupported.length;d++){var f;(f=this.unsupported[d].regex.exec(e))&&a(this.unsupported[d].func(f),f)}return RegExp(e,b)},processGlobalFlag:function(e,a,b){function d(a,b){for(var c=0,d=a.length,e=-1,f=b;f<d&&e===-1;f++)switch(a.charAt(f)){case "\\":f++;break;case "(":c++;break;case ")":c--,
c===0&&(e=f)}return e}var f="(?"+e+")",e="(?"+e+":";if(a.substring(0,f.length)===f)return b(a.substring(f.length));else if(a.substring(0,e.length)===e){f=d(a,0);if(f<a.length-1)throw Error("Only a "+e+") group that encloses the entire regex is supported in: "+a);return b(a.substring(e.length,f))}return a},hasBackReference:function(e){return/\\\d+/.test(e.source)},getSubstitutedRegex:function(e,a,b){for(var b=typeof b==="undefined"?!0:!1,e=e.source.split(/(\\\d+)/g),d=[],f=0;f<e.length;f++){var g=
e[f],h=/\\(\d+)/.exec(g);h?(g=a[h[1]]||"",d.push(b?s.escape(g):g)):d.push(g)}return RegExp(d.join(""))},groupify:function(e,a){for(var b=e.source,d=b.length,f=[],g=0,h=[],c=1,j=1,k=[],l={},m={},p=0;p<d;p++){var n=f[f.length-1],r=b.charAt(p);switch(r){case "(":if(n===4)f.pop(),k.push(")"),h[h.length-1].end=p;var s=p+2<d?b.charAt(p+1)+""+b.charAt(p+2):null;if(s==="?:"||s==="?="||s==="?!"){var t;s==="?:"?t=1:(t=3,g++);f.push(t);h.push({start:p,end:-1,type:t});k.push(r);k.push(s);p+=s.length}else f.push(2),
h.push({start:p,end:-1,type:2,oldNum:c,num:j}),k.push(r),g===0&&(m[j]=null),l[c]=j,c++,j++;break;case ")":n=f.pop();n===3&&g--;h[h.length-1].end=p;k.push(r);break;case "*":case "+":case "?":case "}":var D=r,v=b.charAt(p-1),s=p-1;if(r==="}"){for(t=p-1;b.charAt(t)!=="{"&&t>=0;t--);v=b.charAt(t-1);s=t-1;D=b.substring(t,p+1)}t=h[h.length-1];if(v===")"&&(t.type===2||t.type===4)){k.splice(t.start,0,"(");k.push(D);k.push(")");r={start:t.start,end:k.length-1,type:4,num:t.num};for(v=0;v<h.length;v++)if(n=
h[v],(n.type===2||n.type===4)&&n.start>=t.start&&n.end<=s)if(n.start+=1,n.end+=1,n.num+=1,n.type===2)l[n.oldNum]=n.num;h.push(r);j++;break}default:r!=="|"&&n!==2&&n!==4&&g===0&&(f.push(4),h.push({start:p,end:-1,type:4,num:j}),k.push("("),m[j]=null,j++),k.push(r),r==="\\"&&(r=b.charAt(p+1),k.push(r),p+=1)}}for(;f.length;)f.pop(),k.push(")");var b=RegExp(k.join("")),d={},a=a||l,z;for(z in a)a.hasOwnProperty(z)&&(d[z]="\\"+a[z]);b=this.getSubstitutedRegex(b,d,!1);return[b,l,m]},complexCaptures:function(e){if(!e)return!1;
for(var a in e)if(e.hasOwnProperty(a)&&a!=="0")return!0;return!1}};l.prototype={initialize:function(e,a,b){this.textView=e;this.textView.stylerOptions=this;var d=this;this.textView&&a&&a.startup().then(function(a){k=a.preferences;d.preferences=k;d._updateStylesheet(k,b);d.storageKey=k.listenForChangedSettings(d._listener.onStorage)});this._listener={onModelChanged:function(a){d.onModelChanged(a)},onDestroy:function(a){d.onDestroy(a)},onLineStyle:function(a){d.onLineStyle(a)},onStorage:function(a){d.onStorage(a)}};
e.addEventListener("ModelChanged",this._listener.onModelChanged);e.addEventListener("Destroy",this._listener.onDestroy);e.addEventListener("LineStyle",this._listener.onLineStyle);e.redrawLines()},onDestroy:function(){this.destroy()},onStorage:function(e){e.key===this.storageKey&&this._updateStylesheet(this.preferences)},destroy:function(){if(this.textView)this.textView.removeEventListener("ModelChanged",this._listener.onModelChanged),this.textView.removeEventListener("Destroy",this._listener.onDestroy),
this.textView.removeEventListener("LineStyle",this._listener.onLineStyle),this.textView=null;this._listener=this._tree=this._styles=this.grammar=null},preprocess:function(e){for(e=[e];e.length!==0;){var a=e.pop();if(!a._resolvedRule||!a._typedRule)if(a._resolvedRule=this._resolve(a),a._typedRule=this._createTypedRule(a),this.addStyles(a.name),this.addStyles(a.contentName),this.addStylesForCaptures(a.captures),this.addStylesForCaptures(a.beginCaptures),this.addStylesForCaptures(a.endCaptures),a._resolvedRule!==
a&&e.push(a._resolvedRule),a.patterns)for(var b=0;b<a.patterns.length;b++)e.push(a.patterns[b])}},addStyles:function(e){if(e&&!this._styles[e]){this._styles[e]=[];for(var a=e.split("."),b=0;b<a.length;b++)this._styles[e].push(a.slice(0,b+1).join("-"))}},addStylesForCaptures:function(e){for(var a in e)e.hasOwnProperty(a)&&this.addStyles(e[a].name)},ContainerRule:function(){function e(a){this.rule=a;this.subrules=a.patterns}e.prototype.valueOf=function(){return"aa"};return e}(),BeginEndRule:function(){function e(a){this.rule=
a;this.beginRegex=m.toRegExp(a.begin);this.endRegex=m.toRegExp(a.end);this.subrules=a.patterns||[];this.endRegexHasBackRef=m.hasBackReference(this.endRegex);var b=m.complexCaptures(a.captures),a=m.complexCaptures(a.beginCaptures)||m.complexCaptures(a.endCaptures);if(this.isComplex=b||a)b=m.groupify(this.beginRegex),this.beginRegex=b[0],this.beginOld2New=b[1],this.beginConsuming=b[2],b=m.groupify(this.endRegex,this.beginOld2New),this.endRegex=b[0],this.endOld2New=b[1],this.endConsuming=b[2]}e.prototype.valueOf=
function(){return this.beginRegex};return e}(),MatchRule:function(){function e(a){this.rule=a;this.matchRegex=m.toRegExp(a.match);if(this.isComplex=m.complexCaptures(a.captures))a=m.groupify(this.matchRegex),this.matchRegex=a[0],this.matchOld2New=a[1],this.matchConsuming=a[2]}e.prototype.valueOf=function(){return this.matchRegex};return e}(),_createTypedRule:function(e){return e.match?new this.MatchRule(e):e.begin?new this.BeginEndRule(e):new this.ContainerRule(e)},_resolve:function(e){var a=e;if(e.include){if(e.begin||
e.end||e.match)throw Error('Unexpected regex pattern in "include" rule '+e.include);e=e.include;if(e.charAt(0)==="#"){if(a=this.grammar.repository&&this.grammar.repository[e.substring(1)],!a)throw Error("Couldn't find included rule "+e+" in grammar repository");}else if(e==="$self")a=this.grammar;else if(e==="$base")throw Error('Include "$base" is not supported');else if(a=this._allGrammars[e],!a)for(var b=0;b<this.externalGrammars.length;b++){var d=this.externalGrammars[b];if(d.scopeName===e){this.preprocess(d);
a=this._allGrammars[e]=d;break}}}return a},ContainerNode:function(){function e(a,b){this.parent=a;this.rule=b;this.children=[];this.end=this.start=null}e.prototype.addChild=function(a){this.children.push(a)};e.prototype.valueOf=function(){var a=this.rule;return"ContainerNode { "+(a.include||"")+" "+(a.name||"")+(a.comment||"")+"}"};return e}(),BeginEndNode:function(){function e(a,b,d){this.parent=a;this.rule=b;this.children=[];this.setStart(d);this.endMatch=this.end=null;this.endRegexSubstituted=
b.endRegexHasBackRef?m.getSubstitutedRegex(b.endRegex,d):null}e.prototype.addChild=function(a){this.children.push(a)};e.prototype.getIndexInParent=function(){return this.parent?this.parent.children.indexOf(this):-1};e.prototype.setStart=function(a){this.start=a.index;this.beginMatch=a};e.prototype.setEnd=function(a){a&&typeof a==="object"?(this.endMatch=a,this.end=a.index+a[0].length):(this.endMatch=null,this.end=a)};e.prototype.shiftStart=function(a){this.start+=a;this.beginMatch.index+=a};e.prototype.shiftEnd=
function(a){this.end+=a;this.endMatch&&(this.endMatch.index+=a)};e.prototype.valueOf=function(){return"{"+this.rule.beginRegex+" range="+this.start+".."+this.end+"}"};return e}(),push:function(e,a){if(a)for(var b=a.length;b>0;)e.push(a[--b])},exec:function(e,a,b){(a=e.exec(a))&&(a.index+=b);e.lastIndex=0;return a},afterMatch:function(e){return e.index+e[0].length},getEndMatch:function(e,a,b){if(e instanceof this.BeginEndNode){var d=e.rule,e=e.endRegexSubstituted||d.endRegex;return!e?null:this.exec(e,
a,b)}return null},initialParse:function(){this.textView.getModel().getCharCount();this._tree=new this.ContainerNode(null,this.grammar._typedRule);this.parse(this._tree,!1,0)},onModelChanged:function(e){var a=e.addedCharCount,b=e.removedCharCount,e=e.start;if(this._tree){var d=this.textView.getModel(),f=d.getCharCount(),d=d.getLineEnd(d.getLineAtOffset(e)-1),g=this.getFirstDamaged(d,d),d=d===-1?0:d,a=g?this.parse(g,!0,d,e,a,b):f;this.textView.redrawRange(d,a)}else this.initialParse()},getFirstDamaged:function(e,
a){if(e<0)return this._tree;for(var b=[this._tree],d=null;b.length;){var f=b.pop();if(!f.parent||this.isDamaged(f,e,a)){f instanceof this.BeginEndNode&&(d=f);for(var g=0;g<f.children.length;g++)b.push(f.children[g])}}return d||this._tree},isDamaged:function(e,a,b){return e.start<=b&&e.end>a},parse:function(e,a,b,d,f,g){var h=this.textView.getModel(),c=h.getLineStart(h.getLineCount()-1),j=h.getCharCount(),k=this.getInitialExpected(e,b),l=-1;if(a)e.repaired=!0,e.endNeedsUpdate=!0,l=(l=e.children[e.children.length-
1])?h.getLineEnd(h.getLineAtOffset(l.end+(f-g))):-1,d=h.getLineEnd(h.getLineAtOffset(d+g)),l=Math.max(l,d);for(var l=l===-1?j:l,d=k,m=e,p=!1,n=b,r=-1;m&&(!a||n<l);){var s=this.getNextMatch(h,m,n);s||(n=n>=c?j:h.getLineStart(h.getLineAtOffset(n)+1));var t=s&&s.match,D=s&&s.rule,v=s&&s.isEnd;if(s&&s.isSub){if(n=this.afterMatch(t),D instanceof this.BeginEndRule)p=!0,a&&D===d.rule&&m===d.parent?(m=d,m.setStart(t),m.repaired=!0,m.endNeedsUpdate=!0,d=this.getNextExpected(d,"begin")):(a&&(this.prune(m,d),
a=!1),t=new this.BeginEndNode(m,D,t),m.addChild(t),m=t)}else if(v||n===j){if(m instanceof this.BeginEndNode)t?(p=!0,r=Math.max(r,m.end),m.setEnd(t),n=this.afterMatch(t),a&&m===d&&m.parent===d.parent?(m.repaired=!0,delete m.endNeedsUpdate,d=this.getNextExpected(d,"end")):a&&(this.prune(m,d),a=!1)):(m.setEnd(j),delete m.endNeedsUpdate);m=m.parent}a&&n>=l&&!p&&(this.prune(e,k),a=!1)}this.removeUnrepairedChildren(e,a,b);this.cleanup(a,e,b,l,j,f,g);return a?Math.max(r,n):n},removeUnrepairedChildren:function(e,
a,b){if(a){for(var a=e.children,d=-1,f=0;f<a.length;f++){var g=a[f];if(!g.repaired&&this.isDamaged(g,b,Number.MAX_VALUE)){d=f;break}}if(d!==-1)e.children.length=d}},cleanup:function(e,a,b,d,f,g,h){if(e){e=g-h;f=this.getIntersecting(d-e+1,f);a=this.getIntersecting(b,d);for(b=0;b<f.length;b++)d=f[b],!d.repaired&&d instanceof this.BeginEndNode&&(d.shiftEnd(e),d.shiftStart(e));for(b=0;b<a.length;b++)d=a[b],d.repaired&&d.endNeedsUpdate&&d.shiftEnd(e),delete d.endNeedsUpdate,delete d.repaired}else{a=this.getIntersecting(b,
d);for(b=0;b<a.length;b++)delete a[b].repaired}},getNextMatch:function(e,a,b,d){var f=e.getLineAtOffset(b),f=e.getLineEnd(f),g=e.getText(b,f),h=[],c=[],e=[],f=[];for(this.push(h,a.rule.subrules);h.length;){var j=h.length?h.pop():null,j=j&&j._resolvedRule._typedRule;if(j instanceof this.ContainerRule&&c.indexOf(j)===-1)c.push(j),this.push(h,j.subrules);else if(!j||!d||j.matchRegex){var k=j&&this.exec(j.matchRegex||j.beginRegex,g,b);k&&(e.push(k),f.push(j))}}h=Number.MAX_VALUE;c=-1;for(j=0;j<e.length;j++)if(k=
e[j],k.index<h)h=k.index,c=j;if(!d&&(b=this.getEndMatch(a,g,b)))if(d=a.rule.applyEndPatternLast,c===-1||b.index<h||!d&&b.index===h)return{isEnd:!0,rule:a.rule,match:b};return c===-1?null:{isSub:!0,rule:f[c],match:e[c]}},getInitialExpected:function(e,a){var b,d;if(e===this._tree)for(b=0;b<e.children.length;b++){if(d=e.children[b],d.start>=a)return d}else if(e instanceof this.BeginEndNode&&e.endMatch){var f=e.endMatch.index;for(b=0;b<e.children.length;b++)if(d=e.children[b],d.start>=a)break;if(d&&d.start<
f)return d}return e},getNextExpected:function(e,a){if(a==="begin"){var b=e.children[0];return b?b:e}else if(a==="end"&&(b=e.parent)){var d=b.children[b.children.indexOf(e)+1];return d?d:b}return null},prune:function(e,a){if(a.parent===e)e.children.length=a.getIndexInParent();else if(e instanceof this.BeginEndNode)e.endMatch=null,e.end=null;if(e.parent)e.parent.children.length=e.getIndexInParent()+1},onLineStyle:function(e){this._tree||this.initialParse();var a=e.lineStart,b=this.textView.getModel(),
d=b.getLineEnd(e.lineIndex),f=b.getLineEnd(b.getLineAtOffset(a)-1),f=this.getFirstDamaged(f,f),a=this.getLineScope(b,f,a,d);e.ranges=this.toStyleRanges(a);e.ranges.sort(function(a,b){return a.start-b.start})},getLineScope:function(e,a,b,d){for(var f=b,g=this.getInitialExpected(a,b),h=[],c=[];a&&f<d;){var j=this.getNextMatch(e,a,f);if(!j)break;var k=j&&j.match,l=j&&j.rule,m=j&&j.isSub,j=j&&j.isEnd;k.index!==f&&c.push({start:f,end:k.index,node:a});if(m)f=this.afterMatch(k),l instanceof this.BeginEndRule?
(this.addBeginScope(h,k,l),a=g,g=this.getNextExpected(g,"begin")):this.addMatchScope(h,k,l);else if(j)f=this.afterMatch(k),this.addEndScope(h,k,l),g=this.getNextExpected(g,"end"),a=a.parent}f<d&&c.push({start:f,end:d,node:a});e=this.getInheritedLineScope(c,b,d);return h.concat(e)},getInheritedLineScope:function(e){for(var a=[],b=0;b<e.length;b++)for(var d=e[b],f=d.node;f;){var g=f.rule.rule,h=g.name;if(g=g.contentName||h){this.addScopeRange(a,d.start,d.end,g);break}f=f.parent}return a},addBeginScope:function(e,
a,b){var d=b.rule;this.addCapturesScope(e,a,d.beginCaptures||d.captures,b.isComplex,b.beginOld2New,b.beginConsuming)},addEndScope:function(e,a,b){var d=b.rule;this.addCapturesScope(e,a,d.endCaptures||d.captures,b.isComplex,b.endOld2New,b.endConsuming)},addMatchScope:function(e,a,b){var d=b.rule,f=d.name;(d=d.captures)?this.addCapturesScope(e,a,d,b.isComplex,b.matchOld2New,b.matchConsuming):this.addScope(e,a,f)},addScope:function(e,a,b){b&&e.push({start:a.index,end:this.afterMatch(a),scope:b})},addScopeRange:function(e,
a,b,d){d&&e.push({start:a,end:b,scope:d})},addCapturesScope:function(e,a,b,d,f,g){if(b)if(d){for(var d={1:0},h=0,c=1;a[c]!==void 0;c++)g[c]!==void 0&&(h+=a[c].length),a[c+1]!==void 0&&(d[c+1]=h);g=a.index;for(h=1;b[h];h++){var c=b[h].name,j=f[h],k=g+d[j];typeof a[j]!=="undefined"&&this.addScopeRange(e,k,k+a[j].length,c)}}else this.addScope(e,a,b[0]&&b[0].name)},getIntersecting:function(e,a){for(var b=[],d=this._tree?[this._tree]:[];d.length;){var f=d.pop(),g=!1;f instanceof this.ContainerNode?g=!0:
this.isDamaged(f,e,a)&&(g=!0,b.push(f));if(g)for(var g=f.children.length,h=0;h<g;h++)d.push(f.children[h])}return b.reverse()},toStyleRanges:function(e){for(var a=[],b=0;b<e.length;b++){var d=e[b],f=this._styles[d.scope];if(!f)throw Error("styles not found for "+d.scope);f=f.join(" ");a.push({start:d.start,end:d.end,style:{styleClass:f}})}return a}};return{RegexUtil:m,TextMateStyler:l}});
define("orion/editor/htmlGrammar",[],function(){return{HtmlGrammar:function(){return{scopeName:"source.html",uuid:"3B5C76FB-EBB5-D930-F40C-047D082CE99B",patterns:[{begin:"<!(doctype|DOCTYPE)",end:">",contentName:"entity.name.tag.doctype.html",beginCaptures:{0:{name:"entity.name.tag.doctype.html"}},endCaptures:{0:{name:"entity.name.tag.doctype.html"}}},{begin:"<\!--",end:"--\>",beginCaptures:{0:{name:"punctuation.definition.comment.html"}},endCaptures:{0:{name:"punctuation.definition.comment.html"}},
patterns:[{match:"--",name:"invalid.illegal.badcomment.html"}],contentName:"comment.block.html"},{match:"<[A-Za-z0-9_\\-:]+(?= ?)",name:"entity.name.tag.html"},{include:"#attrName"},{include:"#qString"},{include:"#qqString"},{include:"#entity"},{match:"</[A-Za-z0-9_\\-:]+>",name:"entity.name.tag.html"},{match:">",name:"entity.name.tag.html"}],repository:{attrName:{match:"[A-Za-z\\-:]+(?=\\s*=\\s*['\"])",name:"entity.other.attribute.name.html"},qqString:{match:'(")[^"]+(")',name:"token.string"},qString:{match:"(')[^']+(')",
name:"token.string"},entity:{match:"&[A-Za-z0-9]+;",name:"constant.character.entity.html"}}}}}});
define("examples/editor/textStyler",["orion/editor/annotations"],function(s){function r(a,b){this.keywords=a;this.whitespacesVisible=b;this.setText("")}function p(){r.call(this,null,!0)}function f(a){r.call(this,null,a)}function h(){r.call(this,null,!1)}function l(a,b,c){this.commentStart="/*";this.commentEnd="*/";var d=[];switch(b){case "java":d=m;break;case "js":d=k;break;case "css":d=e}this.whitespacesVisible=!1;this.detectHyperlinks=!0;this.highlightCaretLine=!1;this.detectTasks=this.foldingEnabled=
!0;this._scanner=new r(d,this.whitespacesVisible);this._firstScanner=new h;this._commentScanner=new f(this.whitespacesVisible);this._whitespaceScanner=new p;if(b==="css")this._scanner.isCSS=!0,this._firstScanner.isCSS=!0;this.view=a;this.annotationModel=c;this._bracketAnnotations=void 0;var g=this;this._listener={onChanged:function(a){g._onModelChanged(a)},onDestroy:function(a){g._onDestroy(a)},onLineStyle:function(a){g._onLineStyle(a)},onMouseDown:function(a){g._onMouseDown(a)},onSelection:function(a){g._onSelection(a)}};
b=a.getModel();b.getBaseModel&&(b=b.getBaseModel());b.addEventListener("Changed",this._listener.onChanged);a.addEventListener("MouseDown",this._listener.onMouseDown);a.addEventListener("Selection",this._listener.onSelection);a.addEventListener("Destroy",this._listener.onDestroy);a.addEventListener("LineStyle",this._listener.onLineStyle);this._computeComments();this._computeFolding();a.redrawLines()}var k="break,case,class,catch,continue,const,debugger,default,delete,do,else,enum,export,extends,false,finally,for,function,if,implements,import,in,instanceof,interface,let,new,null,package,private,protected,public,return,static,super,switch,this,throw,true,try,typeof,undefined,var,void,while,with,yield".split(","),
m="abstract,boolean,break,byte,case,catch,char,class,continue,default,do,double,else,extends,false,final,finally,float,for,if,implements,import,instanceof,int,interface,long,native,new,null,package,private,protected,public,return,short,static,super,switch,synchronized,this,throw,throws,transient,true,try,void,volatile,while".split(","),e="alignment-adjust,alignment-baseline,animation,animation-delay,animation-direction,animation-duration,animation-iteration-count,animation-name,animation-play-state,animation-timing-function,appearance,azimuth,backface-visibility,background,background-attachment,background-clip,background-color,background-image,background-origin,background-position,background-repeat,background-size,baseline-shift,binding,bleed,bookmark-label,bookmark-level,bookmark-state,bookmark-target,border,border-bottom,border-bottom-color,border-bottom-left-radius,border-bottom-right-radius,border-bottom-style,border-bottom-width,border-collapse,border-color,border-image,border-image-outset,border-image-repeat,border-image-slice,border-image-source,border-image-width,border-left,border-left-color,border-left-style,border-left-width,border-radius,border-right,border-right-color,border-right-style,border-right-width,border-spacing,border-style,border-top,border-top-color,border-top-left-radius,border-top-right-radius,border-top-style,border-top-width,border-width,bottom,box-align,box-decoration-break,box-direction,box-flex,box-flex-group,box-lines,box-ordinal-group,box-orient,box-pack,box-shadow,box-sizing,break-after,break-before,break-inside,caption-side,clear,clip,color,color-profile,column-count,column-fill,column-gap,column-rule,column-rule-color,column-rule-style,column-rule-width,column-span,column-width,columns,content,counter-increment,counter-reset,crop,cue,cue-after,cue-before,cursor,direction,display,dominant-baseline,drop-initial-after-adjust,drop-initial-after-align,drop-initial-before-adjust,drop-initial-before-align,drop-initial-size,drop-initial-value,elevation,empty-cells,fit,fit-position,flex-align,flex-flow,flex-inline-pack,flex-order,flex-pack,float,float-offset,font,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,grid-columns,grid-rows,hanging-punctuation,height,hyphenate-after,hyphenate-before,hyphenate-character,hyphenate-lines,hyphenate-resource,hyphens,icon,image-orientation,image-rendering,image-resolution,inline-box-align,left,letter-spacing,line-height,line-stacking,line-stacking-ruby,line-stacking-shift,line-stacking-strategy,list-style,list-style-image,list-style-position,list-style-type,margin,margin-bottom,margin-left,margin-right,margin-top,mark,mark-after,mark-before,marker-offset,marks,marquee-direction,marquee-loop,marquee-play-count,marquee-speed,marquee-style,max-height,max-width,min-height,min-width,move-to,nav-down,nav-index,nav-left,nav-right,nav-up,opacity,orphans,outline,outline-color,outline-offset,outline-style,outline-width,overflow,overflow-style,overflow-x,overflow-y,padding,padding-bottom,padding-left,padding-right,padding-top,page,page-break-after,page-break-before,page-break-inside,page-policy,pause,pause-after,pause-before,perspective,perspective-origin,phonemes,pitch,pitch-range,play-during,position,presentation-level,punctuation-trim,quotes,rendering-intent,resize,rest,rest-after,rest-before,richness,right,rotation,rotation-point,ruby-align,ruby-overhang,ruby-position,ruby-span,size,speak,speak-header,speak-numeral,speak-punctuation,speech-rate,stress,string-set,table-layout,target,target-name,target-new,target-position,text-align,text-align-last,text-decoration,text-emphasis,text-height,text-indent,text-justify,text-outline,text-shadow,text-transform,text-wrap,top,transform,transform-origin,transform-style,transition,transition-delay,transition-duration,transition-property,transition-timing-function,unicode-bidi,vertical-align,visibility,voice-balance,voice-duration,voice-family,voice-pitch,voice-pitch-range,voice-rate,voice-stress,voice-volume,volume,white-space,white-space-collapse,widows,width,word-break,word-spacing,word-wrap,z-index".split(","),
a={styleClass:"comment"},b={styleClass:"token_multiline_comment"},d={styleClass:"token_doc_comment"},i={styleClass:"token_doc_html_markup"},g={styleClass:"token_task_tag"},o={styleClass:"token_doc_tag"},c={styleClass:"token-string"},j={styleClass:"token_number"},q={styleClass:"token_keyword"},u={styleClass:"token_space"},A={styleClass:"token_tab"},E={styleClass:"line_caret"};r.prototype={getOffset:function(){return this.offset},getStartOffset:function(){return this.startOffset},getData:function(){return this.text.substring(this.startOffset,
this.offset)},getDataLength:function(){return this.offset-this.startOffset},_default:function(a){switch(a){case 32:case 9:if(this.whitespacesVisible)return a===32?11:10;do a=this._read();while(a===32||a===9);this._unread(a);return 9;case 123:case 125:case 40:case 41:case 91:case 93:case 60:case 62:return a;default:var b=this.isCSS,c=this.offset-1;if(!b&&48<=a&&a<=57){var d=b=!1,e=!1,f=a;do if(a=this._read(),a===46&&!b)b=!0;else if(a===101&&!d)b=d=!0,a=this._read(),a!==45&&this._unread(a);else if(a===
120&&f===48&&this.offset-c===2)b=d=e=!0;else if(!(48<=a&&a<=57||e&&(65<=a&&a<=70||97<=a&&a<=102)))break;while(1);this._unread(a);return 3}if(97<=a&&a<=122||65<=a&&a<=90||a===95||45===a&&b){do a=this._read();while(97<=a&&a<=122||65<=a&&a<=90||a===95||48<=a&&a<=57||45===a&&b);this._unread(a);a=this.keywords;if(a.length>0){c=this.text.substring(c,this.offset);for(b=0;b<a.length;b++)if(this.keywords[b]===c)return 2}}return 1}},_read:function(){return this.offset<this.text.length?this.text.charCodeAt(this.offset++):
-1},_unread:function(a){a!==-1&&this.offset--},nextToken:function(){for(this.startOffset=this.offset;;){var a=this._read(),b;switch(a){case -1:return null;case 47:a=this._read();if(!this.isCSS&&a===47)for(;;)if(a=this._read(),a===-1||a===10||a===13)return this._unread(a),6;if(a===42){a=this._read();b=7;for(a===42&&(b=8);;){for(;a===42;)if(a=this._read(),a===47)return b;if(a===-1)return this._unread(a),b;a=this._read()}}this._unread(a);return 1;case 39:for(b=4;;)switch(a=this._read(),a){case 39:return b;
case 13:case 10:case -1:return this._unread(a),b;case 92:switch(a=this._read(),a){case 10:b=5;break;case 13:b=5,a=this._read(),a!==10&&this._unread(a)}}break;case 34:for(b=4;;)switch(a=this._read(),a){case 34:return b;case 13:case 10:case -1:return this._unread(a),b;case 92:switch(a=this._read(),a){case 10:b=5;break;case 13:b=5,a=this._read(),a!==10&&this._unread(a)}}break;default:return this._default(a)}}},setText:function(a){this.text=a;this.startOffset=this.offset=0}};p.prototype=new r(null);p.prototype.nextToken=
function(){for(this.startOffset=this.offset;;){var a=this._read();switch(a){case -1:return null;case 32:return 11;case 9:return 10;default:do a=this._read();while(!(a===32||a===9||a===-1));this._unread(a);return 1}}};f.prototype=new r(null);f.prototype.setType=function(a){this._type=a};f.prototype.nextToken=function(){for(this.startOffset=this.offset;;){var a=this._read();switch(a){case -1:return null;case 32:case 9:if(this.whitespacesVisible)return a===32?11:10;do a=this._read();while(a===32||a===
9);this._unread(a);return 9;case 60:if(this._type===8){do a=this._read();while(!(a===62||a===-1));if(a===62)return 12}return 1;case 64:if(this._type===8){do a=this._read();while(97<=a&&a<=122||65<=a&&a<=90||a===95||48<=a&&a<=57);this._unread(a);return 13}return 1;case 84:if((a=this._read())===79)if((a=this._read())===68)if((a=this._read())===79)if(a=this._read(),!(97<=a&&a<=122||65<=a&&a<=90||a===95||48<=a&&a<=57))return this._unread(a),14;this._unread(a);default:do a=this._read();while(!(a===32||
a===9||a===-1||a===60||a===64||a===84));this._unread(a);return 1}}};h.prototype=new r(null);h.prototype._default=function(a){for(;;)switch(a=this._read(),a){case 47:case 34:case 39:case -1:return this._unread(a),1}};l.prototype={getClassNameForToken:function(e){switch(e){case "singleLineComment":return a.styleClass;case "multiLineComment":return b.styleClass;case "docComment":return d.styleClass;case "docHtmlComment":return i.styleClass;case "tasktag":return g.styleClass;case "doctag":return o.styleClass;
case "string":return c.styleClass;case "number":return j.styleClass;case "keyword":return q.styleClass;case "space":return u.styleClass;case "tab":return A.styleClass;case "caretLine":return E.styleClass;case "rulerStyle":return"ruler";case "annotationsStyle":return;case "rulerFolding":return;case "rulerOverview":return"ruler.overview";case "rulerLines":return;case "rulerLinesEven":return"rulerLines.even";case "rulerLinesOdd":return"rulerLines.odd"}return null},destroy:function(){var a=this.view;
if(a){var b=a.getModel();b.getBaseModel&&(b=b.getBaseModel());b.removeEventListener("Changed",this._listener.onChanged);a.removeEventListener("MouseDown",this._listener.onMouseDown);a.removeEventListener("Selection",this._listener.onSelection);a.removeEventListener("Destroy",this._listener.onDestroy);a.removeEventListener("LineStyle",this._listener.onLineStyle);this.view=null}},setHighlightCaretLine:function(a){this.highlightCaretLine=a},setWhitespacesVisible:function(a){this.whitespacesVisible=a;
this._scanner.whitespacesVisible=a;this._commentScanner.whitespacesVisible=a},setDetectHyperlinks:function(a){this.detectHyperlinks=a},setFoldingEnabled:function(a){this.foldingEnabled=a},setDetectTasks:function(a){this.detectTasks=a},_binarySearch:function(a,b,c,d,e){var f;d===void 0&&(d=-1);if(e===void 0)e=a.length;for(;e-d>1;)if(f=Math.floor((e+d)/2),b<=a[f].start)e=f;else if(c&&b<a[f].end){e=f;break}else d=f;return e},_computeComments:function(){var a=this.view.getModel();a.getBaseModel&&(a=a.getBaseModel());
this.comments=this._findComments(a.getText())},_computeFolding:function(){if(this.foldingEnabled){var a=this.view.getModel();if(a.getBaseModel){var b=this.annotationModel;if(b){b.removeAnnotations(s.AnnotationType.ANNOTATION_FOLDING);for(var c=[],d=a.getBaseModel(),e=this.comments,f=0;f<e.length;f++){var g=e[f];(g=this._createFoldingAnnotation(a,d,g.start,g.end))&&c.push(g)}b.replaceAnnotations(null,c)}}}},_createFoldingAnnotation:function(a,b,c,d){var e=b.getLineAtOffset(c),b=b.getLineAtOffset(d);
return e===b?null:new (s.AnnotationType.getType(s.AnnotationType.ANNOTATION_FOLDING))(c,d,a)},_computeTasks:function(a,b,c){if(this.detectTasks){var d=this.annotationModel;if(d){var e=this.view.getModel(),f=e;e.getBaseModel&&(f=e.getBaseModel());for(var g=d.getAnnotations(b,c),e=[],h=s.AnnotationType.ANNOTATION_TASK;g.hasNext();){var i=g.next();i.type===h&&e.push(i)}g=[];i=this._commentScanner;i.setText(f.getText(b,c));for(var j;j=i.nextToken();){var k=i.getStartOffset()+b;j===14&&(j=f.getLineEnd(f.getLineAtOffset(k)),
a!==6&&(j=Math.min(j,c-this.commentEnd.length)),g.push(s.AnnotationType.createAnnotation(h,k,j,f.getText(k,j))))}d.replaceAnnotations(e,g)}}},_getLineStyle:function(a){if(this.highlightCaretLine){var b=this.view,c=b.getModel(),b=b.getSelection();if(b.start===b.end&&c.getLineAtOffset(b.start)===a)return E}return null},_getStyles:function(a,e,f){a.getBaseModel&&(f=a.mapOffset(f));for(var g=f+e.length,h=[],i=f,j=this.comments,k=this._binarySearch(j,f,!0);k<j.length;k++){if(j[k].start>=g)break;var l=
j[k].start,m=j[k].end;i<l&&this._parse(e.substring(i-f,l-f),i,h);var o=j[k].type,p;switch(o){case 8:p=d;break;case 7:p=b;break;case 5:p=c}i=Math.max(i,l);l=Math.min(g,m);(o===8||o===7)&&(this.whitespacesVisible||this.detectHyperlinks)?this._parseComment(e.substring(i-f,l-f),i,h,p,o):o===5&&this.whitespacesVisible?this._parseString(e.substring(i-f,l-f),i,h,c):h.push({start:i,end:l,style:p});i=m}i<g&&this._parse(e.substring(i-f,g-f),i,h);if(a.getBaseModel)for(e=0;e<h.length;e++)f=h[e].end-h[e].start,
h[e].start=a.mapOffset(h[e].start,!0),h[e].end=h[e].start+f;return h},_parse:function(e,f,g){var h=this._scanner;for(h.setText(e);e=h.nextToken();){var i=h.getStartOffset()+f,k=null;switch(e){case 2:k=q;break;case 3:k=j;break;case 5:case 4:if(this.whitespacesVisible){this._parseString(h.getData(),i,g,c);continue}else k=c;break;case 8:this._parseComment(h.getData(),i,g,d,e);continue;case 6:this._parseComment(h.getData(),i,g,a,e);continue;case 7:this._parseComment(h.getData(),i,g,b,e);continue;case 10:this.whitespacesVisible&&
(k=A);break;case 11:this.whitespacesVisible&&(k=u)}g.push({start:i,end:h.getOffset()+f,style:k})}},_parseComment:function(a,b,c,d,e){var f=this._commentScanner;f.setText(a);for(f.setType(e);a=f.nextToken();){var e=f.getStartOffset()+b,h=d;switch(a){case 10:this.whitespacesVisible&&(h=A);break;case 11:this.whitespacesVisible&&(h=u);break;case 12:h=i;break;case 13:h=o;break;case 14:h=g;break;default:this.detectHyperlinks&&(h=this._detectHyperlinks(f.getData(),e,c,h))}h&&c.push({start:e,end:f.getOffset()+
b,style:h})}},_parseString:function(a,b,c,d){var e=this._whitespaceScanner;for(e.setText(a);a=e.nextToken();){var f=e.getStartOffset()+b,g=d;switch(a){case 10:this.whitespacesVisible&&(g=A);break;case 11:this.whitespacesVisible&&(g=u)}g&&c.push({start:f,end:e.getOffset()+b,style:g})}},_detectHyperlinks:function(a,b,c,d){var e=null,f;if((f=a.indexOf("://"))>0){for(var e=a,g=f;g>0;){f=e.charCodeAt(g-1);if(!(97<=f&&f<=122||65<=f&&f<=90||45===f||48<=f&&f<=57))break;g--}if(g>0&&(f="\"\"''(){}[]<>".indexOf(e.substring(g-
1,g)),f!==-1&&(f&1)===0&&(f=e.lastIndexOf("\"\"''(){}[]<>".substring(f+1,f+2)))!==-1)){var h=f;f=this._clone(d);f.tagName="A";f.attributes={href:e.substring(g,h)};c.push({start:b,end:b+g,style:d});c.push({start:b+g,end:b+h,style:f});c.push({start:b+h,end:b+a.length,style:d});return null}}else a.toLowerCase().indexOf("bug#")===0&&(e="https://bugs.eclipse.org/bugs/show_bug.cgi?id="+parseInt(a.substring(4),10));return e?(f=this._clone(d),f.tagName="A",f.attributes={href:e},f):d},_clone:function(a){if(!a)return a;
var b={},c;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b},_findComments:function(a,b){var b=b||0,c=this._firstScanner,d;c.setText(a);for(var e=[];d=c.nextToken();)(d===7||d===8||d===5)&&e.push({start:c.getStartOffset()+b,end:c.getOffset()+b,type:d}),(d===6||d===7||d===8)&&this._computeTasks(d,c.getStartOffset()+b,c.getOffset()+b);return e},_findMatchingBracket:function(a,b){var c="{}()[]<>",d=a.getText(b,b+1),e=c.indexOf(d,0);if(e===-1)return-1;var f;f=e&1?c.substring(e-1,e):c.substring(e+
1,e+2);for(var g=a.getLineAtOffset(b),c=a.getLine(g),h=a.getLineStart(g),i=a.getLineEnd(g),c=this._findBrackets(d,f,c,h,h,i),i=0;i<c.length;i++)if(h=c[i]>=0?1:-1,c[i]*h-1===b){var j=1;if(e&1){for(i--;i>=0;i--)if(h=c[i]>=0?1:-1,j+=h,j===0)return c[i]*h-1;for(g-=1;g>=0;){c=a.getLine(g);h=a.getLineStart(g);i=a.getLineEnd(g);c=this._findBrackets(d,f,c,h,h,i);for(e=c.length-1;e>=0;e--)if(h=c[e]>=0?1:-1,j+=h,j===0)return c[e]*h-1;g--}}else{for(i++;i<c.length;i++)if(h=c[i]>=0?1:-1,j+=h,j===0)return c[i]*
h-1;g+=1;for(e=a.getLineCount();g<e;){c=a.getLine(g);h=a.getLineStart(g);i=a.getLineEnd(g);c=this._findBrackets(d,f,c,h,h,i);for(i=0;i<c.length;i++)if(h=c[i]>=0?1:-1,j+=h,j===0)return c[i]*h-1;g++}}break}return-1},_findBrackets:function(a,b,c,d,e,f){for(var g=[],a=a.charCodeAt(0),b=b.charCodeAt(0),h=e,i=this._scanner,j,k=this.comments,l=this._binarySearch(k,e,!0);l<k.length;l++){if(k[l].start>=f)break;j=k[l].start;var m=k[l].end;if(h<j)for(i.setText(c.substring(h-e,j-e));j=i.nextToken();)j===a?g.push(i.getStartOffset()+
h-e+d+1):j===b&&g.push(-(i.getStartOffset()+h-e+d+1));h=m}if(h<f)for(i.setText(c.substring(h-e,f-e));j=i.nextToken();)j===a?g.push(i.getStartOffset()+h-e+d+1):j===b&&g.push(-(i.getStartOffset()+h-e+d+1));return g},_onDestroy:function(){this.destroy()},_onLineStyle:function(a){if(a.textView===this.view)a.style=this._getLineStyle(a.lineIndex);a.ranges=this._getStyles(a.textView.getModel(),a.lineText,a.lineStart)},_onSelection:function(a){var b=a.oldValue,c=a.newValue,d=this.view,a=d.getModel(),e;if(this.highlightCaretLine){var f=
a.getLineAtOffset(b.start);e=a.getLineAtOffset(c.start);var g=c.start===c.end,b=b.start===b.end;f===e&&b&&g||(b&&d.redrawLines(f,f+1),(f!==e||!b)&&g&&d.redrawLines(e,e+1))}if(this.annotationModel){var b=this._bracketAnnotations,h,i;if(c.start===c.end&&(i=d.getCaretOffset())>0)i-=1,a.getBaseModel&&(i=a.mapOffset(i),a=a.getBaseModel()),a=this._findMatchingBracket(a,i),a!==-1&&(h=[s.AnnotationType.createAnnotation(s.AnnotationType.ANNOTATION_MATCHING_BRACKET,a,a+1),s.AnnotationType.createAnnotation(s.AnnotationType.ANNOTATION_CURRENT_BRACKET,
i,i+1)]);this._bracketAnnotations=h;this.annotationModel.replaceAnnotations(b,h)}},_onMouseDown:function(a){if(a.clickCount===2){var b=this.view,c=b.getModel(),d=b.getOffsetAtLocation(a.x,a.y);if(d>0){var e=d-1,f=c;c.getBaseModel&&(e=c.mapOffset(e),f=c.getBaseModel());e=this._findMatchingBracket(f,e);e!==-1&&(a.preventDefault(),a=e,c.getBaseModel&&(a=c.mapOffset(a,!0)),d>a&&(d--,a++),b.setSelection(a,d))}}},_onModelChanged:function(a){var b=a.start,c=a.removedCharCount,d=a.addedCharCount-c,e=this.view,
a=e.getModel(),f=a.getBaseModel?a.getBaseModel():a,c=b+c,g=f.getCharCount(),h=this.comments.length,i=f.getLineStart(f.getLineAtOffset(b)),j=this._binarySearch(this.comments,i,!0),k=this._binarySearch(this.comments,c,!1,j-1,h);j<h&&this.comments[j].start<=i&&i<this.comments[j].end?(i=this.comments[j].start,i>b&&(i+=d)):i=j===h&&h>0&&g-d===this.comments[h-1].end?this.comments[h-1].start:i;var l;k<h?(l=this.comments[k].end,l>b&&(l+=d),k+=1):(k=h,l=g);for(var m,g=this._findComments(f.getText(i,l),i),
h=j;h<this.comments.length;h++)m=this.comments[h],m.start>b&&(m.start+=d),m.start>b&&(m.end+=d);var o=k-j!==g.length;if(!o)for(h=0;h<g.length;h++){m=this.comments[j+h];var p=g[h];if(m.start!==p.start||m.end!==p.end||m.type!==p.type){o=!0;break}}h=[j,k-j].concat(g);Array.prototype.splice.apply(this.comments,h);o&&(h=i,m=l,a!==f&&(h=a.mapOffset(h,!0),m=a.mapOffset(m,!0)),e.redrawRange(h,m));if(this.foldingEnabled&&f!==a&&this.annotationModel){e=this.annotationModel;j=e.getAnnotations(i,l);i=[];for(l=
[];j.hasNext();)if(m=j.next(),m.type===s.AnnotationType.ANNOTATION_FOLDING){l.push(m);for(h=0;h<g.length;h++)if(m.start===g[h].start&&m.end===g[h].end)break;h===g.length?(i.push(m),m.expand()):(h=m.start,k=m.end,h>b&&(h-=d),k>b&&(k-=d),h<=b&&b<k&&h<=c&&c<k&&(h=f.getLineAtOffset(m.start),k=f.getLineAtOffset(m.end),h!==k?m.expanded||(m.expand(),e.modifyAnnotation(m)):e.removeAnnotation(m)))}b=[];for(h=0;h<g.length;h++){m=g[h];for(d=0;d<l.length;d++)if(l[d].start===m.start&&l[d].end===m.end)break;d===
l.length&&(m=this._createFoldingAnnotation(a,f,m.start,m.end))&&b.push(m)}e.replaceAnnotations(i,b)}}};return{TextStyler:l}});
define("orion/editor/edit","orion/editor/textView,orion/editor/textModel,orion/editor/projectionTextModel,orion/editor/eventTarget,orion/editor/keyBinding,orion/editor/rulers,orion/editor/annotations,orion/editor/tooltip,orion/editor/undoStack,orion/editor/textDND,orion/editor/editor,orion/editor/editorFeatures,orion/editor/contentAssist,orion/editor/cssContentAssist,orion/editor/htmlContentAssist,orion/editor/jsTemplateContentAssist,orion/editor/AsyncStyler,orion/editor/mirror,orion/editor/textMateStyler,orion/editor/htmlGrammar,examples/editor/textStyler".split(","),function(s,
r,p,f,h,l,k,m,e,a,b,d,i,g,o,c,j,q,u,A,E){function n(a){var b=a.ownerDocument,c=b.defaultView||b.parentWindow;if(!c.getSelection)return a.innerText||a.textContent;b=b.createRange();b.selectNode(a);var a=c.getSelection(),c=[],d;for(d=0;d<a.rangeCount;d++)c.push(a.getRangeAt(d));a.removeAllRanges();a.addRange(b);b=a.toString();a.removeAllRanges();for(d=0;d<c.length;d++)a.addRange(c[d]);return b}function B(a){if(a.substring(0,12)==="data-editor-")return a=a.substring(12),a=a.replace(/-([a-z])/ig,function(a,
b){return b.toUpperCase()})}function J(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])}function t(a,b){var c={};J(c,b);for(var d,e=0,f=a.attributes,g=f.length;e<g;e++){d=f.item(e);var h=B(d.nodeName);if(h){d=d.nodeValue;if(d==="true"||d==="false")d=d==="true";c[h]=d}}return c}function D(a){var b=a.ownerDocument,b=b.defaultView||b.parentWindow,c;if(b.getComputedStyle)c=b.getComputedStyle(a,null).getPropertyValue("height");else if(a.currentStyle)c=a.currentStyle.height;return parseInt(c,10)||0}
function v(a){var e=a.parent;e||(e="editor");typeof e==="string"&&(e=(a.document||document).getElementById(e));if(!e&&a.className){var f=(a.document||document).getElementsByClassName(a.className);if(f){a.className=void 0;for(var h=[],j=0;j<f.length;j++)a.parent=f[j],h.push(v(a));return h}}if(!e)throw"no parent";var a=t(e,a),k;a.readonly||(h={createContentAssistMode:function(a){k=new i.ContentAssist(a.getTextView());a=new i.ContentAssistWidget(k);return new i.ContentAssistMode(k,a)}});f=new b.Editor({textViewFactory:function(){return new s.TextView({parent:e,
model:new p.ProjectionTextModel(new r.TextModel("")),tabSize:a.tabSize?a.tabSize:4,readonly:a.readonly,fullSelection:a.fullSelection,tabMode:a.tabMode,expandTab:a.expandTab,themeClass:a.themeClass,wrapMode:a.wrapMode})},undoStackFactory:new d.UndoFactory,annotationFactory:new d.AnnotationFactory,lineNumberRulerFactory:new d.LineNumberRulerFactory,foldingRulerFactory:new d.FoldingRulerFactory,textDNDFactory:new d.TextDNDFactory,contentAssistFactory:h,keyBindingFactory:function(a,b,c,e){var f=new d.TextActions(a,
c);b.push(f);a=new d.SourceCodeActions(a,c,e);b.push(a)},statusReporter:a.statusReporter,domNode:e});h=a.contents;h===void 0&&(h=n(e));h||(h="");f.installTextView();f.setLineNumberRulerVisible(a.showLinesRuler===void 0||a.showLinesRuler);f.setAnnotationRulerVisible(a.showAnnotationRuler===void 0||a.showFoldingRuler);f.setOverviewRulerVisible(a.showOverviewRuler===void 0||a.showOverviewRuler);f.setFoldingRulerVisible(a.showFoldingRuler===void 0||a.showFoldingRuler);f.setInput(a.title,null,h);({styler:null,
highlight:function(b,c){if(this.styler)this.styler.destroy(),this.styler=null;if(b){var d=c.getTextView(),e=c.getAnnotationModel();switch(b){case "js":case "java":case "css":this.styler=new E.TextStyler(d,b,e);c.setFoldingRulerVisible(a.showFoldingRuler===void 0||a.showFoldingRuler);break;case "html":this.styler=new u.TextMateStyler(d,new A.HtmlGrammar)}}}}).highlight(a.lang,f);if(k){var l=new g.CssContentAssistProvider,m=new c.JSTemplateContentAssistProvider;k.addEventListener("Activating",function(){/css$/.test(a.lang)?
k.setProviders([l]):/js$/.test(a.lang)&&k.setProviders([m])})}if(D(e)<=50)h=f.getTextView().computeSize().height,e.style.height=h+"px";return f}var z=this.orion?this.orion.editor:void 0;if(z)for(var H=0;H<arguments.length;H++)J(z,arguments[H]);return v});var orion=this.orion||(this.orion={}),editor=orion.editor||(orion.editor={});editor.edit=require("orion/editor/edit");

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,119 @@
/*******************************************************************************
* @license
* Copyright (c) 2012 VMware, Inc. All Rights Reserved.
* THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
* ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
* CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
* You can obtain a current copy of the Eclipse Public License from
* http://www.opensource.org/licenses/eclipse-1.0.php
*
* Contributors:
* Andrew Eisenberg (VMware) - initial API and implementation
******************************************************************************/
/*global define esprima */
define("plugins/esprima/esprimaVisitor", function(scriptedLogger) {
return {
/**
* parses the contents with options that are appropriate for inferencing
*/
parse : function(contents, extraOptions) {
if (!extraOptions) {
extraOptions = {};
}
if (!extraOptions.range) {
extraOptions.range = true;
}
if (!extraOptions.tolerant) {
extraOptions.tolerant = true;
}
if (!extraOptions.comment) {
extraOptions.comment = true;
}
try {
var parsedProgram = esprima.parse(contents, extraOptions);
return parsedProgram;
} catch (e) {
if (typeof scriptedLogger !== "undefined") {
scriptedLogger.warn("Problem parsing file", "CONTENT_ASSIST");
scriptedLogger.warn(e.message, "CONTENT_ASSIST");
scriptedLogger.warn(e.stack, "CONTENT_ASSIST");
}
return null;
}
},
/**
* Generic AST visitor. Visits all children in source order, if they have a range property.
*
* @param node The AST node to visit
* @param {rhsVisit:Boolean,...} context any extra data required to pass between operations. Set rhsVisit to true if the rhs of
* assignments and variable declarators should be visited before the lhs
* @param operation function(node, context, [isInitialOp]) an operation on the AST node and the data. Return falsy if
* the visit should no longer continue. Return truthy to continue.
* @param [postoperation] (optional) function(node, context, [isInitialOp]) an operation that is exectuted after visiting the current node's children.
* will only be invoked if operation returns true for the current node
*/
visit: function(node, context, operation, postoperation) {
var i, key, child, children;
if (operation(node, context, true)) {
// gather children to visit
children = [];
for (key in node) {
if (key !== "range" && key !== "errors" && key !== "target" && key !== "extras" && key !== "comments") {
child = node[key];
if (child instanceof Array) {
for (i = 0; i < child.length; i++) {
if (child[i] && child[i].hasOwnProperty("type")) {
children.push(child[i]);
} else if (key === "properties") {
// might be key-value pair of an object expression
// in old versions of the parser, the 'properties' property did not have a 'type' or a 'range'
// so we must explicitly visit the children here.
// in new versions of the parser, this is fixed, and this branch will never be taken.
if (child[i].hasOwnProperty("key") && child[i].hasOwnProperty("value")) {
children.push(child[i].key);
children.push(child[i].value);
}
}
}
} else {
if (child && child.hasOwnProperty("type")) {
children.push(child);
}
}
}
}
if (children.length > 0) {
// sort children by source location
// children with no source location are visited first
children.sort(function(left, right) {
if (left.range && right.range) {
return left.range[0] - right.range[0];
} else if (left.range) {
return 1;
} else if (right.range) {
return -1;
} else {
return 0;
}
});
// visit children in order
for (i = 0; i < children.length; i++) {
this.visit(children[i], context, operation, postoperation);
}
}
if (postoperation) {
postoperation(node, context, false);
}
}
}
};
});

View file

@ -0,0 +1,104 @@
/*******************************************************************************
* @license
* Copyright (c) 2012 VMware, Inc. All Rights Reserved.
* THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
* ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
* CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
* You can obtain a current copy of the Eclipse Public License from
* http://www.opensource.org/licenses/eclipse-1.0.php
*
* Contributors:
* Andy Clement (VMware) - initial API and implementation
* Andrew Eisenberg (VMware) - implemented visitor pattern
******************************************************************************/
/*global define */
define("plugins/esprima/proposalUtils", {
/**
* Match ignoring case and checking camel case.
* @param prefix
* @param target
* @return
*/
looselyMatches: function(prefix, target) {
if (target === null || prefix === null) {
return false;
}
// Zero length string matches everything.
if (prefix.length === 0) {
return true;
}
// Exclude a bunch right away
if (prefix.charAt(0).toLowerCase() !== target.charAt(0).toLowerCase()) {
return false;
}
if (this.startsWith(target, prefix)) {
return true;
}
var lowerCase = target.toLowerCase();
if (this.startsWith(lowerCase, prefix)) {
return true;
}
// Test for camel characters in the prefix.
if (prefix === prefix.toLowerCase()) {
return false;
}
var prefixParts = this.toCamelCaseParts(prefix);
var targetParts = this.toCamelCaseParts(target);
if (prefixParts.length > targetParts.length) {
return false;
}
for (var i = 0; i < prefixParts.length; ++i) {
if (!this.startsWith(targetParts[i], prefixParts[i])) {
return false;
}
}
return true;
},
/**
* Convert an input string into parts delimited by upper case characters. Used for camel case matches.
* e.g. GroClaL = ['Gro','Cla','L'] to match say 'GroovyClassLoader'.
* e.g. mA = ['m','A']
* @param String str
* @return Array.<String>
*/
toCamelCaseParts: function(str) {
var parts = [];
for (var i = str.length - 1; i >= 0; --i) {
if (this.isUpperCase(str.charAt(i))) {
parts.push(str.substring(i));
str = str.substring(0, i);
}
}
if (str.length !== 0) {
parts.push(str);
}
return parts.reverse();
},
startsWith : function(str, start) {
return str.substr(0, start.length) === start;
},
isUpperCase : function(char) {
return char >= 'A' && char <= 'Z';
},
repeatChar : function(char, times) {
var str = "";
for (var i = 0; i < times; i++) {
str += char;
}
return str;
}
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,211 @@
/*******************************************************************************
* @license
* Copyright (c) 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0
* (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*globals define */
define('custom/editor', [ //$NON-NLS-0$
"orion/editor/textView", //$NON-NLS-0$
"orion/editor/textModel", //$NON-NLS-0$
"orion/editor/projectionTextModel", //$NON-NLS-0$
"orion/editor/eventTarget", //$NON-NLS-0$
"orion/editor/keyBinding", //$NON-NLS-0$
"orion/editor/rulers", //$NON-NLS-0$
"orion/editor/annotations", //$NON-NLS-0$
"orion/editor/tooltip", //$NON-NLS-0$
"orion/editor/undoStack", //$NON-NLS-0$
"orion/editor/textDND", //$NON-NLS-0$
"orion/editor/editor", //$NON-NLS-0$
"orion/editor/editorFeatures", //$NON-NLS-0$
"orion/editor/contentAssist", //$NON-NLS-0$
"examples/editor/textStyler" //$NON-NLS-0$
], function(mTextView, mTextModel, mProjModel, mEventTarget, mKeyBinding, mRulers, mAnnotations, mTooltip, mUndoStack, mTextDND, mEditor, mEditorFeatures, mContentAssist, mTextStyler) {
/** @private */
function getTextFromElement(element) {
var document = element.ownerDocument;
var window = document.defaultView || document.parentWindow;
if (!window.getSelection) {
return element.innerText || element.textContent;
}
var newRange = document.createRange();
newRange.selectNode(element);
var selection = window.getSelection();
var oldRanges = [], i;
for (i = 0; i < selection.rangeCount; i++) {
oldRanges.push(selection.getRangeAt(i));
}
selection.removeAllRanges();
selection.addRange(newRange);
var text = selection.toString();
selection.removeAllRanges();
for (i = 0; i < oldRanges.length; i++) {
selection.addRange(oldRanges[i]);
}
return text;
}
/**
* @class This object describes the options for <code>edit</code>.
* @name orion.editor.EditOptions
*
* @property {String|DOMElement} parent the parent element for the view, it can be either a DOM element or an ID for a DOM element.
* @property {Boolean} [readonly=false] whether or not the view is read-only.
* @property {Boolean} [fullSelection=true] whether or not the view is in full selection mode.
* @property {Boolean} [tabMode=true] whether or not the tab keypress is consumed by the view or is used for focus traversal.
* @property {Boolean} [expandTab=false] whether or not the tab key inserts white spaces.
* @property {String} [themeClass] the CSS class for the view theming.
* @property {Number} [tabSize=4] The number of spaces in a tab.
* @property {Boolean} [wrapMode=false] whether or not the view wraps lines.
* @property {Function} [statusReporter] a status reporter.
* @property {String} [title=""] the editor title.
* @property {String} [contents=""] the editor contents.
* @property {String} [lang] the styler language. Plain text by default.
* @property {Boolean} [showLinesRuler=true] whether or not the lines ruler is shown.
* @property {Boolean} [showAnnotationRuler=true] whether or not the annotation ruler is shown.
* @property {Boolean} [showOverviewRuler=true] whether or not the overview ruler is shown.
* @property {Boolean} [showFoldingRuler=true] whether or not the folding ruler is shown.
*/
/**
* Creates an editor instance configured with the given options.
*
* @param {orion.editor.EditOptions} options the editor options.
*/
function edit(options) {
var parent = options.parent;
if (!parent) { parent = "editor"; } //$NON-NLS-0$
if (typeof(parent) === "string") { //$NON-NLS-0$
parent = (options.document || document).getElementById(parent);
}
if (!parent) {
if (options.className) {
var parents = (options.document || document).getElementsByClassName(options.className);
if (parents) {
options.className = undefined;
var editors = [];
for (var i = 0; i < parents.length; i++) {
options.parent = parents[i];
editors.push(edit(options));
}
return editors;
}
}
}
if (!parent) { throw "no parent"; } //$NON-NLS-0$
var textViewFactory = function() {
return new mTextView.TextView({
parent: parent,
model: new mProjModel.ProjectionTextModel(new mTextModel.TextModel("")),
tabSize: options.tabSize ? options.tabSize : 4,
readonly: options.readonly,
fullSelection: options.fullSelection,
tabMode: options.tabMode,
expandTab: options.expandTab,
themeClass: options.themeClass,
wrapMode: options.wrapMode
});
};
var contentAssist, contentAssistFactory;
if (!options.readonly && options.contentassist) {
contentAssistFactory = {
createContentAssistMode: function(editor) {
contentAssist = new mContentAssist.ContentAssist(editor.getTextView());
var contentAssistWidget = new mContentAssist.ContentAssistWidget(contentAssist);
return new mContentAssist.ContentAssistMode(contentAssist, contentAssistWidget);
}
};
}
// Canned highlighters for js, java, and css. Grammar-based highlighter for html
var syntaxHighlighter = {
styler: null,
highlight: function(lang, editor) {
if (this.styler) {
this.styler.destroy();
this.styler = null;
}
if (lang) {
var textView = editor.getTextView();
var annotationModel = editor.getAnnotationModel();
this.styler = new mTextStyler.TextStyler(textView, lang, annotationModel);
editor.setFoldingRulerVisible(options.showFoldingRuler === undefined || options.showFoldingRuler);
}
}
};
var keyBindingFactory = function(editor, keyModeStack, undoStack, contentAssist) {
// Create keybindings for generic editing
var genericBindings = new mEditorFeatures.TextActions(editor, undoStack);
keyModeStack.push(genericBindings);
// create keybindings for source editing
var codeBindings = new mEditorFeatures.SourceCodeActions(editor, undoStack, contentAssist);
keyModeStack.push(codeBindings);
};
var editor = new mEditor.Editor({
textViewFactory: textViewFactory,
undoStackFactory: new mEditorFeatures.UndoFactory(),
annotationFactory: new mEditorFeatures.AnnotationFactory(),
lineNumberRulerFactory: new mEditorFeatures.LineNumberRulerFactory(),
foldingRulerFactory: new mEditorFeatures.FoldingRulerFactory(),
textDNDFactory: new mEditorFeatures.TextDNDFactory(),
contentAssistFactory: contentAssistFactory,
keyBindingFactory: keyBindingFactory,
statusReporter: options.statusReporter,
domNode: parent
});
var contents = options.contents;
if (contents === undefined) {
contents = getTextFromElement(parent);
}
if (!contents) { contents=""; }
editor.installTextView();
editor.setLineNumberRulerVisible(options.showLinesRuler === undefined || options.showLinesRuler);
editor.setAnnotationRulerVisible(options.showAnnotationRuler === undefined || options.showFoldingRuler);
editor.setOverviewRulerVisible(options.showOverviewRuler === undefined || options.showOverviewRuler);
editor.setFoldingRulerVisible(options.showFoldingRuler === undefined || options.showFoldingRuler);
editor.setInput(options.title, null, contents);
syntaxHighlighter.highlight(options.lang, editor);
if (contentAssist) {
var mJSContentAssist = require("plugins/esprima/esprimaJsContentAssist");
var jsTemplateContentAssistProvider = new mJSContentAssist.EsprimaJavaScriptContentAssistProvider();
contentAssist.addEventListener("Activating", function() { //$NON-NLS-0$
contentAssist.setProviders([jsTemplateContentAssistProvider]);
});
}
editor.addErrorMarker = function (pos, description) {
var annotationModel = editor.getAnnotationModel();
var marker = mAnnotations.AnnotationType.createAnnotation(mAnnotations.AnnotationType.ANNOTATION_WARNING, pos, pos, description);
annotationModel.addAnnotation(marker);
};
editor.removeAllErrorMarkers = function () {
var annotationModel = editor.getAnnotationModel();
annotationModel.removeAnnotations(mAnnotations.AnnotationType.ANNOTATION_WARNING);
};
return editor;
}
return edit;
});

View file

@ -0,0 +1 @@
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}

View file

@ -0,0 +1,28 @@
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
{b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
"string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();

35
thirdparty/esprima-master/assets/require.js vendored Executable file
View file

@ -0,0 +1,35 @@
/*
RequireJS 2.0.4 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
*/
var requirejs,require,define;
(function(Y){function x(b){return J.call(b)==="[object Function]"}function G(b){return J.call(b)==="[object Array]"}function q(b,c){if(b){var e;for(e=0;e<b.length;e+=1)if(b[e]&&c(b[e],e,b))break}}function N(b,c){if(b){var e;for(e=b.length-1;e>-1;e-=1)if(b[e]&&c(b[e],e,b))break}}function y(b,c){for(var e in b)if(b.hasOwnProperty(e)&&c(b[e],e))break}function K(b,c,e,i){c&&y(c,function(c,j){if(e||!b.hasOwnProperty(j))i&&typeof c!=="string"?(b[j]||(b[j]={}),K(b[j],c,e,i)):b[j]=c});return b}function s(b,
c){return function(){return c.apply(b,arguments)}}function Z(b){if(!b)return b;var c=Y;q(b.split("."),function(b){c=c[b]});return c}function $(b,c,e){return function(){var i=fa.call(arguments,0),g;if(e&&x(g=i[i.length-1]))g.__requireJsBuild=!0;i.push(c);return b.apply(null,i)}}function aa(b,c,e){q([["toUrl"],["undef"],["defined","requireDefined"],["specified","requireSpecified"]],function(i){var g=i[1]||i[0];b[i[0]]=c?$(c[g],e):function(){var b=z[O];return b[g].apply(b,arguments)}})}function H(b,
c,e,i){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=i;if(e)c.originalError=e;return c}function ga(){if(I&&I.readyState==="interactive")return I;N(document.getElementsByTagName("script"),function(b){if(b.readyState==="interactive")return I=b});return I}var ha=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ia=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,ba=/\.js$/,ja=/^\.\//,J=Object.prototype.toString,A=Array.prototype,fa=A.slice,ka=A.splice,w=!!(typeof window!==
"undefined"&&navigator&&document),ca=!w&&typeof importScripts!=="undefined",la=w&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,O="_",S=typeof opera!=="undefined"&&opera.toString()==="[object Opera]",z={},p={},P=[],L=!1,j,t,C,u,D,I,E,da,ea;if(typeof define==="undefined"){if(typeof requirejs!=="undefined"){if(x(requirejs))return;p=requirejs;requirejs=void 0}typeof require!=="undefined"&&!x(require)&&(p=require,require=void 0);j=requirejs=function(b,c,e,i){var g=O,r;!G(b)&&
typeof b!=="string"&&(r=b,G(c)?(b=c,c=e,e=i):b=[]);if(r&&r.context)g=r.context;(i=z[g])||(i=z[g]=j.s.newContext(g));r&&i.configure(r);return i.require(b,c,e)};j.config=function(b){return j(b)};require||(require=j);j.version="2.0.4";j.jsExtRegExp=/^\/|:|\?|\.js$/;j.isBrowser=w;A=j.s={contexts:z,newContext:function(b){function c(a,d,o){var l=d&&d.split("/"),f=l,b=k.map,c=b&&b["*"],e,g,h;if(a&&a.charAt(0)===".")if(d){f=k.pkgs[d]?l=[d]:l.slice(0,l.length-1);d=a=f.concat(a.split("/"));for(f=0;d[f];f+=
1)if(e=d[f],e===".")d.splice(f,1),f-=1;else if(e==="..")if(f===1&&(d[2]===".."||d[0]===".."))break;else f>0&&(d.splice(f-1,2),f-=2);f=k.pkgs[d=a[0]];a=a.join("/");f&&a===d+"/"+f.main&&(a=d)}else a.indexOf("./")===0&&(a=a.substring(2));if(o&&(l||c)&&b){d=a.split("/");for(f=d.length;f>0;f-=1){g=d.slice(0,f).join("/");if(l)for(e=l.length;e>0;e-=1)if(o=b[l.slice(0,e).join("/")])if(o=o[g]){h=o;break}!h&&c&&c[g]&&(h=c[g]);if(h){d.splice(0,f,h);a=d.join("/");break}}}return a}function e(a){w&&q(document.getElementsByTagName("script"),
function(d){if(d.getAttribute("data-requiremodule")===a&&d.getAttribute("data-requirecontext")===h.contextName)return d.parentNode.removeChild(d),!0})}function i(a){var d=k.paths[a];if(d&&G(d)&&d.length>1)return e(a),d.shift(),h.undef(a),h.require([a]),!0}function g(a,d,o,b){var f=a?a.indexOf("!"):-1,v=null,e=d?d.name:null,g=a,i=!0,j="",k,m;a||(i=!1,a="_@r"+(N+=1));f!==-1&&(v=a.substring(0,f),a=a.substring(f+1,a.length));v&&(v=c(v,e,b),m=n[v]);a&&(v?j=m&&m.normalize?m.normalize(a,function(a){return c(a,
e,b)}):c(a,e,b):(j=c(a,e,b),k=h.nameToUrl(j)));a=v&&!m&&!o?"_unnormalized"+(O+=1):"";return{prefix:v,name:j,parentMap:d,unnormalized:!!a,url:k,originalName:g,isDefine:i,id:(v?v+"!"+j:j)+a}}function r(a){var d=a.id,o=m[d];o||(o=m[d]=new h.Module(a));return o}function p(a,d,o){var b=a.id,f=m[b];if(n.hasOwnProperty(b)&&(!f||f.defineEmitComplete))d==="defined"&&o(n[b]);else r(a).on(d,o)}function B(a,d){var b=a.requireModules,l=!1;if(d)d(a);else if(q(b,function(d){if(d=m[d])d.error=a,d.events.error&&(l=
!0,d.emit("error",a))}),!l)j.onError(a)}function u(){P.length&&(ka.apply(F,[F.length-1,0].concat(P)),P=[])}function t(a,d,b){a=a&&a.map;d=$(b||h.require,a,d);aa(d,h,a);d.isBrowser=w;return d}function z(a){delete m[a];q(M,function(d,b){if(d.map.id===a)return M.splice(b,1),d.defined||(h.waitCount-=1),!0})}function A(a,d){var b=a.map.id,l=a.depMaps,f;if(a.inited){if(d[b])return a;d[b]=!0;q(l,function(a){if(a=m[a.id])return!a.inited||!a.enabled?(f=null,delete d[b],!0):f=A(a,K({},d))});return f}}function C(a,
d,b){var l=a.map.id,f=a.depMaps;if(a.inited&&a.map.isDefine){if(d[l])return n[l];d[l]=a;q(f,function(f){var f=f.id,c=m[f];!Q[f]&&c&&(!c.inited||!c.enabled?b[l]=!0:(c=C(c,d,b),b[f]||a.defineDepById(f,c)))});a.check(!0);return n[l]}}function D(a){a.check()}function E(){var a=k.waitSeconds*1E3,d=a&&h.startTime+a<(new Date).getTime(),b=[],l=!1,f=!0,c,g,j;if(!T){T=!0;y(m,function(a){c=a.map;g=c.id;if(a.enabled&&!a.error)if(!a.inited&&d)i(g)?l=j=!0:(b.push(g),e(g));else if(!a.inited&&a.fetched&&c.isDefine&&
(l=!0,!c.prefix))return f=!1});if(d&&b.length)return a=H("timeout","Load timeout for modules: "+b,null,b),a.contextName=h.contextName,B(a);f&&(q(M,function(a){if(!a.defined){var a=A(a,{}),d={};a&&(C(a,d,{}),y(d,D))}}),y(m,D));if((!d||j)&&l)if((w||ca)&&!U)U=setTimeout(function(){U=0;E()},50);T=!1}}function V(a){r(g(a[0],null,!0)).init(a[1],a[2])}function J(a){var a=a.currentTarget||a.srcElement,d=h.onScriptLoad;a.detachEvent&&!S?a.detachEvent("onreadystatechange",d):a.removeEventListener("load",d,
!1);d=h.onScriptError;a.detachEvent&&!S||a.removeEventListener("error",d,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}var k={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{}},m={},W={},F=[],n={},R={},N=1,O=1,M=[],T,X,h,Q,U;Q={require:function(a){return t(a)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports=n[a.map.id]={}},module:function(a){return a.module={id:a.map.id,uri:a.map.url,config:function(){return k.config&&k.config[a.map.id]||{}},exports:n[a.map.id]}}};
X=function(a){this.events=W[a.id]||{};this.map=a;this.shim=k.shim[a.id];this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};X.prototype={init:function(a,d,b,l){l=l||{};if(!this.inited){this.factory=d;if(b)this.on("error",b);else this.events.error&&(b=s(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.depMaps.rjsSkipMap=a.rjsSkipMap;this.errback=b;this.inited=!0;this.ignore=l.ignore;l.enabled||this.enabled?this.enable():this.check()}},defineDepById:function(a,
d){var b;q(this.depMaps,function(d,f){if(d.id===a)return b=f,!0});return this.defineDep(b,d)},defineDep:function(a,d){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=d)},fetch:function(){if(!this.fetched){this.fetched=!0;h.startTime=(new Date).getTime();var a=this.map;if(this.shim)t(this,!0)(this.shim.deps||[],s(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;R[a]||
(R[a]=!0,h.load(this.map.id,a))},check:function(a){if(this.enabled&&!this.enabling){var d=this.map.id,b=this.depExports,c=this.exports,f=this.factory,e;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(this.depCount<1&&!this.defined){if(x(f)){if(this.events.error)try{c=h.execCb(d,f,b,c)}catch(g){e=g}else c=h.execCb(d,f,b,c);if(this.map.isDefine)if((b=this.module)&&b.exports!==void 0&&b.exports!==this.exports)c=b.exports;else if(c===void 0&&this.usingExports)c=
this.exports;if(e)return e.requireMap=this.map,e.requireModules=[this.map.id],e.requireType="define",B(this.error=e)}else c=f;this.exports=c;if(this.map.isDefine&&!this.ignore&&(n[d]=c,j.onResourceLoad))j.onResourceLoad(h,this.map,this.depMaps);delete m[d];this.defined=!0;h.waitCount-=1;h.waitCount===0&&(M=[])}this.defining=!1;if(!a&&this.defined&&!this.defineEmitted)this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0}}else this.fetch()}},callPlugin:function(){var a=
this.map,d=a.id,b=g(a.prefix,null,!1,!0);p(b,"defined",s(this,function(b){var f=this.map.name,e=this.map.parentMap?this.map.parentMap.name:null;if(this.map.unnormalized){if(b.normalize&&(f=b.normalize(f,function(a){return c(a,e,!0)})||""),b=g(a.prefix+"!"+f,this.map.parentMap,!1,!0),p(b,"defined",s(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),b=m[b.id]){if(this.events.error)b.on("error",s(this,function(a){this.emit("error",a)}));b.enable()}}else f=s(this,function(a){this.init([],
function(){return a},null,{enabled:!0})}),f.error=s(this,function(a){this.inited=!0;this.error=a;a.requireModules=[d];y(m,function(a){a.map.id.indexOf(d+"_unnormalized")===0&&z(a.map.id)});B(a)}),f.fromText=function(a,d){var b=L;b&&(L=!1);r(g(a));j.exec(d);b&&(L=!0);h.completeLoad(a)},b.load(a.name,t(a.parentMap,!0,function(a,d){a.rjsSkipMap=!0;return h.require(a,d)}),f,k)}));h.enable(b,this);this.pluginMaps[b.id]=b},enable:function(){this.enabled=!0;if(!this.waitPushed)M.push(this),h.waitCount+=
1,this.waitPushed=!0;this.enabling=!0;q(this.depMaps,s(this,function(a,d){var b,c;if(typeof a==="string"){a=g(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.depMaps.rjsSkipMap);this.depMaps[d]=a;if(b=Q[a.id]){this.depExports[d]=b(this);return}this.depCount+=1;p(a,"defined",s(this,function(a){this.defineDep(d,a);this.check()}));this.errback&&p(a,"error",this.errback)}b=a.id;c=m[b];!Q[b]&&c&&!c.enabled&&h.enable(a,this)}));y(this.pluginMaps,s(this,function(a){var b=m[a.id];b&&!b.enabled&&
h.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){q(this.events[a],function(a){a(b)});a==="error"&&delete this.events[a]}};return h={config:k,contextName:b,registry:m,defined:n,urlFetched:R,waitCount:0,defQueue:F,Module:X,makeModuleMap:g,configure:function(a){a.baseUrl&&a.baseUrl.charAt(a.baseUrl.length-1)!=="/"&&(a.baseUrl+="/");var b=k.pkgs,c=k.shim,e=k.paths,f=k.map;K(k,a,!0);k.paths=K(e,a.paths,!0);if(a.map)k.map=
K(f||{},a.map,!0,!0);if(a.shim)y(a.shim,function(a,b){G(a)&&(a={deps:a});if(a.exports&&!a.exports.__buildReady)a.exports=h.makeShimExports(a.exports);c[b]=a}),k.shim=c;if(a.packages)q(a.packages,function(a){a=typeof a==="string"?{name:a}:a;b[a.name]={name:a.name,location:a.location||a.name,main:(a.main||"main").replace(ja,"").replace(ba,"")}}),k.pkgs=b;y(m,function(a,b){a.map=g(b)});if(a.deps||a.callback)h.require(a.deps||[],a.callback)},makeShimExports:function(a){var b;return typeof a==="string"?
(b=function(){return Z(a)},b.exports=a,b):function(){return a.apply(Y,arguments)}},requireDefined:function(a,b){var c=g(a,b,!1,!0).id;return n.hasOwnProperty(c)},requireSpecified:function(a,b){a=g(a,b,!1,!0).id;return n.hasOwnProperty(a)||m.hasOwnProperty(a)},require:function(a,d,c,e){var f;if(typeof a==="string"){if(x(d))return B(H("requireargs","Invalid require call"),c);if(j.get)return j.get(h,a,d);a=g(a,d,!1,!0);a=a.id;return!n.hasOwnProperty(a)?B(H("notloaded",'Module name "'+a+'" has not been loaded yet for context: '+
b)):n[a]}c&&!x(c)&&(e=c,c=void 0);d&&!x(d)&&(e=d,d=void 0);for(u();F.length;)if(f=F.shift(),f[0]===null)return B(H("mismatch","Mismatched anonymous define() module: "+f[f.length-1]));else V(f);r(g(null,e)).init(a,d,c,{enabled:!0});E();return h.require},undef:function(a){var b=g(a,null,!0),c=m[a];delete n[a];delete R[b.url];delete W[a];if(c){if(c.events.defined)W[a]=c.events;z(a)}},enable:function(a){m[a.id]&&r(a).enable()},completeLoad:function(a){var b=k.shim[a]||{},c=b.exports&&b.exports.exports,
e,f;for(u();F.length;){f=F.shift();if(f[0]===null){f[0]=a;if(e)break;e=!0}else f[0]===a&&(e=!0);V(f)}f=m[a];if(!e&&!n[a]&&f&&!f.inited)if(k.enforceDefine&&(!c||!Z(c)))if(i(a))return;else return B(H("nodefine","No define call for "+a,null,[a]));else V([a,b.deps||[],b.exports]);E()},toUrl:function(a,b){var e=a.lastIndexOf("."),g=null;e!==-1&&(g=a.substring(e,a.length),a=a.substring(0,e));return h.nameToUrl(c(a,b&&b.id,!0),g)},nameToUrl:function(a,b){var c,e,f,g,h,i;if(j.jsExtRegExp.test(a))g=a+(b||
"");else{c=k.paths;e=k.pkgs;g=a.split("/");for(h=g.length;h>0;h-=1)if(i=g.slice(0,h).join("/"),f=e[i],i=c[i]){G(i)&&(i=i[0]);g.splice(0,h,i);break}else if(f){c=a===f.name?f.location+"/"+f.main:f.location;g.splice(0,h,c);break}g=g.join("/")+(b||".js");g=(g.charAt(0)==="/"||g.match(/^[\w\+\.\-]+:/)?"":k.baseUrl)+g}return k.urlArgs?g+((g.indexOf("?")===-1?"?":"&")+k.urlArgs):g},load:function(a,b){j.load(h,a,b)},execCb:function(a,b,c,e){return b.apply(e,c)},onScriptLoad:function(a){if(a.type==="load"||
la.test((a.currentTarget||a.srcElement).readyState))I=null,a=J(a),h.completeLoad(a.id)},onScriptError:function(a){var b=J(a);if(!i(b.id))return B(H("scripterror","Script error",a,[b.id]))}}}};j({});aa(j);if(w&&(t=A.head=document.getElementsByTagName("head")[0],C=document.getElementsByTagName("base")[0]))t=A.head=C.parentNode;j.onError=function(b){throw b;};j.load=function(b,c,e){var i=b&&b.config||{},g;if(w)return g=i.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script"),
g.type=i.scriptType||"text/javascript",g.charset="utf-8",g.async=!0,g.setAttribute("data-requirecontext",b.contextName),g.setAttribute("data-requiremodule",c),g.attachEvent&&!(g.attachEvent.toString&&g.attachEvent.toString().indexOf("[native code")<0)&&!S?(L=!0,g.attachEvent("onreadystatechange",b.onScriptLoad)):(g.addEventListener("load",b.onScriptLoad,!1),g.addEventListener("error",b.onScriptError,!1)),g.src=e,E=g,C?t.insertBefore(g,C):t.appendChild(g),E=null,g;else ca&&(importScripts(e),b.completeLoad(c))};
w&&N(document.getElementsByTagName("script"),function(b){if(!t)t=b.parentNode;if(u=b.getAttribute("data-main")){if(!p.baseUrl)D=u.split("/"),da=D.pop(),ea=D.length?D.join("/")+"/":"./",p.baseUrl=ea,u=da;u=u.replace(ba,"");p.deps=p.deps?p.deps.concat(u):[u];return!0}});define=function(b,c,e){var i,g;typeof b!=="string"&&(e=c,c=b,b=null);G(c)||(e=c,c=[]);!c.length&&x(e)&&e.length&&(e.toString().replace(ha,"").replace(ia,function(b,e){c.push(e)}),c=(e.length===1?["require"]:["require","exports","module"]).concat(c));
if(L&&(i=E||ga()))b||(b=i.getAttribute("data-requiremodule")),g=z[i.getAttribute("data-requirecontext")];(g?g.defQueue:P).push([b,c,e])};define.amd={jQuery:!0};j.exec=function(b){return eval(b)};j(p)}})(this);

57
thirdparty/esprima-master/assets/style.css vendored Executable file
View file

@ -0,0 +1,57 @@
a:hover, a:active {
text-decoration: underline;
}
.top-bar a, .tabs a {
text-decoration: none;
}
div.row.copyright {
margin-top: 44px;
padding-top: 11px;
border-top: 1px solid #ddd;
}
.code {
border-left: 3px solid #ddd;
margin: 5px 3px 8px 15px;
padding: 0 0 0 8px;
}
.textviewContainer {
background-color: white;
}
.textviewContainer, .contentassist {
font-family: 'Droid Sans Mono', Menlo, Consolas, 'Courier New', Courier, monospace, sans-serif;
font-size: 10pt;
}
.contentassist {
width: 400px;
}
pre#editor {
border: 1px solid #ccc;
}
div#info {
margin-top: 22px;
}
.textviewTooltip {
color: black;
background-color: #ffffcc;
border-color: #aaa;
}
.annotationRange.readOccurrence {
background-color: #ffffcc;
border: none;
}
.annotationRange.writeOccurrence {
background-color: #ffffcc;
border: 1px solid #ffcc99;
margin: -1px;
border-radius: 4px;
}

127
thirdparty/esprima-master/bin/esparse.js vendored Executable file
View file

@ -0,0 +1,127 @@
#!/usr/bin/env node
/*
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*jslint sloppy:true node:true rhino:true */
var fs, esprima, fname, content, options, syntax;
if (typeof require === 'function') {
fs = require('fs');
esprima = require('esprima');
} else if (typeof load === 'function') {
try {
load('esprima.js');
} catch (e) {
load('../esprima.js');
}
}
// Shims to Node.js objects when running under Rhino.
if (typeof console === 'undefined' && typeof process === 'undefined') {
console = { log: print };
fs = { readFileSync: readFile };
process = { argv: arguments, exit: quit };
process.argv.unshift('esparse.js');
process.argv.unshift('rhino');
}
function showUsage() {
console.log('Usage:');
console.log(' esparse [options] file.js');
console.log();
console.log('Available options:');
console.log();
console.log(' --comment Gather all line and block comments in an array');
console.log(' --loc Include line-column location info for each syntax node');
console.log(' --range Include index-based range for each syntax node');
console.log(' --raw Display the raw value of literals');
console.log(' --tokens List all tokens in an array');
console.log(' --tolerant Tolerate errors on a best-effort basis (experimental)');
console.log(' -v, --version Shows program version');
console.log();
process.exit(1);
}
if (process.argv.length <= 2) {
showUsage();
}
options = {};
process.argv.splice(2).forEach(function (entry) {
if (entry === '-h' || entry === '--help') {
showUsage();
} else if (entry === '-v' || entry === '--version') {
console.log('ECMAScript Parser (using Esprima version', esprima.version, ')');
console.log();
process.exit(0);
} else if (entry === '--comment') {
options.comment = true;
} else if (entry === '--loc') {
options.loc = true;
} else if (entry === '--range') {
options.range = true;
} else if (entry === '--raw') {
options.raw = true;
} else if (entry === '--tokens') {
options.tokens = true;
} else if (entry === '--tolerant') {
options.tolerant = true;
} else if (entry.slice(0, 2) === '--') {
console.log('Error: unknown option ' + entry + '.');
process.exit(1);
} else if (typeof fname === 'string') {
console.log('Error: more than one input file.');
process.exit(1);
} else {
fname = entry;
}
});
if (typeof fname !== 'string') {
console.log('Error: no input file.');
process.exit(1);
}
// Special handling for regular expression literal since we need to
// convert it to a string literal, otherwise it will be decoded
// as object "{}" and the regular expression would be lost.
function adjustRegexLiteral(key, value) {
if (key === 'value' && value instanceof RegExp) {
value = value.toString();
}
return value;
}
try {
content = fs.readFileSync(fname, 'utf-8');
syntax = esprima.parse(content, options);
console.log(JSON.stringify(syntax, adjustRegexLiteral, 4));
} catch (e) {
console.log('Error: ' + e.message);
process.exit(1);
}

199
thirdparty/esprima-master/bin/esvalidate.js vendored Executable file
View file

@ -0,0 +1,199 @@
#!/usr/bin/env node
/*
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*jslint sloppy:true plusplus:true node:true rhino:true */
/*global phantom:true */
var fs, system, esprima, options, fnames, count;
if (typeof esprima === 'undefined') {
// PhantomJS can only require() relative files
if (typeof phantom === 'object') {
fs = require('fs');
system = require('system');
esprima = require('./esprima');
} else if (typeof require === 'function') {
fs = require('fs');
esprima = require('esprima');
} else if (typeof load === 'function') {
try {
load('esprima.js');
} catch (e) {
load('../esprima.js');
}
}
}
// Shims to Node.js objects when running under PhantomJS 1.7+.
if (typeof phantom === 'object') {
fs.readFileSync = fs.read;
process = {
argv: [].slice.call(system.args),
exit: phantom.exit
};
process.argv.unshift('phantomjs');
}
// Shims to Node.js objects when running under Rhino.
if (typeof console === 'undefined' && typeof process === 'undefined') {
console = { log: print };
fs = { readFileSync: readFile };
process = { argv: arguments, exit: quit };
process.argv.unshift('esvalidate.js');
process.argv.unshift('rhino');
}
function showUsage() {
console.log('Usage:');
console.log(' esvalidate [options] file.js');
console.log();
console.log('Available options:');
console.log();
console.log(' --format=type Set the report format, plain (default) or junit');
console.log(' -v, --version Print program version');
console.log();
process.exit(1);
}
if (process.argv.length <= 2) {
showUsage();
}
options = {
format: 'plain'
};
fnames = [];
process.argv.splice(2).forEach(function (entry) {
if (entry === '-h' || entry === '--help') {
showUsage();
} else if (entry === '-v' || entry === '--version') {
console.log('ECMAScript Validator (using Esprima version', esprima.version, ')');
console.log();
process.exit(0);
} else if (entry.slice(0, 9) === '--format=') {
options.format = entry.slice(9);
if (options.format !== 'plain' && options.format !== 'junit') {
console.log('Error: unknown report format ' + options.format + '.');
process.exit(1);
}
} else if (entry.slice(0, 2) === '--') {
console.log('Error: unknown option ' + entry + '.');
process.exit(1);
} else {
fnames.push(entry);
}
});
if (fnames.length === 0) {
console.log('Error: no input file.');
process.exit(1);
}
if (options.format === 'junit') {
console.log('<?xml version="1.0" encoding="UTF-8"?>');
console.log('<testsuites>');
}
count = 0;
fnames.forEach(function (fname) {
var content, timestamp, syntax, name;
try {
content = fs.readFileSync(fname, 'utf-8');
if (content[0] === '#' && content[1] === '!') {
content = '//' + content.substr(2, content.length);
}
timestamp = Date.now();
syntax = esprima.parse(content, { tolerant: true });
if (options.format === 'junit') {
name = fname;
if (name.lastIndexOf('/') >= 0) {
name = name.slice(name.lastIndexOf('/') + 1);
}
console.log('<testsuite name="' + fname + '" errors="0" ' +
' failures="' + syntax.errors.length + '" ' +
' tests="' + syntax.errors.length + '" ' +
' time="' + Math.round((Date.now() - timestamp) / 1000) +
'">');
syntax.errors.forEach(function (error) {
var msg = error.message;
msg = msg.replace(/^Line\ [0-9]*\:\ /, '');
console.log(' <testcase name="Line ' + error.lineNumber + ': ' + msg + '" ' +
' time="0">');
console.log(' <error type="SyntaxError" message="' + error.message + '">' +
error.message + '(' + name + ':' + error.lineNumber + ')' +
'</error>');
console.log(' </testcase>');
});
console.log('</testsuite>');
} else if (options.format === 'plain') {
syntax.errors.forEach(function (error) {
var msg = error.message;
msg = msg.replace(/^Line\ [0-9]*\:\ /, '');
msg = fname + ':' + error.lineNumber + ': ' + msg;
console.log(msg);
++count;
});
}
} catch (e) {
++count;
if (options.format === 'junit') {
console.log('<testsuite name="' + fname + '" errors="1" failures="0" tests="1" ' +
' time="' + Math.round((Date.now() - timestamp) / 1000) + '">');
console.log(' <testcase name="' + e.message + '" ' + ' time="0">');
console.log(' <error type="ParseError" message="' + e.message + '">' +
e.message + '(' + fname + ((e.lineNumber) ? ':' + e.lineNumber : '') +
')</error>');
console.log(' </testcase>');
console.log('</testsuite>');
} else {
console.log('Error: ' + e.message);
}
}
});
if (options.format === 'junit') {
console.log('</testsuites>');
}
if (count > 0) {
process.exit(1);
}
if (count === 0 && typeof phantom === 'object') {
process.exit(0);
}

29
thirdparty/esprima-master/bower.json vendored Executable file
View file

@ -0,0 +1,29 @@
{
"name": "esprima",
"version": "2.0.0-dev",
"main": "./esprima.js",
"scripts": [
"esprima.js"
],
"dependencies": {},
"ignore": [
"examples",
"test",
"tools"
],
"repository": {
"type": "git",
"url": "http://github.com/ariya/esprima.git"
},
"licenses": [{
"type": "BSD",
"url": "http://github.com/ariya/esprima/raw/master/LICENSE.BSD"
}],
"keywords": [
"ast",
"ecmascript",
"javascript",
"parser",
"syntax"
]
}

24
thirdparty/esprima-master/component.json vendored Executable file
View file

@ -0,0 +1,24 @@
{
"name": "esprima",
"version": "2.0.0-dev",
"main": "./esprima.js",
"scripts": [
"esprima.js"
],
"dependencies": {},
"repository": {
"type": "git",
"url": "http://github.com/ariya/esprima.git"
},
"licenses": [{
"type": "BSD",
"url": "http://github.com/ariya/esprima/raw/master/LICENSE.BSD"
}],
"keywords": [
"ast",
"ecmascript",
"javascript",
"parser",
"syntax"
]
}

3974
thirdparty/esprima-master/esprima.js vendored Executable file

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,106 @@
// Usage: node detectnestedternary.js /path/to/some/directory
// For more details, please read http://esprima.org/doc/#nestedternary
/*jslint node:true sloppy:true plusplus:true */
var fs = require('fs'),
esprima = require('../esprima'),
dirname = process.argv[2];
// Executes visitor on the object and its children (recursively).
function traverse(object, visitor) {
var key, child;
visitor.call(null, object);
for (key in object) {
if (object.hasOwnProperty(key)) {
child = object[key];
if (typeof child === 'object' && child !== null) {
traverse(child, visitor);
}
}
}
}
// http://stackoverflow.com/q/5827612/
function walk(dir, done) {
var results = [];
fs.readdir(dir, function (err, list) {
if (err) {
return done(err);
}
var i = 0;
(function next() {
var file = list[i++];
if (!file) {
return done(null, results);
}
file = dir + '/' + file;
fs.stat(file, function (err, stat) {
if (stat && stat.isDirectory()) {
walk(file, function (err, res) {
results = results.concat(res);
next();
});
} else {
results.push(file);
next();
}
});
}());
});
}
walk(dirname, function (err, results) {
if (err) {
console.log('Error', err);
return;
}
results.forEach(function (filename) {
var shortname, first, content, syntax;
shortname = filename;
first = true;
if (shortname.substr(0, dirname.length) === dirname) {
shortname = shortname.substr(dirname.length + 1, shortname.length);
}
function report(node, problem) {
if (first === true) {
console.log(shortname + ': ');
first = false;
}
console.log(' Line', node.loc.start.line, ':', problem);
}
function checkConditional(node) {
var condition;
if (node.consequent.type === 'ConditionalExpression' ||
node.alternate.type === 'ConditionalExpression') {
condition = content.substring(node.test.range[0], node.test.range[1]);
if (condition.length > 20) {
condition = condition.substring(0, 20) + '...';
}
condition = '"' + condition + '"';
report(node, 'Nested ternary for ' + condition);
}
}
try {
content = fs.readFileSync(filename, 'utf-8');
syntax = esprima.parse(content, { tolerant: true, loc: true, range: true });
traverse(syntax, function (node) {
if (node.type === 'ConditionalExpression') {
checkConditional(node);
}
});
} catch (e) {
}
});
});

View file

@ -0,0 +1,173 @@
// Usage: node findbooleantrap.js /path/to/some/directory
// For more details, please read http://esprima.org/doc/#booleantrap.
/*jslint node:true sloppy:true plusplus:true */
var fs = require('fs'),
esprima = require('../esprima'),
dirname = process.argv[2],
doubleNegativeList = [];
// Black-list of terms with double-negative meaning.
doubleNegativeList = [
'hidden',
'caseinsensitive',
'disabled'
];
// Executes visitor on the object and its children (recursively).
function traverse(object, visitor) {
var key, child;
if (visitor.call(null, object) === false) {
return;
}
for (key in object) {
if (object.hasOwnProperty(key)) {
child = object[key];
if (typeof child === 'object' && child !== null) {
traverse(child, visitor);
}
}
}
}
// http://stackoverflow.com/q/5827612/
function walk(dir, done) {
var results = [];
fs.readdir(dir, function (err, list) {
if (err) {
return done(err);
}
var i = 0;
(function next() {
var file = list[i++];
if (!file) {
return done(null, results);
}
file = dir + '/' + file;
fs.stat(file, function (err, stat) {
if (stat && stat.isDirectory()) {
walk(file, function (err, res) {
results = results.concat(res);
next();
});
} else {
results.push(file);
next();
}
});
}());
});
}
walk(dirname, function (err, results) {
if (err) {
console.log('Error', err);
return;
}
results.forEach(function (filename) {
var shortname, first, content, syntax;
shortname = filename;
first = true;
if (shortname.substr(0, dirname.length) === dirname) {
shortname = shortname.substr(dirname.length + 1, shortname.length);
}
function getFunctionName(node) {
if (node.callee.type === 'Identifier') {
return node.callee.name;
}
if (node.callee.type === 'MemberExpression') {
return node.callee.property.name;
}
}
function report(node, problem) {
if (first === true) {
console.log(shortname + ': ');
first = false;
}
console.log(' Line', node.loc.start.line, 'in function',
getFunctionName(node) + ':', problem);
}
function checkSingleArgument(node) {
var args = node['arguments'],
functionName = getFunctionName(node);
if ((args.length !== 1) || (typeof args[0].value !== 'boolean')) {
return;
}
// Check if the method is a setter, i.e. starts with 'set',
// e.g. 'setEnabled(false)'.
if (functionName.substr(0, 3) !== 'set') {
report(node, 'Boolean literal with a non-setter function');
}
// Does it contain a term with double-negative meaning?
doubleNegativeList.forEach(function (term) {
if (functionName.toLowerCase().indexOf(term.toLowerCase()) >= 0) {
report(node, 'Boolean literal with confusing double-negative');
}
});
}
function checkMultipleArguments(node) {
var args = node['arguments'],
literalCount = 0;
args.forEach(function (arg) {
if (typeof arg.value === 'boolean') {
literalCount++;
}
});
// At least two arguments must be Boolean literals.
if (literalCount >= 2) {
// Check for two different Boolean literals in one call.
if (literalCount === 2 && args.length === 2) {
if (args[0].value !== args[1].value) {
report(node, 'Confusing true vs false');
return;
}
}
report(node, 'Multiple Boolean literals');
}
}
function checkLastArgument(node) {
var args = node['arguments'];
if (args.length < 2) {
return;
}
if (typeof args[args.length - 1].value === 'boolean') {
report(node, 'Ambiguous Boolean literal as the last argument');
}
}
try {
content = fs.readFileSync(filename, 'utf-8');
syntax = esprima.parse(content, { tolerant: true, loc: true });
traverse(syntax, function (node) {
if (node.type === 'CallExpression') {
checkSingleArgument(node);
checkLastArgument(node);
checkMultipleArguments(node);
}
});
} catch (e) {
}
});
});

View file

@ -0,0 +1,33 @@
/*jslint node:true */
var fs = require('fs'),
esprima = require('../esprima'),
files = process.argv.splice(2),
histogram,
type;
histogram = {
Boolean: 0,
Identifier: 0,
Keyword: 0,
Null: 0,
Numeric: 0,
Punctuator: 0,
RegularExpression: 0,
String: 0
};
files.forEach(function (filename) {
'use strict';
var content = fs.readFileSync(filename, 'utf-8'),
tokens = esprima.parse(content, { tokens: true }).tokens;
tokens.forEach(function (token) {
histogram[token.type] += 1;
});
});
for (type in histogram) {
if (histogram.hasOwnProperty(type)) {
console.log(type, histogram[type]);
}
}

138
thirdparty/esprima-master/index.html vendored Executable file
View file

@ -0,0 +1,138 @@
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<title>Esprima</title>
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" type="text/css" href="assets/style.css"/>
<link rel="stylesheet" href="assets/foundation/foundation.min.css">
</head>
<body>
<!-- Navigation bar -->
<div class="row">
<div class="twelve columns">
<nav class="top-bar">
<ul>
<li class="name">
<h1><a href="#">Esprima</a></h1>
</li>
</ul>
<section>
<ul class="right">
<li class="divider show-for-medium-and-up"></li>
<li class="has-dropdown">
<a href="demo/index.html">Demo</a>
<ul class="dropdown">
<li><label>Static Analysis</label></li>
<li><a href="demo/parse.html">Online Parsing</a></li>
<li><a href="demo/validate.html">Syntax Validator</a></li>
<li><a href="demo/precedence.html">Operator Precedence</a></li>
<li><a href="demo/collector.html">Regex Collector</a></li>
<li><label>Dynamic Tracing</label></li>
<li><a href="demo/functiontrace.html">Function Instrumentation</a></li>
<li><label>Code Transformation</label></li>
<li><a href="demo/rewrite.html">Source Rewrite</a></li>
<li><a href="demo/minify.html">Minifiy &amp; Obfuscate</a></li>
<li><label>Editing Tools</label></li>
<li><a href="demo/highlight.html">Identifier Highlight</a></li>
<li><a href="demo/rename.html">Rename Refactoring</a></li>
<li><a href="demo/autocomplete.html">Autocomplete</a></li>
</ul>
</li>
<li class="has-dropdown">
<a href="#">Project</a>
<ul class="dropdown">
<li><a href="http://github.com/ariya/esprima">Git Repository</a></li>
<li><a href="https://travis-ci.org/ariya/esprima">Continuous Integration</a></li>
<li><a href="http://groups.google.com/group/esprima">Mailing List</a></li>
<li><a href="http://issues.esprima.org/">Issue Tracker</a></li>
<li class="divider"></li>
<li><label>QA</label></li>
<li><a href="test/index.html">Unit Tests</a></li>
<li><a href="test/benchmarks.html">Benchmarks Suite</a></li>
<li><a href="test/compat.html">Compatibility Tests</a></li>
<li><a href="test/compare.html">Speed Comparison</a></li>
<li><a href="test/module.html">Module Loading</a></li>
<li><a href="test/coverage.html">Coverage Analysis</a></li>
</ul>
</li>
<li><a href="doc/index.html">Documentation</a></li>
</ul>
</section>
</nav>
</div>
</div>
<!-- Title and subtitle -->
<div class="row">
<div class="twelve columns">
<h3 class="subheader"><strong>ECMAScript</strong> parsing infrastructure for multipurpose analysis</h3>
</div>
</div>
<!-- Main content -->
<div class="row">
<div class="eight columns">
<p><strong>Esprima</strong> is a high performance, standard-compliant
<a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript</a> parser written in ECMAScript (also popularly known as
<a href="http://en.wikipedia.org/wiki/JavaScript">JavaScript</a>).</p>
<div class="row">
<div class="twelve columns">
<h4>Features</h4>
<ul class="square">
<li>Full support for ECMAScript 5.1 (<a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262</a>)</li>
<li>Sensible <a href="doc/index.html#ast">syntax tree format</a>, compatible with Mozilla <a href="https://developer.mozilla.org/en/SpiderMonkey/Parser_API">Parser AST</a></li>
<li>Optional tracking of syntax node location (index-based and line-column)</li>
<li>Heavily tested (&gt; 700 <a href="http://esprima.org/test/">tests</a> with <a href="http://esprima.org/test/coverage.html">full code coverage</a>)</li>
<li><a href="doc/es6.html">Partial support</a> for ECMAScript 6</li>
</ul>
<p></p>
<p>Esprima serves as an important <strong>building block</strong> for some JavaScript language tools,
from <a href="demo/functiontrace.html">code instrumentation</a> to <a href="demo/autocomplete.html">editor autocompletion</a>.</p>
<a href="demo/autocomplete.html"><img src="assets/images/autocomplete.png" width="562" height="295" alt="Autocomplete"></a></p>
</div>
</div>
</div>
<div class="four columns">
<div class="panel">
<p>Once the full syntax tree is obtained, various <strong>static code analysis</strong>
can be applied to give an insight to the code:
<a href="demo/parse.html">syntax visualization</a>,
<a href="demo/validate.html">code validation</a>,
<a href="demo/autocomplete.html">editing autocomplete</a> (with type inferencing)
and <a href="demo/index.html">many others</a>.</p>
</div>
<div class="panel">
<p>Regenerating the code from the syntax tree permits a few different types of <strong>code transformation</strong>,
from a simple <a href="demo/rewrite.html">rewriting</a> (with specific formatting) to
a more complicated <a href="demo/minify.html">minification</a>.</p>
</div>
<p>Esprima runs on many popular web browsers, as well as other ECMAScript platforms such as
<a href="http://www.mozilla.org/rhino">Rhino</a>,
<a href="http://openjdk.java.net/projects/nashorn/">Nashorn</a>, and
<a href="https://npmjs.org/package/esprima">Node.js</a>. It is distributed under the
<a href="https://github.com/ariya/esprima/blob/master/LICENSE.BSD">BSD license</a>.</p>
</div>
</div>
<!-- Footer -->
<div class="row copyright">
<div class="six columns">
<p>Esprima is created and mantained by <a href="http://ariya.ofilabs.com/about">Ariya Hidayat</a>.</p>
</div>
<div class="six columns">
<ul class="link-list right">
<li><a href="http://twitter.com/esprima">@Esprima</a></li>
<li><a href="https://github.com/ariya/esprima">GitHub</a></li>
</ul>
</div>
</div>
</body>
</html>

83
thirdparty/esprima-master/package.json vendored Executable file
View file

@ -0,0 +1,83 @@
{
"name": "esprima",
"description": "ECMAScript parsing infrastructure for multipurpose analysis",
"homepage": "http://esprima.org",
"main": "esprima.js",
"bin": {
"esparse": "./bin/esparse.js",
"esvalidate": "./bin/esvalidate.js"
},
"version": "2.0.0-dev",
"files": [
"bin",
"test/run.js",
"test/runner.js",
"test/test.js",
"test/compat.js",
"test/reflect.js",
"esprima.js"
],
"engines": {
"node": ">=0.4.0"
},
"author": {
"name": "Ariya Hidayat",
"email": "ariya.hidayat@gmail.com"
},
"maintainers": [{
"name": "Ariya Hidayat",
"email": "ariya.hidayat@gmail.com",
"web": "http://ariya.ofilabs.com"
}],
"repository": {
"type": "git",
"url": "http://github.com/ariya/esprima.git"
},
"bugs": {
"url": "http://issues.esprima.org"
},
"licenses": [{
"type": "BSD",
"url": "http://github.com/ariya/esprima/raw/master/LICENSE.BSD"
}],
"devDependencies": {
"jslint": "~0.1.9",
"eslint": "~0.4.3",
"jscs": "~1.2.4",
"istanbul": "~0.2.6",
"complexity-report": "~0.6.1",
"regenerate": "~0.5.4",
"unicode-6.3.0": "~0.1.0",
"json-diff": "~0.3.1",
"optimist": "~0.6.0"
},
"keywords": [
"ast",
"ecmascript",
"javascript",
"parser",
"syntax"
],
"scripts": {
"generate-regex": "node tools/generate-identifier-regex.js",
"test": "npm run-script lint && node test/run.js && npm run-script coverage && npm run-script complexity",
"lint": "npm run-script check-version && npm run-script eslint && npm run-script jscs && npm run-script jslint",
"check-version": "node tools/check-version.js",
"eslint": "node node_modules/eslint/bin/eslint.js esprima.js",
"jscs": "node node_modules/.bin/jscs esprima.js",
"jslint": "node node_modules/jslint/bin/jslint.js esprima.js",
"coverage": "npm run-script analyze-coverage && npm run-script check-coverage",
"analyze-coverage": "node node_modules/istanbul/lib/cli.js cover test/runner.js",
"check-coverage": "node node_modules/istanbul/lib/cli.js check-coverage --statement 100 --branch 100 --function 100",
"complexity": "npm run-script analyze-complexity && npm run-script check-complexity",
"analyze-complexity": "node tools/list-complexity.js",
"check-complexity": "node node_modules/complexity-report/src/cli.js --maxcc 14 --silent -l -w esprima.js",
"benchmark": "node test/benchmarks.js",
"benchmark-quick": "node test/benchmarks.js quick"
}
}

View file

@ -0,0 +1,57 @@
#!/usr/bin/env node
'use strict';
var fs = require('fs');
function findCanonicalVersion() {
var matcher, lines, version;
matcher = /exports\.version\s+=\s+\'([0-9\.\-a-zA-Z]+)\'/;
lines = fs.readFileSync('esprima.js', 'utf-8').split('\n');
lines.forEach(function (line) {
if (matcher.test(line)) {
version = matcher.exec(line)[1];
}
});
return version;
}
function ensureVersion(manifestFile, expectedVersion) {
var matcher, lines, version;
console.log('Checking', manifestFile, '...');
matcher = /"version"\s*\:\s*"([0-9\.\-a-zA-Z]+)"/;
lines = fs.readFileSync(manifestFile, 'utf-8').split('\n');
lines.forEach(function (line) {
if (matcher.test(line)) {
version = matcher.exec(line)[1];
}
});
if (expectedVersion !== version) {
console.log('ERROR: Wrong version for', manifestFile);
console.log('Expected:', expectedVersion);
console.log(' Actual:', version);
process.exit(1);
}
}
function checkVersion() {
var version;
console.log('Getting the canonical library version...');
version = findCanonicalVersion();
if (typeof version !== 'string') {
console.log('ERROR: Can not get version number!', typeof version);
process.exit(1);
}
console.log('Library version is', version);
ensureVersion('package.json', version);
ensureVersion('bower.json', version);
ensureVersion('component.json', version);
}
checkVersion();

View file

@ -0,0 +1,52 @@
// Based on https://gist.github.com/mathiasbynens/6334847 by @mathias
var regenerate = require('regenerate');
// Which Unicode version should be used?
var version = '6.3.0'; // note: also update `package.json` when this changes
// Shorthand function
var get = function(what) {
return require('unicode-' + version + '/' + what + '/code-points');
};
// Unicode categories needed to construct the ES5 regex
var Lu = get('categories/Lu');
var Ll = get('categories/Ll');
var Lt = get('categories/Lt');
var Lm = get('categories/Lm');
var Lo = get('categories/Lo');
var Nl = get('categories/Nl');
var Mn = get('categories/Mn');
var Mc = get('categories/Mc');
var Nd = get('categories/Nd');
var Pc = get('categories/Pc');
var generateES5Regex = function() { // ES 5.1
// http://mathiasbynens.be/notes/javascript-identifiers#valid-identifier-names
var identifierStart = regenerate('$', '_')
.add(Lu, Ll, Lt, Lm, Lo, Nl)
.removeRange(0x010000, 0x10FFFF) // remove astral symbols
.removeRange(0x0, 0x7F); // remove ASCII symbols (Esprima-specific)
var identifierStartCodePoints = identifierStart.toArray();
var identifierPart = regenerate(identifierStartCodePoints)
.add('\u200C', '\u200D', Mn, Mc, Nd, Pc)
.removeRange(0x010000, 0x10FFFF) // remove astral symbols
.removeRange(0x0, 0x7F); // remove ASCII symbols (Esprima-specific)
return {
'NonAsciiIdentifierStart': identifierStart.toString(),
'NonAsciiIdentifierPart': identifierPart.toString()
};
};
var result = generateES5Regex();
console.log(
'// ECMAScript 5.1/Unicode v%s NonAsciiIdentifierStart:\n\n%s\n',
version,
result.NonAsciiIdentifierStart
);
console.log(
'// ECMAScript 5.1/Unicode v%s NonAsciiIdentifierPart:\n\n%s',
version,
result.NonAsciiIdentifierPart
);

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,18 @@
var cr = require('complexity-report'),
content = require('fs').readFileSync('esprima.js', 'utf-8'),
opt = { logicalor: false, switchcase: false },
list = [];
cr.run(content, opt).functions.forEach(function (entry) {
var name = (entry.name === '<anonymous>') ? (':' + entry.line) : entry.name;
list.push({ name: name, value: entry.complexity.cyclomatic });
});
list.sort(function (x, y) {
return y.value - x.value;
});
console.log('Most cyclomatic-complex functions:');
list.slice(0, 6).forEach(function (entry) {
console.log(' ', entry.name, entry.value);
});

View file

@ -0,0 +1,14 @@
#!/bin/bash
if [ `command -v istanbul` ]; then
REVISION=`git log -1 --pretty=%h`
DATE=`git log -1 --pretty=%cD | cut -c 6-16`
echo "Running coverage analysis..."
istanbul cover test/runner.js
grep -v 'class="path' coverage/lcov-report/esprima/esprima.js.html | grep -v "class='meta" > test/esprima.js.html
else
echo "Please install Istanbul first!"
fi

14
thirdparty/estraverse-master/.gitignore vendored Executable file
View file

@ -0,0 +1,14 @@
# Emacs
*~
\#*\#
# Node modules
node_modules/
# Cover
.coverage_data/
cover_html/
coverage/
npm-debug.log
.vimrc.local

16
thirdparty/estraverse-master/.jshintrc vendored Executable file
View file

@ -0,0 +1,16 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"eqnull": true,
"latedef": true,
"noarg": true,
"noempty": true,
"quotmark": "single",
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"node": true
}

15
thirdparty/estraverse-master/.npmignore vendored Executable file
View file

@ -0,0 +1,15 @@
npm-debug.log
.DS_Store
.vimrc.local
t.js
.travis.yml
.npmignore
/tmp/
/.git/
/node_modules/
/tools/
/test/
/build/
/cover_html/
/coverage/
/.coverage_data/

9
thirdparty/estraverse-master/.travis.yml vendored Executable file
View file

@ -0,0 +1,9 @@
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.11"
matrix:
allow_failures:
- node_js: "0.11"

19
thirdparty/estraverse-master/LICENSE.BSD vendored Executable file
View file

@ -0,0 +1,19 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

70
thirdparty/estraverse-master/README.md vendored Executable file
View file

@ -0,0 +1,70 @@
### Estraverse [![Build Status](https://secure.travis-ci.org/Constellation/estraverse.png)](http://travis-ci.org/Constellation/estraverse)
Estraverse ([estraverse](http://github.com/Constellation/estraverse)) is
[ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
traversal functions from [esmangle project](http://github.com/Constellation/esmangle).
### Example Usage
The following code will output all variables declared at the root of a file.
```javascript
estraverse.traverse(ast, {
enter: function (node, parent) {
if (node.type == 'FunctionExpression' || node.type == 'FunctionDeclaration')
return estraverse.VisitorOption.Skip;
},
leave: function (node, parent) {
if (node.type == 'VariableDeclarator')
console.log(node.id.name);
}
});
```
We can use `this.skip` and `this.break` functions instead of using Skip and Break.
```javascript
estraverse.traverse(ast, {
enter: function (node) {
this.break();
}
});
```
And estraverse provides `estraverse.replace` function. When returning node from `enter`/`leave`, current node is replaced with it.
```javascript
result = estraverse.replace(tree, {
enter: function (node) {
// Replace it with replaced.
if (node.type === 'Literal')
return replaced;
}
});
```
### License
Copyright (C) 2012-2013 [Yusuke Suzuki](http://github.com/Constellation)
(twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

689
thirdparty/estraverse-master/estraverse.js vendored Executable file
View file

@ -0,0 +1,689 @@
/*
Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com>
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*jslint vars:false, bitwise:true*/
/*jshint indent:4*/
/*global exports:true, define:true*/
(function (root, factory) {
'use strict';
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
// and plain browser loading,
if (typeof define === 'function' && define.amd) {
define(['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.estraverse = {}));
}
}(this, function (exports) {
'use strict';
var Syntax,
isArray,
VisitorOption,
VisitorKeys,
BREAK,
SKIP;
Syntax = {
AssignmentExpression: 'AssignmentExpression',
ArrayExpression: 'ArrayExpression',
ArrayPattern: 'ArrayPattern',
ArrowFunctionExpression: 'ArrowFunctionExpression',
BlockStatement: 'BlockStatement',
BinaryExpression: 'BinaryExpression',
BreakStatement: 'BreakStatement',
CallExpression: 'CallExpression',
CatchClause: 'CatchClause',
ClassBody: 'ClassBody',
ClassDeclaration: 'ClassDeclaration',
ClassExpression: 'ClassExpression',
ConditionalExpression: 'ConditionalExpression',
ContinueStatement: 'ContinueStatement',
DebuggerStatement: 'DebuggerStatement',
DirectiveStatement: 'DirectiveStatement',
DoWhileStatement: 'DoWhileStatement',
EmptyStatement: 'EmptyStatement',
ExpressionStatement: 'ExpressionStatement',
ForStatement: 'ForStatement',
ForInStatement: 'ForInStatement',
FunctionDeclaration: 'FunctionDeclaration',
FunctionExpression: 'FunctionExpression',
Identifier: 'Identifier',
IfStatement: 'IfStatement',
Literal: 'Literal',
LabeledStatement: 'LabeledStatement',
LogicalExpression: 'LogicalExpression',
MemberExpression: 'MemberExpression',
MethodDefinition: 'MethodDefinition',
NewExpression: 'NewExpression',
ObjectExpression: 'ObjectExpression',
ObjectPattern: 'ObjectPattern',
Program: 'Program',
Property: 'Property',
ReturnStatement: 'ReturnStatement',
SequenceExpression: 'SequenceExpression',
SwitchStatement: 'SwitchStatement',
SwitchCase: 'SwitchCase',
ThisExpression: 'ThisExpression',
ThrowStatement: 'ThrowStatement',
TryStatement: 'TryStatement',
UnaryExpression: 'UnaryExpression',
UpdateExpression: 'UpdateExpression',
VariableDeclaration: 'VariableDeclaration',
VariableDeclarator: 'VariableDeclarator',
WhileStatement: 'WhileStatement',
WithStatement: 'WithStatement',
YieldExpression: 'YieldExpression'
};
function ignoreJSHintError() { }
isArray = Array.isArray;
if (!isArray) {
isArray = function isArray(array) {
return Object.prototype.toString.call(array) === '[object Array]';
};
}
function deepCopy(obj) {
var ret = {}, key, val;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
val = obj[key];
if (typeof val === 'object' && val !== null) {
ret[key] = deepCopy(val);
} else {
ret[key] = val;
}
}
}
return ret;
}
function shallowCopy(obj) {
var ret = {}, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
ret[key] = obj[key];
}
}
return ret;
}
ignoreJSHintError(shallowCopy);
// based on LLVM libc++ upper_bound / lower_bound
// MIT License
function upperBound(array, func) {
var diff, len, i, current;
len = array.length;
i = 0;
while (len) {
diff = len >>> 1;
current = i + diff;
if (func(array[current])) {
len = diff;
} else {
i = current + 1;
len -= diff + 1;
}
}
return i;
}
function lowerBound(array, func) {
var diff, len, i, current;
len = array.length;
i = 0;
while (len) {
diff = len >>> 1;
current = i + diff;
if (func(array[current])) {
i = current + 1;
len -= diff + 1;
} else {
len = diff;
}
}
return i;
}
ignoreJSHintError(lowerBound);
VisitorKeys = {
AssignmentExpression: ['left', 'right'],
ArrayExpression: ['elements'],
ArrayPattern: ['elements'],
ArrowFunctionExpression: ['params', 'defaults', 'rest', 'body'],
BlockStatement: ['body'],
BinaryExpression: ['left', 'right'],
BreakStatement: ['label'],
CallExpression: ['callee', 'arguments'],
CatchClause: ['param', 'body'],
ClassBody: ['body'],
ClassDeclaration: ['id', 'body', 'superClass'],
ClassExpression: ['id', 'body', 'superClass'],
ConditionalExpression: ['test', 'consequent', 'alternate'],
ContinueStatement: ['label'],
DebuggerStatement: [],
DirectiveStatement: [],
DoWhileStatement: ['body', 'test'],
EmptyStatement: [],
ExpressionStatement: ['expression'],
ForStatement: ['init', 'test', 'update', 'body'],
ForInStatement: ['left', 'right', 'body'],
ForOfStatement: ['left', 'right', 'body'],
FunctionDeclaration: ['id', 'params', 'defaults', 'rest', 'body'],
FunctionExpression: ['id', 'params', 'defaults', 'rest', 'body'],
Identifier: [],
IfStatement: ['test', 'consequent', 'alternate'],
Literal: [],
LabeledStatement: ['label', 'body'],
LogicalExpression: ['left', 'right'],
MemberExpression: ['object', 'property'],
MethodDefinition: ['key', 'value'],
NewExpression: ['callee', 'arguments'],
ObjectExpression: ['properties'],
ObjectPattern: ['properties'],
Program: ['body'],
Property: ['key', 'value'],
ReturnStatement: ['argument'],
SequenceExpression: ['expressions'],
SwitchStatement: ['discriminant', 'cases'],
SwitchCase: ['test', 'consequent'],
ThisExpression: [],
ThrowStatement: ['argument'],
TryStatement: ['block', 'handlers', 'handler', 'guardedHandlers', 'finalizer'],
UnaryExpression: ['argument'],
UpdateExpression: ['argument'],
VariableDeclaration: ['declarations'],
VariableDeclarator: ['id', 'init'],
WhileStatement: ['test', 'body'],
WithStatement: ['object', 'body'],
YieldExpression: ['argument']
};
// unique id
BREAK = {};
SKIP = {};
VisitorOption = {
Break: BREAK,
Skip: SKIP
};
function Reference(parent, key) {
this.parent = parent;
this.key = key;
}
Reference.prototype.replace = function replace(node) {
this.parent[this.key] = node;
};
function Element(node, path, wrap, ref) {
this.node = node;
this.path = path;
this.wrap = wrap;
this.ref = ref;
}
function Controller() { }
// API:
// return property path array from root to current node
Controller.prototype.path = function path() {
var i, iz, j, jz, result, element;
function addToPath(result, path) {
if (isArray(path)) {
for (j = 0, jz = path.length; j < jz; ++j) {
result.push(path[j]);
}
} else {
result.push(path);
}
}
// root node
if (!this.__current.path) {
return null;
}
// first node is sentinel, second node is root element
result = [];
for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
element = this.__leavelist[i];
addToPath(result, element.path);
}
addToPath(result, this.__current.path);
return result;
};
// API:
// return array of parent elements
Controller.prototype.parents = function parents() {
var i, iz, result;
// first node is sentinel
result = [];
for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
result.push(this.__leavelist[i].node);
}
return result;
};
// API:
// return current node
Controller.prototype.current = function current() {
return this.__current.node;
};
Controller.prototype.__execute = function __execute(callback, element) {
var previous, result;
result = undefined;
previous = this.__current;
this.__current = element;
this.__state = null;
if (callback) {
result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
}
this.__current = previous;
return result;
};
// API:
// notify control skip / break
Controller.prototype.notify = function notify(flag) {
this.__state = flag;
};
// API:
// skip child nodes of current node
Controller.prototype.skip = function () {
this.notify(SKIP);
};
// API:
// break traversals
Controller.prototype['break'] = function () {
this.notify(BREAK);
};
Controller.prototype.__initialize = function(root, visitor) {
this.visitor = visitor;
this.root = root;
this.__worklist = [];
this.__leavelist = [];
this.__current = null;
this.__state = null;
};
Controller.prototype.traverse = function traverse(root, visitor) {
var worklist,
leavelist,
element,
node,
nodeType,
ret,
key,
current,
current2,
candidates,
candidate,
sentinel;
this.__initialize(root, visitor);
sentinel = {};
// reference
worklist = this.__worklist;
leavelist = this.__leavelist;
// initialize
worklist.push(new Element(root, null, null, null));
leavelist.push(new Element(null, null, null, null));
while (worklist.length) {
element = worklist.pop();
if (element === sentinel) {
element = leavelist.pop();
ret = this.__execute(visitor.leave, element);
if (this.__state === BREAK || ret === BREAK) {
return;
}
continue;
}
if (element.node) {
ret = this.__execute(visitor.enter, element);
if (this.__state === BREAK || ret === BREAK) {
return;
}
worklist.push(sentinel);
leavelist.push(element);
if (this.__state === SKIP || ret === SKIP) {
continue;
}
node = element.node;
nodeType = element.wrap || node.type;
candidates = VisitorKeys[nodeType];
current = candidates.length;
while ((current -= 1) >= 0) {
key = candidates[current];
candidate = node[key];
if (!candidate) {
continue;
}
if (!isArray(candidate)) {
worklist.push(new Element(candidate, key, null, null));
continue;
}
current2 = candidate.length;
while ((current2 -= 1) >= 0) {
if (!candidate[current2]) {
continue;
}
if ((nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === candidates[current]) {
element = new Element(candidate[current2], [key, current2], 'Property', null);
} else {
element = new Element(candidate[current2], [key, current2], null, null);
}
worklist.push(element);
}
}
}
}
};
Controller.prototype.replace = function replace(root, visitor) {
var worklist,
leavelist,
node,
nodeType,
target,
element,
current,
current2,
candidates,
candidate,
sentinel,
outer,
key;
this.__initialize(root, visitor);
sentinel = {};
// reference
worklist = this.__worklist;
leavelist = this.__leavelist;
// initialize
outer = {
root: root
};
element = new Element(root, null, null, new Reference(outer, 'root'));
worklist.push(element);
leavelist.push(element);
while (worklist.length) {
element = worklist.pop();
if (element === sentinel) {
element = leavelist.pop();
target = this.__execute(visitor.leave, element);
// node may be replaced with null,
// so distinguish between undefined and null in this place
if (target !== undefined && target !== BREAK && target !== SKIP) {
// replace
element.ref.replace(target);
}
if (this.__state === BREAK || target === BREAK) {
return outer.root;
}
continue;
}
target = this.__execute(visitor.enter, element);
// node may be replaced with null,
// so distinguish between undefined and null in this place
if (target !== undefined && target !== BREAK && target !== SKIP) {
// replace
element.ref.replace(target);
element.node = target;
}
if (this.__state === BREAK || target === BREAK) {
return outer.root;
}
// node may be null
node = element.node;
if (!node) {
continue;
}
worklist.push(sentinel);
leavelist.push(element);
if (this.__state === SKIP || target === SKIP) {
continue;
}
nodeType = element.wrap || node.type;
candidates = VisitorKeys[nodeType];
current = candidates.length;
while ((current -= 1) >= 0) {
key = candidates[current];
candidate = node[key];
if (!candidate) {
continue;
}
if (!isArray(candidate)) {
worklist.push(new Element(candidate, key, null, new Reference(node, key)));
continue;
}
current2 = candidate.length;
while ((current2 -= 1) >= 0) {
if (!candidate[current2]) {
continue;
}
if (nodeType === Syntax.ObjectExpression && 'properties' === candidates[current]) {
element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
} else {
element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
}
worklist.push(element);
}
}
}
return outer.root;
};
function traverse(root, visitor) {
var controller = new Controller();
return controller.traverse(root, visitor);
}
function replace(root, visitor) {
var controller = new Controller();
return controller.replace(root, visitor);
}
function extendCommentRange(comment, tokens) {
var target;
target = upperBound(tokens, function search(token) {
return token.range[0] > comment.range[0];
});
comment.extendedRange = [comment.range[0], comment.range[1]];
if (target !== tokens.length) {
comment.extendedRange[1] = tokens[target].range[0];
}
target -= 1;
if (target >= 0) {
comment.extendedRange[0] = tokens[target].range[1];
}
return comment;
}
function attachComments(tree, providedComments, tokens) {
// At first, we should calculate extended comment ranges.
var comments = [], comment, len, i, cursor;
if (!tree.range) {
throw new Error('attachComments needs range information');
}
// tokens array is empty, we attach comments to tree as 'leadingComments'
if (!tokens.length) {
if (providedComments.length) {
for (i = 0, len = providedComments.length; i < len; i += 1) {
comment = deepCopy(providedComments[i]);
comment.extendedRange = [0, tree.range[0]];
comments.push(comment);
}
tree.leadingComments = comments;
}
return tree;
}
for (i = 0, len = providedComments.length; i < len; i += 1) {
comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
}
// This is based on John Freeman's implementation.
cursor = 0;
traverse(tree, {
enter: function (node) {
var comment;
while (cursor < comments.length) {
comment = comments[cursor];
if (comment.extendedRange[1] > node.range[0]) {
break;
}
if (comment.extendedRange[1] === node.range[0]) {
if (!node.leadingComments) {
node.leadingComments = [];
}
node.leadingComments.push(comment);
comments.splice(cursor, 1);
} else {
cursor += 1;
}
}
// already out of owned node
if (cursor === comments.length) {
return VisitorOption.Break;
}
if (comments[cursor].extendedRange[0] > node.range[1]) {
return VisitorOption.Skip;
}
}
});
cursor = 0;
traverse(tree, {
leave: function (node) {
var comment;
while (cursor < comments.length) {
comment = comments[cursor];
if (node.range[1] < comment.extendedRange[0]) {
break;
}
if (node.range[1] === comment.extendedRange[0]) {
if (!node.trailingComments) {
node.trailingComments = [];
}
node.trailingComments.push(comment);
comments.splice(cursor, 1);
} else {
cursor += 1;
}
}
// already out of owned node
if (cursor === comments.length) {
return VisitorOption.Break;
}
if (comments[cursor].extendedRange[0] > node.range[1]) {
return VisitorOption.Skip;
}
}
});
return tree;
}
exports.version = '1.5.1-dev';
exports.Syntax = Syntax;
exports.traverse = traverse;
exports.replace = replace;
exports.attachComments = attachComments;
exports.VisitorKeys = VisitorKeys;
exports.VisitorOption = VisitorOption;
exports.Controller = Controller;
}));
/* vim: set sw=4 ts=4 et tw=80 : */

38
thirdparty/estraverse-master/package.json vendored Executable file
View file

@ -0,0 +1,38 @@
{
"name": "estraverse",
"description": "ECMAScript JS AST traversal functions",
"homepage": "https://github.com/Constellation/estraverse",
"main": "estraverse.js",
"version": "1.5.1-dev",
"engines": {
"node": ">=0.4.0"
},
"maintainers": [
{
"name": "Yusuke Suzuki",
"email": "utatane.tea@gmail.com",
"web": "http://github.com/Constellation"
}
],
"repository": {
"type": "git",
"url": "http://github.com/Constellation/estraverse.git"
},
"devDependencies": {
"mocha": "~1.12.0",
"chai": "~1.7.2",
"jshint": "2.1.5",
"coffee-script": "~1.6.3"
},
"licenses": [
{
"type": "BSD",
"url": "http://github.com/Constellation/estraverse/raw/master/LICENSE.BSD"
}
],
"scripts": {
"test": "npm run-script lint && npm run-script unit-test",
"lint": "jshint estraverse.js",
"unit-test": "mocha --compilers coffee:coffee-script"
}
}

View file

@ -0,0 +1,60 @@
# Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'use strict'
estraverse = require '../'
Dumper = require './dumper'
expect = require('chai').expect
describe 'controller', ->
it 'traverse', ->
controller = new estraverse.Controller
dumper = new Dumper
tree =
type: 'ObjectExpression'
properties: [{
key:
type: 'Identifier'
name: 'a'
value:
type: 'Identifier'
name: 'a'
}]
controller.traverse tree,
enter: (node) ->
dumper.log("enter - #{node.type}")
leave: (node) ->
dumper.log("leave - #{node.type}")
expect(Dumper.dump(tree)).to.be.equal """
enter - ObjectExpression
enter - undefined
enter - Identifier
leave - Identifier
enter - Identifier
leave - Identifier
leave - undefined
leave - ObjectExpression
"""

View file

@ -0,0 +1,47 @@
# Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'use strict'
estraverse = require '..'
module.exports = class Dumper
constructor: ->
@logs = []
log: (str) ->
@logs.push str
result: ->
@logs.join '\n'
@dump: (tree) ->
dumper = new Dumper
estraverse.traverse tree,
enter: (node) ->
dumper.log("enter - #{node.type}")
leave: (node) ->
dumper.log("leave - #{node.type}")
dumper.result()

View file

@ -0,0 +1,270 @@
# Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'use strict'
Dumper = require './dumper'
expect = require('chai').expect
describe 'object expression', ->
it 'properties', ->
tree =
type: 'ObjectExpression'
properties: [{
type: 'Property'
key:
type: 'Identifier'
name: 'a'
value:
type: 'Identifier'
name: 'a'
}]
expect(Dumper.dump(tree)).to.be.equal """
enter - ObjectExpression
enter - Property
enter - Identifier
leave - Identifier
enter - Identifier
leave - Identifier
leave - Property
leave - ObjectExpression
"""
it 'properties without type', ->
tree =
type: 'ObjectExpression'
properties: [{
key:
type: 'Identifier'
name: 'a'
value:
type: 'Identifier'
name: 'a'
}]
expect(Dumper.dump(tree)).to.be.equal """
enter - ObjectExpression
enter - undefined
enter - Identifier
leave - Identifier
enter - Identifier
leave - Identifier
leave - undefined
leave - ObjectExpression
"""
describe 'object pattern', ->
it 'properties', ->
tree =
type: 'ObjectPattern'
properties: [{
type: 'Property'
key:
type: 'Identifier'
name: 'a'
value:
type: 'Identifier'
name: 'a'
}]
expect(Dumper.dump(tree)).to.be.equal """
enter - ObjectPattern
enter - Property
enter - Identifier
leave - Identifier
enter - Identifier
leave - Identifier
leave - Property
leave - ObjectPattern
"""
it 'properties without type', ->
tree =
type: 'ObjectPattern'
properties: [{
key:
type: 'Identifier'
name: 'a'
value:
type: 'Identifier'
name: 'a'
}]
expect(Dumper.dump(tree)).to.be.equal """
enter - ObjectPattern
enter - undefined
enter - Identifier
leave - Identifier
enter - Identifier
leave - Identifier
leave - undefined
leave - ObjectPattern
"""
describe 'try statement', ->
it 'old interface', ->
tree =
type: 'TryStatement'
handlers: [{
type: 'BlockStatement'
body: []
}]
finalizer:
type: 'BlockStatement'
body: []
expect(Dumper.dump(tree)).to.be.equal """
enter - TryStatement
enter - BlockStatement
leave - BlockStatement
enter - BlockStatement
leave - BlockStatement
leave - TryStatement
"""
it 'new interface', ->
tree =
type: 'TryStatement'
handler: [{
type: 'BlockStatement'
body: []
}]
guardedHandlers: null
finalizer:
type: 'BlockStatement'
body: []
expect(Dumper.dump(tree)).to.be.equal """
enter - TryStatement
enter - BlockStatement
leave - BlockStatement
enter - BlockStatement
leave - BlockStatement
leave - TryStatement
"""
describe 'arrow function expression', ->
it 'traverse', ->
tree =
type: 'ArrowFunctionExpression'
params: [{
type: 'Identifier'
name: 'a'
}]
defaults: [{
type: 'Literal'
value: 20
}]
rest: {
type: 'Identifier'
name: 'rest'
}
body:
type: 'BlockStatement'
body: []
expect(Dumper.dump(tree)).to.be.equal """
enter - ArrowFunctionExpression
enter - Identifier
leave - Identifier
enter - Literal
leave - Literal
enter - Identifier
leave - Identifier
enter - BlockStatement
leave - BlockStatement
leave - ArrowFunctionExpression
"""
describe 'function expression', ->
it 'traverse', ->
tree =
type: 'FunctionExpression'
params: [{
type: 'Identifier'
name: 'a'
}]
defaults: [{
type: 'Literal'
value: 20
}]
rest: {
type: 'Identifier'
name: 'rest'
}
body:
type: 'BlockStatement'
body: []
expect(Dumper.dump(tree)).to.be.equal """
enter - FunctionExpression
enter - Identifier
leave - Identifier
enter - Literal
leave - Literal
enter - Identifier
leave - Identifier
enter - BlockStatement
leave - BlockStatement
leave - FunctionExpression
"""
describe 'function declaration', ->
it 'traverse', ->
tree =
type: 'FunctionDeclaration'
id: {
type: 'Identifier'
name: 'decl'
}
params: [{
type: 'Identifier'
name: 'a'
}]
defaults: [{
type: 'Literal'
value: 20
}]
rest: {
type: 'Identifier'
name: 'rest'
}
body:
type: 'BlockStatement'
body: []
expect(Dumper.dump(tree)).to.be.equal """
enter - FunctionDeclaration
enter - Identifier
leave - Identifier
enter - Identifier
leave - Identifier
enter - Literal
leave - Literal
enter - Identifier
leave - Identifier
enter - BlockStatement
leave - BlockStatement
leave - FunctionDeclaration
"""

3
thirdparty/lodash-amd/.gitattributes vendored Executable file
View file

@ -0,0 +1,3 @@
* text=auto
*.js text eol=lf
*.md text eol=lf

5
thirdparty/lodash-amd/.gitignore vendored Executable file
View file

@ -0,0 +1,5 @@
.coveralls.yml
.DS_Store
*.log
coverage
node_modules

3
thirdparty/lodash-amd/.npmignore vendored Executable file
View file

@ -0,0 +1,3 @@
.*
*.md
bower.json

55
thirdparty/lodash-amd/.travis.yml vendored Executable file
View file

@ -0,0 +1,55 @@
language: node_js
node_js:
- "0.10"
env:
global:
- BIN="phantomjs" BUILD="compat" ISTANBUL=false SAUCE_LABS=false SAUCE_USERNAME="lodash"
- secure: "X3/H+ZNbvxsD/wxQ0uP0d3KpFh2rJFuzqFbz8fG3KK97ZlZv4SYtgQoVzIx+rDClSHPOddTvbry3NusZ2JNadbcQRIaZCgBOE8FBX10YIR1ESDjxFBTZqRj8APD5/4L3akhyOQ62gEWTL4wT8TojIzRoT2bNzXEr6DyupVGW4qk="
matrix:
- LOADER="curl"
- LOADER="dojo"
- LOADER="requirejs"
- BUILD="modern" LOADER="curl"
- BUILD="modern" LOADER="dojo"
- BUILD="modern" LOADER="requirejs"
matrix:
include:
- node_js: "0.10"
env: ISTANBUL=true BUILD="modern-coverage" LOADER="requirejs"
- node_js: "0.10"
env: SAUCE_LABS=true LOADER="curl"
- node_js: "0.10"
env: SAUCE_LABS=true LOADER="dojo"
- node_js: "0.10"
env: SAUCE_LABS=true LOADER="requirejs"
- node_js: "0.10"
env: SAUCE_LABS=true BUILD="modern" LOADER="curl"
- node_js: "0.10"
env: SAUCE_LABS=true BUILD="modern" LOADER="dojo"
- node_js: "0.10"
env: SAUCE_LABS=true BUILD="modern" LOADER="requirejs"
- node_js: "0.10"
env: SAUCE_LABS=true BUILD="underscore" LOADER="curl"
- node_js: "0.10"
env: SAUCE_LABS=true BUILD="underscore" LOADER="dojo"
- node_js: "0.10"
env: SAUCE_LABS=true BUILD="underscore" LOADER="requirejs"
git:
depth: 10
branches:
only:
- master
before_install:
- "git clone --depth=10 --branch=master git://github.com/lodash/lodash.git ./node_modules/lodash"
- "[ $SAUCE_LABS == false ] || BIN=\"node\""
- "[ $SAUCE_LABS == false ] || npm i chalk@\"~0.4.0\" ecstatic@\"~0.4.0\" request@\"~2.34.0\" sauce-tunnel-sc3-1@\"~1.0.0\""
- "[ $ISTANBUL == false ] || npm i -g coveralls@\"~2.10.0\" istanbul@\"~0.2.0\""
script:
- "[ $ISTANBUL == false ] || istanbul instrument --output ./$BUILD ./modern"
- "[ $SAUCE_LABS == true ] || phantomjs --disk-cache=true ./node_modules/lodash/test/test.js \"node_modules/lodash/test/index.html?build=../../../$BUILD/main.js&loader=$LOADER&noglobals=true\""
- "[ $ISTANBUL == false ] || istanbul report lcovonly"
- "[ $ISTANBUL == true ] && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage || true"
- "([ $SAUCE_LABS == false ] || [ $BUILD == 'underscore' ]) || $BIN ./node_modules/lodash/test/saucelabs.js name=\"lodash tests\" runner=\"node_modules/lodash/test/index.html?build=../../../$BUILD/main.js&loader=$LOADER\" tags=\"$BUILD,$LOADER,amd,development\""
- "([ $SAUCE_LABS == false ] || [ $BUILD != 'compat' ]) || $BIN ./node_modules/lodash/test/saucelabs.js name=\"lodash tests\" runner=\"node_modules/lodash/test/index.html?build=../../../$BUILD/main.js&loader=$LOADER\" tags=\"$BUILD,$LOADER,amd,development,ie-compat\" compatMode=7"
- "[ $SAUCE_LABS == false ] || $BIN ./node_modules/lodash/test/saucelabs.js name=\"backbone tests\" runner=\"node_modules/lodash/test/backbone.html?build=../../../$BUILD/main.js&loader=$LOADER\" tags=\"$BUILD,$LOADER,amd,development,backbone\""
- "[ $SAUCE_LABS == false ] || $BIN ./node_modules/lodash/test/saucelabs.js name=\"underscore tests\" runner=\"node_modules/lodash/test/underscore.html?build=../../../$BUILD/main.js&loader=$LOADER\" tags=\"$BUILD,$LOADER,amd,development,underscore\""

22
thirdparty/lodash-amd/LICENSE.txt vendored Executable file
View file

@ -0,0 +1,22 @@
Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
Based on Underscore.js 1.5.2, copyright 2009-2013 Jeremy Ashkenas,
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

64
thirdparty/lodash-amd/README.md vendored Executable file
View file

@ -0,0 +1,64 @@
# lodash-amd v2.4.1
A collection of [Lo-Dash](http://lodash.com/) methods as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules generated by [lodash-cli](https://npmjs.org/package/lodash-cli).
## Packages
Define a build as `'lodash'` (instead of `'lodash-amd/{build}'`)
```js
require({
'packages': [
{ 'name': 'lodash', 'location': 'lodash-amd/modern' }
]
}, ['lodash/collections/forEach'], function(forEach) {
// use `forEach`
});
```
## Migrations
Easily migrate Underscore code to Lo-Dash code.
```js
require({
'packages': [
{ 'name': 'lodash', 'location': 'lodash-amd/compat' },
{ 'name': 'underscore', 'location': 'lodash-amd/underscore' }
]
}, [], function() {});
```
When working with code that must have Underscore compatibility, just import the `'underscore'` dependency.
If you dont need Underscore compatibility & want the [benefits](http://lodash.com/#features) of Lo-Dash, import the `'lodash'` dependency.
You can even mix & match.
```js
define(['underscore', 'lodash/objects/transform'], function(_, transform) {
// use `_` prefixed code with underscore
// use `transform` from lodash
});
```
Eventually, when Underscore compatibility is no longer needed, just switch your `packages` configuration.
```js
require({
'packages': [
{ 'name': 'lodash', 'location': 'lodash-amd/compat' },
{ 'name': 'underscore', 'location': 'lodash-amd/compat' }
]
}, [], function() {});
```
## Author
| [![twitter/jdalton](http://gravatar.com/avatar/299a3d891ff1920b69c364d061007043?s=70)](https://twitter.com/jdalton "Follow @jdalton on Twitter") |
|---|
| [John-David Dalton](http://allyoucanleet.com/) |
## Contributors
| [![twitter/blainebublitz](http://gravatar.com/avatar/ac1c67fd906c9fecd823ce302283b4c1?s=70)](https://twitter.com/blainebublitz "Follow @BlaineBublitz on Twitter") | [![twitter/kitcambridge](http://gravatar.com/avatar/6662a1d02f351b5ef2f8b4d815804661?s=70)](https://twitter.com/kitcambridge "Follow @kitcambridge on Twitter") | [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") |
|---|---|---|
| [Blaine Bublitz](http://www.iceddev.com/) | [Kit Cambridge](http://kitcambridge.be/) | [Mathias Bynens](http://mathiasbynens.be/) |

12
thirdparty/lodash-amd/bower.json vendored Executable file
View file

@ -0,0 +1,12 @@
{
"name": "lodash-amd",
"version": "2.4.1",
"main": "compat/main.js",
"ignore": [
".*",
"*.log",
"*.md",
"coverage",
"node_modules"
]
}

49
thirdparty/lodash-amd/compat/arrays.js vendored Executable file
View file

@ -0,0 +1,49 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['./arrays/compact', './arrays/difference', './arrays/drop', './arrays/dropRight', './arrays/dropRightWhile', './arrays/dropWhile', './arrays/findIndex', './arrays/findLastIndex', './arrays/first', './arrays/flatten', './arrays/indexOf', './arrays/initial', './arrays/intersection', './arrays/last', './arrays/lastIndexOf', './arrays/pull', './arrays/range', './arrays/remove', './arrays/rest', './arrays/slice', './arrays/sortedIndex', './arrays/take', './arrays/takeRight', './arrays/takeRightWhile', './arrays/takeWhile', './arrays/union', './arrays/uniq', './arrays/without', './arrays/xor', './arrays/zip', './arrays/zipObject'], function(compact, difference, drop, dropRight, dropRightWhile, dropWhile, findIndex, findLastIndex, first, flatten, indexOf, initial, intersection, last, lastIndexOf, pull, range, remove, rest, slice, sortedIndex, take, takeRight, takeRightWhile, takeWhile, union, uniq, without, xor, zip, zipObject) {
return {
'compact': compact,
'difference': difference,
'drop': drop,
'dropRight': dropRight,
'dropRightWhile': dropRightWhile,
'dropWhile': dropWhile,
'findIndex': findIndex,
'findLastIndex': findLastIndex,
'first': first,
'flatten': flatten,
'head': first,
'indexOf': indexOf,
'initial': initial,
'intersection': intersection,
'last': last,
'lastIndexOf': lastIndexOf,
'object': zipObject,
'pull': pull,
'range': range,
'remove': remove,
'rest': rest,
'slice': slice,
'sortedIndex': sortedIndex,
'tail': rest,
'take': take,
'takeRight': takeRight,
'takeRightWhile': takeRightWhile,
'takeWhile': takeWhile,
'union': union,
'uniq': uniq,
'unique': uniq,
'unzip': zip,
'without': without,
'xor': xor,
'zip': zip,
'zipObject': zipObject
};
});

View file

@ -0,0 +1,41 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define([], function() {
/**
* Creates an array with all falsey values removed. The values `false`, `null`,
* `0`, `""`, `undefined`, and `NaN` are all falsey.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to compact.
* @returns {Array} Returns the new array of filtered values.
* @example
*
* _.compact([0, 1, false, 2, '', 3]);
* // => [1, 2, 3]
*/
function compact(array) {
var index = -1,
length = array ? array.length : 0,
resIndex = 0,
result = [];
while (++index < length) {
var value = array[index];
if (value) {
result[resIndex++] = value;
}
}
return result;
}
return compact;
});

View file

@ -0,0 +1,31 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['../internals/baseDifference', '../internals/baseFlatten'], function(baseDifference, baseFlatten) {
/**
* Creates an array excluding all values of the provided arrays using strict
* equality for comparisons, i.e. `===`.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to process.
* @param {...Array} [values] The arrays of values to exclude.
* @returns {Array} Returns the new array of filtered values.
* @example
*
* _.difference([1, 2, 3], [5, 2, 10]);
* // => [1, 3]
*/
function difference() {
return baseDifference(arguments[0], baseFlatten(arguments, true, true, 1));
}
return difference;
});

38
thirdparty/lodash-amd/compat/arrays/drop.js vendored Executable file
View file

@ -0,0 +1,38 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['./rest'], function(rest) {
/**
* Creates a slice of `array` with `n` elements dropped from the beginning.
*
* @static
* @memberOf _
* @type Function
* @category Arrays
* @param {Array} array The array to query.
* @param {number} [n=1] The number of elements to drop.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.drop([1, 2, 3], 1);
* // => [2, 3]
*
* _.drop([1, 2, 3], 2);
* // => [3]
*
* _.drop([1, 2, 3], 5);
* // => []
*
* _.drop([1, 2, 3], 0);
* // => [1, 2, 3]
*/
var drop = rest;
return drop;
});

View file

@ -0,0 +1,38 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['./initial'], function(initial) {
/**
* Creates a slice of `array` with `n` elements dropped from the end.
*
* @static
* @memberOf _
* @type Function
* @category Arrays
* @param {Array} array The array to query.
* @param {number} [n=1] The number of elements to drop.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.dropRight([1, 2, 3], 1);
* // => [1, 2]
*
* _.dropRight([1, 2, 3], 2);
* // => [1]
*
* _.dropRight([1, 2, 3], 5);
* // => []
*
* _.dropRight([1, 2, 3], 0);
* // => [1, 2, 3]
*/
var dropRight = initial;
return dropRight;
});

View file

@ -0,0 +1,55 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['./initial'], function(initial) {
/**
* Creates a slice of `array` excluding elements dropped from the end.
* Elements will be dropped until the predicate returns falsey. The predicate
* is bound to `thisArg` and invoked with three arguments; (value, index, array).
*
* If a property name is provided for `predicate` the created "_.pluck" style
* callback will return the property value of the given element.
*
* If an object is provided for `predicate` the created "_.where" style callback
* will return `true` for elements that have the properties of the given object,
* else `false`.
*
* @static
* @memberOf _
* @type Function
* @category Arrays
* @param {Array} array The array to query.
* @param {Function|Object|string} [predicate=identity] The function called
* per element.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.dropRightWhile([1, 2, 3], function(num) {
* return num > 1;
* });
* // => [1]
*
* var characters = [
* { 'name': 'barney', 'employer': 'slate' },
* { 'name': 'fred', 'employer': 'slate', 'blocked': true },
* { 'name': 'pebbles', 'employer': 'na', 'blocked': true }
* ];
*
* // using "_.pluck" callback shorthand
* _.pluck(_.dropRightWhile(characters, 'blocked'), 'name');
* // => ['barney']
*
* // using "_.where" callback shorthand
* _.pluck(_.dropRightWhile(characters, { 'employer': 'na' }), 'name');
* // => ['barney', 'fred']
*/
var dropRightWhile = initial;
return dropRightWhile;
});

View file

@ -0,0 +1,55 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['./rest'], function(rest) {
/**
* Creates a slice of `array` excluding elements dropped from the beginning.
* Elements will be dropped until the predicate returns falsey. The predicate
* is bound to `thisArg` and invoked with three arguments; (value, index, array).
*
* If a property name is provided for `predicate` the created "_.pluck" style
* callback will return the property value of the given element.
*
* If an object is provided for `predicate` the created "_.where" style callback
* will return `true` for elements that have the properties of the given object,
* else `false`.
*
* @static
* @memberOf _
* @type Function
* @category Arrays
* @param {Array} array The array to query.
* @param {Function|Object|string} [predicate=identity] The function called
* per element.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.dropWhile([1, 2, 3], function(num) {
* return num < 3;
* });
* // => [3]
*
* var characters = [
* { 'name': 'barney', 'employer': 'slate', 'blocked': true },
* { 'name': 'fred', 'employer': 'slate' },
* { 'name': 'pebbles', 'employer': 'na', 'blocked': true }
* ];
*
* // using "_.pluck" callback shorthand
* _.pluck(_.dropWhile(characters, 'blocked'), 'name');
* // => ['fred', 'pebbles']
*
* // using "_.where" callback shorthand
* _.pluck(_.dropWhile(characters, { 'employer': 'slate' }), 'name');
* // => ['pebbles']
*/
var dropWhile = rest;
return dropWhile;
});

View file

@ -0,0 +1,66 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['../functions/createCallback'], function(createCallback) {
/**
* This method is like `_.find` except that it returns the index of the first
* element the predicate returns truthy for, instead of the element itself.
*
* If a property name is provided for `predicate` the created "_.pluck" style
* callback will return the property value of the given element.
*
* If an object is provided for `predicate` the created "_.where" style callback
* will return `true` for elements that have the properties of the given object,
* else `false`.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to search.
* @param {Function|Object|string} [predicate=identity] The function called
* per iteration. If a property name or object is provided it will be used
* to create a "_.pluck" or "_.where" style callback respectively.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {number} Returns the index of the found element, else `-1`.
* @example
*
* var characters = [
* { 'name': 'barney', 'age': 36 },
* { 'name': 'fred', 'age': 40, 'blocked': true },
* { 'name': 'pebbles', 'age': 1 }
* ];
*
* _.findIndex(characters, function(chr) {
* return chr.age < 20;
* });
* // => 2
*
* // using "_.where" callback shorthand
* _.findIndex(characters, { 'age': 36 });
* // => 0
*
* // using "_.pluck" callback shorthand
* _.findIndex(characters, 'blocked');
* // => 1
*/
function findIndex(array, predicate, thisArg) {
var index = -1,
length = array ? array.length : 0;
predicate = createCallback(predicate, thisArg, 3);
while (++index < length) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
}
return findIndex;
});

View file

@ -0,0 +1,65 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['../functions/createCallback'], function(createCallback) {
/**
* This method is like `_.findIndex` except that it iterates over elements
* of a collection from right to left.
*
* If a property name is provided for `predicate` the created "_.pluck" style
* callback will return the property value of the given element.
*
* If an object is provided for `predicate` the created "_.where" style callback
* will return `true` for elements that have the properties of the given object,
* else `false`.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to search.
* @param {Function|Object|string} [predicate=identity] The function called
* per iteration. If a property name or object is provided it will be used
* to create a "_.pluck" or "_.where" style callback respectively.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {number} Returns the index of the found element, else `-1`.
* @example
*
* var characters = [
* { 'name': 'barney', 'age': 36, 'blocked': true },
* { 'name': 'fred', 'age': 40 },
* { 'name': 'pebbles', 'age': 1, 'blocked': true }
* ];
*
* _.findLastIndex(characters, function(chr) {
* return chr.age > 30;
* });
* // => 1
*
* // using "_.where" callback shorthand
* _.findLastIndex(characters, { 'age': 36 });
* // => 0
*
* // using "_.pluck" callback shorthand
* _.findLastIndex(characters, 'blocked');
* // => 2
*/
function findLastIndex(array, predicate, thisArg) {
var length = array ? array.length : 0;
predicate = createCallback(predicate, thisArg, 3);
while (length--) {
if (predicate(array[length], length, array)) {
return length;
}
}
return -1;
}
return findLastIndex;
});

54
thirdparty/lodash-amd/compat/arrays/first.js vendored Executable file
View file

@ -0,0 +1,54 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['../functions/createCallback', './slice'], function(createCallback, slice) {
/** Used as a safe reference for `undefined` in pre ES5 environments */
var undefined;
/**
* Gets the first element of `array`.
*
* Note: The `n` and `predicate` arguments are deprecated; replace with
* `_.take` and `_.takeWhile` respectively.
*
* @static
* @memberOf _
* @alias head
* @category Arrays
* @param {Array} array The array to query.
* @returns {*} Returns the first element of `array`.
* @example
*
* _.first([1, 2, 3]);
* // => 1
*
* _.first([]);
* // => undefined
*/
function first(array, predicate, thisArg) {
if (typeof predicate != 'number' && predicate != null) {
var index = -1,
length = array ? array.length : 0,
n = 0;
predicate = createCallback(predicate, thisArg, 3);
while (++index < length && predicate(array[index], index, array)) {
n++;
}
} else {
n = predicate;
if (n == null || thisArg) {
return array ? array[0] : undefined;
}
}
return slice(array, 0, n < 0 ? 0 : n);
}
return first;
});

View file

@ -0,0 +1,77 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['../internals/baseFlatten', '../collections/map'], function(baseFlatten, map) {
/**
* Flattens a nested array (the nesting can be to any depth). If `isShallow`
* is truthy, the array will only be flattened a single level. If a callback
* is provided each element of the array is passed through the callback before
* flattening. The callback is bound to `thisArg` and invoked with three
* arguments; (value, index, array).
*
* If a property name is provided for `callback` the created "_.pluck" style
* callback will return the property value of the given element.
*
* If an object is provided for `callback` the created "_.where" style callback
* will return `true` for elements that have the properties of the given object,
* else `false`.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to flatten.
* @param {boolean} [isShallow=false] A flag to restrict flattening to a single level.
* @param {Function|Object|string} [callback] The function called per iteration.
* If a property name or object is provided it will be used to create a "_.pluck"
* or "_.where" style callback respectively.
* @param {*} [thisArg] The `this` binding of `callback`.
* @returns {Array} Returns the new flattened array.
* @example
*
* _.flatten([1, [2], [3, [[4]]]]);
* // => [1, 2, 3, 4];
*
* // using `isShallow`
* _.flatten([1, [2], [3, [[4]]]], true);
* // => [1, 2, 3, [[4]]];
*
* var characters = [
* { 'name': 'barney', 'age': 30, 'pets': ['hoppy'] },
* { 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }
* ];
*
* // using "_.pluck" callback shorthand
* _.flatten(characters, 'pets');
* // => ['hoppy', 'baby puss', 'dino']
*/
function flatten(array, isShallow, callback, thisArg) {
var length = array ? array.length : 0;
if (!length) {
return [];
}
// juggle arguments
var type = typeof isShallow;
if (type != 'boolean' && isShallow != null) {
thisArg = callback;
callback = isShallow;
isShallow = false;
// enables use as a callback for functions like `_.map`
if ((type == 'number' || type == 'string') && thisArg && thisArg[callback] === array) {
callback = null;
}
}
if (callback != null) {
array = map(array, callback, thisArg);
}
return baseFlatten(array, isShallow);
}
return flatten;
});

View file

@ -0,0 +1,52 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['../internals/baseIndexOf', './sortedIndex'], function(baseIndexOf, sortedIndex) {
/* Native method shortcuts for methods with the same name as other `lodash` methods */
var nativeMax = Math.max;
/**
* Gets the index at which the first occurrence of `value` is found using
* strict equality for comparisons, i.e. `===`. If the array is already sorted
* providing `true` for `fromIndex` will run a faster binary search.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to search.
* @param {*} value The value to search for.
* @param {boolean|number} [fromIndex=0] The index to search from or `true`
* to perform a binary search on a sorted array.
* @returns {number} Returns the index of the matched value, else `-1`.
* @example
*
* _.indexOf([1, 2, 3, 1, 2, 3], 2);
* // => 1
*
* // using `fromIndex`
* _.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
* // => 4
*
* // performing a binary search
* _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
* // => 2
*/
function indexOf(array, value, fromIndex) {
var length = array ? array.length : 0;
if (typeof fromIndex == 'number') {
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
} else if (fromIndex) {
var index = sortedIndex(array, value);
return (length && array[index] === value) ? index : -1;
}
return baseIndexOf(array, value, fromIndex);
}
return indexOf;
});

View file

@ -0,0 +1,46 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['../functions/createCallback', './slice'], function(createCallback, slice) {
/**
* Gets all but the last element of `array`.
*
* Note: The `n` and `predicate` arguments are deprecated; replace with
* `_.dropRight` and `_.dropRightWhile` respectively.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to query.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.initial([1, 2, 3]);
* // => [1, 2]
*/
function initial(array, predicate, thisArg) {
var length = array ? array.length : 0;
if (typeof predicate != 'number' && predicate != null) {
var index = length,
n = 0;
predicate = createCallback(predicate, thisArg, 3);
while (index-- && predicate(array[index], index, array)) {
n++;
}
} else {
n = (predicate == null || thisArg) ? 1 : predicate;
}
n = length - (n || 0);
return slice(array, 0, n < 0 ? 0 : n);
}
return initial;
});

View file

@ -0,0 +1,69 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['../internals/baseIndexOf', '../internals/cacheIndexOf', '../internals/createCache', '../objects/isArguments', '../objects/isArray'], function(baseIndexOf, cacheIndexOf, createCache, isArguments, isArray) {
/**
* Creates an array of unique values present in all provided arrays using
* strict equality for comparisons, i.e. `===`.
*
* @static
* @memberOf _
* @category Arrays
* @param {...Array} [arrays] The arrays to inspect.
* @returns {Array} Returns the new array of shared values.
* @example
*
* _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]);
* // => [1, 2]
*/
function intersection() {
var args = [],
argsIndex = -1,
argsLength = arguments.length,
caches = [],
indexOf = baseIndexOf,
prereq = createCache;
while (++argsIndex < argsLength) {
var value = arguments[argsIndex];
if (isArray(value) || isArguments(value)) {
args.push(value);
caches.push(prereq && value.length >= 120 &&
createCache(argsIndex && value));
}
}
argsLength = args.length;
var array = args[0],
index = -1,
length = array ? array.length : 0,
result = [],
seen = caches[0];
outer:
while (++index < length) {
value = array[index];
if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value)) < 0) {
argsIndex = argsLength;
while (--argsIndex) {
var cache = caches[argsIndex];
if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value)) < 0) {
continue outer;
}
}
if (seen) {
seen.push(value);
}
result.push(value);
}
}
return result;
}
return intersection;
});

52
thirdparty/lodash-amd/compat/arrays/last.js vendored Executable file
View file

@ -0,0 +1,52 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['../functions/createCallback', './slice'], function(createCallback, slice) {
/** Used as a safe reference for `undefined` in pre ES5 environments */
var undefined;
/**
* Gets the last element of `array`.
*
* Note: The `n` and `predicate` arguments are deprecated; replace with
* `_.takeRight` and `_.takeRightWhile` respectively.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to query.
* @returns {*} Returns the last element of `array`.
* @example
*
* _.last([1, 2, 3]);
* // => 3
*/
function last(array, predicate, thisArg) {
var length = array ? array.length : 0;
if (typeof predicate != 'number' && predicate != null) {
var index = length,
n = 0;
predicate = createCallback(predicate, thisArg, 3);
while (index-- && predicate(array[index], index, array)) {
n++;
}
} else {
n = predicate;
if (n == null || thisArg) {
return array ? array[length - 1] : undefined;
}
}
n = length - (n || 0);
return slice(array, n < 0 ? 0 : n);
}
return last;
});

View file

@ -0,0 +1,50 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define([], function() {
/* Native method shortcuts for methods with the same name as other `lodash` methods */
var nativeMax = Math.max,
nativeMin = Math.min;
/**
* Gets the index at which the last occurrence of `value` is found using
* strict equality for comparisons, i.e. `===`. If `fromIndex` is negative,
* it is used as the offset from the end of the collection.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to search.
* @param {*} value The value to search for.
* @param {number} [fromIndex=array.length-1] The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
* @example
*
* _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
* // => 4
*
* // using `fromIndex`
* _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
* // => 1
*/
function lastIndexOf(array, value, fromIndex) {
var index = array ? array.length : 0;
if (typeof fromIndex == 'number') {
index = (fromIndex < 0 ? nativeMax(index + fromIndex, 0) : nativeMin(fromIndex || 0, index - 1)) + 1;
}
while (index--) {
if (array[index] === value) {
return index;
}
}
return -1;
}
return lastIndexOf;
});

56
thirdparty/lodash-amd/compat/arrays/pull.js vendored Executable file
View file

@ -0,0 +1,56 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define([], function() {
/** Used for native method references */
var arrayRef = Array.prototype;
/** Native method shortcuts */
var splice = arrayRef.splice;
/**
* Removes all provided values from `array` using strict equality for
* comparisons, i.e. `===`.
*
* Note: Unlike `_.without`, this method mutates `array`.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to modify.
* @param {...*} [values] The values to remove.
* @returns {Array} Returns `array`.
* @example
*
* var array = [1, 2, 3, 1, 2, 3];
* _.pull(array, 2, 3);
* console.log(array);
* // => [1, 1]
*/
function pull(array) {
var argsIndex = 0,
argsLength = arguments.length,
length = array ? array.length : 0;
while (++argsIndex < argsLength) {
var index = -1,
value = arguments[argsIndex];
while (++index < length) {
if (array[index] === value) {
splice.call(array, index--, 1);
length--;
}
}
}
return array;
}
return pull;
});

73
thirdparty/lodash-amd/compat/arrays/range.js vendored Executable file
View file

@ -0,0 +1,73 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define([], function() {
/** Native method shortcuts */
var ceil = Math.ceil;
/* Native method shortcuts for methods with the same name as other `lodash` methods */
var nativeMax = Math.max;
/**
* Creates an array of numbers (positive and/or negative) progressing from
* `start` up to but not including `end`. If `start` is less than `stop` a
* zero-length range is created unless a negative `step` is specified.
*
* @static
* @memberOf _
* @category Utilities
* @param {number} [start=0] The start of the range.
* @param {number} end The end of the range.
* @param {number} [step=1] The value to increment or decrement by.
* @returns {Array} Returns the new array of numbers.
* @example
*
* _.range(4);
* // => [0, 1, 2, 3]
*
* _.range(1, 5);
* // => [1, 2, 3, 4]
*
* _.range(0, 20, 5);
* // => [0, 5, 10, 15]
*
* _.range(0, -4, -1);
* // => [0, -1, -2, -3]
*
* _.range(1, 4, 0);
* // => [1, 1, 1]
*
* _.range(0);
* // => []
*/
function range(start, end, step) {
start = +start || 0;
step = step == null ? 1 : (+step || 0);
if (end == null) {
end = start;
start = 0;
} else {
end = +end || 0;
}
// use `Array(length)` so engines like Chakra and V8 avoid slower modes
// http://youtu.be/XAqIpGU8ZZk#t=17m25s
var index = -1,
length = nativeMax(ceil((end - start) / (step || 1)), 0),
result = Array(length);
while (++index < length) {
result[index] = start;
start += step;
}
return result;
}
return range;
});

69
thirdparty/lodash-amd/compat/arrays/remove.js vendored Executable file
View file

@ -0,0 +1,69 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['../functions/createCallback'], function(createCallback) {
/** Used for native method references */
var arrayRef = Array.prototype;
/** Native method shortcuts */
var splice = arrayRef.splice;
/**
* Removes all elements from `array` that the predicate returns truthy for
* and returns an array of removed elements. The predicate is bound to `thisArg`
* and invoked with three arguments; (value, index, array).
*
* If a property name is provided for `predicate` the created "_.pluck" style
* callback will return the property value of the given element.
*
* If an object is provided for `predicate` the created "_.where" style callback
* will return `true` for elements that have the properties of the given object,
* else `false`.
*
* Note: Unlike `_.filter`, this method mutates `array`.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to modify.
* @param {Function|Object|string} [predicate=identity] The function called
* per iteration. If a property name or object is provided it will be used
* to create a "_.pluck" or "_.where" style callback respectively.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {Array} Returns the array of removed elements.
* @example
*
* var array = [1, 2, 3, 4, 5, 6];
* var evens = _.remove(array, function(num) { return num % 2 == 0; });
*
* console.log(array);
* // => [1, 3, 5]
*
* console.log(evens);
* // => [2, 4, 6]
*/
function remove(array, predicate, thisArg) {
var index = -1,
length = array ? array.length : 0,
result = [];
predicate = createCallback(predicate, thisArg, 3);
while (++index < length) {
var value = array[index];
if (predicate(value, index, array)) {
result.push(value);
splice.call(array, index--, 1);
length--;
}
}
return result;
}
return remove;
});

47
thirdparty/lodash-amd/compat/arrays/rest.js vendored Executable file
View file

@ -0,0 +1,47 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define(['../functions/createCallback', './slice'], function(createCallback, slice) {
/**
* Gets all but the first element of `array`.
*
* Note: The `n` and `predicate` arguments are deprecated; replace with
* `_.drop` and `_.dropWhile` respectively.
*
* @static
* @memberOf _
* @alias tail
* @category Arrays
* @param {Array} array The array to query.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.rest([1, 2, 3]);
* // => [2, 3]
*/
function rest(array, predicate, thisArg) {
if (typeof predicate != 'number' && predicate != null) {
var index = -1,
length = array ? array.length : 0,
n = 0;
predicate = createCallback(predicate, thisArg, 3);
while (++index < length && predicate(array[index], index, array)) {
n++;
}
} else if (predicate == null || thisArg) {
n = 1;
} else {
n = predicate < 0 ? 0 : predicate;
}
return slice(array, n);
}
return rest;
});

54
thirdparty/lodash-amd/compat/arrays/slice.js vendored Executable file
View file

@ -0,0 +1,54 @@
/**
* Lo-Dash 2.4.1 (Custom Build) <http://lodash.com/>
* Build: `lodash modularize exports="amd" -o ./compat/`
* Copyright 2012-2014 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.6.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <http://lodash.com/license>
*/
define([], function() {
/* Native method shortcuts for methods with the same name as other `lodash` methods */
var nativeMax = Math.max;
/**
* Slices `array` from the `start` index up to, but not including, the `end` index.
*
* Note: This function is used instead of `Array#slice` to support node lists
* in IE < 9 and to ensure dense arrays are returned.
*
* @static
* @memberOf _
* @category Arrays
* @param {Array} array The array to slice.
* @param {number} [start=0] The start index.
* @param {number} [end=array.length] The end index.
* @returns {Array} Returns the slice of `array`.
*/
function slice(array, start, end) {
var index = -1,
length = array ? array.length : 0;
start = typeof start == 'undefined' ? 0 : (+start || 0);
if (start < 0) {
start = nativeMax(length + start, 0);
} else if (start > length) {
start = length;
}
end = typeof end == 'undefined' ? length : (+end || 0);
if (end < 0) {
end = nativeMax(length + end, 0);
} else if (end > length) {
end = length;
}
length = start > end ? 0 : (end - start);
var result = Array(length);
while (++index < length) {
result[index] = array[start + index];
}
return result;
}
return slice;
});

Some files were not shown because too many files have changed in this diff Show more