summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/codeq/hint.js55
1 files changed, 26 insertions, 29 deletions
diff --git a/js/codeq/hint.js b/js/codeq/hint.js
index b26f522..bc42694 100644
--- a/js/codeq/hint.js
+++ b/js/codeq/hint.js
@@ -180,9 +180,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
},
typeHandlers = {
- 'static': function (template, serverHint) {
- var content = prepareStaticHintContent(template, serverHint.indices, serverHint.id),
- args = serverHint ? serverHint.args : null,
+ 'static': function (template, hint) {
+ var content = prepareStaticHintContent(template, hint.indices, hint.id),
+ args = hint ? hint.args : null,
hintIndex = 0,
trButton = {},
Nhints = content.hintLength,
@@ -204,7 +204,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
}
}
catch (e) {
- msg = 'Error processing hint ' + serverHint.id + ' at index ' + hintIndex + ' for language ' + lang + ': ' + e;
+ msg = 'Error processing hint ' + hint.id + ' at index ' + hintIndex + ' for language ' + lang + ': ' + e;
codeq.log.error(msg, e);
trContent[lang] = msg;
}
@@ -254,11 +254,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
// no hint cleaner here, a static hint remains on the screen
},
- 'popup': function (template, serverHint) {
+ 'popup': function (template, hint) {
codeq.log.debug('Processing popup hint');
- var args = serverHint.args,
- style = serverHint.style || '',
- mark = addMark(serverHint.start, serverHint.end, style), // add the mark
+ var args = hint.args,
+ style = hint.style || '',
+ mark = addMark(hint.start, hint.end, style), // add the mark
langs = codeq.availableLangs,
translations = {},
lang, i, content, htmlPrefix, instFunc;
@@ -271,7 +271,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
translations[lang] = codeq.template.process(content, templatePath, args);
}
else {
- translations[lang] = 'No translation in ' + lang + ' available for popup hint ' + serverHint.id;
+ translations[lang] = 'No translation in ' + lang + ' available for popup hint ' + hint.id;
codeq.log.error(translations[lang]);
}
}
@@ -297,7 +297,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
return instFunc;
},
- 'dropdown': function (template, serverHint) {
+ 'dropdown': function (template, hint) {
codeq.log.debug('Processing dropdown hint');
var completion = null, // the completion object, created in showHint()
close = function () {
@@ -313,11 +313,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
}
editor.showHint({
- hint: function () {
+ 'hint': function () {
var hints = {
- list: serverHint.choices,
- from: editor.posFromIndex(serverHint.start),
- to: editor.posFromIndex(serverHint.end)
+ list: hint.choices,
+ from: editor.posFromIndex(hint.start),
+ to: editor.posFromIndex(hint.end)
};
completion = editor.state.completionActive;
return hints;
@@ -363,26 +363,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
* Processes and display appropriately the server hints.
* TODO: sort hints so static and popup hints come first, and a (single) drop-down hint last
*
- * @param {ServerHint[]} serverHints an array of hints from the server
+ * @param {ServerHint[]} hints an array of hints from the server
*/
- 'handle': function (serverHints) {
- var n = serverHints.length,
- finalizers = [],
- i, serverHint, hintId, hintDef, hintContent, hintType, t, fn, ret;
+ 'handle': function (hints) {
+ var finalizers = [],
+ i, hint, hintDef, hintContent, hintType, t, fn, ret;
clearHints();
- mainLoop:
- for (i = 0; i < n; i++) {
- serverHint = serverHints[i];
- hintId = serverHint.id;
- hintDef = hintProblemDefs[hintId] || hintCommonDefs[hintId];
+ for (i = 0; i < hints.length; i++) {
+ hint = hints[i];
+ hintDef = hintProblemDefs[hint.id] || hintCommonDefs[hint.id];
if (!hintDef) {
- codeq.log.error('Undefined hint: ' + hintId);
+ codeq.log.error('Undefined hint: ' + hint.id);
continue;
}
- hintContent = hintProblemTr[hintId] || hintCommonTr[hintId];
+ hintContent = hintProblemTr[hint.id] || hintCommonTr[hint.id];
if (!hintContent) {
- codeq.log.error('Hint without content: ' + hintId);
+ codeq.log.error('Hint without content: ' + hint.id);
continue;
}
@@ -390,14 +387,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
if (t === 'string') hintType = hintDef; // currently a hint type is a string
else if ((t === 'object') && (hintDef !== null)) hintType = hintDef.type; // but in future we may use an object, if a definition becomes more complex
else {
- codeq.log.error('Cannot determine the type of hint ' + hintId + ' from: ' + hintDef);
+ codeq.log.error('Cannot determine the type of hint ' + hint.id + ' from: ' + hintDef);
continue;
}
fn = typeHandlers[hintType];
if (!fn) codeq.log.error('Unsupported hint type: ' + hintType);
else {
- ret = fn(hintContent, serverHint);
+ ret = fn(hintContent, hint);
if (typeof ret === 'function') finalizers.push(ret);
}
}