Example #1
0
    this.gatherCompletions = function(editor, callback) {
        var session = editor.getSession();
        var pos = editor.getCursorPosition();

        var line = session.getLine(pos.row);
        var prefix = util.retrievePrecedingIdentifier(line, pos.column);

        this.base = editor.getCursorPosition();
        this.base.column -= prefix.length;

        var matches = [];
        var total = editor.completers.length;
        editor.completers.forEach(function(completer, i) {
            completer.getCompletions(editor, session, pos, prefix, function(err, results) {
                if (!err)
                    matches = matches.concat(results);
                // Fetch prefix again, because they may have changed by now
                var pos = editor.getCursorPosition();
                var line = session.getLine(pos.row);
                callback(null, {
                    prefix: util.retrievePrecedingIdentifier(line, pos.column, ID_REGEX),
                    matches: matches,
                    finished: (--total === 0)
                });
            });
        });
        return true;
    };
Example #2
0
 completer.getCompletions(editor, session, pos, prefix, function(err, results) {
     if (!err)
         matches = matches.concat(results);
     // Fetch prefix again, because they may have changed by now
     var pos = editor.getCursorPosition();
     var line = session.getLine(pos.row);
     callback(null, {
         prefix: util.retrievePrecedingIdentifier(line, pos.column, ID_REGEX),
         matches: matches,
         finished: (--total === 0)
     });
 });
Example #3
0
this.getCompletions = function(editor, session, pos, callback) {
      var that = this;
      var line = session.getLine(pos.row);
      var prefix = util.retrievePrecedingIdentifier(line, pos.column);
      if(!prefix) {
        callback(null, []);
        return;
      }
      rcloud.get_completions(this.language, session.getValue(),
                             session.getDocument().positionToIndex(pos))
                            .then(function(ret) {
                                callback(null, ret);
                            });
  };