Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
command.exec(env, request.args, request);
// If the request isn't asnync and isn't done, then make it done.
if (!request.isAsync && !request.isDone) {
request.done();
}
}
if (request.getStatus() == Status.INVALID) {
console.error("Canon.exec: Invalid parameter(s) passed to " +
command.name);
return false;
}
// If the request isn't complete yet, try to complete it.
else if (request.getStatus() == Status.INCOMPLETE) {
// Check if the sender has a ArgsProvider, otherwise use the default
// build in one.
var argsProvider;
var senderObj = env[sender];
if (!senderObj || !senderObj.getArgsProvider ||
!(argsProvider = senderObj.getArgsProvider()))
{
argsProvider = defaultArgsProvider;
}
// Ask the paramProvider to complete the request.
argsProvider(request, function() {
if (request.getStatus() == Status.VALID) {
execute();
}
});
update: function() {
this.isUpdating = true;
var input = {
typed: this.element.value,
cursor: {
start: dom.getSelectionStart(this.element),
end: dom.getSelectionEnd(this.element.selectionEnd)
}
};
this.cli.update(input);
var display = this.cli.getAssignmentAt(input.cursor.start).getHint();
// 1. Update the completer with prompt/error marker/TAB info
dom.removeCssClass(this.completer, Status.VALID.toString());
dom.removeCssClass(this.completer, Status.INCOMPLETE.toString());
dom.removeCssClass(this.completer, Status.INVALID.toString());
var completion = '<span class="cptPrompt">></span> ';
if (this.element.value.length > 0) {
var scores = this.cli.getInputStatusMarkup();
completion += this.markupStatusScore(scores);
}
// Display the "-> prediction" at the end of the completer
if (this.element.value.length > 0 &&
display.predictions && display.predictions.length > 0) {
var tab = display.predictions[0];
completion += ' ⇥ ' + (tab.name ? tab.name : tab);
}
this.completer.innerHTML = completion;
dom.addCssClass(this.completer, this.cli.getWorstHint().status.toString());
if (namedArgText !== arg.text) {
i++;
if (i >= args.length) {
break;
}
continue;
}
// boolean parameters don't have values, default to false
if (assignment.param.type.name === 'boolean') {
assignment.setValue(true);
}
else {
if (i + 1 < args.length) {
// Missing value portion of this named param
this._hints.push(new Hint(Status.INCOMPLETE,
'Missing value for: ' + namedArgText,
args[i]));
}
else {
args.splice(i + 1, 1);
assignment.setArgument(args[i + 1]);
}
}
lang.arrayRemove(names, assignment.name);
args.splice(i, 1);
// We don't need to i++ if we splice
}
}, this);
update: function() {
this.isUpdating = true;
var input = {
typed: this.element.value,
cursor: {
start: dom.getSelectionStart(this.element),
end: dom.getSelectionEnd(this.element.selectionEnd)
}
};
this.cli.update(input);
var display = this.cli.getAssignmentAt(input.cursor.start).getHint();
// 1. Update the completer with prompt/error marker/TAB info
dom.removeCssClass(this.completer, Status.VALID.toString());
dom.removeCssClass(this.completer, Status.INCOMPLETE.toString());
dom.removeCssClass(this.completer, Status.INVALID.toString());
var completion = '<span class="cptPrompt">></span> ';
if (this.element.value.length > 0) {
var scores = this.cli.getInputStatusMarkup();
completion += this.markupStatusScore(scores);
}
// Display the "-> prediction" at the end of the completer
if (this.element.value.length > 0 &&
display.predictions && display.predictions.length > 0) {
var tab = display.predictions[0];
completion += ' ⇥ ' + (tab.name ? tab.name : tab);
}
this.completer.innerHTML = completion;
dom.addCssClass(this.completer, this.cli.getWorstHint().status.toString());
if (namedArgText !== arg.text) {
i++;
if (i >= args.length) {
break;
}
continue;
}
// boolean parameters don't have values, default to false
if (assignment.param.type.name === 'boolean') {
assignment.setValue(true);
}
else {
if (i + 1 < args.length) {
// Missing value portion of this named param
this._hints.push(new Hint(Status.INCOMPLETE,
'Missing value for: ' + namedArgText,
args[i]));
}
else {
args.splice(i + 1, 1);
assignment.setArgument(args[i + 1]);
}
}
lang.arrayRemove(names, assignment.name);
args.splice(i, 1);
// We don't need to i++ if we splice
}
}, this);
update: function() {
this.isUpdating = true;
var input = {
typed: this.element.value,
cursor: {
start: this.element.selectionStart,
end: this.element.selectionEnd
}
};
this.cli.update(input);
var display = this.cli.getAssignmentAt(input.cursor.start).getHint();
// 1. Update the completer with prompt/error marker/TAB info
this.completer.classList.remove(Status.VALID.toString());
this.completer.classList.remove(Status.INCOMPLETE.toString());
this.completer.classList.remove(Status.INVALID.toString());
// TODO: borked implementation? This is modern browser only. Fix
// dom.removeCssClass(completer, Status.VALID.toString());
// dom.removeCssClass(completer, Status.INCOMPLETE.toString());
// dom.removeCssClass(completer, Status.INVALID.toString());
var completion = '<span class="cptPrompt">></span> ';
if (this.element.value.length > 0) {
var scores = this.cli.getInputStatusMarkup();
completion += this.markupStatusScore(scores);
}
// Display the "-> prediction" at the end of the completer
if (this.element.value.length > 0 &&
display.predictions && display.predictions.length > 0) {
var tab = display.predictions[0];
update: function() {
this.isUpdating = true;
var input = {
typed: this.element.value,
cursor: {
start: dom.getSelectionStart(this.element),
end: dom.getSelectionEnd(this.element.selectionEnd)
}
};
this.cli.update(input);
var display = this.cli.getAssignmentAt(input.cursor.start).getHint();
// 1. Update the completer with prompt/error marker/TAB info
dom.removeCssClass(this.completer, Status.VALID.toString());
dom.removeCssClass(this.completer, Status.INCOMPLETE.toString());
dom.removeCssClass(this.completer, Status.INVALID.toString());
var completion = '<span class="cptPrompt">></span> ';
if (this.element.value.length > 0) {
var scores = this.cli.getInputStatusMarkup();
completion += this.markupStatusScore(scores);
}
// Display the "-> prediction" at the end of the completer
if (this.element.value.length > 0 &&
display.predictions && display.predictions.length > 0) {
var tab = display.predictions[0];
completion += ' ⇥ ' + (tab.name ? tab.name : tab);
}
this.completer.innerHTML = completion;
dom.addCssClass(this.completer, this.cli.getWorstHint().status.toString());
update: function() {
this.isUpdating = true;
var input = {
typed: this.element.value,
cursor: {
start: dom.getSelectionStart(this.element),
end: dom.getSelectionEnd(this.element.selectionEnd)
}
};
this.cli.update(input);
var display = this.cli.getAssignmentAt(input.cursor.start).getHint();
// 1. Update the completer with prompt/error marker/TAB info
dom.removeCssClass(this.completer, Status.VALID.toString());
dom.removeCssClass(this.completer, Status.INCOMPLETE.toString());
dom.removeCssClass(this.completer, Status.INVALID.toString());
var completion = '<span class="cptPrompt">></span> ';
if (this.element.value.length > 0) {
var scores = this.cli.getInputStatusMarkup();
completion += this.markupStatusScore(scores);
}
// Display the "-> prediction" at the end of the completer
if (this.element.value.length > 0 &&
display.predictions && display.predictions.length > 0) {
var tab = display.predictions[0];
completion += ' ⇥ ' + (tab.name ? tab.name : tab);
}
this.completer.innerHTML = completion;
dom.addCssClass(this.completer, this.cli.getWorstHint().status.toString());
if (namedArgText !== arg.text) {
i++;
if (i >= args.length) {
break;
}
continue;
}
// boolean parameters don't have values, default to false
if (assignment.param.type.name === 'boolean') {
assignment.setValue(true);
}
else {
if (i + 1 < args.length) {
// Missing value portion of this named param
this._hints.push(new Hint(Status.INCOMPLETE,
'Missing value for: ' + namedArgText,
args[i]));
}
else {
args.splice(i + 1, 1);
assignment.setArgument(args[i + 1]);
}
}
lang.arrayRemove(names, assignment.name);
args.splice(i, 1);
// We don't need to i++ if we splice
}
}, this);
this._hints.forEach(function(hint) {
var startInHint = c.start >= hint.start && c.start <= hint.end;
var endInHint = c.end >= hint.start && c.end <= hint.end;
var inHint = startInHint || endInHint;
if (!inHint && hint.status === Status.INCOMPLETE) {
hint.status = Status.INVALID;
}
}, this);