exports.XQLint = function (source, opts) {
    'use strict';

    opts = opts ? opts : {};

    var JSONiqParser = require('./parsers/JSONiqParser').JSONiqParser;
    var XQueryParser = require('./parsers/XQueryParser').XQueryParser;
    var JSONParseTreeHandler = require('./parsers/JSONParseTreeHandler').JSONParseTreeHandler;
    var Translator = require('./compiler/translator').Translator;
    var StyleChecker = require('./formatter/style_checker').StyleChecker;
    var StaticContext = require('./compiler/static_context').StaticContext;
    var completer = require('../lib/completion/completer');

    var defaults = function(current, def){
        if(!current) {
            return def;
        }
        Object.keys(def).forEach(function(key){
            if(current[key] === undefined){
                current[key] = def[key];
            }
        });
        return current;
    };

    opts = defaults(opts, { styleCheck: false });

    this.createStaticContext = function(){
        return new StaticContext();    
    };

    var ast;
    this.getAST = function () {
        return ast;
    };

    var markers = [];
    this.getMarkers = function () {
        return markers;
    };
    
    this.getErrors = function(){
        var errors = [];
        markers.forEach(function(marker){
            if(marker.type === 'error') {
                errors.push(marker);
            }
        });
        return errors;
    };

    this.getWarnings = function(){
        var warnings = [];
        markers.forEach(function(marker){
            if(marker.type === 'warning') {
                warnings.push(marker);
            }
        });
        return warnings;
    };
    
    this.getCompletions = function(pos){
        return completer.complete(source, ast, sctx, pos);
    };

    var syntaxError = false;
    this.hasSyntaxError = function () {
        return syntaxError;
    };

    var convertPosition = function (code, begin, end) {
        var before = code.substring(0, begin);
        var after = code.substring(0, end);
        var startline = before.split('\n').length;
        var startcolumn = begin - before.lastIndexOf('\n');
        var endline = after.split('\n').length;
        var endcolumn = end - after.lastIndexOf('\n');
        var pos = {
            sl: startline - 1,
            sc: startcolumn - 1,
            el: endline - 1,
            ec: endcolumn - 1
        };
        return pos;
    };

    var sctx = opts.staticContext ? opts.staticContext : new StaticContext();
    var file = opts.fileName ? opts.fileName : '';
    var isJSONiq = ((file.substring(file.length - '.jq'.length).indexOf('.jq') !== -1) && source.indexOf('xquery version') !== 0) || source.indexOf('jsoniq version') === 0;
    var h = new JSONParseTreeHandler(source);
    var parser = isJSONiq ? new JSONiqParser(source, h) : new XQueryParser(source, h);
    try {
        parser.parse_XQuery();
    } catch (e) {
        if (e instanceof parser.ParseException) {
            syntaxError = true;
            h.closeParseTree();
            var pos = convertPosition(source, e.getBegin(), e.getEnd());
            var message = parser.getErrorMessage(e);
            if (pos.sc === pos.ec) {
                pos.ec++;
            }
            markers.push({
                pos: pos,
                type: 'error',
                level: 'error',
                message: message
            });
        } else {
            throw e;
        }
    }
    ast = h.getParseTree();
    if(opts.styleCheck) {
        markers = markers.concat(new StyleChecker(ast, source).getMarkers());
    }
    var translator = new Translator(sctx, ast);
    markers = markers.concat(translator.getMarkers());
};

@@ -1,8 +1,203 @@
+'use strict';%0A%0Avar createStaticContext = exports.createStaticContext = function()%7B%0A    var StaticContext = require('./compiler/static_context').StaticContext;%0A    return new StaticContext();%0A%7D;%0A%0A
 exports.
@@ -234,26 +234,8 @@
 s) %7B
-%0A    'use strict';
 %0A%0A  
@@ -643,84 +643,8 @@
 er;%0A
-    var StaticContext = require('./compiler/static_context').StaticContext;%0A
     
@@ -987,24 +987,24 @@
 nt;%0A    %7D;%0A%0A
+
     opts = d
@@ -1046,99 +1046,8 @@
 );%0A%0A
-    this.createStaticContext = function()%7B%0A        return new StaticContext();    %0A    %7D;%0A%0A
     
@@ -2508,20 +2508,22 @@
 ntext : 
-new 
+create
 StaticCo

Fix build