Update Query worker.
This commit is contained in:
parent
431facf08b
commit
d6d3f0b384
1 changed files with 36 additions and 2 deletions
|
|
@ -34,17 +34,51 @@ define(function(require, exports, module) {
|
|||
var oop = require("../lib/oop");
|
||||
var Mirror = require("../worker/mirror").Mirror;
|
||||
var XQLint = require("./xquery/xqlint").XQLint;
|
||||
var StaticContext = require("./xquery/xqlint").StaticContext;
|
||||
|
||||
var XQueryWorker = exports.XQueryWorker = function(sender) {
|
||||
Mirror.call(this, sender);
|
||||
this.setTimeout(200);
|
||||
this.opts = {
|
||||
styleCheck: false,
|
||||
sctx: new StaticContext()
|
||||
};
|
||||
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 mod = index[uri];
|
||||
var variables = {};
|
||||
var functions = {};
|
||||
mod.functions.forEach(function(fn){
|
||||
functions[uri + '#' + fn.name + '#' + fn.arity] = {
|
||||
params: []
|
||||
};
|
||||
fn.parameters.forEach(function(param){
|
||||
functions[uri + '#' + fn.name + '#' + fn.arity].params.push('$' + param.name);
|
||||
});
|
||||
});
|
||||
mod.variables.forEach(function(variable){
|
||||
var name = variable.name.substring(variable.name.indexOf(':') + 1);
|
||||
variables[uri + '#' + name] = { type: 'VarDecl', annotations: [] };
|
||||
});
|
||||
return {
|
||||
variables: variables,
|
||||
functions: functions
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
oop.inherits(XQueryWorker, Mirror);
|
||||
|
|
@ -53,8 +87,8 @@ oop.inherits(XQueryWorker, Mirror);
|
|||
|
||||
this.onUpdate = function() {
|
||||
this.sender.emit("start");
|
||||
var value = this.doc.getValue();
|
||||
this.xqlint = new XQLint(value);
|
||||
var value = this.doc.getValue();
|
||||
this.xqlint = new XQLint(value, this.opts);
|
||||
this.sender.emit("markers", this.xqlint.getMarkers());
|
||||
};
|
||||
}).call(XQueryWorker.prototype);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue