Update xqlint version

This commit is contained in:
William Candillon 2014-04-04 11:29:19 +02:00 committed by nightwing
commit 6c38e136c1
4 changed files with 62 additions and 30 deletions

File diff suppressed because one or more lines are too long

View file

@ -1009,6 +1009,7 @@ function retrievePrecedingIdentifier(text, pos, regex) {
}
return buf.reverse().join('');
}
/*
function retrieveFollowingIdentifier(text, pos, regex) {
regex = regex || ID_REGEX;
@ -1023,6 +1024,7 @@ function retrieveFollowingIdentifier(text, pos, regex) {
return buf;
}
*/
function prefixBinarySearch(items, prefix) {
var startIndex = 0;
var stopIndex = items.length - 1;
@ -1092,7 +1094,8 @@ var completePrefix = function(identifier, pos, sctx){
var match = function(name) {
return {
name: name + ':',
value: name + ':'
value: name + ':',
meta: 'prefix'
};
};
return matches.map(match);
@ -1111,7 +1114,10 @@ var completeFunction = function(identifier, pos, sctx){
if(idx !== -1){
prefix = identifier.substring(0, idx);
name = identifier.substring(idx + 1);
uri = sctx.getNamespaceByPrefix(prefix).uri;
var ns = sctx.getNamespaceByPrefix(prefix);
if(ns){
uri = sctx.getNamespaceByPrefix(prefix).uri;
}
}
Object.keys(functions).forEach(function(key){
var fn = functions[key];
@ -1130,7 +1136,8 @@ var completeFunction = function(identifier, pos, sctx){
var match = function(name) {
return {
name: name,
value: name
value: name,
meta: 'function'
};
};
return matches.map(match);
@ -1191,7 +1198,8 @@ var completeModuleUri = function(line, pos, sctx){
var match = function(name) {
return {
name: name,
value: name
value: name,
meta: 'module'
};
};
return matches.map(match);
@ -1208,6 +1216,7 @@ exports.complete = function(source, ast, rootSctx, pos){
return completeExpr(line, pos, sctx);
}
};
},
{"../tree_ops":10}],
6:[function(_dereq_,module,exports){
@ -78568,7 +78577,9 @@ exports.TreeOps = {
flatten: function(node){
var that = this;
var value = '';
if (node.value === undefined) {
if(!node) {
throw new Error('Invalid node found');
} else if (node.value === undefined) {
node.children.forEach(function(child){
value += that.flatten(child);
});

View file

@ -35,29 +35,11 @@ var oop = require("../lib/oop");
var Mirror = require("../worker/mirror").Mirror;
var XQLintLib = require("./xquery/xqlint");
var XQLint = XQLintLib.XQLint;
var Modules = require("./xquery/modules").Modules;
var XQueryWorker = exports.XQueryWorker = function(sender) {
Mirror.call(this, sender);
this.setTimeout(200);
this.opts = {
styleCheck: false,
staticContext: XQLintLib.createStaticContext()
};
var that = this;
this.sender.on("complete", function(e){
that.sender.emit("markers", that.xqlint.getMarkers());
var pos = { line: e.data.pos.row, col: e.data.pos.column };
var proposals = that.xqlint.getCompletions(pos);
that.sender.emit("complete", proposals);
});
this.sender.on("setAvailableModuleNamespaces", function(e){
that.opts.sctx.availableModuleNamespaces = e.data;
});
this.sender.on("setModuleUriResolver", function(e){
sctx.setModuleResolver(function(uri){
var getModuleResolverFromModules = function(modules){
return function(uri){
var index = modules;
var mod = index[uri];
var variables = {};
var functions = {};
@ -77,7 +59,31 @@ var XQueryWorker = exports.XQueryWorker = function(sender) {
variables: variables,
functions: functions
};
});
};
};
var XQueryWorker = exports.XQueryWorker = function(sender) {
Mirror.call(this, sender);
this.setTimeout(200);
this.opts = {
styleCheck: false
};
this.availableModuleNamespaces = Object.keys(Modules);
this.moduleResolver = getModuleResolverFromModules(Modules);
var that = this;
this.sender.on("complete", function(e){
var pos = { line: e.data.pos.row, col: e.data.pos.column };
var proposals = that.xqlint.getCompletions(pos);
that.sender.emit("complete", proposals);
});
this.sender.on("setAvailableModuleNamespaces", function(e){
that.availableModuleNamespaces = e.data;
});
this.sender.on("setModuleResolver", function(e){
that.moduleResolver = getModuleResolverFromModules(e.data);
});
};
@ -88,7 +94,18 @@ oop.inherits(XQueryWorker, Mirror);
this.onUpdate = function() {
this.sender.emit("start");
var value = this.doc.getValue();
this.xqlint = new XQLint(value, this.opts);
var sctx = XQLintLib.createStaticContext();
if(this.moduleResolver) {
sctx.setModuleResolver(this.moduleResolver);
}
if(this.availableModuleNamespaces) {
sctx.availableModuleNamespaces = this.availableModuleNamespaces;
}
var opts = {
styleCheck: this.styleCheck,
staticContext: sctx,
};
this.xqlint = new XQLint(value, opts);
this.sender.emit("markers", this.xqlint.getMarkers());
};
}).call(XQueryWorker.prototype);

View file

@ -72,7 +72,7 @@ var deps = {
xqlint: {
path: "mode/xquery/xqlint.js",
browserify: {
npmModule: "git+https://github.com/wcandillon/xqlint.git#master",
npmModule: "git+https://github.com/wcandillon/xqlint.git#0.0.8",
path: "xqlint/lib/xqlint.js",
exports: "XQLint"
},