Update XQuery semantic highlighter.
This commit is contained in:
parent
e807106c8f
commit
248fb57cda
15 changed files with 19620 additions and 19554 deletions
|
|
@ -35,18 +35,19 @@
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
define('ace/mode/xquery', ['require', 'exports', 'module' , 'ace/worker/worker_client', 'ace/lib/oop', 'ace/mode/text', 'ace/mode/xquery_tokenizer', 'ace/mode/behaviour/xquery', 'ace/range'], function(require, exports, module) {
|
define('ace/mode/xquery', ['require', 'exports', 'module' , 'ace/worker/worker_client', 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xquery_highlight_rules', 'ace/mode/behaviour/xquery', 'ace/range'], function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var TextMode = require("./text").Mode;
|
var TextMode = require("./text").Mode;
|
||||||
var XQueryTokenizer = require("./xquery_tokenizer").XQueryTokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
|
var XQueryHighlightRules = require("./xquery_highlight_rules").XQueryHighlightRules;
|
||||||
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
|
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
|
||||||
var Range = require("../range").Range;
|
var Range = require("../range").Range;
|
||||||
|
|
||||||
var Mode = function(parent) {
|
var Mode = function(parent) {
|
||||||
this.$tokenizer = new XQueryTokenizer();
|
this.$tokenizer = new Tokenizer(new XQueryHighlightRules().getRules());
|
||||||
this.$behaviour = new XQueryBehaviour(parent);
|
this.$behaviour = new XQueryBehaviour(parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -116,11 +117,22 @@ oop.inherits(Mode, TextMode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.deltas = [];
|
||||||
|
|
||||||
this.createWorker = function(session) {
|
this.createWorker = function(session) {
|
||||||
var worker = new WorkerClient(["ace"], "worker-xquery.js", "ace/mode/xquery_worker", "XQueryWorker");
|
var worker = new WorkerClient(["ace"], "worker-xquery.js", "ace/mode/xquery_worker", "XQueryWorker");
|
||||||
var self = this;
|
var that = this;
|
||||||
|
|
||||||
|
session.getDocument().on('change', function(evt){
|
||||||
|
that.deltas.push(evt.data);
|
||||||
|
});
|
||||||
|
|
||||||
worker.attachToDocument(session.getDocument());
|
worker.attachToDocument(session.getDocument());
|
||||||
|
|
||||||
|
worker.on("start", function(e) {
|
||||||
|
that.deltas = [];
|
||||||
|
});
|
||||||
|
|
||||||
worker.on("error", function(e) {
|
worker.on("error", function(e) {
|
||||||
session.setAnnotations([e.data]);
|
session.setAnnotations([e.data]);
|
||||||
});
|
});
|
||||||
|
|
@ -130,15 +142,47 @@ oop.inherits(Mode, TextMode);
|
||||||
});
|
});
|
||||||
|
|
||||||
worker.on("highlight", function(tokens) {
|
worker.on("highlight", function(tokens) {
|
||||||
self.$tokenizer.cache = tokens.data;
|
|
||||||
var firstRow = 0;
|
var firstRow = 0;
|
||||||
var lastRow = session.getLength() - 1;
|
var lastRow = session.getLength() - 1;
|
||||||
var currentLineIndex = session.bgTokenizer.currentLine;
|
|
||||||
var currentLine = session.bgTokenizer.lines[currentLineIndex];
|
var lines = tokens.data;
|
||||||
session.bgTokenizer.lines = [];
|
|
||||||
session.bgTokenizer.lines[currentLineIndex] = currentLine;
|
for(var i in that.deltas)
|
||||||
|
{
|
||||||
|
var delta = that.deltas[i];
|
||||||
|
if (delta.action === "insertLines")
|
||||||
|
{
|
||||||
|
var newLineCount = delta.range.end.row - delta.range.start.row;
|
||||||
|
this.$insertNewRows(delta.range.start.row, newLineCount);
|
||||||
|
for (var i = 0; i < newLineCount; i++) {
|
||||||
|
lines.splice(delta.range.start.row + i, 0, undefined);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (delta.action === "insertText")
|
||||||
|
{
|
||||||
|
if (session.getDocument().isNewLine(delta.text))
|
||||||
|
{
|
||||||
|
lines.splice(delta.range.start.row, 0, undefined);
|
||||||
|
} else {
|
||||||
|
delete lines[delta.range.start.row];
|
||||||
|
}
|
||||||
|
} else if (delta.action === "removeLines") {
|
||||||
|
var oldLineCount = delta.range.end.row - delta.range.start.row;
|
||||||
|
lines.splice(delta.range.start.row, oldLineCount);
|
||||||
|
} else if (delta.action === "removeText") {
|
||||||
|
if (session.getDocument().isNewLine(delta.text))
|
||||||
|
{
|
||||||
|
lines.splice(delta.range.start.row, 0);
|
||||||
|
} else {
|
||||||
|
delete lines[delta.range.start.row];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
session.bgTokenizer.lines = lines;
|
||||||
session.bgTokenizer.fireUpdateEvent(firstRow, lastRow);
|
session.bgTokenizer.fireUpdateEvent(firstRow, lastRow);
|
||||||
});
|
});
|
||||||
|
|
||||||
return worker;
|
return worker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -311,68 +355,6 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, mod, classname) {
|
||||||
|
|
||||||
exports.WorkerClient = WorkerClient;
|
exports.WorkerClient = WorkerClient;
|
||||||
|
|
||||||
});
|
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is Ajax.org Code Editor (ACE).
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Ajax.org B.V.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* William Candillon <wcandillon AT gmail DOT com>
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the MPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
define('ace/mode/xquery_tokenizer', ['require', 'exports', 'module' , 'ace/tokenizer', 'ace/mode/xquery_highlight_rules'], function(require, exports, module) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
|
||||||
var XQueryHighlightRules = require("./xquery_highlight_rules").XQueryHighlightRules;
|
|
||||||
|
|
||||||
var XQueryTokenizer = exports.XQueryTokenizer = function(){
|
|
||||||
this.cache = [];
|
|
||||||
this.$regexpTokenizer = new Tokenizer(new XQueryHighlightRules().getRules());
|
|
||||||
};
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
this.getLineTokens = function(line, startState) {
|
|
||||||
var cachedLine = null;
|
|
||||||
for(var i in this.cache)
|
|
||||||
{
|
|
||||||
var c = this.cache[i];
|
|
||||||
if(c && c.line == line && c.startState == startState) {
|
|
||||||
return c.tokens;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.$regexpTokenizer.getLineTokens(line, startState);
|
|
||||||
};
|
|
||||||
}).call(XQueryTokenizer.prototype);
|
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
* eXide - web-based XQuery IDE
|
* eXide - web-based XQuery IDE
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
|
|
@ -35,18 +35,19 @@
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
ace.define('ace/mode/xquery', ['require', 'exports', 'module' , 'ace/worker/worker_client', 'ace/lib/oop', 'ace/mode/text', 'ace/mode/xquery_tokenizer', 'ace/mode/behaviour/xquery', 'ace/range'], function(require, exports, module) {
|
ace.define('ace/mode/xquery', ['require', 'exports', 'module' , 'ace/worker/worker_client', 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xquery_highlight_rules', 'ace/mode/behaviour/xquery', 'ace/range'], function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var TextMode = require("./text").Mode;
|
var TextMode = require("./text").Mode;
|
||||||
var XQueryTokenizer = require("./xquery_tokenizer").XQueryTokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
|
var XQueryHighlightRules = require("./xquery_highlight_rules").XQueryHighlightRules;
|
||||||
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
|
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
|
||||||
var Range = require("../range").Range;
|
var Range = require("../range").Range;
|
||||||
|
|
||||||
var Mode = function(parent) {
|
var Mode = function(parent) {
|
||||||
this.$tokenizer = new XQueryTokenizer();
|
this.$tokenizer = new Tokenizer(new XQueryHighlightRules().getRules());
|
||||||
this.$behaviour = new XQueryBehaviour(parent);
|
this.$behaviour = new XQueryBehaviour(parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -116,11 +117,22 @@ oop.inherits(Mode, TextMode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.deltas = [];
|
||||||
|
|
||||||
this.createWorker = function(session) {
|
this.createWorker = function(session) {
|
||||||
var worker = new WorkerClient(["ace"], "worker-xquery.js", "ace/mode/xquery_worker", "XQueryWorker");
|
var worker = new WorkerClient(["ace"], "worker-xquery.js", "ace/mode/xquery_worker", "XQueryWorker");
|
||||||
var self = this;
|
var that = this;
|
||||||
|
|
||||||
|
session.getDocument().on('change', function(evt){
|
||||||
|
that.deltas.push(evt.data);
|
||||||
|
});
|
||||||
|
|
||||||
worker.attachToDocument(session.getDocument());
|
worker.attachToDocument(session.getDocument());
|
||||||
|
|
||||||
|
worker.on("start", function(e) {
|
||||||
|
that.deltas = [];
|
||||||
|
});
|
||||||
|
|
||||||
worker.on("error", function(e) {
|
worker.on("error", function(e) {
|
||||||
session.setAnnotations([e.data]);
|
session.setAnnotations([e.data]);
|
||||||
});
|
});
|
||||||
|
|
@ -130,15 +142,47 @@ oop.inherits(Mode, TextMode);
|
||||||
});
|
});
|
||||||
|
|
||||||
worker.on("highlight", function(tokens) {
|
worker.on("highlight", function(tokens) {
|
||||||
self.$tokenizer.cache = tokens.data;
|
|
||||||
var firstRow = 0;
|
var firstRow = 0;
|
||||||
var lastRow = session.getLength() - 1;
|
var lastRow = session.getLength() - 1;
|
||||||
var currentLineIndex = session.bgTokenizer.currentLine;
|
|
||||||
var currentLine = session.bgTokenizer.lines[currentLineIndex];
|
var lines = tokens.data;
|
||||||
session.bgTokenizer.lines = [];
|
|
||||||
session.bgTokenizer.lines[currentLineIndex] = currentLine;
|
for(var i in that.deltas)
|
||||||
|
{
|
||||||
|
var delta = that.deltas[i];
|
||||||
|
if (delta.action === "insertLines")
|
||||||
|
{
|
||||||
|
var newLineCount = delta.range.end.row - delta.range.start.row;
|
||||||
|
this.$insertNewRows(delta.range.start.row, newLineCount);
|
||||||
|
for (var i = 0; i < newLineCount; i++) {
|
||||||
|
lines.splice(delta.range.start.row + i, 0, undefined);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (delta.action === "insertText")
|
||||||
|
{
|
||||||
|
if (session.getDocument().isNewLine(delta.text))
|
||||||
|
{
|
||||||
|
lines.splice(delta.range.start.row, 0, undefined);
|
||||||
|
} else {
|
||||||
|
delete lines[delta.range.start.row];
|
||||||
|
}
|
||||||
|
} else if (delta.action === "removeLines") {
|
||||||
|
var oldLineCount = delta.range.end.row - delta.range.start.row;
|
||||||
|
lines.splice(delta.range.start.row, oldLineCount);
|
||||||
|
} else if (delta.action === "removeText") {
|
||||||
|
if (session.getDocument().isNewLine(delta.text))
|
||||||
|
{
|
||||||
|
lines.splice(delta.range.start.row, 0);
|
||||||
|
} else {
|
||||||
|
delete lines[delta.range.start.row];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
session.bgTokenizer.lines = lines;
|
||||||
session.bgTokenizer.fireUpdateEvent(firstRow, lastRow);
|
session.bgTokenizer.fireUpdateEvent(firstRow, lastRow);
|
||||||
});
|
});
|
||||||
|
|
||||||
return worker;
|
return worker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -146,68 +190,6 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
});
|
});
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is Ajax.org Code Editor (ACE).
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Ajax.org B.V.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* William Candillon <wcandillon AT gmail DOT com>
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the MPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
ace.define('ace/mode/xquery_tokenizer', ['require', 'exports', 'module' , 'ace/tokenizer', 'ace/mode/xquery_highlight_rules'], function(require, exports, module) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
|
||||||
var XQueryHighlightRules = require("./xquery_highlight_rules").XQueryHighlightRules;
|
|
||||||
|
|
||||||
var XQueryTokenizer = exports.XQueryTokenizer = function(){
|
|
||||||
this.cache = [];
|
|
||||||
this.$regexpTokenizer = new Tokenizer(new XQueryHighlightRules().getRules());
|
|
||||||
};
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
this.getLineTokens = function(line, startState) {
|
|
||||||
var cachedLine = null;
|
|
||||||
for(var i in this.cache)
|
|
||||||
{
|
|
||||||
var c = this.cache[i];
|
|
||||||
if(c && c.line == line && c.startState == startState) {
|
|
||||||
return c.tokens;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.$regexpTokenizer.getLineTokens(line, startState);
|
|
||||||
};
|
|
||||||
}).call(XQueryTokenizer.prototype);
|
|
||||||
});
|
|
||||||
/*
|
/*
|
||||||
* eXide - web-based XQuery IDE
|
* eXide - web-based XQuery IDE
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -35,18 +35,19 @@
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
define('ace/mode/xquery', ['require', 'exports', 'module' , 'ace/worker/worker_client', 'ace/lib/oop', 'ace/mode/text', 'ace/mode/xquery_tokenizer', 'ace/mode/behaviour/xquery', 'ace/range'], function(require, exports, module) {
|
define('ace/mode/xquery', ['require', 'exports', 'module' , 'ace/worker/worker_client', 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xquery_highlight_rules', 'ace/mode/behaviour/xquery', 'ace/range'], function(require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var TextMode = require("./text").Mode;
|
var TextMode = require("./text").Mode;
|
||||||
var XQueryTokenizer = require("./xquery_tokenizer").XQueryTokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
|
var XQueryHighlightRules = require("./xquery_highlight_rules").XQueryHighlightRules;
|
||||||
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
|
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
|
||||||
var Range = require("../range").Range;
|
var Range = require("../range").Range;
|
||||||
|
|
||||||
var Mode = function(parent) {
|
var Mode = function(parent) {
|
||||||
this.$tokenizer = new XQueryTokenizer();
|
this.$tokenizer = new Tokenizer(new XQueryHighlightRules().getRules());
|
||||||
this.$behaviour = new XQueryBehaviour(parent);
|
this.$behaviour = new XQueryBehaviour(parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -116,11 +117,22 @@ oop.inherits(Mode, TextMode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.deltas = [];
|
||||||
|
|
||||||
this.createWorker = function(session) {
|
this.createWorker = function(session) {
|
||||||
var worker = new WorkerClient(["ace"], "worker-xquery.js", "ace/mode/xquery_worker", "XQueryWorker");
|
var worker = new WorkerClient(["ace"], "worker-xquery.js", "ace/mode/xquery_worker", "XQueryWorker");
|
||||||
var self = this;
|
var that = this;
|
||||||
|
|
||||||
|
session.getDocument().on('change', function(evt){
|
||||||
|
that.deltas.push(evt.data);
|
||||||
|
});
|
||||||
|
|
||||||
worker.attachToDocument(session.getDocument());
|
worker.attachToDocument(session.getDocument());
|
||||||
|
|
||||||
|
worker.on("start", function(e) {
|
||||||
|
that.deltas = [];
|
||||||
|
});
|
||||||
|
|
||||||
worker.on("error", function(e) {
|
worker.on("error", function(e) {
|
||||||
session.setAnnotations([e.data]);
|
session.setAnnotations([e.data]);
|
||||||
});
|
});
|
||||||
|
|
@ -130,15 +142,47 @@ oop.inherits(Mode, TextMode);
|
||||||
});
|
});
|
||||||
|
|
||||||
worker.on("highlight", function(tokens) {
|
worker.on("highlight", function(tokens) {
|
||||||
self.$tokenizer.cache = tokens.data;
|
|
||||||
var firstRow = 0;
|
var firstRow = 0;
|
||||||
var lastRow = session.getLength() - 1;
|
var lastRow = session.getLength() - 1;
|
||||||
var currentLineIndex = session.bgTokenizer.currentLine;
|
|
||||||
var currentLine = session.bgTokenizer.lines[currentLineIndex];
|
var lines = tokens.data;
|
||||||
session.bgTokenizer.lines = [];
|
|
||||||
session.bgTokenizer.lines[currentLineIndex] = currentLine;
|
for(var i in that.deltas)
|
||||||
|
{
|
||||||
|
var delta = that.deltas[i];
|
||||||
|
if (delta.action === "insertLines")
|
||||||
|
{
|
||||||
|
var newLineCount = delta.range.end.row - delta.range.start.row;
|
||||||
|
this.$insertNewRows(delta.range.start.row, newLineCount);
|
||||||
|
for (var i = 0; i < newLineCount; i++) {
|
||||||
|
lines.splice(delta.range.start.row + i, 0, undefined);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (delta.action === "insertText")
|
||||||
|
{
|
||||||
|
if (session.getDocument().isNewLine(delta.text))
|
||||||
|
{
|
||||||
|
lines.splice(delta.range.start.row, 0, undefined);
|
||||||
|
} else {
|
||||||
|
delete lines[delta.range.start.row];
|
||||||
|
}
|
||||||
|
} else if (delta.action === "removeLines") {
|
||||||
|
var oldLineCount = delta.range.end.row - delta.range.start.row;
|
||||||
|
lines.splice(delta.range.start.row, oldLineCount);
|
||||||
|
} else if (delta.action === "removeText") {
|
||||||
|
if (session.getDocument().isNewLine(delta.text))
|
||||||
|
{
|
||||||
|
lines.splice(delta.range.start.row, 0);
|
||||||
|
} else {
|
||||||
|
delete lines[delta.range.start.row];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
session.bgTokenizer.lines = lines;
|
||||||
session.bgTokenizer.fireUpdateEvent(firstRow, lastRow);
|
session.bgTokenizer.fireUpdateEvent(firstRow, lastRow);
|
||||||
});
|
});
|
||||||
|
|
||||||
return worker;
|
return worker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -146,68 +190,6 @@ oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
exports.Mode = Mode;
|
exports.Mode = Mode;
|
||||||
});
|
});
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is Ajax.org Code Editor (ACE).
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Ajax.org B.V.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* William Candillon <wcandillon AT gmail DOT com>
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the MPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
define('ace/mode/xquery_tokenizer', ['require', 'exports', 'module' , 'ace/tokenizer', 'ace/mode/xquery_highlight_rules'], function(require, exports, module) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
|
||||||
var XQueryHighlightRules = require("./xquery_highlight_rules").XQueryHighlightRules;
|
|
||||||
|
|
||||||
var XQueryTokenizer = exports.XQueryTokenizer = function(){
|
|
||||||
this.cache = [];
|
|
||||||
this.$regexpTokenizer = new Tokenizer(new XQueryHighlightRules().getRules());
|
|
||||||
};
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
this.getLineTokens = function(line, startState) {
|
|
||||||
var cachedLine = null;
|
|
||||||
for(var i in this.cache)
|
|
||||||
{
|
|
||||||
var c = this.cache[i];
|
|
||||||
if(c && c.line == line && c.startState == startState) {
|
|
||||||
return c.tokens;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.$regexpTokenizer.getLineTokens(line, startState);
|
|
||||||
};
|
|
||||||
}).call(XQueryTokenizer.prototype);
|
|
||||||
});
|
|
||||||
/*
|
/*
|
||||||
* eXide - web-based XQuery IDE
|
* eXide - web-based XQuery IDE
|
||||||
*
|
*
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
|
@ -41,12 +41,13 @@ define(function(require, exports, module) {
|
||||||
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
var WorkerClient = require("../worker/worker_client").WorkerClient;
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
var TextMode = require("./text").Mode;
|
var TextMode = require("./text").Mode;
|
||||||
var XQueryTokenizer = require("./xquery_tokenizer").XQueryTokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
|
var XQueryHighlightRules = require("./xquery_highlight_rules").XQueryHighlightRules;
|
||||||
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
|
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
|
||||||
var Range = require("../range").Range;
|
var Range = require("../range").Range;
|
||||||
|
|
||||||
var Mode = function(parent) {
|
var Mode = function(parent) {
|
||||||
this.$tokenizer = new XQueryTokenizer();
|
this.$tokenizer = new Tokenizer(new XQueryHighlightRules().getRules());
|
||||||
this.$behaviour = new XQueryBehaviour(parent);
|
this.$behaviour = new XQueryBehaviour(parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -116,11 +117,22 @@ oop.inherits(Mode, TextMode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.deltas = [];
|
||||||
|
|
||||||
this.createWorker = function(session) {
|
this.createWorker = function(session) {
|
||||||
var worker = new WorkerClient(["ace"], "worker-xquery.js", "ace/mode/xquery_worker", "XQueryWorker");
|
var worker = new WorkerClient(["ace"], "worker-xquery.js", "ace/mode/xquery_worker", "XQueryWorker");
|
||||||
var self = this;
|
var that = this;
|
||||||
|
|
||||||
|
session.getDocument().on('change', function(evt){
|
||||||
|
that.deltas.push(evt.data);
|
||||||
|
});
|
||||||
|
|
||||||
worker.attachToDocument(session.getDocument());
|
worker.attachToDocument(session.getDocument());
|
||||||
|
|
||||||
|
worker.on("start", function(e) {
|
||||||
|
that.deltas = [];
|
||||||
|
});
|
||||||
|
|
||||||
worker.on("error", function(e) {
|
worker.on("error", function(e) {
|
||||||
session.setAnnotations([e.data]);
|
session.setAnnotations([e.data]);
|
||||||
});
|
});
|
||||||
|
|
@ -130,15 +142,47 @@ oop.inherits(Mode, TextMode);
|
||||||
});
|
});
|
||||||
|
|
||||||
worker.on("highlight", function(tokens) {
|
worker.on("highlight", function(tokens) {
|
||||||
self.$tokenizer.cache = tokens.data;
|
|
||||||
var firstRow = 0;
|
var firstRow = 0;
|
||||||
var lastRow = session.getLength() - 1;
|
var lastRow = session.getLength() - 1;
|
||||||
var currentLineIndex = session.bgTokenizer.currentLine;
|
|
||||||
var currentLine = session.bgTokenizer.lines[currentLineIndex];
|
var lines = tokens.data;
|
||||||
session.bgTokenizer.lines = [];
|
|
||||||
session.bgTokenizer.lines[currentLineIndex] = currentLine;
|
for(var i in that.deltas)
|
||||||
|
{
|
||||||
|
var delta = that.deltas[i];
|
||||||
|
if (delta.action === "insertLines")
|
||||||
|
{
|
||||||
|
var newLineCount = delta.range.end.row - delta.range.start.row;
|
||||||
|
this.$insertNewRows(delta.range.start.row, newLineCount);
|
||||||
|
for (var i = 0; i < newLineCount; i++) {
|
||||||
|
lines.splice(delta.range.start.row + i, 0, undefined);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (delta.action === "insertText")
|
||||||
|
{
|
||||||
|
if (session.getDocument().isNewLine(delta.text))
|
||||||
|
{
|
||||||
|
lines.splice(delta.range.start.row, 0, undefined);
|
||||||
|
} else {
|
||||||
|
delete lines[delta.range.start.row];
|
||||||
|
}
|
||||||
|
} else if (delta.action === "removeLines") {
|
||||||
|
var oldLineCount = delta.range.end.row - delta.range.start.row;
|
||||||
|
lines.splice(delta.range.start.row, oldLineCount);
|
||||||
|
} else if (delta.action === "removeText") {
|
||||||
|
if (session.getDocument().isNewLine(delta.text))
|
||||||
|
{
|
||||||
|
lines.splice(delta.range.start.row, 0);
|
||||||
|
} else {
|
||||||
|
delete lines[delta.range.start.row];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
session.bgTokenizer.lines = lines;
|
||||||
session.bgTokenizer.fireUpdateEvent(firstRow, lastRow);
|
session.bgTokenizer.fireUpdateEvent(firstRow, lastRow);
|
||||||
});
|
});
|
||||||
|
|
||||||
return worker;
|
return worker;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
// $ANTLR 3.3 Nov 30, 2010 12:50:56 xquery/StringLexer.g 2012-04-20 08:26:29
|
// $ANTLR 3.3 Nov 30, 2010 12:50:56 xquery/StringLexer.g 2012-04-23 09:26:59
|
||||||
|
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
// $ANTLR 3.3 Nov 30, 2010 12:50:56 xquery/XMLLexer.g 2012-04-20 08:26:30
|
// $ANTLR 3.3 Nov 30, 2010 12:50:56 xquery/XMLLexer.g 2012-04-23 09:27:01
|
||||||
|
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
// $ANTLR 3.3 Nov 30, 2010 12:50:56 xquery/XQueryLexer.g 2012-04-20 08:26:27
|
// $ANTLR 3.3 Nov 30, 2010 12:50:56 xquery/XQueryLexer.g 2012-04-23 09:26:57
|
||||||
|
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -90,8 +90,9 @@ define(function(require, exports, module){
|
||||||
}
|
}
|
||||||
//Check if the tokenized line is equal to the original one:
|
//Check if the tokenized line is equal to the original one:
|
||||||
if(sourceLine == tokenizedLine) {
|
if(sourceLine == tokenizedLine) {
|
||||||
result[i] = { line: sourceLine, startState: previousState, tokens: { tokens: lineTokens, state: nextState } };
|
result[i] = { tokens: lineTokens, state: nextState };
|
||||||
} else {
|
} else {
|
||||||
|
result[i] = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is Ajax.org Code Editor (ACE).
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Ajax.org B.V.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
* William Candillon <wcandillon AT gmail DOT com>
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the MPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
|
||||||
var XQueryHighlightRules = require("./xquery_highlight_rules").XQueryHighlightRules;
|
|
||||||
|
|
||||||
var XQueryTokenizer = exports.XQueryTokenizer = function(){
|
|
||||||
this.cache = [];
|
|
||||||
this.$regexpTokenizer = new Tokenizer(new XQueryHighlightRules().getRules());
|
|
||||||
};
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
this.getLineTokens = function(line, startState) {
|
|
||||||
var cachedLine = null;
|
|
||||||
for(var i in this.cache)
|
|
||||||
{
|
|
||||||
var c = this.cache[i];
|
|
||||||
if(c && c.line == line && c.startState == startState) {
|
|
||||||
return c.tokens;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.$regexpTokenizer.getLineTokens(line, startState);
|
|
||||||
};
|
|
||||||
}).call(XQueryTokenizer.prototype);
|
|
||||||
});
|
|
||||||
|
|
@ -55,6 +55,7 @@ oop.inherits(XQueryWorker, Mirror);
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.onUpdate = function() {
|
this.onUpdate = function() {
|
||||||
|
this.sender.emit("start");
|
||||||
var value = this.doc.getValue();
|
var value = this.doc.getValue();
|
||||||
var parser = xquery.getParser(value);
|
var parser = xquery.getParser(value);
|
||||||
var ast = parser.p_Module();
|
var ast = parser.p_Module();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue