Bug fixes

This commit is contained in:
William Candillon 2014-03-29 23:28:26 +01:00 • committed by nightwing
commit 3c13b4bf33

View file

@ -988,8 +988,6 @@ var TreeOps = _dereq_('../tree_ops').TreeOps;
var ID_REGEX = /[a-zA-Z_0-9\$]/;
function retrievePrecedingIdentifier(text, pos, regex) {
console.log(text);
console.log(pos);
regex = regex || ID_REGEX;
var buf = [];
for (var i = pos-1; i >= 0; i--) {
@ -1041,6 +1039,24 @@ var nameChar = '[' + char + ']';
var nameCharRegExp = new RegExp(nameChar);
//var varCharRegExp = new RegExp(varChar);
var varDeclLabels = {
'LetBinding': 'Let binding',
'Param': 'Function parameter',
'QuantifiedExpr': 'Quantified expression binding',
'VarDeclStatement': 'Local variable',
'ForBinding': 'For binding',
'TumblingWindowClause': 'Tumbling window binding',
'WindowVars': 'Window variable',
'SlidingWindowClause': 'Sliding window binding',
'PositionalVar': 'Positional variable',
'CurrentItem': 'Current item',
'PreviousItem': 'Previous item',
'NextItem': 'Next item',
'CountClause': 'Count binding',
'GroupingVariable': 'Grouping variable',
'VarDecl': 'Module variable'
};
var findCompletions = function(prefix, allIdentifiers) {
allIdentifiers.sort();
var startIdx = prefixBinarySearch(allIdentifiers, prefix);
@ -1066,7 +1082,6 @@ var completePrefix = function(identifier, pos, sctx){
var match = function(name) {
return {
name: name + ':',
score: 8,
value: name + ':'
};
};
@ -1105,7 +1120,6 @@ var completeFunction = function(identifier, pos, sctx){
var match = function(name) {
return {
name: name,
score: 4,
value: name
};
};
@ -1123,14 +1137,17 @@ var completeVariable = function(identifier, pos, sctx){
}
var decls = sctx.getVariables();
var names = [];
var types = {};
Object.keys(decls).forEach(function(key){
var i = key.indexOf('#');
var ns = key.substring(0, i);
var name = key.substring(i+1);
if(ns !== ''){
names.push(sctx.getPrefixByNamespace(ns) + ':' + name);
types[sctx.getPrefixByNamespace(ns) + ':' + name] = decls[key].type;
} else {
names.push(name);
types[name] = decls[key].type;
}
});
@ -1138,17 +1155,14 @@ var completeVariable = function(identifier, pos, sctx){
var match = function(name) {
return {
name: '$' + name,
score: 4,
value: '$' + name
value: '$' + name,
meta: varDeclLabels[types[name]]
};
};
return matches.map(match);
};
var completeExpr = function(line, pos, sctx){
console.log('line');
console.log(line);
console.log('=');
var identifier = retrievePrecedingIdentifier(line, pos.col, nameCharRegExp);
var before = line.substring(0, pos.col - (identifier.length === 0 ? 0 : identifier.length));
var isVar = before[before.length - 1] === '$';