From 40237a10c783ec90590e233b733a24241dceafd2 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Tue, 23 May 2017 08:23:47 +0800 Subject: [PATCH 1/8] Fix two loop bounds. --- plugins/c9.ide.scm/log/log.js | 2 +- plugins/c9.ide.ui/docklayout.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/c9.ide.scm/log/log.js b/plugins/c9.ide.scm/log/log.js index fd864568..79df9426 100644 --- a/plugins/c9.ide.scm/log/log.js +++ b/plugins/c9.ide.scm/log/log.js @@ -115,7 +115,7 @@ function GitGraph(editor) { var p = d.parent2; var k = 0; for (var j = 0; k < p.length; j++) { - while (k <= p.length) { + while (k < p.length) { var parent = p[k]; if (parent) { if (parent.row - d.row < MAX_GAP) { diff --git a/plugins/c9.ide.ui/docklayout.js b/plugins/c9.ide.ui/docklayout.js index c2e196d1..43b0536d 100644 --- a/plugins/c9.ide.ui/docklayout.js +++ b/plugins/c9.ide.ui/docklayout.js @@ -1533,7 +1533,7 @@ define(function(require, exports, module) { function findSnapPos(pos, dir, side) { var snapPos = margin[dir === "v" ? 0 : 3]; var rows = sizes[dir]; - for (var i = 0; i <= rows.length; i++) { + for (var i = 0; i < rows.length; i++) { if (side > 0 && i > 1) snapPos += padding; if (Math.abs(pos - snapPos) < SNAP_DIST) From edfe3b0ff72f6857210ef2359c9446ecc7b1263d Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Tue, 23 May 2017 08:25:38 +0800 Subject: [PATCH 2/8] Fix four duplicate properties. --- plugins/c9.ide.ui/lib_apf.js | 3 --- plugins/c9.ide.ui/widgets.list.js | 1 - 2 files changed, 4 deletions(-) diff --git a/plugins/c9.ide.ui/lib_apf.js b/plugins/c9.ide.ui/lib_apf.js index 4b23e8aa..43df5ddd 100644 --- a/plugins/c9.ide.ui/lib_apf.js +++ b/plugins/c9.ide.ui/lib_apf.js @@ -3953,9 +3953,6 @@ apf.extend(apf.config, { debug: false, - disableSpace: true, - allowSelect: false, - allowBlur: true, // initdelay: false, diff --git a/plugins/c9.ide.ui/widgets.list.js b/plugins/c9.ide.ui/widgets.list.js index 7de39e75..a2b8b03b 100644 --- a/plugins/c9.ide.ui/widgets.list.js +++ b/plugins/c9.ide.ui/widgets.list.js @@ -82,7 +82,6 @@ define(function(require, exports, module) { scrollbarVisibilityChanged: acetree.renderer, afterRender: acetree.renderer, resize: acetree.renderer, - afterRender: acetree.renderer, expand: model, collapse: model, check: model, From f721e110febd9ef95fd1b3d713541a3601cbb8c3 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Tue, 23 May 2017 08:32:20 +0800 Subject: [PATCH 3/8] Fix two spurious self-comparisons. --- plugins/c9.ide.collab/ot/index_cache.js | 2 +- plugins/c9.ide.language.jsonalyzer/server/invoke_helper.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/c9.ide.collab/ot/index_cache.js b/plugins/c9.ide.collab/ot/index_cache.js index a13c5e8a..6187aae5 100644 --- a/plugins/c9.ide.collab/ot/index_cache.js +++ b/plugins/c9.ide.collab/ot/index_cache.js @@ -49,7 +49,7 @@ function IndexCache(doc) { if (check) { var slowPos = doc.indexToPositionSlow(index); - if (slowPos.row !== pos.row && slowPos.column !== slowPos.column) + if (slowPos.row !== pos.row && slowPos.column !== pos.column) reportError("Inconsistency in indexToPosition"); return slowPos; } diff --git a/plugins/c9.ide.language.jsonalyzer/server/invoke_helper.js b/plugins/c9.ide.language.jsonalyzer/server/invoke_helper.js index c5add499..d243cc09 100644 --- a/plugins/c9.ide.language.jsonalyzer/server/invoke_helper.js +++ b/plugins/c9.ide.language.jsonalyzer/server/invoke_helper.js @@ -30,7 +30,7 @@ handler.init = function(options, callback) { }; handler.invoke = function(path, doc, ast, options, callback) { - options.mode == options.mode || "stdin"; + options.mode = options.mode || "stdin"; if (options.overrideLine != null) { var lines = doc.toString().split(/\r\n|\n|\r/); if (lines[options.overrideLineRow] !== options.overrideLine) { From 59f506844ff655fddbb40d3d1c32165c5dbc80b0 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Tue, 23 May 2017 08:46:54 +0800 Subject: [PATCH 4/8] Fix a few superfluous (and hence ignored) arguments. --- plugins/c9.core/settings.js | 2 +- plugins/c9.ide.collab/chat/chat.js | 6 ++--- plugins/c9.ide.language.core/worker.js | 6 ++--- .../ast_updater.js | 24 +++++++++---------- .../scrape/nodemanual.js | 4 ++-- .../c9.ide.language.jsonalyzer/jsonalyzer.js | 2 +- plugins/c9.ide.terminal/link_handler.js | 2 +- plugins/c9.ide.terminal/predict_echo.js | 6 ++--- plugins/c9.preview/static/livecss.js | 4 ++-- 9 files changed, 27 insertions(+), 29 deletions(-) diff --git a/plugins/c9.core/settings.js b/plugins/c9.core/settings.js index 44affaff..c3d84efd 100644 --- a/plugins/c9.core/settings.js +++ b/plugins/c9.core/settings.js @@ -451,7 +451,7 @@ define(function(require, exports, module) { function getNumber(query) { var double = get(query); - return parseFloat(double, 10); + return parseFloat(double); } function getNode(query) { diff --git a/plugins/c9.ide.collab/chat/chat.js b/plugins/c9.ide.collab/chat/chat.js index 61ceb6ee..5089e8ce 100644 --- a/plugins/c9.ide.collab/chat/chat.js +++ b/plugins/c9.ide.collab/chat/chat.js @@ -98,9 +98,7 @@ define(function(require, exports, module) { if (accessInfo.private && (!accessInfo.member || accessInfo.pending)) return console.warn("Don't have read access - You can't use chat"); var chatHistory = workspace.chatHistory || []; - chatHistory.forEach(function(msg) { - addMessage(msg, msg.increment); - }); + chatHistory.forEach(addMessage); scrollDown(); chatCounter.innerHTML = chatHistory.length; } @@ -402,4 +400,4 @@ define(function(require, exports, module) { }); } -}); \ No newline at end of file +}); diff --git a/plugins/c9.ide.language.core/worker.js b/plugins/c9.ide.language.core/worker.js index 1be8bd31..fc0d44f4 100644 --- a/plugins/c9.ide.language.core/worker.js +++ b/plugins/c9.ide.language.core/worker.js @@ -826,9 +826,9 @@ function endTime(t, message, indent) { var posInPart = syntaxDetector.posToRegion(part.region, pos); this.parse(part, function(ast) { if (!ast) - return callHandlers(ast, null, posInPart); + return callHandlers(ast, null); _self.findNode(ast, pos, function(currentNode) { - callHandlers(ast, currentNode, posInPart); + callHandlers(ast, currentNode); }); }, true, true); @@ -1932,4 +1932,4 @@ function endTime(t, message, indent) { }).call(LanguageWorker.prototype); -}); \ No newline at end of file +}); diff --git a/plugins/c9.ide.language.javascript.infer/ast_updater.js b/plugins/c9.ide.language.javascript.infer/ast_updater.js index b570e48e..b9686b80 100644 --- a/plugins/c9.ide.language.javascript.infer/ast_updater.js +++ b/plugins/c9.ide.language.javascript.infer/ast_updater.js @@ -89,7 +89,7 @@ define(function(require, exports, module) { if (newAST[j].cons !== "Var") return false; // Var(x) was just inserted - copyAnnos(findScopeNode(oldAST), newAST[j], dryRun); + copyAnnos(findScopeNode(oldAST), newAST[j]); if (!newAST[j].annos) return false; continue; @@ -97,17 +97,17 @@ define(function(require, exports, module) { if (oldAST[i].cons !== newAST[j].cons) { // Var(x) became PropAccess(Var(x), y) if (oldAST[i].cons === "Var" && newAST[j].isMatch("PropAccess(Var(_),_)")) { - copyAnnos(oldAST[i], newAST[j][0], dryRun); + copyAnnos(oldAST[i], newAST[j][0]); continue; } // PropAccess(Var(x), y) became Var(x) if (newAST[j].cons === "Var" && oldAST[i].isMatch("PropAccess(Var(_),_)")) { - copyAnnos(oldAST[i][0], newAST[j], dryRun); + copyAnnos(oldAST[i][0], newAST[j]); continue; } // PropAccess became Call(PropAccess, _) if (oldAST[i].isMatch("PropAccess(Var(_),_)") && newAST[j].isMatch("Call(PropAccess(Var(_),_),_)")) { - copyAnnos(oldAST[i][0], newAST[j][0][0], dryRun); + copyAnnos(oldAST[i][0], newAST[j][0][0]); var oldTemplate = new tree.ListNode([oldAST[i][0]]); oldTemplate.parent = oldAST; copyAnnosTop(oldTemplate, newAST[j][1], dryRun); @@ -115,12 +115,12 @@ define(function(require, exports, module) { } // Call(PropAccess, _) became PropAccess if (newAST[j].isMatch("PropAccess(Var(_),_)") && oldAST[i].isMatch("Call(PropAccess(Var(_),_),_)")) { - copyAnnos(oldAST[i][0][0], newAST[j][0], dryRun); + copyAnnos(oldAST[i][0][0], newAST[j][0]); continue; } // Var(x) was (possibly) inserted if (newAST[j].cons === "Var" && newAST[j + 1] && newAST[j + 1].cons === oldAST[i].cons) { - copyAnnos(findScopeNode(oldAST), newAST[j], dryRun); + copyAnnos(findScopeNode(oldAST), newAST[j]); if (!newAST[j].annos) return false; i--; @@ -128,7 +128,7 @@ define(function(require, exports, module) { } // Var(x) was (possibly) added if (oldAST[i].cons === "None" && newAST[j].cons === "Var") { - copyAnnos(findScopeNode(oldAST), newAST[j], dryRun); + copyAnnos(findScopeNode(oldAST), newAST[j]); if (!newAST[j].annos) return false; i--; @@ -143,7 +143,7 @@ define(function(require, exports, module) { if (["If", "Return", "Throw"].indexOf(newAST[j].cons) > -1 && (!newAST[j][1] || newAST[j][1].isMatch("Block([])"))) { var cond = newAST[j][0].toString(); if (cond === oldAST[i].toString()) { - copyAnnos(oldAST[i], newAST[j][0], dryRun); + copyAnnos(oldAST[i], newAST[j][0]); continue; } else if (!oldAST[i + 1]) { @@ -151,7 +151,7 @@ define(function(require, exports, module) { } else if (cond === oldAST[i + 1].toString()) { i++; - copyAnnos(oldAST[i], newAST[j][0], dryRun); + copyAnnos(oldAST[i], newAST[j][0]); continue; } } @@ -161,10 +161,10 @@ define(function(require, exports, module) { var newCond = newAST[0]; var newBody = newAST[1]; if (oldCond.toString() === newBody.toString()) { - copyAnnos(findScopeNode(oldAST), newCond, dryRun); + copyAnnos(findScopeNode(oldAST), newCond); if (!newCond.annos) return false; - copyAnnos(oldCond, newBody, dryRun); + copyAnnos(oldCond, newBody); continue; } } @@ -234,4 +234,4 @@ define(function(require, exports, module) { } -}); \ No newline at end of file +}); diff --git a/plugins/c9.ide.language.javascript.infer/scrape/nodemanual.js b/plugins/c9.ide.language.javascript.infer/scrape/nodemanual.js index 655fe815..721420cc 100644 --- a/plugins/c9.ide.language.javascript.infer/scrape/nodemanual.js +++ b/plugins/c9.ide.language.javascript.infer/scrape/nodemanual.js @@ -164,7 +164,7 @@ function extractProperty(item, results, isConstructor) { } function extractSignature(item, signature, result) { - var returns = extractType(signature.returns ? signature.returns[0].type : null, true); + var returns = extractType(signature.returns ? signature.returns[0].type : null); if (item.type === "class property") { result.properties.___proto__ = returns; @@ -191,7 +191,7 @@ function extractSignatureArgs(signature, results) { var argFargs = arg.args && extractSignatureArgs(arg, []); results.push({ id: arg.name, - type: extractType(arg.type, true), + type: extractType(arg.type), doc: arg.description, opt: arg.optional, fargs: argFargs diff --git a/plugins/c9.ide.language.jsonalyzer/jsonalyzer.js b/plugins/c9.ide.language.jsonalyzer/jsonalyzer.js index 8187b8bd..b181c424 100644 --- a/plugins/c9.ide.language.jsonalyzer/jsonalyzer.js +++ b/plugins/c9.ide.language.jsonalyzer/jsonalyzer.js @@ -392,7 +392,7 @@ define(function(require, exports, module) { tries.push(Date.now()); var trySeriesStart = tries[tries.length - 1 - maxTrySeriesLength]; if (!trySeriesStart || trySeriesStart < Date.now() - maxTrySeriesTime) - return setupCall(value); + return setupCall(); var err = new Error("Too many disconnects. Server crashing?"); err.code = "EFATAL"; diff --git a/plugins/c9.ide.terminal/link_handler.js b/plugins/c9.ide.terminal/link_handler.js index be95f5d0..49d2e033 100644 --- a/plugins/c9.ide.terminal/link_handler.js +++ b/plugins/c9.ide.terminal/link_handler.js @@ -94,7 +94,7 @@ define(function(require, exports, module) { menuPath = new Menu({ items: menuItems, onitemclick: function(e) { - var info = buildPath(lastLink, true); + var info = buildPath(lastLink); if (e.value == "open") open(lastLink); diff --git a/plugins/c9.ide.terminal/predict_echo.js b/plugins/c9.ide.terminal/predict_echo.js index 44e40ecf..be9de8b8 100644 --- a/plugins/c9.ide.terminal/predict_echo.js +++ b/plugins/c9.ide.terminal/predict_echo.js @@ -638,7 +638,7 @@ define(function(require, exports, module) { */ CursorLeftCommand.tryCreate = function(inputText) { if (inputText === INPUT_LEFT) - return new CursorLeftCommand(inputText); + return new CursorLeftCommand(); }; function CursorLeftCommand() { var noChange = false; @@ -680,7 +680,7 @@ define(function(require, exports, module) { if (INPUTS_HOME.indexOf(inputText) > -1 // Only attempt home if we'd jump to the start of a prompt && (peek(-predictIndex - 1) === "$" || peek(-predictIndex - 2) === "$")) - return new HomeCommand(inputText); + return new HomeCommand(); }; function HomeCommand() { var oldIndex; @@ -762,4 +762,4 @@ define(function(require, exports, module) { register(null, { "terminal.predict_echo": plugin }); } -}); \ No newline at end of file +}); diff --git a/plugins/c9.preview/static/livecss.js b/plugins/c9.preview/static/livecss.js index 4156d54b..826acd07 100644 --- a/plugins/c9.preview/static/livecss.js +++ b/plugins/c9.preview/static/livecss.js @@ -988,7 +988,7 @@ function findCssRule(name, stylesheet) { * @param {Object} [win] A reference to a window */ function setStyleRule(name, type, value, stylesheet, win) { - var rule = findCssRule(name, stylesheet, win); + var rule = findCssRule(name, stylesheet); if (rule) { if (value.indexOf("!important") > -1) { rule.style.cssText = type + ":" + value; @@ -1027,4 +1027,4 @@ window.addEventListener("message", function(e) { if (parent != window) init(id); -})(); \ No newline at end of file +})(); From acc27242a132b318e639f714a1db6a31ac2e605f Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Tue, 23 May 2017 08:49:44 +0800 Subject: [PATCH 5/8] Fix NaN test. --- plugins/c9.ide.ui/lib_apf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/c9.ide.ui/lib_apf.js b/plugins/c9.ide.ui/lib_apf.js index 43df5ddd..f5ece5db 100644 --- a/plugins/c9.ide.ui/lib_apf.js +++ b/plugins/c9.ide.ui/lib_apf.js @@ -3726,7 +3726,7 @@ apf.setNodeValue = function(xmlNode, nodeValue) { else { var oldValue = xmlNode.nodeValue; xmlNode.nodeValue = nodeValue === undefined || nodeValue === null || - nodeValue == NaN ? "" : String(nodeValue); + isNaN(nodeValue) ? "" : String(nodeValue); //AML support - getters/setters would be awesome if (xmlNode.$triggerUpdate) From 57fcce4ca19691bb0c79ab47483b85d8cb3f9dc6 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Tue, 23 May 2017 08:51:48 +0800 Subject: [PATCH 6/8] Fix three overwritten properties. --- plugins/c9.ide.language.generic/mode_completer.js | 2 -- plugins/c9.ide.ui/lib_apf.js | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/c9.ide.language.generic/mode_completer.js b/plugins/c9.ide.language.generic/mode_completer.js index cd94b7e2..5a367a4a 100644 --- a/plugins/c9.ide.language.generic/mode_completer.js +++ b/plugins/c9.ide.language.generic/mode_completer.js @@ -51,8 +51,6 @@ completer.complete = function(doc, fullAst, pos, options, callback) { return null; var iconMap = { "variable": "property", - "constant": "property", - "function": "method", "type": "property2", "constant": "method2", "color": "method2", diff --git a/plugins/c9.ide.ui/lib_apf.js b/plugins/c9.ide.ui/lib_apf.js index f5ece5db..d9c8a41a 100644 --- a/plugins/c9.ide.ui/lib_apf.js +++ b/plugins/c9.ide.ui/lib_apf.js @@ -20833,7 +20833,7 @@ apf.textbox.masking = function(){ "107": "+", "109": "-", "110": ".", - "110": "/" + "111": "/" }; this.addEventListener("keydown", function(e) { From cbb63a37b1d9081400896586e339db2de3aa2496 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Tue, 23 May 2017 08:52:49 +0800 Subject: [PATCH 7/8] Fix `isArray` check. --- plugins/c9.ide.ui/lib_apf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/c9.ide.ui/lib_apf.js b/plugins/c9.ide.ui/lib_apf.js index d9c8a41a..ca9733d3 100644 --- a/plugins/c9.ide.ui/lib_apf.js +++ b/plugins/c9.ide.ui/lib_apf.js @@ -1819,7 +1819,7 @@ defineProp(Array.prototype, "pushUnique", function(){ */ defineProp(Array.prototype, "search", function(){ for (var i = 0, length = arguments.length; i < length; i++) { - if (typeof this[i] != "array") + if (!Array.isArray(this[i])) continue; for (var j = 0; j < length; j++) { if (this[i][j] != arguments[j]) From a8ee6231f682d1121d82221a9c74f820006ccd4c Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 23 May 2017 22:24:02 +0400 Subject: [PATCH 8/8] revert isNaN check, remove unused function --- plugins/c9.ide.ui/lib_apf.js | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/plugins/c9.ide.ui/lib_apf.js b/plugins/c9.ide.ui/lib_apf.js index ca9733d3..bb95ee75 100644 --- a/plugins/c9.ide.ui/lib_apf.js +++ b/plugins/c9.ide.ui/lib_apf.js @@ -1811,25 +1811,6 @@ defineProp(Array.prototype, "pushUnique", function(){ return this; }); -/* - * @todo: Ruben: could you please comment on this function? Seems to serve a very - * specific purpose... - * - * I also could not find an occurrence in our codebase. - */ -defineProp(Array.prototype, "search", function(){ - for (var i = 0, length = arguments.length; i < length; i++) { - if (!Array.isArray(this[i])) - continue; - for (var j = 0; j < length; j++) { - if (this[i][j] != arguments[j]) - break; - else if (j == (length - 1)) - return this[i]; - } - } -}); - /* * Iterate through each value of an array instance from left to right (front to * back) and execute a callback Function for each value. @@ -3725,8 +3706,7 @@ apf.setNodeValue = function(xmlNode, nodeValue) { } else { var oldValue = xmlNode.nodeValue; - xmlNode.nodeValue = nodeValue === undefined || nodeValue === null || - isNaN(nodeValue) ? "" : String(nodeValue); + xmlNode.nodeValue = nodeValue == null ? "" : String(nodeValue); //AML support - getters/setters would be awesome if (xmlNode.$triggerUpdate)