Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'fix/another-ceeditor-regression' into HEAD

  • Loading branch information...
commit 3dda0c69459a5f90ae842ebdb22d205595001a5d 2 parents 5c958b1 + 59999c0
@lennartcl lennartcl authored
View
1  .gitignore
@@ -36,6 +36,7 @@ plugins-client/lib.packed/www/
plugins-client/lib.ace/www/worker/
plugins-client/cloud9.core/www/js/
plugins-client/ext.jsinfer
+plugins-client/ext.jsonalyzer
node_modules/
deps/ace/
plugins-server/fixtures/
View
19 plugins-client/ext.code/code.js
@@ -765,25 +765,6 @@ module.exports = ext.register("ext/code/code", {
init: function(amlPage) {
var _self = this;
- if (window.__defineGetter__ && !window.cloud9config.packed) {
- function getCeEditor() {
- var d = document.createElement("div");
- d.style.position = "absolute";
- d.style.zIndex = 100001;
- d.style.left = ((apf.getWindowWidth() / 2) - 200) + "px";
- d.style.top = ((apf.getWindowHeight() / 2) - 200) + "px";
- d.addEventListener("click", function () {
- document.body.removeChild(d);
- });
- var i = document.createElement("img");
- i.src = "http://100procentjan.nl/c9/3rlzgl.jpeg";
- d.appendChild(i);
- document.body.appendChild(d);
- }
- window.__defineGetter__("ceEditor", getCeEditor);
- this.__defineGetter__("ceEditor", getCeEditor);
- }
-
_self.amlEditor = codeEditor_dontEverUseThisVariable;
_self.amlEditor.show();
View
16 plugins-client/ext.codecomplete/mode_completer.js
@@ -70,13 +70,13 @@ completer.complete = function(doc, fullAst, pos, currentNode, callback) {
var compls = completeUtil.findCompletions(identifier, mode[type]);
matches.push.apply(matches, compls.map(function(m) {
return {
- name : m + nameAppend,
- replaceText : m + replaceAppend,
- doc : deprecated ? ("Deprecated: <del>" + m + nameAppend + "</del>") : null,
- icon : icon,
- meta : type,
- idRegex : idRegex,
- priority : 2 - deprecated
+ name : m + nameAppend,
+ replaceText : m + replaceAppend,
+ doc : deprecated ? ("Deprecated: <del>" + m + nameAppend + "</del>") : null,
+ icon : icon,
+ meta : type,
+ identifierRegex : idRegex,
+ priority : 2 - deprecated
};
}));
});
@@ -85,4 +85,4 @@ completer.complete = function(doc, fullAst, pos, currentNode, callback) {
};
-});
+});
View
2  plugins-client/ext.csslanguage/csslint_test.js
@@ -23,7 +23,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/csslanguage/css_handler");
assert.equal(worker.handlers.length, 1);
- worker.switchFile("test.css", "css", "#hello { color: 1px; } #nonused{}");
+ worker.switchFile("test.css", "css", "#hello { color: 1px; } #nonused{}", null, "");
}
};
View
4 plugins-client/ext.githistory/githistory.js
@@ -2,7 +2,9 @@
* File history browser & comparison tool for Cloud9 IDE
*
* TODO:
- *
+ *
+ * Remove ceEditor (see http://100procentjan.nl/c9/3rlzgl.jpeg)
+ *
* Implement "Restore" functionality
* - Popup about what just happened ("Changes have not been committed")
* - Set ceEditor's content
View
16 plugins-client/ext.htmllanguage/html_completer.js
@@ -36,13 +36,13 @@ completer.complete = function(doc, fullAst, pos, currentNode, callback) {
"\">^^", "</", match[1] || "div", ">"].join("");
}
callback([{
- name : match[1]+match[2]+match[3],
- replaceText : replaceText,
- doc : "<pre>" + replaceText.replace("\^\^", "&#9251;") + "</pre>",
- icon : null,
- meta : "Jade-Haml",
- idRegex : JADE_ID_REGEX,
- priority : 100
+ name : match[1]+match[2]+match[3],
+ replaceText : replaceText,
+ doc : "<pre>" + replaceText.replace("\^\^", "&#9251;") + "</pre>",
+ icon : null,
+ meta : "Jade-Haml",
+ identifierRegex : JADE_ID_REGEX,
+ priority : 100
}]);
}
else {
@@ -63,4 +63,4 @@ completer.complete = function(doc, fullAst, pos, currentNode, callback) {
};
-});
+});
View
10 plugins-client/ext.jslanguage/jshint_test.js
@@ -22,7 +22,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/jshint");
assert.equal(worker.handlers.length, 1);
- worker.switchFile("test.js", "javascript", "hello();");
+ worker.switchFile("test.js", "javascript", "hello();", null, "");
},
"test integration JSHint" : function(next) {
@@ -36,7 +36,7 @@ module.exports = {
});
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/jshint");
- worker.switchFile("test.js", "javascript", "console.log(1);\nhello()");
+ worker.switchFile("test.js", "javascript", "console.log(1);\nhello()", null, "");
},
"test JSHint output filtering" : function(next) {
@@ -49,7 +49,7 @@ module.exports = {
});
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/jshint");
- worker.switchFile("no-errors.js", "javascript", "var foo = function() {};\nfoo && foo();");
+ worker.switchFile("no-errors.js", "javascript", "var foo = function() {};\nfoo && foo();", null, "");
},
"test JSHint const support" : function(next) {
@@ -62,7 +62,7 @@ module.exports = {
});
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/jshint");
- worker.switchFile("no-errors.js", "javascript", "const foo = 1;");
+ worker.switchFile("no-errors.js", "javascript", "const foo = 1;", null, "");
},
"test JSHint globals" : function(next) {
@@ -75,7 +75,7 @@ module.exports = {
});
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/jshint");
- worker.switchFile("no-errors.js", "javascript", "/*global foo:true*/ foo;");
+ worker.switchFile("no-errors.js", "javascript", "/*global foo:true*/ foo;", null, "");
}
};
View
6 plugins-client/ext.jslanguage/parse_test.js
@@ -18,7 +18,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/parse");
assert.equal(worker.handlers.length, 1);
- worker.switchFile("test.js", "javascript", "hello();");
+ worker.switchFile("test.js", "javascript", "hello();", null, "");
worker.parse(function(ast) {
assert.equal(ast, '[Call(Var("hello"),[])]');
});
@@ -29,7 +29,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/parse");
assert.equal(worker.handlers.length, 1);
- worker.switchFile("test.js", "javascript", "hello(");
+ worker.switchFile("test.js", "javascript", "hello(", null, "");
worker.parse(function(ast) {
assert.equal(ast, '[Call(Var("hello"),[])]');
});
@@ -40,7 +40,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/parse");
assert.equal(worker.handlers.length, 1);
- worker.switchFile("test.js", "javascript", "console.log\n\n\n\n");
+ worker.switchFile("test.js", "javascript", "console.log\n\n\n\n", null, "");
worker.parse(function(ast) {
assert.equal(ast, '[PropAccess(Var("console"),"log")]');
});
View
42 plugins-client/ext.jslanguage/scope_analyzer_test.js
@@ -27,7 +27,7 @@ module.exports = {
worker.$analyzeInterval = {};
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "/*global foo:true*/ foo;");
+ worker.switchFile("test.js", "javascript", "/*global foo:true*/ foo;", null, "");
},
"test unused variable" : function(next) {
disabledFeatures = { jshint: true };
@@ -46,7 +46,7 @@ module.exports = {
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
assert.equal(worker.handlers.length, 2);
- worker.switchFile("test.js", "javascript", "var hello = false;");
+ worker.switchFile("test.js", "javascript", "var hello = false;", null, "");
},
"test unused const" : function(next) {
disabledFeatures = { jshint: true };
@@ -60,7 +60,7 @@ module.exports = {
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
assert.equal(worker.handlers.length, 2);
- worker.switchFile("test.js", "javascript", "const hello = false;");
+ worker.switchFile("test.js", "javascript", "const hello = false;", null, "");
},
"test unused variable scoped" : function(next) {
disabledFeatures = { jshint: true };
@@ -75,7 +75,7 @@ module.exports = {
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
assert.equal(worker.handlers.length, 2);
- worker.switchFile("test.js", "javascript", "var hello = false; function noName() { var hello = true; hello = false; }");
+ worker.switchFile("test.js", "javascript", "var hello = false; function noName() { var hello = true; hello = false; }", null, "");
},
"test unused variable scoped without var decl" : function(next) {
disabledFeatures = { jshint: true };
@@ -89,7 +89,7 @@ module.exports = {
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
assert.equal(worker.handlers.length, 2);
- worker.switchFile("test.js", "javascript", "var hello = false; function noName() { hello = false; }");
+ worker.switchFile("test.js", "javascript", "var hello = false; function noName() { hello = false; }", null, "");
},
"test undeclared variable" : function(next) {
disabledFeatures = { jshint: true };
@@ -104,7 +104,7 @@ module.exports = {
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
assert.equal(worker.handlers.length, 2);
- worker.switchFile("test.js", "javascript", "hello = false;");
+ worker.switchFile("test.js", "javascript", "hello = false;", null, "");
},
"test undeclared iteration variable" : function(next) {
disabledFeatures = { jshint: true };
@@ -118,7 +118,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "for(p in {}) { }");
+ worker.switchFile("test.js", "javascript", "for(p in {}) { }", null, "");
},
"test bad this call" : function(next) {
disabledFeatures = { jshint: true };
@@ -131,7 +131,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "var accept = function(){}; accept('evt', function(){this});");
+ worker.switchFile("test.js", "javascript", "var accept = function(){}; accept('evt', function(){this});", null, "");
},
"test bad this call (2)" : function(next) {
disabledFeatures = { jshint: true };
@@ -144,7 +144,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "var accept = function(){}; accept(function(err){this});");
+ worker.switchFile("test.js", "javascript", "var accept = function(){}; accept(function(err){this});", null, "");
},
"test bad this call (3)" : function(next) {
disabledFeatures = { jshint: true };
@@ -157,7 +157,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "function g(err){this};");
+ worker.switchFile("test.js", "javascript", "function g(err){this};", null, "");
},
"test jump to definition should point to variable declaration" : function(next) {
disabledFeatures = { jshint: true };
@@ -180,7 +180,7 @@ module.exports = {
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/jumptodef");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "var ab = 4; console.log(ab);");
+ worker.switchFile("test.js", "javascript", "var ab = 4; console.log(ab);", null, "");
},
"test jump to definition on a position without code should not throw" : function(next) {
disabledFeatures = { jshint: true };
@@ -200,7 +200,7 @@ module.exports = {
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/jumptodef");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "var ab = 4; console.log(ab); ");
+ worker.switchFile("test.js", "javascript", "var ab = 4; console.log(ab); ", null, "");
// definition listener should not be called
setTimeout(function () {
@@ -228,7 +228,7 @@ module.exports = {
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/jumptodef");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "var ab = 4; console.log(ab);");
+ worker.switchFile("test.js", "javascript", "var ab = 4; console.log(ab);", null, "");
},
"test isJumpToDefinitionAvailable should return false when not available" : function(next) {
disabledFeatures = { jshint: true };
@@ -250,7 +250,7 @@ module.exports = {
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/jumptodef");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "var ab = 4; console.log(ab);");
+ worker.switchFile("test.js", "javascript", "var ab = 4; console.log(ab);", null, "");
},
"test missing return in err handler" : function(next) {
@@ -264,7 +264,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "function doSomethingElse() { } function helloAsync(callback) { doSomethingElse(function(err) { if(err) callback(err); }); }");
+ worker.switchFile("test.js", "javascript", "function doSomethingElse() { } function helloAsync(callback) { doSomethingElse(function(err) { if(err) callback(err); }); }", null, "");
},
"test missing return in err handler without using err in call" : function(next) {
disabledFeatures = { jshint: true };
@@ -277,7 +277,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "function doSomethingElse() { } doSomethingElse(function(err) { if(err) console.log('sup'); });");
+ worker.switchFile("test.js", "javascript", "function doSomethingElse() { } doSomethingElse(function(err) { if(err) console.log('sup'); });", null, "");
},
"test not reporting error when there is a return in err handler" : function(next) {
disabledFeatures = { jshint: true };
@@ -290,7 +290,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "function doSomethingElse() { } function helloAsync(callback) { doSomethingElse(function(err) { if(err) return callback(err); }); }");
+ worker.switchFile("test.js", "javascript", "function doSomethingElse() { } function helloAsync(callback) { doSomethingElse(function(err) { if(err) return callback(err); }); }", null, "");
},
"test be less complainy" : function(next) {
disabledFeatures = { jshint: true };
@@ -303,7 +303,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "var foo = true ? false\n: { a : 1\n b : 2}");
+ worker.switchFile("test.js", "javascript", "var foo = true ? false\n: { a : 1\n b : 2}", null, "");
},
"test be less complainy 2" : function(next) {
disabledFeatures = { jshint: true };
@@ -316,7 +316,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "for(;;) { [].forEach(function() {}) }");
+ worker.switchFile("test.js", "javascript", "for(;;) { [].forEach(function() {}) }", null, "");
},
"test be selectively complainy about functions in loops" : function(next) {
disabledFeatures = { jshint: true };
@@ -329,7 +329,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "for(;;) { [].bar(function() {}) }");
+ worker.switchFile("test.js", "javascript", "for(;;) { [].bar(function() {}) }", null, "");
},
"test complain about functions in 'for in'" : function(next) {
disabledFeatures = { jshint: true };
@@ -342,7 +342,7 @@ module.exports = {
var worker = new LanguageWorker(emitter);
worker.register("ext/jslanguage/scope_analyzer");
worker.register("ext/jslanguage/parse");
- worker.switchFile("test.js", "javascript", "for(var x in []) { x.bar(function() {}) }");
+ worker.switchFile("test.js", "javascript", "for(var x in []) { x.bar(function() {}) }", null, "");
}
};
View
39 plugins-client/ext.language/complete.js
@@ -22,7 +22,7 @@ var complete;
var oldCommandKey, oldOnTextInput;
var isDocShown;
-var ID_REGEX = /[a-zA-Z_0-9\$]/;
+var ID_REGEX = /[a-zA-Z_0-9\$\/]/;
var CLASS_SELECTED = "cc_complete_option selected";
var CLASS_UNSELECTED = "cc_complete_option";
@@ -43,7 +43,7 @@ var deferredInvoke = lang.deferredCall(function() {
var line = editor.getSession().getDocument().getLine(pos.row);
if (keyhandler.preceededByIdentifier(line, pos.column) ||
(line[pos.column - 1] === '.' && (!line[pos.column] || !line[pos.column].match(ID_REGEX))) ||
- (completer.idRegex && line[pos.column-1].match(completer.idRegex)) ||
+ (lastIdentifierRegex && line[pos.column-1].match(lastIdentifierRegex)) ||
keyhandler.isRequireJSCall(line, pos.column)) {
completer.invoke(true);
}
@@ -54,6 +54,7 @@ var deferredInvoke = lang.deferredCall(function() {
});
var isInvokeScheduled = false;
var ignoreMouseOnce = false;
+var lastIdentifierRegex;
var drawDocInvoke = lang.deferredCall(function() {
if (isPopupVisible() && complete.matches[complete.selectedIdx].doc) {
@@ -106,7 +107,7 @@ function asyncReplaceText(editor, match) {
var session = editor.getSession();
var line = session.getLine(pos.row);
var doc = session.getDocument();
- var prefix = completeUtil.retrievePreceedingIdentifier(line, pos.column, match.idRegex);
+ var prefix = completeUtil.retrievePreceedingIdentifier(line, pos.column, match.identifierRegex);
if (match.replaceText === "require(^^)" && isJavaScript()) {
newText = "require(\"^^\")";
@@ -128,11 +129,11 @@ function asyncReplaceText(editor, match) {
var prefixWhitespace = line.substring(0, i);
// Remove HTML duplicate '<' completions
- var preId = completeUtil.retrievePreceedingIdentifier(line, pos.column, match.idRegex);
+ var preId = completeUtil.retrievePreceedingIdentifier(line, pos.column, match.identifierRegex);
if (isHtml() && line[pos.column-preId.length-1] === '<' && newText[0] === '<')
newText = newText.substring(1);
- var postfix = completeUtil.retrieveFollowingIdentifier(line, pos.column, match.idRegex) || "";
+ var postfix = completeUtil.retrieveFollowingIdentifier(line, pos.column, match.identifierRegex) || "";
// Pad the text to be inserted
var paddedLines = newText.split("\n").join("\n" + prefixWhitespace);
@@ -196,7 +197,7 @@ module.exports = {
this.ext = ext;
},
- showCompletionBox: function(matches, prefix) {
+ showCompletionBox: function(matches, prefix, line, column) {
var _self = this;
this.editor = editors.currentEditor;
var ace = this.editor.amlEditor.$editor;
@@ -272,7 +273,7 @@ module.exports = {
undrawDocInvoke.schedule(HIDE_DOC_DELAY);
},
- populateCompletionBox: function (matches) {
+ populateCompletionBox: function(matches) {
var _self = this;
_self.completionElement.innerHTML = "";
var cursorConfig = code.amlEditor.$editor.renderer.$cursorLayer.config;
@@ -301,7 +302,7 @@ module.exports = {
docHead = match.name + " : " + _self.$guidToLongString(match.type) + "</div>";
}
}
- var prefix = completeUtil.retrievePreceedingIdentifier(line, pos.column, match.idRegex);
+ var prefix = completeUtil.retrievePreceedingIdentifier(line, pos.column, match.identifierRegex);
var trim = match.meta ? " maintrim" : "";
if (!isInferAvailable || match.icon) {
html += '<span class="main' + trim + '"><u>' + prefix + "</u>" + match.name.substring(prefix.length) + '</span>';
@@ -320,7 +321,7 @@ module.exports = {
match.doc = '<p>' + match.doc + '</p>';
if (match.icon || match.type)
- match.doc = '<div class="code_complete_doc_head">' + (docHead || match.name) + '</div>' + (match.doc || "")
+ match.doc = '<div class="code_complete_doc_head">' + (docHead || match.name) + '</div>' + (match.doc || "");
matchEl.innerHTML = html;
matchEl.addEventListener("mouseover", function() {
@@ -395,7 +396,7 @@ module.exports = {
var matched = false;
var matches = this.matches;
for (var i = 0; i < matches.length && !matched; i++)
- matched = (matches[i].idRegex || ID_REGEX).test(text);
+ matched = (matches[i].identifierRegex || ID_REGEX).test(text);
if (matched)
this.deferredInvoke();
else
@@ -516,33 +517,27 @@ module.exports = {
var pos = editor.getCursorPosition();
var eventPos = event.data.pos;
var line = editor.getSession().getLine(pos.row);
- var idRegex;
editor.removeEventListener("change", this.$onChange);
killCrashedCompletionInvoke.cancel();
- if (pos.column !== eventPos.column || pos.row !== eventPos.row)
+ if (pos.column !== eventPos.column || pos.row !== eventPos.row || event.data.line != line)
+ return;
+ if (event.data.isUpdate && !isPopupVisible())
return;
var matches = event.data.matches;
- var identifier;
- // Remove out-of-date matches
+ lastIdentifierRegex = null;
for (var i = 0; i < matches.length; i++) {
- idRegex = idRegex || matches[i].idRegex;
- identifier = completeUtil.retrievePreceedingIdentifier(line, pos.column, matches[i].idRegex);
- if(matches[i].name.indexOf(identifier) !== 0) {
- matches.splice(i, 1);
- i--;
- }
+ lastIdentifierRegex = lastIdentifierRegex || matches[i].identifierRegex;
}
- this.idRegex = idRegex;
if (matches.length === 1 && !this.forceBox) {
replaceText(editor, matches[0]);
}
else if (matches.length > 0) {
- identifier = completeUtil.retrievePreceedingIdentifier(line, pos.column, idRegex);
+ var identifier = completeUtil.retrievePreceedingIdentifier(line, pos.column, matches[0].identifierRegex);
this.showCompletionBox(matches, identifier);
}
else {
View
20 plugins-client/ext.language/keyhandler.js
@@ -9,6 +9,9 @@ define(function(require, exports, module) {
var editors = require("ext/editors/editors");
var completionUtil = require("ext/codecomplete/complete_util");
var editors = require("ext/editors/editors");
+
+var REQUIRE_ID_REGEX = /(?!["'])./;
+
var language;
function hook(ext) {
@@ -53,7 +56,7 @@ function typeAlongComplete(e) {
var editor = editors.currentEditor.amlEditor.$editor;
var pos = editor.getCursorPosition();
var line = editor.session.getDocument().getLine(pos.row);
- if(!preceededByIdentifier(line, pos.column))
+ if (!preceededByIdentifier(line, pos.column))
return false;
complete.deferredInvoke();
}
@@ -78,12 +81,12 @@ function isJavaScript() {
}
function handleChar(ch) {
- if(ch.match(/[A-Za-z0-9_\$\.]/)) {
+ if (ch.match(/[A-Za-z0-9_\$\.\"\'\/]/)) {
var ext = require("ext/language/complete");
var editor = editors.currentEditor.amlEditor.$editor;
var pos = editor.getCursorPosition();
var line = editor.session.getDocument().getLine(pos.row);
- if(!preceededByIdentifier(line, pos.column, ch))
+ if (!preceededByIdentifier(line, pos.column, ch))
return false;
ext.deferredInvoke();
}
@@ -130,16 +133,19 @@ function inCompletableCodeContext(line, column, id) {
function preceededByIdentifier(line, column, postfix) {
var id = completionUtil.retrievePreceedingIdentifier(line, column);
if(postfix) id += postfix;
- return id !== "" && !(id[0] >= '0' && id[0] <= '9') && inCompletableCodeContext(line, column, id);
+ return id !== "" && !(id[0] >= '0' && id[0] <= '9') &&
+ (inCompletableCodeContext(line, column, id) || isRequireJSCall(line, column, id));
}
-function isRequireJSCall(line, column) {
+function isRequireJSCall(line, column, identifier) {
if (editors.currentEditor.amlEditor.syntax !== "javascript" || !language.isInferAvailable())
return false;
- var id = completionUtil.retrievePreceedingIdentifier(line, column);
+ var id = identifier || completionUtil.retrievePreceedingIdentifier(line, column, REQUIRE_ID_REGEX);
var LENGTH = 'require("'.length;
var start = column - id.length - LENGTH;
- return start >= 0 && line.substr(start, LENGTH) === 'require("';
+
+ return start >= 0 && line.substr(start, LENGTH).match(/require\(["']/)
+ || line.substr(start + 1, LENGTH).match(/require\(["']/);
}
exports.hook = hook;
View
2  plugins-client/ext.language/outline.js
@@ -223,7 +223,7 @@ module.exports = {
renderOutline: function(ignoreFilter) {
var editor = editors.currentEditor;
- if (!editor || editor.path != "ext/code" || !editor.amlEditor)
+ if (!editor || editor.path != "ext/code/code" || !editor.amlEditor)
return;
ext.initExtension(gotofile);
View
133 plugins-client/ext.language/worker.js
@@ -169,32 +169,6 @@ var isWorkerEnabled = exports.isWorkerEnabled = function() {
return !window.location || !window.location.search.match(/[?&]noworker=1/);
};
-exports.createUIWorkerClient = function() {
- var emitter = Object.create(require("ace/lib/event_emitter").EventEmitter);
- var result = new LanguageWorker(emitter);
- result.on = function(name, f) {
- emitter.on.call(result, name, f);
- };
- result.call = function(cmd, args, callback) {
- if (callback) {
- var id = this.callbackId++;
- this.callbacks[id] = callback;
- args.push(id);
- }
- this.send(cmd, args);
- };
- result.send = function(cmd, args) {
- setTimeout(function() { result[cmd].apply(result, args); }, 0);
- };
- result.emit = function(event, data) {
- emitter._dispatchEvent.call(emitter, event, data);
- };
- emitter.emit = function(event, data) {
- emitter._dispatchEvent.call(result, event, { data: data });
- };
- return result;
-};
-
/**
* Ensure that an event handler is called only once if multiple
* events are received at the same time.
@@ -285,6 +259,8 @@ function asyncParForEach(array, fn, callback) {
handler.proxy = _self.serverProxy;
handler.sender = _self.sender;
_self.$initHandler(handler, null, function() {
+ // Note: may not return for a while for asynchronous workers,
+ // don't use this for queueing other tasks
_self.handlers.push(handler);
});
}
@@ -327,7 +303,7 @@ function asyncParForEach(array, fn, callback) {
this.cachedAst = null;
asyncForEach(this.handlers, function(handler, next) {
if (handler.handlesLanguage(_self.$language)) {
- handler.parse(_self.doc.getValue(), function(ast) {
+ handler.parse(_self.doc.getValue(), function onParse(ast) {
if (ast)
_self.cachedAst = ast;
next();
@@ -731,7 +707,6 @@ function asyncParForEach(array, fn, callback) {
});
};
- // TODO: BUG open an XML file and switch between, language doesn't update soon enough
this.switchFile = function(path, language, code, pos, workspaceDir) {
var _self = this;
if (!this.$analyzeInterval) {
@@ -741,9 +716,9 @@ function asyncParForEach(array, fn, callback) {
}
var oldPath = this.$path;
code = code || "";
+ linereport.workspaceDir = this.$workspaceDir = workspaceDir;
linereport.path = this.$path = path;
this.$language = language;
- linereport.workspaceDir = this.$workspaceDir = workspaceDir;
this.cachedAst = null;
this.isParserCalled = false;
this.lastCurrentNode = null;
@@ -762,10 +737,13 @@ function asyncParForEach(array, fn, callback) {
handler.workspaceDir = this.$workspaceDir;
handler.doc = this.doc;
handler.sender = this.sender;
+ handler.$completeUpdate = this.completeUpdate.bind(this);
var _self = this;
if (!handler.$isInited) {
handler.$isInited = true;
handler.init(function() {
+ // Note: may not return for a while for asynchronous workers,
+ // don't use this for queueing other tasks
handler.onDocumentOpen(_self.$path, _self.doc, oldPath, callback);
});
} else {
@@ -825,52 +803,69 @@ function asyncParForEach(array, fn, callback) {
_self.findNode(ast, currentPos, function(node) {
var currentNode = node;
var matches = [];
-
- asyncForEach(_self.handlers, function(handler, next) {
- if (handler.handlesLanguage(_self.$language)) {
- handler.staticPrefix = data.staticPrefix;
- handler.complete(_self.doc, ast, data.pos, currentNode, function(completions) {
- if (completions)
- matches = matches.concat(completions);
+
+ asyncForEach(_self.handlers, function(handler, next) {
+ if (handler.handlesLanguage(_self.$language)) {
+ handler.staticPrefix = data.staticPrefix;
+ handler.workspaceDir = _self.$workspaceDir;
+ handler.complete(_self.doc, ast, data.pos, currentNode, function(completions) {
+ if (completions)
+ matches = matches.concat(completions);
+ next();
+ });
+ }
+ else
next();
- });
- }
- else
- next();
- }, function() {
- removeDuplicateMatches(matches);
- // Sort by priority, score
- matches.sort(function(a, b) {
- if (a.priority < b.priority)
- return 1;
- else if (a.priority > b.priority)
- return -1;
- else if (a.score < b.score)
- return 1;
- else if (a.score > b.score)
- return -1;
- else if (a.id && a.id === b.id) {
- if (a.isFunction)
+ }, function() {
+ removeDuplicateMatches(matches);
+ // Sort by priority, score
+ matches.sort(function(a, b) {
+ if (a.priority < b.priority)
+ return 1;
+ else if (a.priority > b.priority)
return -1;
- else if (b.isFunction)
+ else if (a.score < b.score)
return 1;
- }
- if (a.name < b.name)
- return -1;
- else if(a.name > b.name)
- return 1;
- else
- return 0;
- });
- // Removed for the java completion result caching cases
- // matches = matches.slice(0, 50); // 50 ought to be enough for everybody
- _self.sender.emit("complete", {
- pos: pos,
- matches: matches
+ else if (a.score > b.score)
+ return -1;
+ else if (a.id && a.id === b.id) {
+ if (a.isFunction)
+ return -1;
+ else if (b.isFunction)
+ return 1;
+ }
+ if (a.name < b.name)
+ return -1;
+ else if(a.name > b.name)
+ return 1;
+ else
+ return 0;
+ });
+ _self.sender.emit("complete", {
+ pos: pos,
+ matches: matches,
+ isUpdate: event.data.isUpdate,
+ line: _self.doc.getLine(pos.row)
+ });
});
});
});
- });
+ };
+
+ /**
+ * Retrigger completion if the popup is still open and new
+ * information is now available.
+ */
+ this.completeUpdate = function(pos) {
+ if (!isWorkerEnabled()) { // Avoid making the stack too deep in ?noworker=1 mode
+ var _self = this;
+ setTimeout(function onCompleteUpdate() {
+ _self.complete({data: {pos: pos, staticPrefix: _self.staticPrefix, isUpdate: true}});
+ }, 0);
+ }
+ else {
+ this.complete({data: {pos: pos, staticPrefix: this.staticPrefix, isUpdate: true}});
+ }
};
}).call(LanguageWorker.prototype);
View
43 plugins-client/ext.linereport/linereport.js
@@ -24,10 +24,11 @@ module.exports = ext.register("ext/linereport/linereport", {
deps : [language, editors],
nodes : [],
- buffers : {},
- saveTriggers : {},
- firstUsed : false,
-
+ stdoutBuffers : {},
+ stderrBuffers : {},
+ saveTriggers : {},
+ firstUsed : false,
+
hook: function() {
var _self = this;
ide.addEventListener("init.ext/language/language", function() {
@@ -40,12 +41,17 @@ module.exports = ext.register("ext/linereport/linereport", {
},
onWorkerMessage : function(event) {
+ if (ide.readonly || this.isCollabSlave()) {
+ this.disabled = true;
+ return;
+ }
+
if (!this.firstUsed && event.data.path) {
this.firstUsed = true;
this.onFirstUse(event);
}
-
- var doc = window.tabEditors.getPage().$doc;
+
+ var doc = window.tabEditors.getPage() && window.tabEditors.getPage().$doc;
var path = event.data.path;
if (ext.disabled || !doc || (path && path !== util.stripWSFromPath(doc.getNode().getAttribute("path"))))
return;
@@ -58,21 +64,36 @@ module.exports = ext.register("ext/linereport/linereport", {
this.saveTriggers[path] = send;
},
+ isCollabSlave : function() {
+ var collab = require("core/ext").extLut["ext/collaborate/collaborate"];
+ // Use != here instead of !== since we may compare numbers and strings. Yup.
+ return collab && collab.ownerUid && collab.myUserId != collab.ownerUid;
+ },
+
onServerMessage : function(event) {
- var id = event.message.extra && event.message.extra.linereport_id;
+ var message = event.message;
+ var id = message.extra && message.extra.linereport_id;
if (!id)
return;
- switch (event.message.type) {
+ switch (message.type) {
case "npm-module-data":
- this.buffers[id] = (this.buffers[id] || "") + event.message.data;
+ if (event.message.stream === "stdout")
+ this.stdoutBuffers[id] = (this.stdoutBuffers[id] || "") + event.message.data;
+ else
+ this.stderrBuffers[id] = (this.stderrBuffers[id] || "") + event.message.data;
+
break;
case "npm-module-exit":
language.worker.emit("linereport_invoke_result", {data: {
id: id,
code: event.message.code,
- output: this.buffers[id] || ""
+ stdout: this.stdoutBuffers[id] || "",
+ stderr: this.stderrBuffers[id] || ""
}});
- delete this.buffers[id];
+ if (this.stdoutBuffers[id])
+ delete this.stdoutBuffers[id];
+ if (this.stderrBuffers[id])
+ delete this.stderrBuffers[id];
break;
}
},
View
29 plugins-client/ext.linereport/linereport_base.js
@@ -18,22 +18,24 @@ var callbacks = {};
var resultCache = {}; // // map command to doc to result array
var inProgress = {}; // map command to boolean
var nextJob = {}; // map command to function
-
+
worker.init = function() {
+ worker.$isInited = false; // allow children to still be inited
worker.sender.on("linereport_invoke_result", function(event) {
worker.$onInvokeResult(event.data);
});
};
worker.initReporter = function(checkInstall, performInstall, callback) {
- worker.$invoke(checkInstall, null, function(code, output) {
- if (code !== 0) {
- // console.log(performInstall);
- worker.$invoke(performInstall, null, callback);
- } else {
- callback();
- }
- });
+ // TODO: make sure IDE is online
+ worker.$invoke(checkInstall, null, function(code, stdout, stderr) {
+ if (code !== 0) {
+ // console.log(performInstall);
+ worker.$invoke(performInstall, null, callback);
+ } else {
+ callback();
+ }
+ });
},
worker.invokeReporter = function(command, processLine, callback) {
@@ -53,16 +55,17 @@ worker.invokeReporter = function(command, processLine, callback) {
inProgress[command] = setTimeout(function() {
delete inProgress[command];
}, REPORTER_TIMEOUT);
- _self.$invoke(command, worker.path, function(code, output) {
+ _self.$invoke(command, worker.path, function(code, stdout, stderr) {
var doc = _self.doc.getValue();
resultCache[command] = resultCache[command] || {};
- var result = resultCache[command]['_' + doc] = _self.parseOutput(output, processLine);
+ var result = resultCache[command]['_' + doc] =
+ _self.parseOutput(stdout, processLine) + _self.parseOutput(stderr, processLine);
setTimeout(function() {
if (resultCache[command] && resultCache[command]['_' + doc])
delete resultCache[command]['_' + doc];
}, CACHE_TIMEOUT);
if (result.length === 0 && code !== 0)
- console.log("External tool produced an error that could not be parsed:", output);
+ console.log("External tool produced an error that could not be parsed:\n", stderr + '\n' + stdout);
if (inProgress[command]) {
clearTimeout(inProgress[command]);
@@ -106,7 +109,7 @@ worker.$onInvokeResult = function(event) {
// Note: invoked at least once for each linereport_base instance
if (!callbacks[event.id])
return; // already handled
- callbacks[event.id](event.code, event.output);
+ callbacks[event.id](event.code, event.stdout, event.stderr);
delete callbacks[event.id];
};
View
2  plugins-client/ext.linereport_php/linereport_php_worker.js
@@ -11,6 +11,8 @@ var handler = module.exports = Object.create(baseLanguageHandler);
handler.disabled = false;
+handler.$isInited = false;
+
handler.handlesLanguage = function(language) {
return language === 'php';
};
View
4 plugins-server/cloud9.ide.search/search-plugin.js
@@ -43,13 +43,15 @@ module.exports = function setup(options, imports, register) {
var self = this;
return Search.exec(message, Vfs,
- // data
+ // data
function(msg) {
msg.extra = "codesearch";
self.ide.broadcast(JSON.stringify(msg), self.name);
},
// exit
function(code, stderr, msg) {
+ msg = msg || {};
+
msg.code = code;
msg.stderr = stderr;
msg.extra = "codesearch";
View
5 plugins-server/cloud9.ide.search/search.js
@@ -53,7 +53,10 @@ module.exports = function() {
vfs.spawn(args.command, { args: args, cwd: options.path, stdoutEncoding: "utf8", stderrEncoding: "utf8" }, function(err, meta) {
if (err || !meta.process)
- return onExit(1, err);
+ return onExit(1, err, {
+ count: 0,
+ filecount: 0
+ });
var child = meta.process;
self.activeProcess = child;
View
8 test/run-tests.sh
@@ -1,6 +1,9 @@
#!/bin/bash -e
npm install amd-loader
+
+which mocha 2>/dev/null || npm install -g mocha
+
BLACKLIST=`cat test/blacklist.txt`
for F in `find . -name '*_test.js' | grep -v backup- | grep -v node_modules | grep -v -e "\./\." | sort`; do
BLACKLISTED=
@@ -14,8 +17,7 @@ for F in `find . -name '*_test.js' | grep -v backup- | grep -v node_modules | gr
echo $F
cd `dirname $F`
# two cases: either run with mocha or run with node
- if grep -q "mocha" `basename $F`
- then
+ if grep -q "mocha" `basename $F`; then
# mocha test
echo "[mocha]"
echo ------------------
@@ -31,4 +33,4 @@ for F in `find . -name '*_test.js' | grep -v backup- | grep -v node_modules | gr
else
echo $F SKIPPED
fi
-done
+done
Please sign in to comment.
Something went wrong with that request. Please try again.