You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4689 lines
396 KiB
JavaScript

ace.define("ace/mode/xquery/jsoniq_lexer",["require","exports","module"], function(require, exports, module) {
module.exports = (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({
1:[function(_dereq_,module,exports){
var JSONiqTokenizer = exports.JSONiqTokenizer = function JSONiqTokenizer(string, parsingEventHandler)
{
init(string, parsingEventHandler);
var self = this;
this.ParseException = function(b, e, s, o, x)
{
var
begin = b,
end = e,
state = s,
offending = o,
expected = x;
this.getBegin = function() {return begin;};
this.getEnd = function() {return end;};
this.getState = function() {return state;};
this.getExpected = function() {return expected;};
this.getOffending = function() {return offending;};
this.getMessage = function()
{
return offending < 0 ? "lexical analysis failed" : "syntax error";
};
};
function init(string, parsingEventHandler)
{
eventHandler = parsingEventHandler;
input = string;
size = string.length;
reset(0, 0, 0);
}
this.getInput = function()
{
return input;
};
function reset(l, b, e)
{
b0 = b; e0 = b;
l1 = l; b1 = b; e1 = e;
end = e;
eventHandler.reset(input);
}
this.getOffendingToken = function(e)
{
var o = e.getOffending();
return o >= 0 ? JSONiqTokenizer.TOKEN[o] : null;
};
this.getExpectedTokenSet = function(e)
{
var expected;
if (e.getExpected() < 0)
{
expected = JSONiqTokenizer.getTokenSet(- e.getState());
}
else
{
expected = [JSONiqTokenizer.TOKEN[e.getExpected()]];
}
return expected;
};
this.getErrorMessage = function(e)
{
var tokenSet = this.getExpectedTokenSet(e);
var found = this.getOffendingToken(e);
var prefix = input.substring(0, e.getBegin());
var lines = prefix.split("\n");
var line = lines.length;
var column = lines[line - 1].length + 1;
var size = e.getEnd() - e.getBegin();
return e.getMessage()
+ (found == null ? "" : ", found " + found)
+ "\nwhile expecting "
+ (tokenSet.length == 1 ? tokenSet[0] : ("[" + tokenSet.join(", ") + "]"))
+ "\n"
+ (size == 0 || found != null ? "" : "after successfully scanning " + size + " characters beginning ")
+ "at line " + line + ", column " + column + ":\n..."
+ input.substring(e.getBegin(), Math.min(input.length, e.getBegin() + 64))
+ "...";
};
this.parse_start = function()
{
eventHandler.startNonterminal("start", e0);
lookahead1W(14); // ModuleDecl | Annotation | OptionDecl | Operator | Variable | Tag | AttrTest |
switch (l1)
{
case 58: // '<![CDATA['
shift(58); // '<![CDATA['
break;
case 57: // '<!--'
shift(57); // '<!--'
break;
case 59: // '<?'
shift(59); // '<?'
break;
case 43: // '(#'
shift(43); // '(#'
break;
case 45: // '(:~'
shift(45); // '(:~'
break;
case 44: // '(:'
shift(44); // '(:'
break;
case 37: // '"'
shift(37); // '"'
break;
case 41: // "'"
shift(41); // "'"
break;
case 277: // '}'
shift(277); // '}'
break;
case 274: // '{'
shift(274); // '{'
break;
case 42: // '('
shift(42); // '('
break;
case 46: // ')'
shift(46); // ')'
break;
case 52: // '/'
shift(52); // '/'
break;
case 65: // '['
shift(65); // '['
break;
case 66: // ']'
shift(66); // ']'
break;
case 49: // ','
shift(49); // ','
break;
case 51: // '.'
shift(51); // '.'
break;
case 56: // ';'
shift(56); // ';'
break;
case 54: // ':'
shift(54); // ':'
break;
case 36: // '!'
shift(36); // '!'
break;
case 276: // '|'
shift(276); // '|'
break;
case 40: // '$$'
shift(40); // '$$'
break;
case 5: // Annotation
shift(5); // Annotation
break;
case 4: // ModuleDecl
shift(4); // ModuleDecl
break;
case 6: // OptionDecl
shift(6); // OptionDecl
break;
case 15: // AttrTest
shift(15); // AttrTest
break;
case 16: // Wildcard
shift(16); // Wildcard
break;
case 18: // IntegerLiteral
shift(18); // IntegerLiteral
break;
case 19: // DecimalLiteral
shift(19); // DecimalLiteral
break;
case 20: // DoubleLiteral
shift(20); // DoubleLiteral
break;
case 8: // Variable
shift(8); // Variable
break;
case 9: // Tag
shift(9); // Tag
break;
case 7: // Operator
shift(7); // Operator
break;
case 35: // EOF
shift(35); // EOF
break;
default:
parse_EQName();
}
eventHandler.endNonterminal("start", e0);
};
this.parse_StartTag = function()
{
eventHandler.startNonterminal("StartTag", e0);
lookahead1W(8); // QName | S^WS | EOF | '"' | "'" | '/>' | '=' | '>'
switch (l1)
{
case 61: // '>'
shift(61); // '>'
break;
case 53: // '/>'
shift(53); // '/>'
break;
case 29: // QName
shift(29); // QName
break;
case 60: // '='
shift(60); // '='
break;
case 37: // '"'
shift(37); // '"'
break;
case 41: // "'"
shift(41); // "'"
break;
default:
shift(35); // EOF
}
eventHandler.endNonterminal("StartTag", e0);
};
this.parse_TagContent = function()
{
eventHandler.startNonterminal("TagContent", e0);
lookahead1(11); // Tag | EndTag | PredefinedEntityRef | ElementContentChar | CharRef | EOF |
switch (l1)
{
case 25: // ElementContentChar
shift(25); // ElementContentChar
break;
case 9: // Tag
shift(9); // Tag
break;
case 10: // EndTag
shift(10); // EndTag
break;
case 58: // '<![CDATA['
shift(58); // '<![CDATA['
break;
case 57: // '<!--'
shift(57); // '<!--'
break;
case 21: // PredefinedEntityRef
shift(21); // PredefinedEntityRef
break;
case 31: // CharRef
shift(31); // CharRef
break;
case 275: // '{{'
shift(275); // '{{'
break;
case 278: // '}}'
shift(278); // '}}'
break;
case 274: // '{'
shift(274); // '{'
break;
default:
shift(35); // EOF
}
eventHandler.endNonterminal("TagContent", e0);
};
this.parse_AposAttr = function()
{
eventHandler.startNonterminal("AposAttr", e0);
lookahead1(10); // PredefinedEntityRef | EscapeApos | AposAttrContentChar | CharRef | EOF | "'" |
switch (l1)
{
case 23: // EscapeApos
shift(23); // EscapeApos
break;
case 27: // AposAttrContentChar
shift(27); // AposAttrContentChar
break;
case 21: // PredefinedEntityRef
shift(21); // PredefinedEntityRef
break;
case 31: // CharRef
shift(31); // CharRef
break;
case 275: // '{{'
shift(275); // '{{'
break;
case 278: // '}}'
shift(278); // '}}'
break;
case 274: // '{'
shift(274); // '{'
break;
case 41: // "'"
shift(41); // "'"
break;
default:
shift(35); // EOF
}
eventHandler.endNonterminal("AposAttr", e0);
};
this.parse_QuotAttr = function()
{
eventHandler.startNonterminal("QuotAttr", e0);
lookahead1(9); // PredefinedEntityRef | EscapeQuot | QuotAttrContentChar | CharRef | EOF | '"' |
switch (l1)
{
case 22: // EscapeQuot
shift(22); // EscapeQuot
break;
case 26: // QuotAttrContentChar
shift(26); // QuotAttrContentChar
break;
case 21: // PredefinedEntityRef
shift(21); // PredefinedEntityRef
break;
case 31: // CharRef
shift(31); // CharRef
break;
case 275: // '{{'
shift(275); // '{{'
break;
case 278: // '}}'
shift(278); // '}}'
break;
case 274: // '{'
shift(274); // '{'
break;
case 37: // '"'
shift(37); // '"'
break;
default:
shift(35); // EOF
}
eventHandler.endNonterminal("QuotAttr", e0);
};
this.parse_CData = function()
{
eventHandler.startNonterminal("CData", e0);
lookahead1(1); // CDataSectionContents | EOF | ']]>'
switch (l1)
{
case 14: // CDataSectionContents
shift(14); // CDataSectionContents
break;
case 67: // ']]>'
shift(67); // ']]>'
break;
default:
shift(35); // EOF
}
eventHandler.endNonterminal("CData", e0);
};
this.parse_XMLComment = function()
{
eventHandler.startNonterminal("XMLComment", e0);
lookahead1(0); // DirCommentContents | EOF | '-->'
switch (l1)
{
case 12: // DirCommentContents
shift(12); // DirCommentContents
break;
case 50: // '-->'
shift(50); // '-->'
break;
default:
shift(35); // EOF
}
eventHandler.endNonterminal("XMLComment", e0);
};
this.parse_PI = function()
{
eventHandler.startNonterminal("PI", e0);
lookahead1(3); // DirPIContents | EOF | '?' | '?>'
switch (l1)
{
case 13: // DirPIContents
shift(13); // DirPIContents
break;
case 62: // '?'
shift(62); // '?'
break;
case 63: // '?>'
shift(63); // '?>'
break;
default:
shift(35); // EOF
}
eventHandler.endNonterminal("PI", e0);
};
this.parse_Pragma = function()
{
eventHandler.startNonterminal("Pragma", e0);
lookahead1(2); // PragmaContents | EOF | '#' | '#)'
switch (l1)
{
case 11: // PragmaContents
shift(11); // PragmaContents
break;
case 38: // '#'
shift(38); // '#'
break;
case 39: // '#)'
shift(39); // '#)'
break;
default:
shift(35); // EOF
}
eventHandler.endNonterminal("Pragma", e0);
};
this.parse_Comment = function()
{
eventHandler.startNonterminal("Comment", e0);
lookahead1(4); // CommentContents | EOF | '(:' | ':)'
switch (l1)
{
case 55: // ':)'
shift(55); // ':)'
break;
case 44: // '(:'
shift(44); // '(:'
break;
case 32: // CommentContents
shift(32); // CommentContents
break;
default:
shift(35); // EOF
}
eventHandler.endNonterminal("Comment", e0);
};
this.parse_CommentDoc = function()
{
eventHandler.startNonterminal("CommentDoc", e0);
lookahead1(6); // DocTag | DocCommentContents | EOF | '(:' | ':)'
switch (l1)
{
case 33: // DocTag
shift(33); // DocTag
break;
case 34: // DocCommentContents
shift(34); // DocCommentContents
break;
case 55: // ':)'
shift(55); // ':)'
break;
case 44: // '(:'
shift(44); // '(:'
break;
default:
shift(35); // EOF
}
eventHandler.endNonterminal("CommentDoc", e0);
};
this.parse_QuotString = function()
{
eventHandler.startNonterminal("QuotString", e0);
lookahead1(5); // JSONChar | JSONCharRef | JSONPredefinedCharRef | EOF | '"'
switch (l1)
{
case 3: // JSONPredefinedCharRef
shift(3); // JSONPredefinedCharRef
break;
case 2: // JSONCharRef
shift(2); // JSONCharRef
break;
case 1: // JSONChar
shift(1); // JSONChar
break;
case 37: // '"'
shift(37); // '"'
break;
default:
shift(35); // EOF
}
eventHandler.endNonterminal("QuotString", e0);
};
this.parse_AposString = function()
{
eventHandler.startNonterminal("AposString", e0);
lookahead1(7); // PredefinedEntityRef | EscapeApos | AposChar | CharRef | EOF | "'"
switch (l1)
{
case 21: // PredefinedEntityRef
shift(21); // PredefinedEntityRef
break;
case 31: // CharRef
shift(31); // CharRef
break;
case 23: // EscapeApos
shift(23); // EscapeApos
break;
case 24: // AposChar
shift(24); // AposChar
break;
case 41: // "'"
shift(41); // "'"
break;
default:
shift(35); // EOF
}
eventHandler.endNonterminal("AposString", e0);
};
this.parse_Prefix = function()
{
eventHandler.startNonterminal("Prefix", e0);
lookahead1W(13); // NCName^Token | S^WS | 'after' | 'allowing' | 'ancestor' | 'ancestor-or-self' |
whitespace();
parse_NCName();
eventHandler.endNonterminal("Prefix", e0);
};
this.parse__EQName = function()
{
eventHandler.startNonterminal("_EQName", e0);
lookahead1W(12); // EQName^Token | S^WS | 'after' | 'allowing' | 'ancestor' | 'ancestor-or-self' |
whitespace();
parse_EQName();
eventHandler.endNonterminal("_EQName", e0);
};
function parse_EQName()
{
eventHandler.startNonterminal("EQName", e0);
switch (l1)
{
case 80: // 'attribute'
shift(80); // 'attribute'
break;
case 94: // 'comment'
shift(94); // 'comment'
break;
case 118: // 'document-node'
shift(118); // 'document-node'
break;
case 119: // 'element'
shift(119); // 'element'
break;
case 122: // 'empty-sequence'
shift(122); // 'empty-sequence'
break;
case 143: // 'function'
shift(143); // 'function'
break;
case 150: // 'if'
shift(150); // 'if'
break;
case 163: // 'item'
shift(163); // 'item'
break;
case 183: // 'namespace-node'
shift(183); // 'namespace-node'
break;
case 189: // 'node'
shift(189); // 'node'
break;
case 214: // 'processing-instruction'
shift(214); // 'processing-instruction'
break;
case 224: // 'schema-attribute'
shift(224); // 'schema-attribute'
break;
case 225: // 'schema-element'
shift(225); // 'schema-element'
break;
case 241: // 'switch'
shift(241); // 'switch'
break;
case 242: // 'text'
shift(242); // 'text'
break;
case 251: // 'typeswitch'
shift(251); // 'typeswitch'
break;
default:
parse_FunctionName();
}
eventHandler.endNonterminal("EQName", e0);
}
function parse_FunctionName()
{
eventHandler.startNonterminal("FunctionName", e0);
switch (l1)
{
case 17: // EQName^Token
shift(17); // EQName^Token
break;
case 68: // 'after'
shift(68); // 'after'
break;
case 71: // 'ancestor'
shift(71); // 'ancestor'
break;
case 72: // 'ancestor-or-self'
shift(72); // 'ancestor-or-self'
break;
case 73: // 'and'
shift(73); // 'and'
break;
case 77: // 'as'
shift(77); // 'as'
break;
case 78: // 'ascending'
shift(78); // 'ascending'
break;
case 82: // 'before'
shift(82); // 'before'
break;
case 86: // 'case'
shift(86); // 'case'
break;
case 87: // 'cast'
shift(87); // 'cast'
break;
case 88: // 'castable'
shift(88); // 'castable'
break;
case 91: // 'child'
shift(91); // 'child'
break;
case 92: // 'collation'
shift(92); // 'collation'
break;
case 101: // 'copy'
shift(101); // 'copy'
break;
case 103: // 'count'
shift(103); // 'count'
break;
case 106: // 'declare'
shift(106); // 'declare'
break;
case 107: // 'default'
shift(107); // 'default'
break;
case 108: // 'delete'
shift(108); // 'delete'
break;
case 109: // 'descendant'
shift(109); // 'descendant'
break;
case 110: // 'descendant-or-self'
shift(110); // 'descendant-or-self'
break;
case 111: // 'descending'
shift(111); // 'descending'
break;
case 116: // 'div'
shift(116); // 'div'
break;
case 117: // 'document'
shift(117); // 'document'
break;
case 120: // 'else'
shift(120); // 'else'
break;
case 121: // 'empty'
shift(121); // 'empty'
break;
case 124: // 'end'
shift(124); // 'end'
break;
case 126: // 'eq'
shift(126); // 'eq'
break;
case 127: // 'every'
shift(127); // 'every'
break;
case 129: // 'except'
shift(129); // 'except'
break;
case 132: // 'first'
shift(132); // 'first'
break;
case 133: // 'following'
shift(133); // 'following'
break;
case 134: // 'following-sibling'
shift(134); // 'following-sibling'
break;
case 135: // 'for'
shift(135); // 'for'
break;
case 144: // 'ge'
shift(144); // 'ge'
break;
case 146: // 'group'
shift(146); // 'group'
break;
case 148: // 'gt'
shift(148); // 'gt'
break;
case 149: // 'idiv'
shift(149); // 'idiv'
break;
case 151: // 'import'
shift(151); // 'import'
break;
case 157: // 'insert'
shift(157); // 'insert'
break;
case 158: // 'instance'
shift(158); // 'instance'
break;
case 160: // 'intersect'
shift(160); // 'intersect'
break;
case 161: // 'into'
shift(161); // 'into'
break;
case 162: // 'is'
shift(162); // 'is'
break;
case 168: // 'last'
shift(168); // 'last'
break;
case 170: // 'le'
shift(170); // 'le'
break;
case 172: // 'let'
shift(172); // 'let'
break;
case 176: // 'lt'
shift(176); // 'lt'
break;
case 178: // 'mod'
shift(178); // 'mod'
break;
case 179: // 'modify'
shift(179); // 'modify'
break;
case 180: // 'module'
shift(180); // 'module'
break;
case 182: // 'namespace'
shift(182); // 'namespace'
break;
case 184: // 'ne'
shift(184); // 'ne'
break;
case 196: // 'only'
shift(196); // 'only'
break;
case 198: // 'or'
shift(198); // 'or'
break;
case 199: // 'order'
shift(199); // 'order'
break;
case 200: // 'ordered'
shift(200); // 'ordered'
break;
case 204: // 'parent'
shift(204); // 'parent'
break;
case 210: // 'preceding'
shift(210); // 'preceding'
break;
case 211: // 'preceding-sibling'
shift(211); // 'preceding-sibling'
break;
case 216: // 'rename'
shift(216); // 'rename'
break;
case 217: // 'replace'
shift(217); // 'replace'
break;
case 218: // 'return'
shift(218); // 'return'
break;
case 222: // 'satisfies'
shift(222); // 'satisfies'
break;
case 227: // 'self'
shift(227); // 'self'
break;
case 233: // 'some'
shift(233); // 'some'
break;
case 234: // 'stable'
shift(234); // 'stable'
break;
case 235: // 'start'
shift(235); // 'start'
break;
case 246: // 'to'
shift(246); // 'to'
break;
case 247: // 'treat'
shift(247); // 'treat'
break;
case 248: // 'try'
shift(248); // 'try'
break;
case 252: // 'union'
shift(252); // 'union'
break;
case 254: // 'unordered'
shift(254); // 'unordered'
break;
case 258: // 'validate'
shift(258); // 'validate'
break;
case 264: // 'where'
shift(264); // 'where'
break;
case 268: // 'with'
shift(268); // 'with'
break;
case 272: // 'xquery'
shift(272); // 'xquery'
break;
case 70: // 'allowing'
shift(70); // 'allowing'
break;
case 79: // 'at'
shift(79); // 'at'
break;
case 81: // 'base-uri'
shift(81); // 'base-uri'
break;
case 83: // 'boundary-space'
shift(83); // 'boundary-space'
break;
case 84: // 'break'
shift(84); // 'break'
break;
case 89: // 'catch'
shift(89); // 'catch'
break;
case 96: // 'construction'
shift(96); // 'construction'
break;
case 99: // 'context'
shift(99); // 'context'
break;
case 100: // 'continue'
shift(100); // 'continue'
break;
case 102: // 'copy-namespaces'
shift(102); // 'copy-namespaces'
break;
case 104: // 'decimal-format'
shift(104); // 'decimal-format'
break;
case 123: // 'encoding'
shift(123); // 'encoding'
break;
case 130: // 'exit'
shift(130); // 'exit'
break;
case 131: // 'external'
shift(131); // 'external'
break;
case 139: // 'ft-option'
shift(139); // 'ft-option'
break;
case 152: // 'in'
shift(152); // 'in'
break;
case 153: // 'index'
shift(153); // 'index'
break;
case 159: // 'integrity'
shift(159); // 'integrity'
break;
case 169: // 'lax'
shift(169); // 'lax'
break;
case 190: // 'nodes'
shift(190); // 'nodes'
break;
case 197: // 'option'
shift(197); // 'option'
break;
case 201: // 'ordering'
shift(201); // 'ordering'
break;
case 220: // 'revalidation'
shift(220); // 'revalidation'
break;
case 223: // 'schema'
shift(223); // 'schema'
break;
case 226: // 'score'
shift(226); // 'score'
break;
case 232: // 'sliding'
shift(232); // 'sliding'
break;
case 238: // 'strict'
shift(238); // 'strict'
break;
case 249: // 'tumbling'
shift(249); // 'tumbling'
break;
case 250: // 'type'
shift(250); // 'type'
break;
case 255: // 'updating'
shift(255); // 'updating'
break;
case 259: // 'value'
shift(259); // 'value'
break;
case 260: // 'variable'
shift(260); // 'variable'
break;
case 261: // 'version'
shift(261); // 'version'
break;
case 265: // 'while'
shift(265); // 'while'
break;
case 95: // 'constraint'
shift(95); // 'constraint'
break;
case 174: // 'loop'
shift(174); // 'loop'
break;
default:
shift(219); // 'returning'
}
eventHandler.endNonterminal("FunctionName", e0);
}
function parse_NCName()
{
eventHandler.startNonterminal("NCName", e0);
switch (l1)
{
case 28: // NCName^Token
shift(28); // NCName^Token
break;
case 68: // 'after'
shift(68); // 'after'
break;
case 73: // 'and'
shift(73); // 'and'
break;
case 77: // 'as'
shift(77); // 'as'
break;
case 78: // 'ascending'
shift(78); // 'ascending'
break;
case 82: // 'before'
shift(82); // 'before'
break;
case 86: // 'case'
shift(86); // 'case'
break;
case 87: // 'cast'
shift(87); // 'cast'
break;
case 88: // 'castable'
shift(88); // 'castable'
break;
case 92: // 'collation'
shift(92); // 'collation'
break;
case 103: // 'count'
shift(103); // 'count'
break;
case 107: // 'default'
shift(107); // 'default'
break;
case 111: // 'descending'
shift(111); // 'descending'
break;
case 116: // 'div'
shift(116); // 'div'
break;
case 120: // 'else'
shift(120); // 'else'
break;
case 121: // 'empty'
shift(121); // 'empty'
break;
case 124: // 'end'
shift(124); // 'end'
break;
case 126: // 'eq'
shift(126); // 'eq'
break;
case 129: // 'except'
shift(129); // 'except'
break;
case 135: // 'for'
shift(135); // 'for'
break;
case 144: // 'ge'
shift(144); // 'ge'
break;
case 146: // 'group'
shift(146); // 'group'
break;
case 148: // 'gt'
shift(148); // 'gt'
break;
case 149: // 'idiv'
shift(149); // 'idiv'
break;
case 158: // 'instance'
shift(158); // 'instance'
break;
case 160: // 'intersect'
shift(160); // 'intersect'
break;
case 161: // 'into'
shift(161); // 'into'
break;
case 162: // 'is'
shift(162); // 'is'
break;
case 170: // 'le'
shift(170); // 'le'
break;
case 172: // 'let'
shift(172); // 'let'
break;
case 176: // 'lt'
shift(176); // 'lt'
break;
case 178: // 'mod'
shift(178); // 'mod'
break;
case 179: // 'modify'
shift(179); // 'modify'
break;
case 184: // 'ne'
shift(184); // 'ne'
break;
case 196: // 'only'
shift(196); // 'only'
break;
case 198: // 'or'
shift(198); // 'or'
break;
case 199: // 'order'
shift(199); // 'order'
break;
case 218: // 'return'
shift(218); // 'return'
break;
case 222: // 'satisfies'
shift(222); // 'satisfies'
break;
case 234: // 'stable'
shift(234); // 'stable'
break;
case 235: // 'start'
shift(235); // 'start'
break;
case 246: // 'to'
shift(246); // 'to'
break;
case 247: // 'treat'
shift(247); // 'treat'
break;
case 252: // 'union'
shift(252); // 'union'
break;
case 264: // 'where'
shift(264); // 'where'
break;
case 268: // 'with'
shift(268); // 'with'
break;
case 71: // 'ancestor'
shift(71); // 'ancestor'
break;
case 72: // 'ancestor-or-self'
shift(72); // 'ancestor-or-self'
break;
case 80: // 'attribute'
shift(80); // 'attribute'
break;
case 91: // 'child'
shift(91); // 'child'
break;
case 94: // 'comment'
shift(94); // 'comment'
break;
case 101: // 'copy'
shift(101); // 'copy'
break;
case 106: // 'declare'
shift(106); // 'declare'
break;
case 108: // 'delete'
shift(108); // 'delete'
break;
case 109: // 'descendant'
shift(109); // 'descendant'
break;
case 110: // 'descendant-or-self'
shift(110); // 'descendant-or-self'
break;
case 117: // 'document'
shift(117); // 'document'
break;
case 118: // 'document-node'
shift(118); // 'document-node'
break;
case 119: // 'element'
shift(119); // 'element'
break;
case 122: // 'empty-sequence'
shift(122); // 'empty-sequence'
break;
case 127: // 'every'
shift(127); // 'every'
break;
case 132: // 'first'
shift(132); // 'first'
break;
case 133: // 'following'
shift(133); // 'following'
break;
case 134: // 'following-sibling'
shift(134); // 'following-sibling'
break;
case 143: // 'function'
shift(143); // 'function'
break;
case 150: // 'if'
shift(150); // 'if'
break;
case 151: // 'import'
shift(151); // 'import'
break;
case 157: // 'insert'
shift(157); // 'insert'
break;
case 163: // 'item'
shift(163); // 'item'
break;
case 168: // 'last'
shift(168); // 'last'
break;
case 180: // 'module'
shift(180); // 'module'
break;
case 182: // 'namespace'
shift(182); // 'namespace'
break;
case 183: // 'namespace-node'
shift(183); // 'namespace-node'
break;
case 189: // 'node'
shift(189); // 'node'
break;
case 200: // 'ordered'
shift(200); // 'ordered'
break;
case 204: // 'parent'
shift(204); // 'parent'
break;
case 210: // 'preceding'
shift(210); // 'preceding'
break;
case 211: // 'preceding-sibling'
shift(211); // 'preceding-sibling'
break;
case 214: // 'processing-instruction'
shift(214); // 'processing-instruction'
break;
case 216: // 'rename'
shift(216); // 'rename'
break;
case 217: // 'replace'
shift(217); // 'replace'
break;
case 224: // 'schema-attribute'
shift(224); // 'schema-attribute'
break;
case 225: // 'schema-element'
shift(225); // 'schema-element'
break;
case 227: // 'self'
shift(227); // 'self'
break;
case 233: // 'some'
shift(233); // 'some'
break;
case 241: // 'switch'
shift(241); // 'switch'
break;
case 242: // 'text'
shift(242); // 'text'
break;
case 248: // 'try'
shift(248); // 'try'
break;
case 251: // 'typeswitch'
shift(251); // 'typeswitch'
break;
case 254: // 'unordered'
shift(254); // 'unordered'
break;
case 258: // 'validate'
shift(258); // 'validate'
break;
case 260: // 'variable'
shift(260); // 'variable'
break;
case 272: // 'xquery'
shift(272); // 'xquery'
break;
case 70: // 'allowing'
shift(70); // 'allowing'
break;
case 79: // 'at'
shift(79); // 'at'
break;
case 81: // 'base-uri'
shift(81); // 'base-uri'
break;
case 83: // 'boundary-space'
shift(83); // 'boundary-space'
break;
case 84: // 'break'
shift(84); // 'break'
break;
case 89: // 'catch'
shift(89); // 'catch'
break;
case 96: // 'construction'
shift(96); // 'construction'
break;
case 99: // 'context'
shift(99); // 'context'
break;
case 100: // 'continue'
shift(100); // 'continue'
break;
case 102: // 'copy-namespaces'
shift(102); // 'copy-namespaces'
break;
case 104: // 'decimal-format'
shift(104); // 'decimal-format'
break;
case 123: // 'encoding'
shift(123); // 'encoding'
break;
case 130: // 'exit'
shift(130); // 'exit'
break;
case 131: // 'external'
shift(131); // 'external'
break;
case 139: // 'ft-option'
shift(139); // 'ft-option'
break;
case 152: // 'in'
shift(152); // 'in'
break;
case 153: // 'index'
shift(153); // 'index'
break;
case 159: // 'integrity'
shift(159); // 'integrity'
break;
case 169: // 'lax'
shift(169); // 'lax'
break;
case 190: // 'nodes'
shift(190); // 'nodes'
break;
case 197: // 'option'
shift(197); // 'option'
break;
case 201: // 'ordering'
shift(201); // 'ordering'
break;
case 220: // 'revalidation'
shift(220); // 'revalidation'
break;
case 223: // 'schema'
shift(223); // 'schema'
break;
case 226: // 'score'
shift(226); // 'score'
break;
case 232: // 'sliding'
shift(232); // 'sliding'
break;
case 238: // 'strict'
shift(238); // 'strict'
break;
case 249: // 'tumbling'
shift(249); // 'tumbling'
break;
case 250: // 'type'
shift(250); // 'type'
break;
case 255: // 'updating'
shift(255); // 'updating'
break;
case 259: // 'value'
shift(259); // 'value'
break;
case 261: // 'version'
shift(261); // 'version'
break;
case 265: // 'while'
shift(265); // 'while'
break;
case 95: // 'constraint'
shift(95); // 'constraint'
break;
case 174: // 'loop'
shift(174); // 'loop'
break;
default:
shift(219); // 'returning'
}
eventHandler.endNonterminal("NCName", e0);
}
function shift(t)
{
if (l1 == t)
{
whitespace();
eventHandler.terminal(JSONiqTokenizer.TOKEN[l1], b1, e1 > size ? size : e1);
b0 = b1; e0 = e1; l1 = 0;
}
else
{
error(b1, e1, 0, l1, t);
}
}
function whitespace()
{
if (e0 != b1)
{
b0 = e0;
e0 = b1;
eventHandler.whitespace(b0, e0);
}
}
function matchW(set)
{
var code;
for (;;)
{
code = match(set);
if (code != 30) // S^WS
{
break;
}
}
return code;
}
function lookahead1W(set)
{
if (l1 == 0)
{
l1 = matchW(set);
b1 = begin;
e1 = end;
}
}
function lookahead1(set)
{
if (l1 == 0)
{
l1 = match(set);
b1 = begin;
e1 = end;
}
}
function error(b, e, s, l, t)
{
throw new self.ParseException(b, e, s, l, t);
}
var lk, b0, e0;
var l1, b1, e1;
var eventHandler;
var input;
var size;
var begin;
var end;
function match(tokenSetId)
{
var nonbmp = false;
begin = end;
var current = end;
var result = JSONiqTokenizer.INITIAL[tokenSetId];
var state = 0;
for (var code = result & 4095; code != 0; )
{
var charclass;
var c0 = current < size ? input.charCodeAt(current) : 0;
++current;
if (c0 < 0x80)
{
charclass = JSONiqTokenizer.MAP0[c0];
}
else if (c0 < 0xd800)
{
var c1 = c0 >> 4;
charclass = JSONiqTokenizer.MAP1[(c0 & 15) + JSONiqTokenizer.MAP1[(c1 & 31) + JSONiqTokenizer.MAP1[c1 >> 5]]];
}
else
{
if (c0 < 0xdc00)
{
var c1 = current < size ? input.charCodeAt(current) : 0;
if (c1 >= 0xdc00 && c1 < 0xe000)
{
++current;
c0 = ((c0 & 0x3ff) << 10) + (c1 & 0x3ff) + 0x10000;
nonbmp = true;
}
}
var lo = 0, hi = 5;
for (var m = 3; ; m = (hi + lo) >> 1)
{
if (JSONiqTokenizer.MAP2[m] > c0) hi = m - 1;
else if (JSONiqTokenizer.MAP2[6 + m] < c0) lo = m + 1;
else {charclass = JSONiqTokenizer.MAP2[12 + m]; break;}
if (lo > hi) {charclass = 0; break;}
}
}
state = code;
var i0 = (charclass << 12) + code - 1;
code = JSONiqTokenizer.TRANSITION[(i0 & 15) + JSONiqTokenizer.TRANSITION[i0 >> 4]];
if (code > 4095)
{
result = code;
code &= 4095;
end = current;
}
}
result >>= 12;
if (result == 0)
{
end = current - 1;
var c1 = end < size ? input.charCodeAt(end) : 0;
if (c1 >= 0xdc00 && c1 < 0xe000) --end;
return error(begin, end, state, -1, -1);
}
if (nonbmp)
{
for (var i = result >> 9; i > 0; --i)
{
--end;
var c1 = end < size ? input.charCodeAt(end) : 0;
if (c1 >= 0xdc00 && c1 < 0xe000) --end;
}
}
else
{
end -= result >> 9;
}
return (result & 511) - 1;
}
}
JSONiqTokenizer.getTokenSet = function(tokenSetId)
{
var set = [];
var s = tokenSetId < 0 ? - tokenSetId : INITIAL[tokenSetId] & 4095;
for (var i = 0; i < 279; i += 32)
{
var j = i;
var i0 = (i >> 5) * 2066 + s - 1;
var i1 = i0 >> 2;
var i2 = i1 >> 2;
var f = JSONiqTokenizer.EXPECTED[(i0 & 3) + JSONiqTokenizer.EXPECTED[(i1 & 3) + JSONiqTokenizer.EXPECTED[(i2 & 3) + JSONiqTokenizer.EXPECTED[i2 >> 2]]]];
for ( ; f != 0; f >>>= 1, ++j)
{
if ((f & 1) != 0)
{
set.push(JSONiqTokenizer.TOKEN[j]);
}
}
}
return set;
};
JSONiqTokenizer.MAP0 =
[ 67, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 31, 31, 33, 31, 31, 31, 31, 31, 31, 34, 35, 36, 37, 31, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 31, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 31, 62, 63, 64, 65, 37
];
JSONiqTokenizer.MAP1 =
[ 108, 124, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 156, 181, 181, 181, 181, 181, 214, 215, 213, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 214, 247, 261, 277, 293, 309, 347, 363, 379, 416, 416, 416, 408, 331, 323, 331, 323, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 433, 433, 433, 433, 433, 433, 433, 316, 331, 331, 331, 331, 331, 331, 331, 331, 394, 416, 416, 417, 415, 416, 416, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, 330, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 416, 67, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 37, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 31, 31, 33, 31, 31, 31, 31, 31, 31, 34, 35, 36, 37, 31, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 31, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 31, 62, 63, 64, 65, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 31, 31, 37, 37, 37, 37, 37, 37, 37, 66, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66
];
JSONiqTokenizer.MAP2 =
[ 57344, 63744, 64976, 65008, 65536, 983040, 63743, 64975, 65007, 65533, 983039, 1114111, 37, 31, 37, 31, 31, 37
];
JSONiqTokenizer.INITIAL =
[ 1, 2, 49155, 57348, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
];
JSONiqTokenizer.TRANSITION =
[ 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 17408, 19288, 17439, 36866, 17466, 36890, 36866, 21991, 22971, 22987, 17556, 17575, 22288, 17486, 17509, 17525, 18373, 18855, 22984, 17553, 17572, 22285, 22126, 17990, 18622, 19411, 20306, 17996, 17689, 17470, 17591, 20896, 17468, 17619, 22083, 36867, 19404, 20299, 36866, 17647, 17672, 18921, 19514, 17705, 20311, 37017, 17728, 17756, 17784, 17800, 17825, 17854, 18403, 18928, 19521, 17712, 37008, 19469, 17878, 18884, 17900, 17922, 17944, 18178, 17960, 18012, 18381, 18064, 18218, 17884, 18890, 17906, 17928, 18102, 25022, 18130, 36931, 36963, 17493, 18150, 18166, 18214, 25010, 25026, 36919, 18234, 18262, 18278, 18294, 18320, 18336, 18361, 18397, 18419, 18432, 18304, 18448, 18485, 18523, 18553, 18583, 18599, 18638, 18497, 19656, 18664, 18680, 18507, 18696, 19164, 18712, 18737, 17681, 22026, 20906, 20915, 22054, 17838, 17450, 22022, 18765, 18825, 18841, 18871, 18906, 18944, 18960, 18976, 19041, 19056, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19058, 19074, 36169, 17439, 36866, 17466, 36890, 36866, 22314, 19105, 22987, 17556, 17575, 22288, 17486, 17509, 17525, 18373, 18855, 22984, 17553, 17572, 22285, 22126, 17990, 18622, 19411, 20306, 17996, 17689, 17470, 17591, 20896, 17468, 17619, 22083, 36867, 19404, 20299, 36866, 17647, 17672, 18921, 19514, 17705, 20311, 37017, 17728, 17756, 17784, 17800, 17825, 17854, 18403, 18928, 19521, 17712, 37008, 19469, 17878, 18884, 17900, 17922, 17944, 18178, 17960, 18012, 18381, 1
];
JSONiqTokenizer.EXPECTED =
[ 291, 300, 304, 341, 315, 309, 305, 295, 319, 323, 327, 329, 296, 333, 337, 339, 342, 346, 350, 294, 356, 360, 312, 367, 352, 371, 363, 375, 379, 383, 387, 391, 395, 726, 399, 405, 518, 684, 405, 405, 405, 405, 808, 405, 405, 405, 512, 405, 405, 405, 431, 405, 405, 406, 405, 405, 404, 405, 405, 405, 405, 405, 405, 405, 908, 631, 410, 415, 405, 414, 419, 608, 405, 429, 602, 405, 435, 443, 405, 441, 641, 478, 405, 447, 451, 450, 456, 643, 461, 460, 762, 679, 465, 469, 741, 473, 477, 482, 486, 492, 932, 931, 523, 498, 504, 720, 405, 510, 596, 405, 516, 941, 580, 522, 929, 527, 590, 589, 897, 939, 534, 538, 547, 551, 555, 559, 563, 567, 571, 969, 575, 708, 690, 689, 579, 584, 634, 405, 594, 731, 405, 600, 882, 405, 606, 895, 786, 452, 612, 405, 615, 620, 876, 624, 628, 638, 647, 651, 655, 659, 663, 667, 676, 683, 688, 695, 694, 791, 405, 699, 437, 405, 706, 714, 405, 712, 825, 870, 405, 718, 724, 769, 768, 823, 730, 735, 745, 751, 422, 755, 759, 425, 766, 902, 810, 587, 775, 888, 887, 405, 773, 992, 405, 779, 962, 405, 785, 781, 986, 790, 795, 797, 506, 500, 499, 801, 805, 814, 820, 829, 833, 837, 841, 845, 849, 853, 857, 861, 616, 865, 869, 868, 488, 405, 874, 816, 405, 880, 738, 405, 886, 892, 543, 405, 901, 906, 913, 912, 918, 494, 541, 922, 926, 936, 945, 949, 953, 957, 530, 966, 973, 960, 702, 701, 405, 979, 981, 405, 985, 747, 405, 990, 998, 914, 405, 996, 1004, 672, 975, 974, 1014, 1002, 1008, 670, 1012, 405, 405, 405, 405, 405, 401, 1018, 1022, 1026, 1106, 1071, 1111, 1111, 1111, 1082, 1145, 1030, 1101, 1034, 1038, 1106, 1106, 1106, 1106, 1046, 1206, 1052, 1106, 1072, 1111, 1111, 1042, 1134, 1065, 1111, 1112, 1056, 1160, 1207, 1062, 1204, 1208, 1069, 1106, 1106, 1106, 1076, 1111, 1207, 1161, 1122, 1205, 1064, 1094, 1106, 1106, 1107, 1111, 1111, 1111, 1078, 1086, 1207, 1092, 1098, 1046, 1058, 1106, 1106, 1110, 1111, 1111, 1116, 1120, 1161, 1126, 1202, 1104, 1106, 1145, 1146, 1129, 1138, 1088, 1151, 1048, 1157, 1153, 1132, 1141, 1165, 1107, 1111, 1172, 1179, 1109, 1183, 1175, 1143, 1147, 1187, 1108, 1191, 1195, 1144, 1199, 1168, 1212, 1216, 1220, 1224, 1228, 1232, 1236, 1557, 1247, 1241, 1241, 1038, 1434, 1241, 1241, 1241, 1241, 1254, 1275, 1617, 1241, 1280, 1287, 1241, 1241, 1241, 1287, 1241, 2114, 1291, 1241, 1243, 1241, 2049, 1824, 2094, 2095, 1520, 1309, 1241, 1241, 1302, 1241, 1321, 1311, 1241, 1241, 1313, 1778, 1325, 1336, 1241, 1241, 1325, 1330, 1353, 1241, 1241, 1695, 1354, 1241, 1241, 1241, 1294, 1686, 1331, 1241, 1696, 1368, 1241, 1338, 1370, 1241, 1392, 1399, 1364, 2017, 1406, 2016, 1405, 1716, 1406, 1407, 1422, 1417, 1421, 1241, 1241, 1241, 1349, 1426, 1241, 1774, 1756, 1241, 1773, 1241, 1241, 1345, 1964, 1812, 1432, 1241, 1241, 1345, 1993, 1459, 1241, 1241, 1241, 1395, 1848, 1767, 1465, 1241, 1241, 1394, 1847, 1242, 1477, 1241, 1241, 1428, 1241, 1445, 1492, 1241, 1241, 1438, 1241, 1499, 1241, 1241, 1241, 1455, 1241, 1818, 1448, 1241, 1250, 1241, 2026, 1623, 1449, 1241, 1612, 1616, 1241, 1614, 1241, 1257, 1241, 1241, 1985, 1292, 1586, 1512, 1241, 1517, 2050, 1526, 1674, 1519, 1524, 1647, 2051, 1532, 1537, 1551, 1544, 1550, 1555, 1561, 1571, 1578, 1584, 1590, 1591, 1653, 1595, 1602, 1606, 1610, 1634, 1628, 1640, 1633, 1645, 1241, 1241, 1241, 1469, 1241, 1970, 1651, 1241, 1270, 1241, 1241, 1819, 1449, 1241, 1293, 1664, 1241, 1241, 1481, 1485, 1574, 1672, 1241, 1241, 1513, 1317, 1487, 1684, 1241, 1241, 1533, 1299, 1694, 1241, 1241, 1295, 1241, 1241, 1241, 1546, 1700, 1241, 1241, 1707, 1241, 1713, 1241, 1849, 1715, 1241, 1720, 1241, 1276, 1267, 1241, 1241, 2107, 1657, 1864, 1241, 1881, 1241, 1326, 1292, 1241, 1685, 1358, 1724, 1338, 1241, 1363, 1362, 1342, 1340, 1361, 1339, 1833, 1372, 1360, 1833, 1833, 1342, 1343, 1835, 1341, 1731, 1738, 1344, 1241, 1745, 1241, 1379, 1241, 1241, 2092, 1241, 1388, 1761, 1754, 1241, 1386, 1241, 1400, 1760, 1241, 1241, 1241, 1598, 1734, 1241, 1241, 1241, 1635, 1645, 1241, 1780, 1766, 1241, 1241, 1332, 1771, 1241, 1241, 1629, 2079, 1241, 1242, 1784, 1241, 1241, 1680, 1639, 2063, 1790, 1241, 1241, 1741, 1241, 1241, 1800, 1241, 1241, 1762, 147
];
JSONiqTokenizer.TOKEN =
[
"(0)",
"JSONChar",
"JSONCharRef",
"JSONPredefinedCharRef",
"ModuleDecl",
"Annotation",
"OptionDecl",
"Operator",
"Variable",
"Tag",
"EndTag",
"PragmaContents",
"DirCommentContents",
"DirPIContents",
"CDataSectionContents",
"AttrTest",
"Wildcard",
"EQName",
"IntegerLiteral",
"DecimalLiteral",
"DoubleLiteral",
"PredefinedEntityRef",
"'\"\"'",
"EscapeApos",
"AposChar",
"ElementContentChar",
"QuotAttrContentChar",
"AposAttrContentChar",
"NCName",
"QName",
"S",
"CharRef",
"CommentContents",
"DocTag",
"DocCommentContents",
"EOF",
"'!'",
"'\"'",
"'#'",
"'#)'",
"'$$'",
"''''",
"'('",
"'(#'",
"'(:'",
"'(:~'",
"')'",
"'*'",
"'*'",
"','",
"'-->'",
"'.'",
"'/'",
"'/>'",
"':'",
"':)'",
"';'",
"'<!--'",
"'<![CDATA['",
"'<?'",
"'='",
"'>'",
"'?'",
"'?>'",
"'NaN'",
"'['",
"']'",
"']]>'",
"'after'",
"'all'",
"'allowing'",
"'ancestor'",
"'ancestor-or-self'",
"'and'",
"'any'",
"'append'",
"'array'",
"'as'",
"'ascending'",
"'at'",
"'attribute'",
"'base-uri'",
"'before'",
"'boundary-space'",
"'break'",
"'by'",
"'case'",
"'cast'",
"'castable'",
"'catch'",
"'check'",
"'child'",
"'collation'",
"'collection'",
"'comment'",
"'constraint'",
"'construction'",
"'contains'",
"'content'",
"'context'",
"'continue'",
"'copy'",
"'copy-namespaces'",
"'count'",
"'decimal-format'",
"'decimal-separator'",
"'declare'",
"'default'",
"'delete'",
"'descendant'",
"'descendant-or-self'",
"'descending'",
"'diacritics'",
"'different'",
"'digit'",
"'distance'",
"'div'",
"'document'",
"'document-node'",
"'element'",
"'else'",
"'empty'",
"'empty-sequence'",
"'encoding'",
"'end'",
"'entire'",
"'eq'",
"'every'",
"'exactly'",
"'except'",
"'exit'",
"'external'",
"'first'",
"'following'",
"'following-sibling'",
"'for'",
"'foreach'",
"'foreign'",
"'from'",
"'ft-option'",
"'ftand'",
"'ftnot'",
"'ftor'",
"'function'",
"'ge'",
"'greatest'",
"'group'",
"'grouping-separator'",
"'gt'",
"'idiv'",
"'if'",
"'import'",
"'in'",
"'index'",
"'infinity'",
"'inherit'",
"'insensitive'",
"'insert'",
"'instance'",
"'integrity'",
"'intersect'",
"'into'",
"'is'",
"'item'",
"'json'",
"'json-item'",
"'key'",
"'language'",
"'last'",
"'lax'",
"'le'",
"'least'",
"'let'",
"'levels'",
"'loop'",
"'lowercase'",
"'lt'",
"'minus-sign'",
"'mod'",
"'modify'",
"'module'",
"'most'",
"'namespace'",
"'namespace-node'",
"'ne'",
"'next'",
"'no'",
"'no-inherit'",
"'no-preserve'",
"'node'",
"'nodes'",
"'not'",
"'object'",
"'occurs'",
"'of'",
"'on'",
"'only'",
"'option'",
"'or'",
"'order'",
"'ordered'",
"'ordering'",
"'paragraph'",
"'paragraphs'",
"'parent'",
"'pattern-separator'",
"'per-mille'",
"'percent'",
"'phrase'",
"'position'",
"'preceding'",
"'preceding-sibling'",
"'preserve'",
"'previous'",
"'processing-instruction'",
"'relationship'",
"'rename'",
"'replace'",
"'return'",
"'returning'",
"'revalidation'",
"'same'",
"'satisfies'",
"'schema'",
"'schema-attribute'",
"'schema-element'",
"'score'",
"'self'",
"'sensitive'",
"'sentence'",
"'sentences'",
"'skip'",
"'sliding'",
"'some'",
"'stable'",
"'start'",
"'stemming'",
"'stop'",
"'strict'",
"'strip'",
"'structured-item'",
"'switch'",
"'text'",
"'then'",
"'thesaurus'",
"'times'",
"'to'",
"'treat'",
"'try'",
"'tumbling'",
"'type'",
"'typeswitch'",
"'union'",
"'unique'",
"'unordered'",
"'updating'",
"'uppercase'",
"'using'",
"'validate'",
"'value'",
"'variable'",
"'version'",
"'weight'",
"'when'",
"'where'",
"'while'",
"'wildcards'",
"'window'",
"'with'",
"'without'",
"'word'",
"'words'",
"'xquery'",
"'zero-digit'",
"'{'",
"'{{'",
"'|'",
"'}'",
"'}}'"
];
},
{}],
2:[function(_dereq_,module,exports){
'use strict';
var JSONiqTokenizer = _dereq_('./JSONiqTokenizer').JSONiqTokenizer;
var TokenHandler = function(code) {
var input = code;
this.tokens = [];
this.reset = function() {
input = input;
this.tokens = [];
};
this.startNonterminal = function() {};
this.endNonterminal = function() {};
this.terminal = function(name, begin, end) {
this.tokens.push({
name: name,
value: input.substring(begin, end)
});
};
this.whitespace = function(begin, end) {
this.tokens.push({
name: 'WS',
value: input.substring(begin, end)
});
};
};
var keys = 'NaN|after|allowing|ancestor|ancestor-or-self|and|append|array|as|ascending|at|attribute|base-uri|before|boundary-space|break|by|case|cast|castable|catch|child|collation|comment|constraint|construction|contains|context|continue|copy|copy-namespaces|count|decimal-format|decimal-separator|declare|default|delete|descendant|descendant-or-self|descending|digit|div|document|document-node|element|else|empty|empty-sequence|encoding|end|eq|every|except|exit|external|false|first|following|following-sibling|for|from|ft-option|function|ge|greatest|group|grouping-separator|gt|idiv|if|import|in|index|infinity|insert|instance|integrity|intersect|into|is|item|json|json-item|jsoniq|last|lax|le|least|let|loop|lt|minus-sign|mod|modify|module|namespace|namespace-node|ne|next|node|nodes|not|null|object|of|only|option|or|order|ordered|ordering|paragraphs|parent|pattern-separator|per-mille|percent|preceding|preceding-sibling|previous|processing-instruction|rename|replace|return|returning|revalidation|satisfies|schema|schema-attribute|schema-element|score|select|self|sentences|sliding|some|stable|start|strict|switch|text|then|times|to|treat|true|try|tumbling|type|typeswitch|union|unordered|updating|validate|value|variable|version|when|where|while|window|with|words|xquery|zero-digit'.split('|');
var keywords = keys.map(function(val) { return { name: '\'' + val + '\'', token: 'keyword' }; });
var ncnames = keys.map(function(val) { return { name: '\'' + val + '\'', token: 'text', next: function(stack){ stack.pop(); } }; });
var cdata = 'constant.language';
var number = 'constant';
var xmlcomment = 'comment';
var pi = 'xml-pe';
var pragma = 'constant.buildin';
var n = function(name){
return '\'' + name + '\'';
};
var Rules = {
start: [
{ name: n('(#'), token: pragma, next: function(stack){ stack.push('Pragma'); } },
{ name: n('(:'), token: 'comment', next: function(stack){ stack.push('Comment'); } },
{ name: n('(:~'), token: 'comment.doc', next: function(stack){ stack.push('CommentDoc'); } },
{ name: n('<!--'), token: xmlcomment, next: function(stack){ stack.push('XMLComment'); } },
{ name: n('<?'), token: pi, next: function(stack) { stack.push('PI'); } },
{ name: n('\'\''), token: 'string', next: function(stack){ stack.push('AposString'); } },
{ name: n('"'), token: 'string', next: function(stack){ stack.push('QuotString'); } },
{ name: 'Annotation', token: 'support.function' },
{ name: 'ModuleDecl', token: 'keyword', next: function(stack){ stack.push('Prefix'); } },
{ name: 'OptionDecl', token: 'keyword', next: function(stack){ stack.push('_EQName'); } },
{ name: 'AttrTest', token: 'support.type' },
{ name: 'Variable', token: 'variable' },
{ name: n('<![CDATA['), token: cdata, next: function(stack){ stack.push('CData'); } },
{ name: 'IntegerLiteral', token: number },
{ name: 'DecimalLiteral', token: number },
{ name: 'DoubleLiteral', token: number },
{ name: 'Operator', token: 'keyword.operator' },
{ name: 'EQName', token: function(val) { return keys.indexOf(val) !== -1 ? 'keyword' : 'support.function'; } },
{ name: n('('), token: 'lparen' },
{ name: n(')'), token: 'rparen' },
{ name: 'Tag', token: 'meta.tag', next: function(stack){ stack.push('StartTag'); } },
{ name: n('}'), token: 'text', next: function(stack){ if(stack.length > 1) { stack.pop(); } } },
{ name: n('{'), token: 'text', next: function(stack){ stack.push('start'); } } //, next: function(stack){ if(stack.length > 1) { stack.pop(); } } }
].concat(keywords),
_EQName: [
{ name: 'EQName', token: 'text', next: function(stack) { stack.pop(); } }
].concat(ncnames),
Prefix: [
{ name: 'NCName', token: 'text', next: function(stack) { stack.pop(); } }
].concat(ncnames),
StartTag: [
{ name: n('>'), token: 'meta.tag', next: function(stack){ stack.push('TagContent'); } },
{ name: 'QName', token: 'entity.other.attribute-name' },
{ name: n('='), token: 'text' },
{ name: n('\'\''), token: 'string', next: function(stack){ stack.push('AposAttr'); } },
{ name: n('"'), token: 'string', next: function(stack){ stack.push('QuotAttr'); } },
{ name: n('/>'), token: 'meta.tag.r', next: function(stack){ stack.pop(); } }
],
TagContent: [
{ name: 'ElementContentChar', token: 'text' },
{ name: n('<![CDATA['), token: cdata, next: function(stack){ stack.push('CData'); } },
{ name: n('<!--'), token: xmlcomment, next: function(stack){ stack.push('XMLComment'); } },
{ name: 'Tag', token: 'meta.tag', next: function(stack){ stack.push('StartTag'); } },
{ name: 'PredefinedEntityRef', token: 'constant.language.escape' },
{ name: 'CharRef', token: 'constant.language.escape' },
{ name: n('{{'), token: 'text' },
{ name: n('}}'), token: 'text' },
{ name: n('{'), token: 'text', next: function(stack){ stack.push('start'); } },
{ name: 'EndTag', token: 'meta.tag', next: function(stack){ stack.pop(); stack.pop(); } }
],
AposAttr: [
{ name: n('\'\''), token: 'string', next: function(stack){ stack.pop(); } },
{ name: 'EscapeApos', token: 'constant.language.escape' },
{ name: 'AposAttrContentChar', token: 'string' },
{ name: 'PredefinedEntityRef', token: 'constant.language.escape' },
{ name: 'CharRef', token: 'constant.language.escape' },
{ name: n('{{'), token: 'string' },
{ name: n('}}'), token: 'string' },
{ name: n('{'), token: 'text', next: function(stack){ stack.push('start'); } }
],
QuotAttr: [
{ name: n('\"'), token: 'string', next: function(stack){ stack.pop(); } },
{ name: 'EscapeQuot', token: 'constant.language.escape' },
{ name: 'QuotAttrContentChar', token: 'string' },
{ name: 'PredefinedEntityRef', token: 'constant.language.escape' },
{ name: 'CharRef', token: 'constant.language.escape' },
{ name: n('{{'), token: 'string' },
{ name: n('}}'), token: 'string' },
{ name: n('{'), token: 'text', next: function(stack){ stack.push('start'); } }
],
Pragma: [
{ name: 'PragmaContents', token: pragma },
{ name: n('#'), token: pragma },
{ name: n('#)'), token: pragma, next: function(stack){ stack.pop(); } }
],
Comment: [
{ name: 'CommentContents', token: 'comment' },
{ name: n('(:'), token: 'comment', next: function(stack){ stack.push('Comment'); } },
{ name: n(':)'), token: 'comment', next: function(stack){ stack.pop(); } }
],
CommentDoc: [
{ name: 'DocCommentContents', token: 'comment.doc' },
{ name: 'DocTag', token: 'comment.doc.tag' },
{ name: n('(:'), token: 'comment.doc', next: function(stack){ stack.push('CommentDoc'); } },
{ name: n(':)'), token: 'comment.doc', next: function(stack){ stack.pop(); } }
],
XMLComment: [
{ name: 'DirCommentContents', token: xmlcomment },
{ name: n('-->'), token: xmlcomment, next: function(stack){ stack.pop(); } }
],
CData: [
{ name: 'CDataSectionContents', token: cdata },
{ name: n(']]>'), token: cdata, next: function(stack){ stack.pop(); } }
],
PI: [
{ name: 'DirPIContents', token: pi },
{ name: n('?'), token: pi },
{ name: n('?>'), token: pi, next: function(stack){ stack.pop(); } }
],
AposString: [
{ name: n('\'\''), token: 'string', next: function(stack){ stack.pop(); } },
{ name: 'PredefinedEntityRef', token: 'constant.language.escape' },
{ name: 'CharRef', token: 'constant.language.escape' },
{ name: 'EscapeApos', token: 'constant.language.escape' },
{ name: 'AposChar', token: 'string' }
],
QuotString: [
{ name: n('"'), token: 'string', next: function(stack){ stack.pop(); } },
{ name: 'JSONPredefinedCharRef', token: 'constant.language.escape' },
{ name: 'JSONCharRef', token: 'constant.language.escape' },
{ name: 'JSONChar', token: 'string' }
]
};
exports.JSONiqLexer = function() {
this.tokens = [];
this.getLineTokens = function(line, state) {
state = (state === 'start' || !state) ? '["start"]' : state;
var stack = JSON.parse(state);
var h = new TokenHandler(line);
var tokenizer = new JSONiqTokenizer(line, h);
var tokens = [];
while(true) {
var currentState = stack[stack.length - 1];
try {
h.tokens = [];
tokenizer['parse_' + currentState]();
var info = null;
if(h.tokens.length > 1 && h.tokens[0].name === 'WS') {
tokens.push({
type: 'text',
value: h.tokens[0].value
});
h.tokens.splice(0, 1);
}
var token = h.tokens[0];
var rules = Rules[currentState];
for(var k = 0; k < rules.length; k++) {
var rule = Rules[currentState][k];
if((typeof(rule.name) === 'function' && rule.name(token)) || rule.name === token.name) {
info = rule;
break;
}
}
if(token.name === 'EOF') { break; }
if(token.value === '') { throw 'Encountered empty string lexical rule.'; }
tokens.push({
type: info === null ? 'text' : (typeof(info.token) === 'function' ? info.token(token.value) : info.token),
value: token.value
});
if(info && info.next) {
info.next(stack);
}
} catch(e) {
if(e instanceof tokenizer.ParseException) {
var index = 0;
for(var i=0; i < tokens.length; i++) {
index += tokens[i].value.length;
}
tokens.push({ type: 'text', value: line.substring(index) });
return {
tokens: tokens,
state: JSON.stringify(['start'])
};
} else {
throw e;
}
}
}
return {
tokens: tokens,
state: JSON.stringify(stack)
};
};
};
},
{"./JSONiqTokenizer":1}]},{},[2])
(2)
});
ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var Behaviour = require("../behaviour").Behaviour;
var TokenIterator = require("../../token_iterator").TokenIterator;
var lang = require("../../lib/lang");
var SAFE_INSERT_IN_TOKENS =
["text", "paren.rparen", "punctuation.operator"];
var SAFE_INSERT_BEFORE_TOKENS =
["text", "paren.rparen", "punctuation.operator", "comment"];
var context;
var contextCache = {}
var initContext = function(editor) {
var id = -1;
if (editor.multiSelect) {
id = editor.selection.id;
if (contextCache.rangeCount != editor.multiSelect.rangeCount)
contextCache = {rangeCount: editor.multiSelect.rangeCount};
}
if (contextCache[id])
return context = contextCache[id];
context = contextCache[id] = {
autoInsertedBrackets: 0,
autoInsertedRow: -1,
autoInsertedLineEnd: "",
maybeInsertedBrackets: 0,
maybeInsertedRow: -1,
maybeInsertedLineStart: "",
maybeInsertedLineEnd: ""
};
};
var CstyleBehaviour = function() {
this.add("braces", "insertion", function(state, action, editor, session, text) {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
if (text == '{') {
initContext(editor);
var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection);
if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
return {
text: '{' + selected + '}',
selection: false
};
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
CstyleBehaviour.recordAutoInsert(editor, session, "}");
return {
text: '{}',
selection: [1, 1]
};
} else {
CstyleBehaviour.recordMaybeInsert(editor, session, "{");
return {
text: '{',
selection: [1, 1]
};
}
}
} else if (text == '}') {
initContext(editor);
var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '}') {
var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
CstyleBehaviour.popAutoInsertedClosing();
return {
text: '',
selection: [1, 1]
};
}
}
} else if (text == "\n" || text == "\r\n") {
initContext(editor);
var closing = "";
if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
CstyleBehaviour.clearMaybeInsertedClosing();
}
var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar === '}') {
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
if (!openBracePos)
return null;
var next_indent = this.$getIndent(session.getLine(openBracePos.row));
} else if (closing) {
var next_indent = this.$getIndent(line);
} else {
CstyleBehaviour.clearMaybeInsertedClosing();
return;
}
var indent = next_indent + session.getTabString();
return {
text: '\n' + indent + '\n' + next_indent + closing,
selection: [1, indent.length, 1, indent.length]
};
} else {
CstyleBehaviour.clearMaybeInsertedClosing();
}
});
this.add("braces", "deletion", function(state, action, editor, session, range) {
var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '{') {
initContext(editor);
var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.end.column, range.end.column + 1);
if (rightChar == '}') {
range.end.column++;
return range;
} else {
context.maybeInsertedBrackets--;
}
}
});
this.add("parens", "insertion", function(state, action, editor, session, text) {
if (text == '(') {
initContext(editor);
var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection);
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
return {
text: '(' + selected + ')',
selection: false
};
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
CstyleBehaviour.recordAutoInsert(editor, session, ")");
return {
text: '()',
selection: [1, 1]
};
}
} else if (text == ')') {
initContext(editor);
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == ')') {
var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
CstyleBehaviour.popAutoInsertedClosing();
return {
text: '',
selection: [1, 1]
};
}
}
}
});
this.add("parens", "deletion", function(state, action, editor, session, range) {
var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '(') {
initContext(editor);
var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == ')') {
range.end.column++;
return range;
}
}
});
this.add("brackets", "insertion", function(state, action, editor, session, text) {
if (text == '[') {
initContext(editor);
var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection);
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
return {
text: '[' + selected + ']',
selection: false
};
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
CstyleBehaviour.recordAutoInsert(editor, session, "]");
return {
text: '[]',
selection: [1, 1]
};
}
} else if (text == ']') {
initContext(editor);
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == ']') {
var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
CstyleBehaviour.popAutoInsertedClosing();
return {
text: '',
selection: [1, 1]
};
}
}
}
});
this.add("brackets", "deletion", function(state, action, editor, session, range) {
var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '[') {
initContext(editor);
var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == ']') {
range.end.column++;
return range;
}
}
});
this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
if (text == '"' || text == "'") {
initContext(editor);
var quote = text;
var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection);
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
return {
text: quote + selected + quote,
selection: false
};
} else {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var leftChar = line.substring(cursor.column-1, cursor.column);
if (leftChar == '\\') {
return null;
}
var tokens = session.getTokens(selection.start.row);
var col = 0, token;
var quotepos = -1; // Track whether we're inside an open quote.
for (var x = 0; x < tokens.length; x++) {
token = tokens[x];
if (token.type == "string") {
quotepos = -1;
} else if (quotepos < 0) {
quotepos = token.value.indexOf(quote);
}
if ((token.value.length + col) > selection.start.column) {
break;
}
col += tokens[x].value.length;
}
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
if (!CstyleBehaviour.isSaneInsertion(editor, session))
return;
return {
text: quote + quote,
selection: [1,1]
};
} else if (token && token.type === "string") {
var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == quote) {
return {
text: '',
selection: [1, 1]
};
}
}
}
}
});
this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
initContext(editor);
var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == selected) {
range.end.column++;
return range;
}
}
});
};
CstyleBehaviour.isSaneInsertion = function(editor, session) {
var cursor = editor.getCursorPosition();
var iterator = new TokenIterator(session, cursor.row, cursor.column);
if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
return false;
}
iterator.stepForward();
return iterator.getCurrentTokenRow() !== cursor.row ||
this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
};
CstyleBehaviour.$matchTokenType = function(token, types) {
return types.indexOf(token.type || token) > -1;
};
CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
context.autoInsertedBrackets = 0;
context.autoInsertedRow = cursor.row;
context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
context.autoInsertedBrackets++;
};
CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
if (!this.isMaybeInsertedClosing(cursor, line))
context.maybeInsertedBrackets = 0;
context.maybeInsertedRow = cursor.row;
context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
context.maybeInsertedLineEnd = line.substr(cursor.column);
context.maybeInsertedBrackets++;
};
CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
return context.autoInsertedBrackets > 0 &&
cursor.row === context.autoInsertedRow &&
bracket === context.autoInsertedLineEnd[0] &&
line.substr(cursor.column) === context.autoInsertedLineEnd;
};
CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
return context.maybeInsertedBrackets > 0 &&
cursor.row === context.maybeInsertedRow &&
line.substr(cursor.column) === context.maybeInsertedLineEnd &&
line.substr(0, cursor.column) == context.maybeInsertedLineStart;
};
CstyleBehaviour.popAutoInsertedClosing = function() {
context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
context.autoInsertedBrackets--;
};
CstyleBehaviour.clearMaybeInsertedClosing = function() {
if (context) {
context.maybeInsertedBrackets = 0;
context.maybeInsertedRow = -1;
}
};
oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour;
});
ace.define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator"], function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var Behaviour = require("../behaviour").Behaviour;
var TokenIterator = require("../../token_iterator").TokenIterator;
function is(token, type) {
return token.type.lastIndexOf(type + ".xml") > -1;
}
var XmlBehaviour = function () {
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"' || text == "'") {
var quote = text;
var selected = session.doc.getTextRange(editor.getSelectionRange());
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
return {
text: quote + selected + quote,
selection: false
};
}
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var rightChar = line.substring(cursor.column, cursor.column + 1);
var iterator = new TokenIterator(session, cursor.row, cursor.column);
var token = iterator.getCurrentToken();
if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
return {
text: "",
selection: [1, 1]
};
}
if (!token)
token = iterator.stepBackward();
if (!token)
return;
while (is(token, "tag-whitespace") || is(token, "whitespace")) {
token = iterator.stepBackward();
}
var rightSpace = !rightChar || rightChar.match(/\s/);
if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
return {
text: quote + quote,
selection: [1, 1]
};
}
}
});
this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == selected) {
range.end.column++;
return range;
}
}
});
this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
if (text == '>') {
var position = editor.getCursorPosition();
var iterator = new TokenIterator(session, position.row, position.column);
var token = iterator.getCurrentToken() || iterator.stepBackward();
if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
return;
if (is(token, "reference.attribute-value"))
return;
if (is(token, "attribute-value")) {
var firstChar = token.value.charAt(0);
if (firstChar == '"' || firstChar == "'") {
var lastChar = token.value.charAt(token.value.length - 1);
var tokenEnd = iterator.getCurrentTokenColumn() + token.value.length;
if (tokenEnd > position.column || tokenEnd == position.column && firstChar != lastChar)
return;
}
}
while (!is(token, "tag-name")) {
token = iterator.stepBackward();
}
var tokenRow = iterator.getCurrentTokenRow();
var tokenColumn = iterator.getCurrentTokenColumn();
if (is(iterator.stepBackward(), "end-tag-open"))
return;
var element = token.value;
if (tokenRow == position.row)
element = element.substring(0, position.column - tokenColumn);
if (this.voidElements.hasOwnProperty(element.toLowerCase()))
return;
return {
text: '>' + '</' + element + '>',
selection: [1, 1]
};
}
});
this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
if (text == "\n") {
var cursor = editor.getCursorPosition();
var line = session.getLine(cursor.row);
var rightChars = line.substring(cursor.column, cursor.column + 2);
if (rightChars == '</') {
var next_indent = this.$getIndent(line);
var indent = next_indent + session.getTabString();
return {
text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length]
};
}
}
});
};
oop.inherits(XmlBehaviour, Behaviour);
exports.XmlBehaviour = XmlBehaviour;
});
ace.define("ace/mode/behaviour/xquery",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/mode/behaviour/cstyle","ace/mode/behaviour/xml","ace/token_iterator"], function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var Behaviour = require('../behaviour').Behaviour;
var CstyleBehaviour = require('./cstyle').CstyleBehaviour;
var XmlBehaviour = require("../behaviour/xml").XmlBehaviour;
var TokenIterator = require("../../token_iterator").TokenIterator;
function hasType(token, type) {
var hasType = true;
var typeList = token.type.split('.');
var needleList = type.split('.');
needleList.forEach(function(needle){
if (typeList.indexOf(needle) == -1) {
hasType = false;
return false;
}
});
return hasType;
}
var XQueryBehaviour = function () {
this.inherit(CstyleBehaviour, ["braces", "parens", "string_dquotes"]); // Get string behaviour
this.inherit(XmlBehaviour); // Get xml behaviour
this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
if (text == '>') {
var position = editor.getCursorPosition();
var iterator = new TokenIterator(session, position.row, position.column);
var token = iterator.getCurrentToken();
var atCursor = false;
var state = JSON.parse(state).pop();
if ((token && token.value === '>') || state !== "StartTag") return;
if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
do {
token = iterator.stepBackward();
} while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
} else {
atCursor = true;
}
var previous = iterator.stepBackward();
if (!token || !hasType(token, 'meta.tag') || (previous !== null && previous.value.match('/'))) {
return
}
var tag = token.value.substring(1);
if (atCursor){
var tag = tag.substring(0, position.column - token.start);
}
return {
text: '>' + '</' + tag + '>',
selection: [1, 1]
}
}
});
}
oop.inherits(XQueryBehaviour, Behaviour);
exports.XQueryBehaviour = XQueryBehaviour;
});
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var Range = require("../../range").Range;
var BaseFoldMode = require("./fold_mode").FoldMode;
var FoldMode = exports.FoldMode = function(commentRegex) {
if (commentRegex) {
this.foldingStartMarker = new RegExp(
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
);
this.foldingStopMarker = new RegExp(
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
);
}
};
oop.inherits(FoldMode, BaseFoldMode);
(function() {
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
var line = session.getLine(row);
var match = line.match(this.foldingStartMarker);
if (match) {
var i = match.index;
if (match[1])
return this.openingBracketBlock(session, match[1], row, i);
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
if (range && !range.isMultiLine()) {
if (forceMultiline) {
range = this.getSectionRange(session, row);
} else if (foldStyle != "all")
range = null;
}
return range;
}
if (foldStyle === "markbegin")
return;
var match = line.match(this.foldingStopMarker);
if (match) {
var i = match.index + match[0].length;
if (match[1])
return this.closingBracketBlock(session, match[1], row, i);
return session.getCommentFoldRange(row, i, -1);
}
};
this.getSectionRange = function(session, row) {
var line = session.getLine(row);
var startIndent = line.search(/\S/);
var startRow = row;
var startColumn = line.length;
row = row + 1;
var endRow = row;
var maxRow = session.getLength();
while (++row < maxRow) {
line = session.getLine(row);
var indent = line.search(/\S/);
if (indent === -1)
continue;
if (startIndent > indent)
break;
var subRange = this.getFoldWidgetRange(session, "all", row);
if (subRange) {
if (subRange.start.row <= startRow) {
break;
} else if (subRange.isMultiLine()) {
row = subRange.end.row;
} else if (startIndent == indent) {
break;
}
}
endRow = row;
}
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
};
}).call(FoldMode.prototype);
});
ace.define("ace/snippets",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/anchor","ace/keyboard/hash_handler","ace/tokenizer","ace/lib/dom","ace/editor"], function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var lang = require("./lib/lang");
var Range = require("./range").Range;
var Anchor = require("./anchor").Anchor;
var HashHandler = require("./keyboard/hash_handler").HashHandler;
var Tokenizer = require("./tokenizer").Tokenizer;
var comparePoints = Range.comparePoints;
var SnippetManager = function() {
this.snippetMap = {};
this.snippetNameMap = {};
};
(function() {
oop.implement(this, EventEmitter);
this.getTokenizer = function() {
function TabstopToken(str, _, stack) {
str = str.substr(1);
if (/^\d+$/.test(str) && !stack.inFormatString)
return [{tabstopId: parseInt(str, 10)}];
return [{text: str}];
}
function escape(ch) {
return "(?:[^\\\\" + ch + "]|\\\\.)";
}
SnippetManager.$tokenizer = new Tokenizer({
start: [
{regex: /:/, onMatch: function(val, state, stack) {
if (stack.length && stack[0].expectIf) {
stack[0].expectIf = false;
stack[0].elseBranch = stack[0];
return [stack[0]];
}
return ":";
}},
{regex: /\\./, onMatch: function(val, state, stack) {
var ch = val[1];
if (ch == "}" && stack.length) {
val = ch;
}else if ("`$\\".indexOf(ch) != -1) {
val = ch;
} else if (stack.inFormatString) {
if (ch == "n")
val = "\n";
else if (ch == "t")
val = "\n";
else if ("ulULE".indexOf(ch) != -1) {
val = {changeCase: ch, local: ch > "a"};
}
}
return [val];
}},
{regex: /}/, onMatch: function(val, state, stack) {
return [stack.length ? stack.shift() : val];
}},
{regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken},
{regex: /\$\{[\dA-Z_a-z]+/, onMatch: function(str, state, stack) {
var t = TabstopToken(str.substr(1), state, stack);
stack.unshift(t[0]);
return t;
}, next: "snippetVar"},
{regex: /\n/, token: "newline", merge: false}
],
snippetVar: [
{regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) {
stack[0].choices = val.slice(1, -1).split(",");
}, next: "start"},
{regex: "/(" + escape("/") + "+)/(?:(" + escape("/") + "*)/)(\\w*):?",
onMatch: function(val, state, stack) {
var ts = stack[0];
ts.fmtString = val;
val = this.splitRegex.exec(val);
ts.guard = val[1];
ts.fmt = val[2];
ts.flag = val[3];
return "";
}, next: "start"},
{regex: "`" + escape("`") + "*`", onMatch: function(val, state, stack) {
stack[0].code = val.splice(1, -1);
return "";
}, next: "start"},
{regex: "\\?", onMatch: function(val, state, stack) {
if (stack[0])
stack[0].expectIf = true;
}, next: "start"},
{regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start"}
],
formatString: [
{regex: "/(" + escape("/") + "+)/", token: "regex"},
{regex: "", onMatch: function(val, state, stack) {
stack.inFormatString = true;
}, next: "start"}
]
});
SnippetManager.prototype.getTokenizer = function() {
return SnippetManager.$tokenizer;
};
return SnippetManager.$tokenizer;
};
this.tokenizeTmSnippet = function(str, startState) {
return this.getTokenizer().getLineTokens(str, startState).tokens.map(function(x) {
return x.value || x;
});
};
this.$getDefaultValue = function(editor, name) {
if (/^[A-Z]\d+$/.test(name)) {
var i = name.substr(1);
return (this.variables[name[0] + "__"] || {})[i];
}
if (/^\d+$/.test(name)) {
return (this.variables.__ || {})[name];
}
name = name.replace(/^TM_/, "");
if (!editor)
return;
var s = editor.session;
switch(name) {
case "CURRENT_WORD":
var r = s.getWordRange();
case "SELECTION":
case "SELECTED_TEXT":
return s.getTextRange(r);
case "CURRENT_LINE":
return s.getLine(editor.getCursorPosition().row);
case "PREV_LINE": // not possible in textmate
return s.getLine(editor.getCursorPosition().row - 1);
case "LINE_INDEX":
return editor.getCursorPosition().column;
case "LINE_NUMBER":
return editor.getCursorPosition().row + 1;
case "SOFT_TABS":
return s.getUseSoftTabs() ? "YES" : "NO";
case "TAB_SIZE":
return s.getTabSize();
case "FILENAME":
case "FILEPATH":
return "";
case "FULLNAME":
return "Ace";
}
};
this.variables = {};
this.getVariableValue = function(editor, varName) {
if (this.variables.hasOwnProperty(varName))
return this.variables[varName](editor, varName) || "";
return this.$getDefaultValue(editor, varName) || "";
};
this.tmStrFormat = function(str, ch, editor) {
var flag = ch.flag || "";
var re = ch.guard;
re = new RegExp(re, flag.replace(/[^gi]/, ""));
var fmtTokens = this.tokenizeTmSnippet(ch.fmt, "formatString");
var _self = this;
var formatted = str.replace(re, function() {
_self.variables.__ = arguments;
var fmtParts = _self.resolveVariables(fmtTokens, editor);
var gChangeCase = "E";
for (var i = 0; i < fmtParts.length; i++) {
var ch = fmtParts[i];
if (typeof ch == "object") {
fmtParts[i] = "";
if (ch.changeCase && ch.local) {
var next = fmtParts[i + 1];
if (next && typeof next == "string") {
if (ch.changeCase == "u")
fmtParts[i] = next[0].toUpperCase();
else
fmtParts[i] = next[0].toLowerCase();
fmtParts[i + 1] = next.substr(1);
}
} else if (ch.changeCase) {
gChangeCase = ch.changeCase;
}
} else if (gChangeCase == "U") {
fmtParts[i] = ch.toUpperCase();
} else if (gChangeCase == "L") {
fmtParts[i] = ch.toLowerCase();
}
}
return fmtParts.join("");
});
this.variables.__ = null;
return formatted;
};
this.resolveVariables = function(snippet, editor) {
var result = [];
for (var i = 0; i < snippet.length; i++) {
var ch = snippet[i];
if (typeof ch == "string") {
result.push(ch);
} else if (typeof ch != "object") {
continue;
} else if (ch.skip) {
gotoNext(ch);
} else if (ch.processed < i) {
continue;
} else if (ch.text) {
var value = this.getVariableValue(editor, ch.text);
if (value && ch.fmtString)
value = this.tmStrFormat(value, ch);
ch.processed = i;
if (ch.expectIf == null) {
if (value) {
result.push(value);
gotoNext(ch);
}
} else {
if (value) {
ch.skip = ch.elseBranch;
} else
gotoNext(ch);
}
} else if (ch.tabstopId != null) {
result.push(ch);
} else if (ch.changeCase != null) {
result.push(ch);
}
}
function gotoNext(ch) {
var i1 = snippet.indexOf(ch, i + 1);
if (i1 != -1)
i = i1;
}
return result;
};
this.insertSnippetForSelection = function(editor, snippetText) {
var cursor = editor.getCursorPosition();
var line = editor.session.getLine(cursor.row);
var tabString = editor.session.getTabString();
var indentString = line.match(/^\s*/)[0];
if (cursor.column < indentString.length)
indentString = indentString.slice(0, cursor.column);
var tokens = this.tokenizeTmSnippet(snippetText);
tokens = this.resolveVariables(tokens, editor);
tokens = tokens.map(function(x) {
if (x == "\n")
return x + indentString;
if (typeof x == "string")
return x.replace(/\t/g, tabString);
return x;
});
var tabstops = [];
tokens.forEach(function(p, i) {
if (typeof p != "object")
return;
var id = p.tabstopId;
var ts = tabstops[id];
if (!ts) {
ts = tabstops[id] = [];
ts.index = id;
ts.value = "";
}
if (ts.indexOf(p) !== -1)
return;
ts.push(p);
var i1 = tokens.indexOf(p, i + 1);
if (i1 === -1)
return;
var value = tokens.slice(i + 1, i1);
var isNested = value.some(function(t) {return typeof t === "object"});
if (isNested && !ts.value) {
ts.value = value;
} else if (value.length && (!ts.value || typeof ts.value !== "string")) {
ts.value = value.join("");
}
});
tabstops.forEach(function(ts) {ts.length = 0});
var expanding = {};
function copyValue(val) {
var copy = [];
for (var i = 0; i < val.length; i++) {
var p = val[i];
if (typeof p == "object") {
if (expanding[p.tabstopId])
continue;
var j = val.lastIndexOf(p, i - 1);
p = copy[j] || {tabstopId: p.tabstopId};
}
copy[i] = p;
}
return copy;
}
for (var i = 0; i < tokens.length; i++) {
var p = tokens[i];
if (typeof p != "object")
continue;
var id = p.tabstopId;
var i1 = tokens.indexOf(p, i + 1);
if (expanding[id]) {
if (expanding[id] === p)
expanding[id] = null;
continue;
}
var ts = tabstops[id];
var arg = typeof ts.value == "string" ? [ts.value] : copyValue(ts.value);
arg.unshift(i + 1, Math.max(0, i1 - i));
arg.push(p);
expanding[id] = p;
tokens.splice.apply(tokens, arg);
if (ts.indexOf(p) === -1)
ts.push(p);
}
var row = 0, column = 0;
var text = "";
tokens.forEach(function(t) {
if (typeof t === "string") {
if (t[0] === "\n"){
column = t.length - 1;
row ++;
} else
column += t.length;
text += t;
} else {
if (!t.start)
t.start = {row: row, column: column};
else
t.end = {row: row, column: column};
}
});
var range = editor.getSelectionRange();
var end = editor.session.replace(range, text);
var tabstopManager = new TabstopManager(editor);
var selectionId = editor.inVirtualSelectionMode && editor.selection.index;
tabstopManager.addTabstops(tabstops, range.start, end, selectionId);
};
this.insertSnippet = function(editor, snippetText) {
var self = this;
if (editor.inVirtualSelectionMode)
return self.insertSnippetForSelection(editor, snippetText);
editor.forEachSelection(function() {
self.insertSnippetForSelection(editor, snippetText);
}, null, {keepOrder: true});
if (editor.tabstopManager)
editor.tabstopManager.tabNext();
};
this.$getScope = function(editor) {
var scope = editor.session.$mode.$id || "";
scope = scope.split("/").pop();
if (scope === "html" || scope === "php") {
if (scope === "php" && !editor.session.$mode.inlinePhp)
scope = "html";
var c = editor.getCursorPosition();
var state = editor.session.getState(c.row);
if (typeof state === "object") {
state = state[0];
}
if (state.substring) {
if (state.substring(0, 3) == "js-")
scope = "javascript";
else if (state.substring(0, 4) == "css-")
scope = "css";
else if (state.substring(0, 4) == "php-")
scope = "php";
}
}
return scope;
};
this.getActiveScopes = function(editor) {
var scope = this.$getScope(editor);
var scopes = [scope];
var snippetMap = this.snippetMap;
if (snippetMap[scope] && snippetMap[scope].includeScopes) {
scopes.push.apply(scopes, snippetMap[scope].includeScopes);
}
scopes.push("_");
return scopes;
};
this.expandWithTab = function(editor, options) {
var self = this;
var result = editor.forEachSelection(function() {
return self.expandSnippetForSelection(editor, options);
}, null, {keepOrder: true});
if (result && editor.tabstopManager)
editor.tabstopManager.tabNext();
return result;
};
this.expandSnippetForSelection = function(editor, options) {
var cursor = editor.getCursorPosition();
var line = editor.session.getLine(cursor.row);
var before = line.substring(0, cursor.column);
var after = line.substr(cursor.column);
var snippetMap = this.snippetMap;
var snippet;
this.getActiveScopes(editor).some(function(scope) {
var snippets = snippetMap[scope];
if (snippets)
snippet = this.findMatchingSnippet(snippets, before, after);
return !!snippet;
}, this);
if (!snippet)
return false;
if (options && options.dryRun)
return true;
editor.session.doc.removeInLine(cursor.row,
cursor.column - snippet.replaceBefore.length,
cursor.column + snippet.replaceAfter.length
);
this.variables.M__ = snippet.matchBefore;
this.variables.T__ = snippet.matchAfter;
this.insertSnippetForSelection(editor, snippet.content);
this.variables.M__ = this.variables.T__ = null;
return true;
};
this.findMatchingSnippet = function(snippetList, before, after) {
for (var i = snippetList.length; i--;) {
var s = snippetList[i];
if (s.startRe && !s.startRe.test(before))
continue;
if (s.endRe && !s.endRe.test(after))
continue;
if (!s.startRe && !s.endRe)
continue;
s.matchBefore = s.startRe ? s.startRe.exec(before) : [""];
s.matchAfter = s.endRe ? s.endRe.exec(after) : [""];
s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : "";
s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : "";
return s;
}
};
this.snippetMap = {};
this.snippetNameMap = {};
this.register = function(snippets, scope) {
var snippetMap = this.snippetMap;
var snippetNameMap = this.snippetNameMap;
var self = this;
if (!snippets)
snippets = [];
function wrapRegexp(src) {
if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src))
src = "(?:" + src + ")";
return src || "";
}
function guardedRegexp(re, guard, opening) {
re = wrapRegexp(re);
guard = wrapRegexp(guard);
if (opening) {
re = guard + re;
if (re && re[re.length - 1] != "$")
re = re + "$";
} else {
re = re + guard;
if (re && re[0] != "^")
re = "^" + re;
}
return new RegExp(re);
}
function addSnippet(s) {
if (!s.scope)
s.scope = scope || "_";
scope = s.scope;
if (!snippetMap[scope]) {
snippetMap[scope] = [];
snippetNameMap[scope] = {};
}
var map = snippetNameMap[scope];
if (s.name) {
var old = map[s.name];
if (old)
self.unregister(old);
map[s.name] = s;
}
snippetMap[scope].push(s);
if (s.tabTrigger && !s.trigger) {
if (!s.guard && /^\w/.test(s.tabTrigger))
s.guard = "\\b";
s.trigger = lang.escapeRegExp(s.tabTrigger);
}
s.startRe = guardedRegexp(s.trigger, s.guard, true);
s.triggerRe = new RegExp(s.trigger, "", true);
s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true);
s.endTriggerRe = new RegExp(s.endTrigger, "", true);
}
if (snippets && snippets.content)
addSnippet(snippets);
else if (Array.isArray(snippets))
snippets.forEach(addSnippet);
this._signal("registerSnippets", {scope: scope});
};
this.unregister = function(snippets, scope) {
var snippetMap = this.snippetMap;
var snippetNameMap = this.snippetNameMap;
function removeSnippet(s) {
var nameMap = snippetNameMap[s.scope||scope];
if (nameMap && nameMap[s.name]) {
delete nameMap[s.name];
var map = snippetMap[s.scope||scope];
var i = map && map.indexOf(s);
if (i >= 0)
map.splice(i, 1);
}
}
if (snippets.content)
removeSnippet(snippets);
else if (Array.isArray(snippets))
snippets.forEach(removeSnippet);
};
this.parseSnippetFile = function(str) {
str = str.replace(/\r/g, "");
var list = [], snippet = {};
var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm;
var m;
while (m = re.exec(str)) {
if (m[1]) {
try {
snippet = JSON.parse(m[1]);
list.push(snippet);
} catch (e) {}
} if (m[4]) {
snippet.content = m[4].replace(/^\t/gm, "");
list.push(snippet);
snippet = {};
} else {
var key = m[2], val = m[3];
if (key == "regex") {
var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g;
snippet.guard = guardRe.exec(val)[1];
snippet.trigger = guardRe.exec(val)[1];
snippet.endTrigger = guardRe.exec(val)[1];
snippet.endGuard = guardRe.exec(val)[1];
} else if (key == "snippet") {
snippet.tabTrigger = val.match(/^\S*/)[0];
if (!snippet.name)
snippet.name = val;
} else {
snippet[key] = val;
}
}
}
return list;
};
this.getSnippetByName = function(name, editor) {
var snippetMap = this.snippetNameMap;
var snippet;
this.getActiveScopes(editor).some(function(scope) {
var snippets = snippetMap[scope];
if (snippets)
snippet = snippets[name];
return !!snippet;
}, this);
return snippet;
};
}).call(SnippetManager.prototype);
var TabstopManager = function(editor) {
if (editor.tabstopManager)
return editor.tabstopManager;
editor.tabstopManager = this;
this.$onChange = this.onChange.bind(this);
this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule;
this.$onChangeSession = this.onChangeSession.bind(this);
this.$onAfterExec = this.onAfterExec.bind(this);
this.attach(editor);
};
(function() {
this.attach = function(editor) {
this.index = 0;
this.ranges = [];
this.tabstops = [];
this.$openTabstops = null;
this.selectedTabstop = null;
this.editor = editor;
this.editor.on("change", this.$onChange);
this.editor.on("changeSelection", this.$onChangeSelection);
this.editor.on("changeSession", this.$onChangeSession);
this.editor.commands.on("afterExec", this.$onAfterExec);
this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
};
this.detach = function() {
this.tabstops.forEach(this.removeTabstopMarkers, this);
this.ranges = null;
this.tabstops = null;
this.selectedTabstop = null;
this.editor.removeListener("change", this.$onChange);
this.editor.removeListener("changeSelection", this.$onChangeSelection);
this.editor.removeListener("changeSession", this.$onChangeSession);
this.editor.commands.removeListener("afterExec", this.$onAfterExec);
this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
this.editor.tabstopManager = null;
this.editor = null;
};
this.onChange = function(e) {
var changeRange = e.data.range;
var isRemove = e.data.action[0] == "r";
var start = changeRange.start;
var end = changeRange.end;
var startRow = start.row;
var endRow = end.row;
var lineDif = endRow - startRow;
var colDiff = end.column - start.column;
if (isRemove) {
lineDif = -lineDif;
colDiff = -colDiff;
}
if (!this.$inChange && isRemove) {
var ts = this.selectedTabstop;
var changedOutside = ts && !ts.some(function(r) {
return comparePoints(r.start, start) <= 0 && comparePoints(r.end, end) >= 0;
});
if (changedOutside)
return this.detach();
}
var ranges = this.ranges;
for (var i = 0; i < ranges.length; i++) {
var r = ranges[i];
if (r.end.row < start.row)
continue;
if (isRemove && comparePoints(start, r.start) < 0 && comparePoints(end, r.end) > 0) {
this.removeRange(r);
i--;
continue;
}
if (r.start.row == startRow && r.start.column > start.column)
r.start.column += colDiff;
if (r.end.row == startRow && r.end.column >= start.column)
r.end.column += colDiff;
if (r.start.row >= startRow)
r.start.row += lineDif;
if (r.end.row >= startRow)
r.end.row += lineDif;
if (comparePoints(r.start, r.end) > 0)
this.removeRange(r);
}
if (!ranges.length)
this.detach();
};
this.updateLinkedFields = function() {
var ts = this.selectedTabstop;
if (!ts || !ts.hasLinkedRanges)
return;
this.$inChange = true;
var session = this.editor.session;
var text = session.getTextRange(ts.firstNonLinked);
for (var i = ts.length; i--;) {
var range = ts[i];
if (!range.linked)
continue;
var fmt = exports.snippetManager.tmStrFormat(text, range.original);
session.replace(range, fmt);
}
this.$inChange = false;
};
this.onAfterExec = function(e) {
if (e.command && !e.command.readOnly)
this.updateLinkedFields();
};
this.onChangeSelection = function() {
if (!this.editor)
return;
var lead = this.editor.selection.lead;
var anchor = this.editor.selection.anchor;
var isEmpty = this.editor.selection.isEmpty();
for (var i = this.ranges.length; i--;) {
if (this.ranges[i].linked)
continue;
var containsLead = this.ranges[i].contains(lead.row, lead.column);
var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column);
if (containsLead && containsAnchor)
return;
}
this.detach();
};
this.onChangeSession = function() {
this.detach();
};
this.tabNext = function(dir) {
var max = this.tabstops.length;
var index = this.index + (dir || 1);
index = Math.min(Math.max(index, 1), max);
if (index == max)
index = 0;
this.selectTabstop(index);
if (index === 0)
this.detach();
};
this.selectTabstop = function(index) {
this.$openTabstops = null;
var ts = this.tabstops[this.index];
if (ts)
this.addTabstopMarkers(ts);
this.index = index;
ts = this.tabstops[this.index];
if (!ts || !ts.length)
return;
this.selectedTabstop = ts;
if (!this.editor.inVirtualSelectionMode) {
var sel = this.editor.multiSelect;
sel.toSingleRange(ts.firstNonLinked.clone());
for (var i = ts.length; i--;) {
if (ts.hasLinkedRanges && ts[i].linked)
continue;
sel.addRange(ts[i].clone(), true);
}
if (sel.ranges[0])
sel.addRange(sel.ranges[0].clone());
} else {
this.editor.selection.setRange(ts.firstNonLinked);
}
this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
};
this.addTabstops = function(tabstops, start, end) {
if (!this.$openTabstops)
this.$openTabstops = [];
if (!tabstops[0]) {
var p = Range.fromPoints(end, end);
moveRelative(p.start, start);
moveRelative(p.end, start);
tabstops[0] = [p];
tabstops[0].index = 0;
}
var i = this.index;
var arg = [i + 1, 0];
var ranges = this.ranges;
tabstops.forEach(function(ts, index) {
var dest = this.$openTabstops[index] || ts;
for (var i = ts.length; i--;) {
var p = ts[i];
var range = Range.fromPoints(p.start, p.end || p.start);
movePoint(range.start, start);
movePoint(range.end, start);
range.original = p;
range.tabstop = dest;
ranges.push(range);
if (dest != ts)
dest.unshift(range);
else
dest[i] = range;
if (p.fmtString) {
range.linked = true;
dest.hasLinkedRanges = true;
} else if (!dest.firstNonLinked)
dest.firstNonLinked = range;
}
if (!dest.firstNonLinked)
dest.hasLinkedRanges = false;
if (dest === ts) {
arg.push(dest);
this.$openTabstops[index] = dest;
}
this.addTabstopMarkers(dest);
}, this);
if (arg.length > 2) {
if (this.tabstops.length)
arg.push(arg.splice(2, 1)[0]);
this.tabstops.splice.apply(this.tabstops, arg);
}
};
this.addTabstopMarkers = function(ts) {
var session = this.editor.session;
ts.forEach(function(range) {
if (!range.markerId)
range.markerId = session.addMarker(range, "ace_snippet-marker", "text");
});
};
this.removeTabstopMarkers = function(ts) {
var session = this.editor.session;
ts.forEach(function(range) {
session.removeMarker(range.markerId);
range.markerId = null;
});
};
this.removeRange = function(range) {
var i = range.tabstop.indexOf(range);
range.tabstop.splice(i, 1);
i = this.ranges.indexOf(range);
this.ranges.splice(i, 1);
this.editor.session.removeMarker(range.markerId);
if (!range.tabstop.length) {
i = this.tabstops.indexOf(range.tabstop);
if (i != -1)
this.tabstops.splice(i, 1);
if (!this.tabstops.length)
this.detach();
}
};
this.keyboardHandler = new HashHandler();
this.keyboardHandler.bindKeys({
"Tab": function(ed) {
if (exports.snippetManager && exports.snippetManager.expandWithTab(ed)) {
return;
}
ed.tabstopManager.tabNext(1);
},
"Shift-Tab": function(ed) {
ed.tabstopManager.tabNext(-1);
},
"Esc": function(ed) {
ed.tabstopManager.detach();
},
"Return": function(ed) {
return false;
}
});
}).call(TabstopManager.prototype);
var changeTracker = {};
changeTracker.onChange = Anchor.prototype.onChange;
changeTracker.setPosition = function(row, column) {
this.pos.row = row;
this.pos.column = column;
};
changeTracker.update = function(pos, delta, $insertRight) {
this.$insertRight = $insertRight;
this.pos = pos;
this.onChange(delta);
};
var movePoint = function(point, diff) {
if (point.row == 0)
point.column += diff.column;
point.row += diff.row;
};
var moveRelative = function(point, start) {
if (point.row == start.row)
point.column -= start.column;
point.row -= start.row;
};
require("./lib/dom").importCssString("\
.ace_snippet-marker {\
-moz-box-sizing: border-box;\
box-sizing: border-box;\
background: rgba(194, 193, 208, 0.09);\
border: 1px dotted rgba(211, 208, 235, 0.62);\
position: absolute;\
}");
exports.snippetManager = new SnippetManager();
var Editor = require("./editor").Editor;
(function() {
this.insertSnippet = function(content, options) {
return exports.snippetManager.insertSnippet(this, content, options);
};
this.expandSnippet = function(options) {
return exports.snippetManager.expandWithTab(this, options);
};
}).call(Editor.prototype);
});
ace.define("ace/autocomplete/popup",["require","exports","module","ace/edit_session","ace/virtual_renderer","ace/editor","ace/range","ace/lib/event","ace/lib/lang","ace/lib/dom"], function(require, exports, module) {
"use strict";
var EditSession = require("../edit_session").EditSession;
var Renderer = require("../virtual_renderer").VirtualRenderer;
var Editor = require("../editor").Editor;
var Range = require("../range").Range;
var event = require("../lib/event");
var lang = require("../lib/lang");
var dom = require("../lib/dom");
var $singleLineEditor = function(el) {
var renderer = new Renderer(el);
renderer.$maxLines = 4;
var editor = new Editor(renderer);
editor.setHighlightActiveLine(false);
editor.setShowPrintMargin(false);
editor.renderer.setShowGutter(false);
editor.renderer.setHighlightGutterLine(false);
editor.$mouseHandler.$focusWaitTimout = 0;
editor.$highlightTagPending = true;
return editor;
};
var AcePopup = function(parentNode) {
var el = dom.createElement("div");
var popup = new $singleLineEditor(el);
if (parentNode)
parentNode.appendChild(el);
el.style.display = "none";
popup.renderer.content.style.cursor = "default";
popup.renderer.setStyle("ace_autocomplete");
popup.setOption("displayIndentGuides", false);
popup.setOption("dragDelay", 150);
var noop = function(){};
popup.focus = noop;
popup.$isFocused = true;
popup.renderer.$cursorLayer.restartTimer = noop;
popup.renderer.$cursorLayer.element.style.opacity = 0;
popup.renderer.$maxLines = 8;
popup.renderer.$keepTextAreaAtCursor = false;
popup.setHighlightActiveLine(false);
popup.session.highlight("");
popup.session.$searchHighlight.clazz = "ace_highlight-marker";
popup.on("mousedown", function(e) {
var pos = e.getDocumentPosition();
popup.selection.moveToPosition(pos);
selectionMarker.start.row = selectionMarker.end.row = pos.row;
e.stop();
});
var lastMouseEvent;
var hoverMarker = new Range(-1,0,-1,Infinity);
var selectionMarker = new Range(-1,0,-1,Infinity);
selectionMarker.id = popup.session.addMarker(selectionMarker, "ace_active-line", "fullLine");
popup.setSelectOnHover = function(val) {
if (!val) {
hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine");
} else if (hoverMarker.id) {
popup.session.removeMarker(hoverMarker.id);
hoverMarker.id = null;
}
};
popup.setSelectOnHover(false);
popup.on("mousemove", function(e) {
if (!lastMouseEvent) {
lastMouseEvent = e;
return;
}
if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) {
return;
}
lastMouseEvent = e;
lastMouseEvent.scrollTop = popup.renderer.scrollTop;
var row = lastMouseEvent.getDocumentPosition().row;
if (hoverMarker.start.row != row) {
if (!hoverMarker.id)
popup.setRow(row);
setHoverMarker(row);
}
});
popup.renderer.on("beforeRender", function() {
if (lastMouseEvent && hoverMarker.start.row != -1) {
lastMouseEvent.$pos = null;
var row = lastMouseEvent.getDocumentPosition().row;
if (!hoverMarker.id)
popup.setRow(row);
setHoverMarker(row, true);
}
});
popup.renderer.on("afterRender", function() {
var row = popup.getRow();
var t = popup.renderer.$textLayer;
var selected = t.element.childNodes[row - t.config.firstRow];
if (selected == t.selectedNode)
return;
if (t.selectedNode)
dom.removeCssClass(t.selectedNode, "ace_selected");
t.selectedNode = selected;
if (selected)
dom.addCssClass(selected, "ace_selected");
});
var hideHoverMarker = function() { setHoverMarker(-1) };
var setHoverMarker = function(row, suppressRedraw) {
if (row !== hoverMarker.start.row) {
hoverMarker.start.row = hoverMarker.end.row = row;
if (!suppressRedraw)
popup.session._emit("changeBackMarker");
popup._emit("changeHoverMarker");
}
};
popup.getHoveredRow = function() {
return hoverMarker.start.row;
};
event.addListener(popup.container, "mouseout", hideHoverMarker);
popup.on("hide", hideHoverMarker);
popup.on("changeSelection", hideHoverMarker);
popup.session.doc.getLength = function() {
return popup.data.length;
};
popup.session.doc.getLine = function(i) {
var data = popup.data[i];
if (typeof data == "string")
return data;
return (data && data.value) || "";
};
var bgTokenizer = popup.session.bgTokenizer;
bgTokenizer.$tokenizeRow = function(row) {
var data = popup.data[row];
var tokens = [];
if (!data)
return tokens;
if (typeof data == "string")
data = {value: data};
if (!data.caption)
data.caption = data.value || data.name;
var last = -1;
var flag, c;
for (var i = 0; i < data.caption.length; i++) {
c = data.caption[i];
flag = data.matchMask & (1 << i) ? 1 : 0;
if (last !== flag) {
tokens.push({type: data.className || "" + ( flag ? "completion-highlight" : ""), value: c});
last = flag;
} else {
tokens[tokens.length - 1].value += c;
}
}
if (data.meta) {
var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth;
if (data.meta.length + data.caption.length < maxW - 2)
tokens.push({type: "rightAlignedText", value: data.meta});
}
return tokens;
};
bgTokenizer.$updateOnChange = noop;
bgTokenizer.start = noop;
popup.session.$computeWidth = function() {
return this.screenWidth = 0;
};
popup.isOpen = false;
popup.isTopdown = false;
popup.data = [];
popup.setData = function(list) {
popup.data = list || [];
popup.setValue(lang.stringRepeat("\n", list.length), -1);
popup.setRow(0);
};
popup.getData = function(row) {
return popup.data[row];
};
popup.getRow = function() {
return selectionMarker.start.row;
};
popup.setRow = function(line) {
line = Math.max(-1, Math.min(this.data.length, line));
if (selectionMarker.start.row != line) {
popup.selection.clearSelection();
selectionMarker.start.row = selectionMarker.end.row = line || 0;
popup.session._emit("changeBackMarker");
popup.moveCursorTo(line || 0, 0);
if (popup.isOpen)
popup._signal("select");
}
};
popup.on("changeSelection", function() {
if (popup.isOpen)
popup.setRow(popup.selection.lead.row);
});
popup.hide = function() {
this.container.style.display = "none";
this._signal("hide");
popup.isOpen = false;
};
popup.show = function(pos, lineHeight, topdownOnly) {
var el = this.container;
var screenHeight = window.innerHeight;
var screenWidth = window.innerWidth;
var renderer = this.renderer;
var maxH = renderer.$maxLines * lineHeight * 1.4;
var top = pos.top + this.$borderSize;
if (top + maxH > screenHeight - lineHeight && !topdownOnly) {
el.style.top = "";
el.style.bottom = screenHeight - top + "px";
popup.isTopdown = false;
} else {
top += lineHeight;
el.style.top = top + "px";
el.style.bottom = "";
popup.isTopdown = true;
}
el.style.display = "";
this.renderer.$textLayer.checkForSizeChanges();
var left = pos.left;
if (left + el.offsetWidth > screenWidth)
left = screenWidth - el.offsetWidth;
el.style.left = left + "px";
this._signal("show");
lastMouseEvent = null;
popup.isOpen = true;
};
popup.getTextLeftOffset = function() {
return this.$borderSize + this.renderer.$padding + this.$imageSize;
};
popup.$imageSize = 0;
popup.$borderSize = 1;
return popup;
};
dom.importCssString("\
.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\
background-color: #CAD6FA;\
z-index: 1;\
}\
.ace_editor.ace_autocomplete .ace_line-hover {\
border: 1px solid #abbffe;\
margin-top: -1px;\
background: rgba(233,233,253,0.4);\
}\
.ace_editor.ace_autocomplete .ace_line-hover {\
position: absolute;\
z-index: 2;\
}\
.ace_editor.ace_autocomplete .ace_scroller {\
background: none;\
border: none;\
box-shadow: none;\
}\
.ace_rightAlignedText {\
color: gray;\
display: inline-block;\
position: absolute;\
right: 4px;\
text-align: right;\
z-index: -1;\
}\
.ace_editor.ace_autocomplete .ace_completion-highlight{\
color: #000;\
text-shadow: 0 0 0.01em;\
}\
.ace_editor.ace_autocomplete {\
width: 280px;\
z-index: 200000;\
background: #fbfbfb;\
color: #444;\
border: 1px lightgray solid;\
position: fixed;\
box-shadow: 2px 3px 5px rgba(0,0,0,.2);\
line-height: 1.4;\
}");
exports.AcePopup = AcePopup;
});
ace.define("ace/autocomplete/util",["require","exports","module"], function(require, exports, module) {
"use strict";
exports.parForEach = function(array, fn, callback) {
var completed = 0;
var arLength = array.length;
if (arLength === 0)
callback();
for (var i = 0; i < arLength; i++) {
fn(array[i], function(result, err) {
completed++;
if (completed === arLength)
callback(result, err);
});
}
};
var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\uFFFF]/;
exports.retrievePrecedingIdentifier = function(text, pos, regex) {
regex = regex || ID_REGEX;
var buf = [];
for (var i = pos-1; i >= 0; i--) {
if (regex.test(text[i]))
buf.push(text[i]);
else
break;
}
return buf.reverse().join("");
};
exports.retrieveFollowingIdentifier = function(text, pos, regex) {
regex = regex || ID_REGEX;
var buf = [];
for (var i = pos; i < text.length; i++) {
if (regex.test(text[i]))
buf.push(text[i]);
else
break;
}
return buf;
};
});
ace.define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/event","ace/lib/lang","ace/snippets"], function(require, exports, module) {
"use strict";
var HashHandler = require("./keyboard/hash_handler").HashHandler;
var AcePopup = require("./autocomplete/popup").AcePopup;
var util = require("./autocomplete/util");
var event = require("./lib/event");
var lang = require("./lib/lang");
var snippetManager = require("./snippets").snippetManager;
var Autocomplete = function() {
this.autoInsert = true;
this.autoSelect = true;
this.keyboardHandler = new HashHandler();
this.keyboardHandler.bindKeys(this.commands);
this.blurListener = this.blurListener.bind(this);
this.changeListener = this.changeListener.bind(this);
this.mousedownListener = this.mousedownListener.bind(this);
this.mousewheelListener = this.mousewheelListener.bind(this);
this.changeTimer = lang.delayedCall(function() {
this.updateCompletions(true);
}.bind(this));
};
(function() {
this.gatherCompletionsId = 0;
this.$init = function() {
this.popup = new AcePopup(document.body || document.documentElement);
this.popup.on("click", function(e) {
this.insertMatch();
e.stop();
}.bind(this));
this.popup.focus = this.editor.focus.bind(this.editor);
};
this.openPopup = function(editor, prefix, keepPopupPosition) {
if (!this.popup)
this.$init();
this.popup.setData(this.completions.filtered);
var renderer = editor.renderer;
this.popup.setRow(this.autoSelect ? 0 : -1);
if (!keepPopupPosition) {
this.popup.setTheme(editor.getTheme());
this.popup.setFontSize(editor.getFontSize());
var lineHeight = renderer.layerConfig.lineHeight;
var pos = renderer.$cursorLayer.getPixelPosition(this.base, true);
pos.left -= this.popup.getTextLeftOffset();
var rect = editor.container.getBoundingClientRect();
pos.top += rect.top - renderer.layerConfig.offset;
pos.left += rect.left - editor.renderer.scrollLeft;
pos.left += renderer.$gutterLayer.gutterWidth;
this.popup.show(pos, lineHeight);
}
};
this.detach = function() {
this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
this.editor.off("changeSelection", this.changeListener);
this.editor.off("blur", this.blurListener);
this.editor.off("mousedown", this.mousedownListener);
this.editor.off("mousewheel", this.mousewheelListener);
this.changeTimer.cancel();
if (this.popup && this.popup.isOpen) {
this.gatherCompletionsId += 1;
this.popup.hide();
}
if (this.base)
this.base.detach();
this.activated = false;
this.completions = this.base = null;
};
this.changeListener = function(e) {
var cursor = this.editor.selection.lead;
if (cursor.row != this.base.row || cursor.column < this.base.column) {
this.detach();
}
if (this.activated)
this.changeTimer.schedule();
else
this.detach();
};
this.blurListener = function() {
var el = document.activeElement;
if (el != this.editor.textInput.getElement() && el.parentNode != this.popup.container)
this.detach();
};
this.mousedownListener = function(e) {
this.detach();
};
this.mousewheelListener = function(e) {
this.detach();
};
this.goTo = function(where) {
var row = this.popup.getRow();
var max = this.popup.session.getLength() - 1;
switch(where) {
case "up": row = row <= 0 ? max : row - 1; break;
case "down": row = row >= max ? -1 : row + 1; break;
case "start": row = 0; break;
case "end": row = max; break;
}
this.popup.setRow(row);
};
this.insertMatch = function(data) {
if (!data)
data = this.popup.getData(this.popup.getRow());
if (!data)
return false;
if (data.completer && data.completer.insertMatch) {
data.completer.insertMatch(this.editor);
} else {
if (this.completions.filterText) {
var ranges = this.editor.selection.getAllRanges();
for (var i = 0, range; range = ranges[i]; i++) {
range.start.column -= this.completions.filterText.length;
this.editor.session.remove(range);
}
}
if (data.snippet)
snippetManager.insertSnippet(this.editor, data.snippet);
else
this.editor.execCommand("insertstring", data.value || data);
}
this.detach();
};
this.commands = {
"Up": function(editor) { editor.completer.goTo("up"); },
"Down": function(editor) { editor.completer.goTo("down"); },
"Ctrl-Up|Ctrl-Home": function(editor) { editor.completer.goTo("start"); },
"Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); },
"Esc": function(editor) { editor.completer.detach(); },
"Space": function(editor) { editor.completer.detach(); editor.insert(" ");},
"Return": function(editor) { return editor.completer.insertMatch(); },
"Shift-Return": function(editor) { editor.completer.insertMatch(true); },
"Tab": function(editor) {
var result = editor.completer.insertMatch();
if (!result && !editor.tabstopManager)
editor.completer.goTo("down");
else
return result;
},
"PageUp": function(editor) { editor.completer.popup.gotoPageUp(); },
"PageDown": function(editor) { editor.completer.popup.gotoPageDown(); }
};
this.gatherCompletions = function(editor, callback) {
var session = editor.getSession();
var pos = editor.getCursorPosition();
var line = session.getLine(pos.row);
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
var matches = [];
var total = editor.completers.length;
editor.completers.forEach(function(completer, i) {
completer.getCompletions(editor, session, pos, prefix, function(err, results) {
if (!err)
matches = matches.concat(results);
var pos = editor.getCursorPosition();
var line = session.getLine(pos.row);
callback(null, {
prefix: util.retrievePrecedingIdentifier(line, pos.column, results[0] && results[0].identifierRegex),
matches: matches,
finished: (--total === 0)
});
});
});
return true;
};
this.showPopup = function(editor) {
if (this.editor)
this.detach();
this.activated = true;
this.editor = editor;
if (editor.completer != this) {
if (editor.completer)
editor.completer.detach();
editor.completer = this;
}
editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
editor.on("changeSelection", this.changeListener);
editor.on("blur", this.blurListener);
editor.on("mousedown", this.mousedownListener);
editor.on("mousewheel", this.mousewheelListener);
this.updateCompletions();
};
this.updateCompletions = function(keepPopupPosition) {
if (keepPopupPosition && this.base && this.completions) {
var pos = this.editor.getCursorPosition();
var prefix = this.editor.session.getTextRange({start: this.base, end: pos});
if (prefix == this.completions.filterText)
return;
this.completions.setFilter(prefix);
if (!this.completions.filtered.length)
return this.detach();
if (this.completions.filtered.length == 1
&& this.completions.filtered[0].value == prefix
&& !this.completions.filtered[0].snippet)
return this.detach();
this.openPopup(this.editor, prefix, keepPopupPosition);
return;
}
var _id = this.gatherCompletionsId;
this.gatherCompletions(this.editor, function(err, results) {
var detachIfFinished = function() {
if (!results.finished) return;
return this.detach();
}.bind(this);
var prefix = results.prefix;
var matches = results && results.matches;
if (!matches || !matches.length)
return detachIfFinished();
if (prefix.indexOf(results.prefix) !== 0 || _id != this.gatherCompletionsId)
return;
this.completions = new FilteredList(matches);
this.completions.setFilter(prefix);
var filtered = this.completions.filtered;
if (!filtered.length)
return detachIfFinished();
if (filtered.length == 1 && filtered[0].value == prefix && !filtered[0].snippet)
return detachIfFinished();
if (this.autoInsert && filtered.length == 1)
return this.insertMatch(filtered[0]);
this.openPopup(this.editor, prefix, keepPopupPosition);
}.bind(this));
};
this.cancelContextMenu = function() {
this.editor.$mouseHandler.cancelContextMenu();
};
}).call(Autocomplete.prototype);
Autocomplete.startCommand = {
name: "startAutocomplete",
exec: function(editor) {
if (!editor.completer)
editor.completer = new Autocomplete();
editor.completer.autoInsert =
editor.completer.autoSelect = true;
editor.completer.showPopup(editor);
editor.completer.cancelContextMenu();
},
bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"
};
var FilteredList = function(array, filterText, mutateData) {
this.all = array;
this.filtered = array;
this.filterText = filterText || "";
};
(function(){
this.setFilter = function(str) {
if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0)
var matches = this.filtered;
else
var matches = this.all;
this.filterText = str;
matches = this.filterCompletions(matches, this.filterText);
matches = matches.sort(function(a, b) {
return b.exactMatch - a.exactMatch || b.score - a.score;
});
var prev = null;
matches = matches.filter(function(item){
var caption = item.value || item.caption || item.snippet;
if (caption === prev) return false;
prev = caption;
return true;
});
this.filtered = matches;
};
this.filterCompletions = function(items, needle) {
var results = [];
var upper = needle.toUpperCase();
var lower = needle.toLowerCase();
loop: for (var i = 0, item; item = items[i]; i++) {
var caption = item.value || item.caption || item.snippet;
if (!caption) continue;
var lastIndex = -1;
var matchMask = 0;
var penalty = 0;
var index, distance;
for (var j = 0; j < needle.length; j++) {
var i1 = caption.indexOf(lower[j], lastIndex + 1);
var i2 = caption.indexOf(upper[j], lastIndex + 1);
index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
if (index < 0)
continue loop;
distance = index - lastIndex - 1;
if (distance > 0) {
if (lastIndex === -1)
penalty += 10;
penalty += distance;
}
matchMask = matchMask | (1 << index);
lastIndex = index;
}
item.matchMask = matchMask;
item.exactMatch = penalty ? 0 : 1;
item.score = (item.score || 0) - penalty;
results.push(item);
}
return results;
};
}).call(FilteredList.prototype);
exports.Autocomplete = Autocomplete;
exports.FilteredList = FilteredList;
});
ace.define("ace/autocomplete/text_completer",["require","exports","module","ace/range"], function(require, exports, module) {
var Range = require("../range").Range;
var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/;
function getWordIndex(doc, pos) {
var textBefore = doc.getTextRange(Range.fromPoints({row: 0, column:0}, pos));
return textBefore.split(splitRegex).length - 1;
}
function wordDistance(doc, pos) {
var prefixPos = getWordIndex(doc, pos);
var words = doc.getValue().split(splitRegex);
var wordScores = Object.create(null);
var currentWord = words[prefixPos];
words.forEach(function(word, idx) {
if (!word || word === currentWord) return;
var distance = Math.abs(prefixPos - idx);
var score = words.length - distance;
if (wordScores[word]) {
wordScores[word] = Math.max(score, wordScores[word]);
} else {
wordScores[word] = score;
}
});
return wordScores;
}
exports.getCompletions = function(editor, session, pos, prefix, callback) {
var wordScore = wordDistance(session, pos, prefix);
var wordList = Object.keys(wordScore);
callback(null, wordList.map(function(word) {
return {
caption: word,
value: word,
score: wordScore[word],
meta: "local"
};
}));
};
});
ace.define("ace/ext/language_tools",["require","exports","module","ace/snippets","ace/autocomplete","ace/config","ace/autocomplete/util","ace/autocomplete/text_completer","ace/editor","ace/config"], function(require, exports, module) {
"use strict";
var snippetManager = require("../snippets").snippetManager;
var Autocomplete = require("../autocomplete").Autocomplete;
var config = require("../config");
var util = require("../autocomplete/util");
var textCompleter = require("../autocomplete/text_completer");
var keyWordCompleter = {
getCompletions: function(editor, session, pos, prefix, callback) {
var state = editor.session.getState(pos.row);
var completions = session.$mode.getCompletions(state, session, pos, prefix);
callback(null, completions);
}
};
var snippetCompleter = {
getCompletions: function(editor, session, pos, prefix, callback) {
var snippetMap = snippetManager.snippetMap;
var completions = [];
snippetManager.getActiveScopes(editor).forEach(function(scope) {
var snippets = snippetMap[scope] || [];
for (var i = snippets.length; i--;) {
var s = snippets[i];
var caption = s.name || s.tabTrigger;
if (!caption)
continue;
completions.push({
caption: caption,
snippet: s.content,
meta: s.tabTrigger && !s.name ? s.tabTrigger + "\u21E5 " : "snippet"
});
}
}, this);
callback(null, completions);
}
};
var completers = [snippetCompleter, textCompleter, keyWordCompleter];
exports.addCompleter = function(completer) {
completers.push(completer);
};
exports.textCompleter = textCompleter;
exports.keyWordCompleter = keyWordCompleter;
exports.snippetCompleter = snippetCompleter;
var expandSnippet = {
name: "expandSnippet",
exec: function(editor) {
var success = snippetManager.expandWithTab(editor);
if (!success)
editor.execCommand("indent");
},
bindKey: "Tab"
};
var onChangeMode = function(e, editor) {
loadSnippetsForMode(editor.session.$mode);
};
var loadSnippetsForMode = function(mode) {
var id = mode.$id;
if (!snippetManager.files)
snippetManager.files = {};
loadSnippetFile(id);
if (mode.modes)
mode.modes.forEach(loadSnippetsForMode);
};
var loadSnippetFile = function(id) {
if (!id || snippetManager.files[id])
return;
var snippetFilePath = id.replace("mode", "snippets");
snippetManager.files[id] = {};
config.loadModule(snippetFilePath, function(m) {
if (m) {
snippetManager.files[id] = m;
if (!m.snippets && m.snippetText)
m.snippets = snippetManager.parseSnippetFile(m.snippetText);
snippetManager.register(m.snippets || [], m.scope);
if (m.includeScopes) {
snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes;
m.includeScopes.forEach(function(x) {
loadSnippetFile("ace/mode/" + x);
});
}
}
});
};
function getCompletionPrefix(editor) {
var pos = editor.getCursorPosition();
var line = editor.session.getLine(pos.row);
var prefix = util.retrievePrecedingIdentifier(line, pos.column);
editor.completers.forEach(function(completer) {
if (completer.identifierRegexps) {
completer.identifierRegexps.forEach(function(identifierRegex) {
if (!prefix && identifierRegex)
prefix = util.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
});
}
});
return prefix;
}
var doLiveAutocomplete = function(e) {
var editor = e.editor;
var text = e.args || "";
var hasCompleter = editor.completer && editor.completer.activated;
if (e.command.name === "backspace") {
if (hasCompleter && !getCompletionPrefix(editor))
editor.completer.detach();
}
else if (e.command.name === "insertstring") {
var prefix = getCompletionPrefix(editor);
if (prefix && !hasCompleter) {
if (!editor.completer) {
editor.completer = new Autocomplete();
}
editor.completer.autoSelect = false;
editor.completer.autoInsert = false;
editor.completer.showPopup(editor);
}
}
};
var Editor = require("../editor").Editor;
require("../config").defineOptions(Editor.prototype, "editor", {
enableBasicAutocompletion: {
set: function(val) {
if (val) {
if (!this.completers)
this.completers = Array.isArray(val)? val: completers;
this.commands.addCommand(Autocomplete.startCommand);
} else {
this.commands.removeCommand(Autocomplete.startCommand);
}
},
value: false
},
enableLiveAutocompletion: {
set: function(val) {
if (val) {
if (!this.completers)
this.completers = Array.isArray(val)? val: completers;
this.commands.on('afterExec', doLiveAutocomplete);
} else {
this.commands.removeListener('afterExec', doLiveAutocomplete);
}
},
value: false
},
enableSnippets: {
set: function(val) {
if (val) {
this.commands.addCommand(expandSnippet);
this.on("changeMode", onChangeMode);
onChangeMode(null, this);
} else {
this.commands.removeCommand(expandSnippet);
this.off("changeMode", onChangeMode);
}
},
value: false
}
});
});
ace.define("ace/mode/jsoniq",["require","exports","module","ace/worker/worker_client","ace/lib/oop","ace/mode/text","ace/mode/text_highlight_rules","ace/mode/xquery/jsoniq_lexer","ace/range","ace/mode/behaviour/xquery","ace/mode/folding/cstyle","ace/anchor","ace/ext/language_tools"], function(require, exports, module) {
"use strict";
var WorkerClient = require("../worker/worker_client").WorkerClient;
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var JSONiqLexer = require("./xquery/jsoniq_lexer").JSONiqLexer;
var Range = require("../range").Range;
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Anchor = require("../anchor").Anchor;
var LanguageTools = require("../ext/language_tools");
var Mode = function() {
this.$tokenizer = new JSONiqLexer();
this.$behaviour = new XQueryBehaviour();
this.foldingRules = new CStyleFoldMode();
this.$highlightRules = new TextHighlightRules();
};
oop.inherits(Mode, TextMode);
(function() {
LanguageTools.addCompleter({
getCompletions: function(editor, session, pos, prefix, callback) {
session.$worker.emit("complete", { data: { pos: pos, prefix: prefix } });
session.$worker.on("complete", function(e){
callback(null, e.data);
});
}
});
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var match = line.match(/\s*(?:then|else|return|[{\(]|<\w+>)\s*$/);
if (match)
indent += tab;
return indent;
};
this.checkOutdent = function(state, line, input) {
if (! /^\s+$/.test(line))
return false;
return /^\s*[\}\)]/.test(input);
};
this.autoOutdent = function(state, doc, row) {
var line = doc.getLine(row);
var match = line.match(/^(\s*[\}\)])/);
if (!match) return 0;
var column = match[1].length;
var openBracePos = doc.findMatchingBracket({row: row, column: column});
if (!openBracePos || openBracePos.row == row) return 0;
var indent = this.$getIndent(doc.getLine(openBracePos.row));
doc.replace(new Range(row, 0, row, column-1), indent);
};
this.toggleCommentLines = function(state, doc, startRow, endRow) {
var i, line;
var outdent = true;
var re = /^\s*\(:(.*):\)/;
for (i=startRow; i<= endRow; i++) {
if (!re.test(doc.getLine(i))) {
outdent = false;
break;
}
}
var range = new Range(0, 0, 0, 0);
for (i=startRow; i<= endRow; i++) {
line = doc.getLine(i);
range.start.row = i;
range.end.row = i;
range.end.column = line.length;
doc.replace(range, outdent ? line.match(re)[1] : "(:" + line + ":)");
}
};
this.createWorker = function(session) {
var worker = new WorkerClient(["ace"], "ace/mode/xquery_worker", "XQueryWorker");
var that = this;
worker.attachToDocument(session.getDocument());
worker.on("ok", function(e) {
session.clearAnnotations();
});
worker.on("markers", function(e) {
session.clearAnnotations();
that.addMarkers(e.data, session);
});
return worker;
};
this.removeMarkers = function(session) {
var markers = session.getMarkers(false);
for (var id in markers) {
if (markers[id].clazz.indexOf('language_highlight_') === 0) {
session.removeMarker(id);
}
}
for (var i = 0; i < session.markerAnchors.length; i++) {
session.markerAnchors[i].detach();
}
session.markerAnchors = [];
};
this.addMarkers = function(annos, mySession) {
var _self = this;
if (!mySession.markerAnchors) mySession.markerAnchors = [];
this.removeMarkers(mySession);
mySession.languageAnnos = [];
annos.forEach(function(anno) {
var anchor = new Anchor(mySession.getDocument(), anno.pos.sl, anno.pos.sc || 0);
mySession.markerAnchors.push(anchor);
var markerId;
var colDiff = anno.pos.ec - anno.pos.sc;
var rowDiff = anno.pos.el - anno.pos.sl;
var gutterAnno = {
guttertext: anno.message,
type: anno.level || "warning",
text: anno.message
};
function updateFloat(single) {
if (markerId)
mySession.removeMarker(markerId);
gutterAnno.row = anchor.row;
if (anno.pos.sc !== undefined && anno.pos.ec !== undefined) {
var range = new Range(anno.pos.sl, anno.pos.sc, anno.pos.el, anno.pos.ec);
markerId = mySession.addMarker(range, "language_highlight_" + (anno.type ? anno.type : "default"));
}
if (single) mySession.setAnnotations(mySession.languageAnnos);
}
updateFloat();
anchor.on("change", function() {
updateFloat(true);
});
if (anno.message) mySession.languageAnnos.push(gutterAnno);
});
mySession.setAnnotations(mySession.languageAnnos);
};
this.$id = "ace/mode/jsoniq";
}).call(Mode.prototype);
exports.Mode = Mode;
});