summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--bundles/org.eclipse.orion.client.cf/web/cfui/plugins/cFPlugin.js36
-rw-r--r--bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js9
-rw-r--r--bundles/org.eclipse.orion.client.core/web/mocha/promocha.js42
-rw-r--r--bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js60
-rw-r--r--bundles/org.eclipse.orion.client.javascript/bundle.properties15
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/eslint/lib/rules/missing-doc.js30
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/eslint/tests/lib/rules/missing-func-decl-doc.js44
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/eslint/tests/lib/rules/missing-func-expr-doc.js73
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/esprima/esprima.js57
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/astManager.js4
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/commands/generateDocCommand.js174
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/finder.js30
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/messages.js4
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js22
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/validator.js48
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/JsMochaSuite.html1
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/contentAssistTests.js23
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.js82
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/finderTests.js53
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js29
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/fileDownloader.js145
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js75
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/navigate/nls/root/messages.js6
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/webui/SideMenu.js4
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js10
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js52
-rw-r--r--bundles/org.eclipse.orion.client.webtools/bundle.properties15
-rw-r--r--bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/cssValidatorTests.js75
-rw-r--r--bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/webtoolsMochaTests.html31
-rw-r--r--features/org.eclipse.orion.client-feature/feature.xml2
-rw-r--r--features/org.eclipse.orion.client-feature/pom.xml4
-rw-r--r--pom.xml20
33 files changed, 983 insertions, 297 deletions
diff --git a/.gitignore b/.gitignore
index 929cd70..e499c3a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,7 @@ bin
target
/doc/org.eclipse.orion.doc.isv/jsdoc/files.html
/doc/org.eclipse.orion.doc.isv/jsdoc/index.html
-/doc/org.eclipse.orion.doc.isv/jsdoc/symbols/ \ No newline at end of file
+/doc/org.eclipse.orion.doc.isv/jsdoc/symbols/
+built-js
+optimized
+staging
diff --git a/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/cFPlugin.js b/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/cFPlugin.js
index 66418d7..472e4be 100644
--- a/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/cFPlugin.js
+++ b/bundles/org.eclipse.orion.client.cf/web/cfui/plugins/cFPlugin.js
@@ -481,6 +481,42 @@ define(['i18n!cfui/nls/messages','require', 'orion/xhr', 'orion/Deferred', 'orio
}
);
+ /** Add cf routes command **/
+ function describeRoute(route) {
+ var host = route.Host;
+ var strResult = "\n" + host + "\t";
+ if (host.length <= 4) {
+ strResult += "\t";
+ }
+ strResult += route.DomainName + "\t";
+ return strResult;
+ }
+
+ var routesImpl = {
+ callback: function(args) {
+ return cFService.getRoutes().then(function(result) {
+ result = result.Routes;
+
+ if (!result || result.length === 0) {
+ return "No routes.";
+ }
+ var strResult = "\nhost\tdomain\tapps\n";
+ result.forEach(function(route) {
+ strResult += describeRoute(route);
+ });
+ return strResult;
+ });
+ }
+ };
+
+ provider.registerServiceProvider(
+ "orion.shell.command",
+ routesImpl, {
+ name: "cfo routes",
+ description: "List all routes in the target space"
+ }
+ );
+
/** Add cf delete command **/
/** var deleteImpl = {
callback: function(args, context) {
diff --git a/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js b/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js
index eef959c..54b3538 100644
--- a/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js
+++ b/bundles/org.eclipse.orion.client.cf/web/orion/cfui/cFClient.js
@@ -218,6 +218,15 @@ define(['require', 'orion/xhr', 'orion/Deferred', 'orion/operation'], function(r
url += "?Target=" + JSON.stringify(target);
return this._xhrV1("GET", url);
+ },
+
+ getRoutes: function(target) {
+ var url = require.toUrl("cfapi/routes");
+
+ if (target)
+ url += "?Target=" + JSON.stringify(target);
+
+ return this._xhrV1("GET", url);
}
};
diff --git a/bundles/org.eclipse.orion.client.core/web/mocha/promocha.js b/bundles/org.eclipse.orion.client.core/web/mocha/promocha.js
new file mode 100644
index 0000000..71f9bfb
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.core/web/mocha/promocha.js
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * @license
+ * Copyright (c) 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+/*jslint amd:true*/
+/*global it:true*/
+
+/*
+ * A shim allowing mocha tests to return a promise. Works by returning a wrapped `it()`
+ * function that is promise-aware. This shim should be removed once mocha is updated to 1.18.x.
+ */
+define([
+ "mocha/mocha"
+], function() {
+ function wrap(obj, funcName) {
+ if (typeof obj[funcName] !== "function")
+ throw new Error("Could not find " + funcName + "()");
+
+ var original = obj[funcName];
+ return function(name, test) {
+ original(name, function(done) {
+ var result = test(done); // Traditional case: test calls done()
+ if (result && result.then) {
+ // Promise case
+ result.then(done.bind(null, undefined /*no error*/), done /*error*/);
+ }
+ // mocha will handle the timeout if result never calls back.
+ });
+ };
+ }
+
+ var global = new Function("return this;")();
+ return {
+ it: wrap(global, "it")
+ };
+}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js b/bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js
index 65c9e39..d3c0b2c 100644
--- a/bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js
+++ b/bundles/org.eclipse.orion.client.editor/web/orion/editor/textView.js
@@ -1348,6 +1348,8 @@ define("orion/editor/textView", [ //$NON-NLS-0$
var lineIndex = this.lineIndex;
var result = 0, range, length;
var lineOffset = model.getLineStart(lineIndex);
+ var lineText = model.getLine(lineIndex);
+ var lineStart = model.getLineStart(lineIndex);
var document = child.ownerDocument;
var lineChild;
var step = data.count < 0 ? -1 : 1;
@@ -1396,6 +1398,18 @@ define("orion/editor/textView", [ //$NON-NLS-0$
lineChild = lineChild.nextSibling;
}
}
+ var offsetInLine = result - lineStart;
+ c = lineText.charCodeAt(offsetInLine);
+ // Handle Unicode surrogates
+ if (0xDC00 <= c && c <= 0xDFFF) {
+ if (offsetInLine > 0) {
+ c = lineText.charCodeAt(offsetInLine - 1);
+ if (0xD800 <= c && c <= 0xDBFF) {
+ offsetInLine += step;
+ }
+ }
+ }
+ result = offsetInLine + lineStart;
data.count -= step;
return result;
},
@@ -3117,6 +3131,18 @@ define("orion/editor/textView", [ //$NON-NLS-0$
this.onBlur({type: "Blur"}); //$NON-NLS-0$
}
},
+ _handleCompositionStart: function (e) {
+ if (this._ignoreEvent(e)) { return; }
+ this._startIME();
+ if (this._mutationObserver) {
+ this._mutationObserver.disconnect();
+ this._mutationObserver = null;
+ }
+ },
+ _handleCompositionEnd: function (e) {
+ if (this._ignoreEvent(e)) { return; }
+ this._commitIME(e.data);
+ },
_handleContextMenu: function (e) {
if (this._ignoreEvent(e)) { return; }
if (util.isIE && this._lastMouseButton === 3) {
@@ -4979,25 +5005,29 @@ define("orion/editor/textView", [ //$NON-NLS-0$
this._setSelection(selection, true);
return true;
},
- _commitIME: function () {
+ _commitIME: function (insertText) {
if (this._imeOffset === -1) { return; }
- // make the state of the IME match the state the view expects it be in
- // when the view commits the text and IME also need to be committed
- // this can be accomplished by changing the focus around
- this._scrollDiv.focus();
- this._clientDiv.focus();
-
var model = this._model;
var lineIndex = model.getLineAtOffset(this._imeOffset);
var lineStart = model.getLineStart(lineIndex);
var line = this._getLineNode(lineIndex);
- var newText = this._getDOMText(line).text;
- var oldText = model.getLine(lineIndex);
- var start = this._imeOffset - lineStart;
- var end = start + newText.length - oldText.length;
- if (start !== end) {
- var insertText = newText.substring(start, end);
- if (!this._doContent(insertText) && util.isFirefox) {
+ if (!insertText) {
+ // make the state of the IME match the state the view expects it be in
+ // when the view commits the text and IME also need to be committed
+ // this can be accomplished by changing the focus around
+ this._scrollDiv.focus();
+ this._clientDiv.focus();
+
+ var newText = this._getDOMText(line).text;
+ var oldText = model.getLine(lineIndex);
+ var start = this._imeOffset - lineStart;
+ var end = start + newText.length - oldText.length;
+ if (start !== end) {
+ insertText = newText.substring(start, end);
+ }
+ }
+ if (insertText) {
+ if (!this._doContent(insertText) && !util.isWebkit) {
line.lineRemoved = true;
this._queueUpdate();
}
@@ -5729,6 +5759,8 @@ define("orion/editor/textView", [ //$NON-NLS-0$
} else {
handlers.push({target: this._clientDiv, type: "DOMCharacterDataModified", handler: function (e) { return self._handleDataModified(e ? e : window.event); }}); //$NON-NLS-0$
}
+ handlers.push({target: this._clientDiv, type: "compositionstart", handler: function (e) { return self._handleCompositionStart(e ? e : window.event); }}); //$NON-NLS-0$
+ handlers.push({target: this._clientDiv, type: "compositionend", handler: function (e) { return self._handleCompositionEnd(e ? e : window.event); }}); //$NON-NLS-0$
}
if (this._overlayDiv) {
handlers.push({target: this._overlayDiv, type: "mousedown", handler: function(e) { return self._handleMouseDown(e ? e : window.event);}}); //$NON-NLS-0$
diff --git a/bundles/org.eclipse.orion.client.javascript/bundle.properties b/bundles/org.eclipse.orion.client.javascript/bundle.properties
index 4a3dc37..46fc4f0 100644
--- a/bundles/org.eclipse.orion.client.javascript/bundle.properties
+++ b/bundles/org.eclipse.orion.client.javascript/bundle.properties
@@ -1,3 +1,12 @@
-#Properties file for org.eclipse.orion.client.javascript
-Bundle-Vendor = Eclipse.org
-Bundle-Name = Orion JavaScript Tools \ No newline at end of file
+###############################################################################
+# Copyright (c) 2014 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+Bundle-Vendor = Eclipse.org - Orion
+Bundle-Name = Orion Client JavaScript Tools \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/rules/missing-doc.js b/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/rules/missing-doc.js
index e42b988..c7af831 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/rules/missing-doc.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/rules/missing-doc.js
@@ -10,6 +10,12 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*global define module require exports */
+/**
+ * Rule configuration is passed in context.options[0] which should be an object.
+ * Settings are:
+ * * context.options[0].expr If the value of this field is a number > 0, FunctionExpressions are checked
+ * * context.options[0].decl If the value of this field is a number > 0, FunctionDeclarations are checked
+ */
(function(root, factory) {
if(typeof exports === 'object') { //$NON-NLS-0$
module.exports = factory(require, exports, module);
@@ -26,7 +32,11 @@
}(this, function(require, exports, module) {
module.exports = function(context) {
"use strict"; //$NON-NLS-0$
-
+
+ var config = (context.options && context.options[0]) || {},
+ declEnabled = Number(config.decl) > 0,
+ exprEnabled = Number(config.expr) > 0;
+
/**
* @name checkDoc
* @description Call-back to check the currently visited node
@@ -34,14 +44,14 @@
* @param {Object} node The currently visited AST node
*/
function checkDoc(node) {
- if(!context.options) {
+ if(!declEnabled && !exprEnabled) {
return;
}
var comments;
var name;
switch(node.type) {
case 'Property': //$NON-NLS-0$
- if((context.options[0] === 'expr') && node.value && (node.value.type === 'FunctionExpression')) { //$NON-NLS-0$ //$NON-NLS-1$
+ if(exprEnabled && node.value && (node.value.type === 'FunctionExpression')) { //$NON-NLS-0$ //$NON-NLS-1$
comments = context.getComments(node);
if(!comments || comments.leading.length < 1) {
switch(node.key.type) {
@@ -52,27 +62,27 @@
name = node.key.value;
break;
}
- reportMissingDoc(node.key, name);
+ reportMissingDoc(node.key, name, "expr"); //$NON-NLS-0$
}
}
break;
case 'FunctionDeclaration': //$NON-NLS-0$
- if(context.options[0] === 'decl') { //$NON-NLS-0$
+ if(declEnabled) { //$NON-NLS-0$
comments = context.getComments(node);
if(!comments || comments.leading.length < 1) {
- reportMissingDoc(node.id, node.id.name);
+ reportMissingDoc(node.id, node.id.name, "decl"); //$NON-NLS-0$
}
}
break;
case 'ExpressionStatement': //$NON-NLS-0$
- if((context.options[0] === 'expr') && node.expression && node.expression.type === 'AssignmentExpression') { //$NON-NLS-0$ //$NON-NLS-1$
+ if(exprEnabled && node.expression && node.expression.type === 'AssignmentExpression') { //$NON-NLS-0$ //$NON-NLS-1$
var anode = node.expression;
if(anode.right && (anode.right.type === 'FunctionExpression') && anode.left && (anode.left.type === 'MemberExpression')) { //$NON-NLS-0$ //$NON-NLS-1$
//comments are attached to the enclosing expression statement
comments = context.getComments(node);
if(!comments || comments.leading.length < 1) {
name = anode.left.computed === true ? anode.left.property.value : anode.left.property.name;
- reportMissingDoc(anode.left.property, name);
+ reportMissingDoc(anode.left.property, name, "expr"); //$NON-NLS-0$
}
}
}
@@ -85,8 +95,8 @@
* @description Creates a new error marker in the context
* @private
*/
- function reportMissingDoc(node, name) {
- context.report(node, 'Missing documentation for function \'{{name}}\'', {name: name});
+ function reportMissingDoc(node, name, kind) {
+ context.report(node, 'Missing documentation for function \'{{name}}\'', {name: name}, { type: kind });
}
return {
diff --git a/bundles/org.eclipse.orion.client.javascript/web/eslint/tests/lib/rules/missing-func-decl-doc.js b/bundles/org.eclipse.orion.client.javascript/web/eslint/tests/lib/rules/missing-func-decl-doc.js
index 6c0901c..83f5577 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/eslint/tests/lib/rules/missing-func-decl-doc.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/eslint/tests/lib/rules/missing-func-decl-doc.js
@@ -19,14 +19,15 @@
assert = assert.assert /*chai*/ || assert;
var RULE_ID = "missing-doc";
+ var flagDecl = { rules: {} };
+ flagDecl.rules[RULE_ID] = [1, {decl: 1}];
describe("missing-doc - function declaration", function() {
describe("should not flag", function() {
it("for root function declaration", function() {
var topic = "var v;\n/**foo*/function f() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -34,8 +35,7 @@
it("for excessive white space", function() {
var topic = "var v;\n/**foo*/\n\n\nfunction f() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -43,8 +43,7 @@
it("for line comment", function() {
var topic = "var v;\n//foo\nfunction f() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -52,8 +51,7 @@
it("for excessive space with line comment", function() {
var topic = "var v;\n//foo\n\n\n\nfunction f() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -61,8 +59,7 @@
it("for inner block comment", function() {
var topic = "var v;\n/***/function o() {/***/function f() {};};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -70,8 +67,7 @@
it("for excessive space with inner block comment", function() {
var topic = "var v;\n/***/function o() {/***/\n\n\n\nfunction f() {};};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -79,8 +75,7 @@
it("for inner line comment", function() {
var topic = "var v;\n/***/function o() {//foo\nfunction f() {};};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -88,8 +83,7 @@
it("for excessive space with inner line comment", function() {
var topic = "var v;\n/***/function o() {//foo\n\n\n\nfunction f() {};};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -99,8 +93,7 @@
it("for function f", function() {
var topic = "var foo;\nfunction f() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 1);
@@ -111,8 +104,7 @@
it("for inner function declaration", function() {
var topic = "var foo;\n/***/\nfunction o() {\nfunction f() {}; };";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 1);
@@ -127,8 +119,7 @@
*/
var topic = "/***/function f() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 1);
@@ -136,6 +127,15 @@
assert.equal(messages[0].message, "Missing documentation for function \'f\'");
assert.equal(messages[0].node.type, "Identifier");
});
+ it("should include {type: 'decl'} as related object", function() {
+ var topic = "var foo;\nfunction f() {};";
+
+ var config = flagDecl;
+
+ var messages = eslint.verify(topic, config);
+ assert.equal(messages.length, 1);
+ assert.equal(messages[0].related.type, "decl");
+ });
});
});
})); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.javascript/web/eslint/tests/lib/rules/missing-func-expr-doc.js b/bundles/org.eclipse.orion.client.javascript/web/eslint/tests/lib/rules/missing-func-expr-doc.js
index 8ddde9b..b4dddf0 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/eslint/tests/lib/rules/missing-func-expr-doc.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/eslint/tests/lib/rules/missing-func-expr-doc.js
@@ -19,14 +19,17 @@
assert = assert.assert /*chai*/ || assert;
var RULE_ID = "missing-doc";
+ var flagDecl = { rules: {} };
+ var flagExpr = { rules: {} };
+ flagDecl.rules[RULE_ID] = [1, {decl: 1}];
+ flagExpr.rules[RULE_ID] = [1, {expr: 1}];
describe("missing-doc - function expression", function() {
describe("should not flag", function() {
it("for object property function expression", function() {
var topic = "var foo = {/**foo*/f: function() {}};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'expr'];
+ var config = flagExpr;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -34,8 +37,7 @@
it("for excessive white space", function() {
var topic = "var foo = {/**foo*/\n\n\n\nf: function() {}};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'expr'];
+ var config = flagExpr;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -43,8 +45,7 @@
it("for line comment", function() {
var topic = "var foo = {//foo\nf: function() {}};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'expr'];
+ var config = flagExpr;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -52,8 +53,7 @@
it("for excessive space with line comment", function() {
var topic = "var foo = {//foo\n\n\n\n\n\nf: function() {}};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'expr'];
+ var config = flagExpr;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -61,8 +61,7 @@
it("for inner block comment", function() {
var topic = "var foo = {/**foo*/o: function() { var bar = { /***/f: function() {}}}};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'expr'];
+ var config = flagExpr;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -70,8 +69,7 @@
it("for excessive space with inner block comment", function() {
var topic = "var foo = {/**foo*/o: function() { var bar = { /***/\n\n\n\n\nf: function() {}}}};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'expr'];
+ var config = flagExpr;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -79,8 +77,7 @@
it("for inner line comment", function() {
var topic = "var foo = {/**foo*/o: function() { var bar = { //foo\nf: function() {}}}};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -88,8 +85,7 @@
it("for excessive space with inner line comment", function() {
var topic = "var foo = {/**foo*/o: function() { var bar = { //foo\n\n\n\n\n\nf: function() {}}}};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -97,8 +93,7 @@
it("for member expression assignment", function() {
var topic = "var Foo; /***/Foo.bar = function() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -106,8 +101,7 @@
it("for member literal expression assignment", function() {
var topic = "var Foo; /***/Foo[\'bar\'] = function() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -115,8 +109,7 @@
it("for member expression assignment excessive space", function() {
var topic = "var Foo; /***/\n\n\n\n\nFoo.bar = function() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -124,8 +117,7 @@
it("nfor member literal expression assignment excessive space", function() {
var topic = "var Foo; /***/\n\n\n\n\nFoo[\'bar\'] = function() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -133,8 +125,7 @@
it("for member expression assignment line comment", function() {
var topic = "var Foo; //comment\nFoo.bar = function() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -142,8 +133,7 @@
it("for member literal expression assignment line comment", function() {
var topic = "var Foo; //comment\nFoo[\'bar\'] = function() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -151,8 +141,7 @@
it("for member expression assignment line comment excessive space", function() {
var topic = "var Foo; //comment\n\n\n\n\n\nFoo.bar = function() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -160,8 +149,7 @@
it("for member literal expression assignment line comment excessive space", function() {
var topic = "var Foo; //comment\n\n\n\n\n\nFoo[\'bar\'] = function() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'decl'];
+ var config = flagDecl;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 0);
@@ -171,8 +159,7 @@
it("for function expression f", function() {
var topic = "var foo = { f: function() {}};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'expr'];
+ var config = flagExpr;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 1);
@@ -183,8 +170,7 @@
it("for function expression member", function() {
var topic = "var Foo; Foo.member = function() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'expr'];
+ var config = flagExpr;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 1);
@@ -195,8 +181,7 @@
it("for function expression literal member", function() {
var topic = "var Foo; Foo[\'member\'] = function() {};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'expr'];
+ var config = flagExpr;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 1);
@@ -207,8 +192,7 @@
it("for inner function expression", function() {
var topic = "var foo = {/**foo*/o: function() { var bar = { f: function() {}}}};";
- var config = { rules: {} };
- config.rules[RULE_ID] = [1, 'expr'];
+ var config = flagExpr;
var messages = eslint.verify(topic, config);
assert.equal(messages.length, 1);
@@ -216,6 +200,15 @@
assert.equal(messages[0].message, "Missing documentation for function \'f\'");
assert.equal(messages[0].node.type, "Identifier");
});
+ it("should include {type: 'decl'} as related object", function() {
+ var topic = "var foo;\nfunction f() {};";
+
+ var config = flagDecl;
+
+ var messages = eslint.verify(topic, config);
+ assert.equal(messages.length, 1);
+ assert.equal(messages[0].related.type, "decl");
+ });
});
});
})); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.javascript/web/esprima/esprima.js b/bundles/org.eclipse.orion.client.javascript/web/esprima/esprima.js
index d1ea92b..95afa29 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/esprima/esprima.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/esprima/esprima.js
@@ -537,12 +537,13 @@ parseStatement: true, parseSourceElement: true */
return String.fromCharCode(code);
}
+ //mrennie https://bugs.eclipse.org/bugs/show_bug.cgi?id=433893
function getEscapedIdentifier() {
var ch, id;
ch = source.charCodeAt(index++);
id = String.fromCharCode(ch);
-
+
// '\u' (char #92, char #117) denotes an escaped character.
if (ch === 92) {
if (source.charCodeAt(index) !== 117) {
@@ -555,20 +556,16 @@ parseStatement: true, parseSourceElement: true */
}
id = ch;
}
-
while (index < length) {
ch = source.charCodeAt(index);
if (!isIdentifierPart(ch)) {
break;
}
++index;
- id += String.fromCharCode(ch);
-
// '\u' (char #92, char #117) denotes an escaped character.
if (ch === 92) {
- id = id.substr(0, id.length - 1);
if (source.charCodeAt(index) !== 117) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
}
++index;
ch = scanHexEscape('u');
@@ -576,6 +573,8 @@ parseStatement: true, parseSourceElement: true */
throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
}
id += ch;
+ } else {
+ id += String.fromCharCode(ch);
}
}
@@ -1382,7 +1381,7 @@ parseStatement: true, parseSourceElement: true */
}
// Check for possible additional trailing comments.
- peek();
+ //peek();
for (i = 0; i < extra.pendingComments.length; ++i) {
attacher = extra.pendingComments[i];
@@ -2088,14 +2087,14 @@ parseStatement: true, parseSourceElement: true */
if(extra.errors) {
var token = advance();
if(token.value === ':') {
- token = lex(); // eat the ':' so the assignment parsing starts on the correct index
try {
+ token = lex(); // eat the ':' so the assignment parsing starts on the correct index
return delegate.markEnd(delegate.createProperty('init', id, parseAssignmentExpression()));
- } catch(e) {
- //trap the exception and ignore the broken property
- delegate.markEndIf(id);
- return null;
- }
+ }
+ catch(e) {
+ delegate.markEndIf(id);
+ return null;
+ }
} else if(token.type === Token.Punctuator && token.value === '}') {
throwErrorTolerant(prev, Messages.UnexpectedToken, prev.value);
delegate.markEndIf(id);
@@ -2169,14 +2168,18 @@ parseStatement: true, parseSourceElement: true */
if (!match('}')) {
//mrennie https://bugs.eclipse.org/bugs/show_bug.cgi?id=432956
- var token = lookahead;
- if(token.type !== Token.Punctuator && token.value !== ',') {
- if(extra.tokens && extra.tokens.length > 0) {
- token = extra.tokens[extra.tokens.length-1];
- }
- throwErrorTolerant(token, Messages.MissingToken, ',');
+ if(extra.errors) {
+ var token = lookahead;
+ if(token.type !== Token.Punctuator && token.value !== ',') {
+ if(extra.tokens && extra.tokens.length > 0) {
+ token = extra.tokens[extra.tokens.length-1];
+ }
+ throwErrorTolerant(token, Messages.MissingToken, ',');
+ } else {
+ lex();
+ }
} else {
- lex();
+ expect(',');
}
}
}
@@ -3367,9 +3370,7 @@ parseStatement: true, parseSourceElement: true */
delete state.labelSet[key];
return delegate.markEnd(delegate.createLabeledStatement(expr, labeledBody));
}
-
consumeSemicolon();
-
return delegate.markEnd(delegate.createExpressionStatement(expr));
}
@@ -3418,14 +3419,16 @@ parseStatement: true, parseSourceElement: true */
state.inSwitch = false;
state.inFunctionBody = true;
+ var startidx = index;
while (index < length) {
if (match('}')) {
break;
}
sourceElement = parseSourceElement();
- if (typeof sourceElement === 'undefined') {
+ if (typeof sourceElement === 'undefined' || startidx === index) {
break;
}
+ startidx = index;
sourceElements.push(sourceElement);
}
@@ -3627,12 +3630,13 @@ parseStatement: true, parseSourceElement: true */
}
}
}
-
+ var startidx = index;
while (index < length) {
sourceElement = parseSourceElement();
- if (typeof sourceElement === 'undefined') {
+ if (typeof sourceElement === 'undefined' || startidx === index) {
break;
}
+ startidx = index;
sourceElements.push(sourceElement);
}
return sourceElements;
@@ -4029,8 +4033,9 @@ parseStatement: true, parseSourceElement: true */
} catch (e) {
pushError(e);
// Clean up un-popped end markers from failed parse
- while (state.markerStack.length > initialHeight)
+ while (state.markerStack.length > initialHeight) {
delegate.markEndIf(null);
+ }
return null;
}
};
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/astManager.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/astManager.js
index c2c3c87..126cf46 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/astManager.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/astManager.js
@@ -13,7 +13,7 @@
define([
'orion/Deferred',
'orion/objects',
- 'orion/serialize',
+ 'orion/serialize'
], function(Deferred, Objects, Serialize) {
/**
* @description Object of error types
@@ -72,7 +72,7 @@ define([
tolerant: true,
comment: true,
tokens: true,
- attachComments: true
+ attachComment: true
});
} catch (e) {
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/commands/generateDocCommand.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/commands/generateDocCommand.js
new file mode 100644
index 0000000..d168883
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/commands/generateDocCommand.js
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * @license
+ * Copyright (c) 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*global define*/
+define([
+'orion/objects',
+'javascript/finder',
+'javascript/signatures',
+'orion/Deferred'
+], function(Objects, Finder, Signatures, Deferred) {
+
+ /**
+ * @description Creates a new generate doc command
+ * @constructor
+ * @public
+ * @returns {javascript.commands.GenerateDocCommand} A new command
+ * @since 6.0
+ */
+ function GenerateDocCommand(ASTManager) {
+ this.astManager = ASTManager;
+ }
+
+ Objects.mixin(GenerateDocCommand.prototype, {
+ /* override */
+ execute: function(editorContext, options) {
+ var that = this;
+ return Deferred.all([
+ this.astManager.getAST(editorContext),
+ editorContext.getText(),
+ editorContext.getCaretOffset()
+ ]).then(function(results) {
+ var node = Finder.findNode(results[2], results[0], {parents:true});
+ if(node) {
+ var text = results[1];
+ var parent = that._resolveParent(node);
+ if(parent && (!parent.leadingComments || parent.leadingComments.length < 1)) {
+ //don't monkey with existing comments
+ var template;
+ var start = parent.range[0];
+ if(parent.type === 'FunctionDeclaration') { //$NON-NLS-0$
+ template = that._genTemplate(parent.id.name, parent.params, false, parent.range[0], text);
+ } else if(parent.type === 'Property') { //$NON-NLS-0$
+ template = that._genTemplate((parent.key.name ? parent.key.name : parent.key.value), parent.value.params, true, parent.range[0], text);
+ } else if(parent.type === 'VariableDeclarator') { //$NON-NLS-0$
+ start = parent.range[0];
+ if(parent.decl) {
+ if(parent.decl.leadingComments) {
+ return;
+ }
+ if(parent.decl.declarations && parent.decl.declarations.length === 1) {
+ start = parent.decl.range[0];
+ }
+ }
+ template = that._genTemplate(parent.id.name, parent.init.params, true, start, text);
+ } else if(parent.type === 'AssignmentExpression') {
+ template = that._genTemplate(Signatures.expandMemberExpression(parent.left, ''),
+ parent.right.params,
+ true,
+ parent.range[0],
+ text);
+ }
+ }
+ if(template) {
+ return Deferred.all([
+ editorContext.setText(template, start, start),
+ editorContext.setCaretOffset(results[2]+template.length)
+ ]);
+ }
+ }
+ });
+ },
+
+ /**
+ * @description Creates the boilerplate template
+ * @function
+ * @private
+ * @param {String} name The name of the function
+ * @param {Array} params The array of AST nodes
+ * @param {Boolean} isexpr If the template is for a function expression
+ * @param {Number} offset The offset to start the template from
+ * @param {String} text The original text
+ */
+ _genTemplate: function(name, params, isexpr, offset, text) {
+ var char = text[--offset];
+ var preamble = '';
+ //walk the preceeding whitespace so we will insert formatted at the same level
+ while(char === ' ' || char === '\t') {
+ preamble += char;
+ char = text[--offset];
+ }
+ var parts = [];
+ parts.push('/**\n'+preamble+' * @name '+name+'\n');
+ //TODO add in description template once editor bug is fixed
+ //${description}
+ parts.push(preamble+' * @description description\n'); //$NON-NLS-0$
+ if(isexpr) {
+ parts.push(preamble+' * @function\n');
+ }
+ if(name.charAt(0) === '_') {
+ parts.push(preamble+' * @private\n');
+ }
+ if(params) {
+ var len = params.length;
+ for(var i = 0; i < len; i++) {
+ //TODO add template for type infos after suporting editor bug is fixed
+ // {${param'+(i+1)+'}}
+ parts.push(preamble+' * @param '+ params[i].name+'\n'); //$NON-NLS-0$ //$NON-NLS-0$
+ }
+ }
+ //TODO add in returns template once editor bug is fixed
+ //{${returns}}
+ parts.push(preamble+' * @returns returns\n'+preamble+' */\n'+preamble);
+ return parts.join('');
+ },
+
+ /**
+ * @description Computes the parent node to attach the doc to
+ * @function
+ * @private
+ * @param {Object} node The AST node
+ * @returns {Object} The parent node to attach the doc to or <code>null</code>
+ */
+ _resolveParent: function(node) {
+ if(!node.parents || node.parents.length < 1) {
+ return null;
+ }
+ switch(node.type) {
+ case 'FunctionDeclaration':
+ return node;
+ case 'Property':
+ if(node.value && node.value.type === 'FunctionExpression') {
+ return node;
+ }
+ return null;
+ case 'VariableDeclarator':
+ if(node.init && node.init.type === 'FunctionExpression') {
+ node.decl = node.parents[node.parents.length -1];
+ return node;
+ }
+ return null;
+ case 'VariableDeclaration':
+ if(node.declarations && node.declarations.length === 1) {
+ var n = node.declarations[0];
+ if(n.init && n.init.type === 'FunctionExpression') {
+ node.parents.push(node);
+ n.parents = node.parents;
+ return this._resolveParent(n);
+ }
+ }
+ case 'AssignmentExpression':
+ if((node.left && node.left.type === 'MemberExpression') &&
+ (node.right && node.right.type === 'FunctionExpression')) {
+ return node;
+ }
+ }
+ var len = node.parents.length-1;
+ var parent = node.parents[len];
+ parent.parents = node.parents.slice(0, len);
+ return this._resolveParent(parent);
+ }
+ });
+
+ return {
+ GenerateDocCommand : GenerateDocCommand
+ };
+});
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/finder.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/finder.js
index 030faa5..cd50486 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/finder.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/finder.js
@@ -377,10 +377,12 @@ define([
* @memberof javascript.Finder
* @param {Number} offset The offset into the source file
* @param {Object} ast The AST to search
+ * @param {Object} options The optional options
* @returns The AST node at the given offset or <code>null</code> if it could not be computed.
*/
- findNode: function(offset, ast) {
+ findNode: function(offset, ast, options) {
var found = null;
+ var parents = options && options.parents ? [] : null;
if(offset != null && offset > -1 && ast) {
Estraverse.traverse(ast, {
/**
@@ -391,14 +393,32 @@ define([
//only check nodes that are typed, we don't care about any others
if(node.range[0] <= offset) {
found = node;
- }
- else {
+ if(parents) {
+ parents.push(node);
+ }
+ } else {
+ if(parents && parents.length > 0) {
+ var p = parents[parents.length-1];
+ if(p.range[0] === found.range[0] && p.range[1] === found.range[1]) {
+ //a node can't be its own parent
+ parents.pop();
+ }
+ }
return Estraverse.VisitorOption.Break;
}
}
- }
+ },
+ /** override */
+ leave: function(node) {
+ if(parents && offset >= node.range[1]) {
+ parents.pop();
+ }
+ }
});
}
+ if(found && parents) {
+ found.parents = parents;
+ }
return found;
},
@@ -523,7 +543,7 @@ define([
* @description Finds all of the occurrences of the token / ranges / text from the context within the given AST
* @function
* @public
- * @param {Object} editorContext The editor context to get the AST from
+ * @param {Object} ast The editor context to get the AST from
* @param {Object} ctxt The context object {start:number, end:number, contentType:string}
* @returns {orion.Promise} The promise to compute occurrences
* @since 6.0
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/messages.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/messages.js
index 54419d6..0e25d3e 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/messages.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/messages.js
@@ -36,5 +36,7 @@ define({
'varRedecl' : 'Variable re-declarations', //$NON-NLS-0$ //$NON-NLS-1$
'undefMember' : 'Undefined member use', //$NON-NLS-0$ //$NON-NLS-1$
'unnecessarySemis' : 'Unnecessary semicolons', //$NON-NLS-0$ //$NON-NLS-1$
- 'unusedParams' : 'Unused parameters' //$NON-NLS-0$ //$NON-NLS-1$
+ 'unusedParams' : 'Unused parameters', //$NON-NLS-0$ //$NON-NLS-1$
+ 'generateDocName' : 'Generate Element Comment', //$NON-NLS-0$ //$NON-NLS-1$
+ 'generateDocTooltip' : 'Generate a JSDoc-like comment for the selected JavaScript element', //$NON-NLS-0$ //$NON-NLS-1$
});
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js
index 0d74132..98c03d4 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js
@@ -25,12 +25,14 @@ define([
'javascript/occurrences',
'javascript/outliner',
'orion/plugin',
+ 'orion/util',
+ 'javascript/commands/generateDocCommand',
'orion/editor/stylers/application_javascript/syntax',
'orion/editor/stylers/application_json/syntax',
'orion/editor/stylers/application_schema_json/syntax',
'orion/editor/stylers/application_x-ejs/syntax'
-], function(Esprima, ASTManager, MongodbIndex, MysqlIndex, PostgresIndex, RedisIndex, ExpressIndex, AMQPIndex, ContentAssist, EslintValidator, Occurrences, Outliner,
- PluginProvider, mJS, mJSON, mJSONSchema, mEJS) {
+], function(Esprima, ASTManager, MongodbIndex, MysqlIndex, PostgresIndex, RedisIndex, ExpressIndex, AMQPIndex, ContentAssist,
+ EslintValidator, Occurrences, Outliner, PluginProvider, Util, GenerateDocCommand, mJS, mJSON, mJSONSchema, mEJS) {
/**
* Plug-in headers
@@ -82,7 +84,19 @@ define([
contentType: ["application/javascript"], //$NON-NLS-0$
types: ["ModelChanging", 'Destroy'] //$NON-NLS-0$ //$NON-NLS-1$
});
-
+
+ provider.registerServiceProvider("orion.edit.command", //$NON-NLS-0$
+ new GenerateDocCommand.GenerateDocCommand(astManager),
+ {
+ nameKey : 'generateDocName', //$NON-NLS-0$
+ tooltipKey : 'generateDocTooltip', //$NON-NLS-0$
+ id : "generate.js.doc.comment", //$NON-NLS-0$
+ nls: 'javascript/nls/messages', //$NON-NLS-0$
+ key : [ "j", false, true, !Util.isMac, Util.isMac], //$NON-NLS-0$
+ contentType: ['application/javascript'] //$NON-NLS-0$
+ }
+ );
+
/**
* Register the jsdoc-based outline
*/
@@ -310,4 +324,4 @@ define([
});
provider.connect();
-}); \ No newline at end of file
+});
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/validator.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/validator.js
index 9d18240..298c3c9 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/validator.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/validator.js
@@ -27,8 +27,7 @@ define([
"no-use-before-define": 1, //$NON-NLS-0$
"semi": 1, //$NON-NLS-0$
"no-extra-semi": 1, //$NON-NLS-0$
- "missing-func-decl-doc": [0, 'decl'], //$NON-NLS-0$ //$NON-NLS-1$
- "missing-func-expr-doc": [0, 'expr'], //$NON-NLS-0$ //$NON-NLS-1$
+ "missing-doc": [1, {decl: 0, expr: 0}], //$NON-NLS-0$
'no-debugger' : 1, //$NON-NLS-0$
'no-dupe-keys' : 2, //$NON-NLS-0$
'no-eval' : 0, //$NON-NLS-0$
@@ -46,15 +45,22 @@ define([
* @function
* @private
* @param {String} ruleId The id of the rule to change
- * @param {Number} value The vlaue to set the rule to
+ * @param {Number} value The value to set the rule to
+ * @param {Object} [key] Optional key to use for complex rule configuration.
*/
- setOption: function(ruleId, value) {
+ setOption: function(ruleId, value, key) {
if (typeof value === "number") {
- if(Array.isArray(this.rules[ruleId])) {
- this.rules[ruleId][0] = value;
+ var ruleConfig = this.rules[ruleId];
+ if(Array.isArray(ruleConfig)) {
+ if (key) {
+ ruleConfig[1] = ruleConfig[1] || {};
+ ruleConfig[1][key] = value;
+ } else {
+ ruleConfig[0] = value;
+ }
}
else {
- this.rules[ruleId] = value;
+ ruleConfig = value;
}
}
}
@@ -79,11 +85,19 @@ define([
*/
function getSeverity(prob) {
var val = 2;
- if(Array.isArray(config.rules[prob.ruleId])) {
- val = config.rules[prob.ruleId][0];
+ var ruleConfig = config.rules[prob.ruleId];
+ if(Array.isArray(ruleConfig)) {
+ // Hack for missing-doc which overloads the prob.related object to expose which subrule
+ // generated the problem
+ var related = prob.related, ruleType = related && related.type;
+ if (prob.ruleId === "missing-doc" && ruleConfig[1][ruleType] !== undefined) {
+ val = ruleConfig[1][ruleType];
+ } else {
+ val = ruleConfig[0];
+ }
}
else {
- val = config.rules[prob.ruleId];
+ val = ruleConfig;
}
switch (val) {
case 1: return "warning"; //$NON-NLS-0$
@@ -104,7 +118,7 @@ define([
// Error produced by eslint
start = e.node.range[0];
end = e.node.range[1];
- if (e.related) {
+ if (e.related && e.related.range) {
// Flagging the entire node is distracting. Just flag the bad token.
var relatedToken = e.related;
start = relatedToken.range[0];
@@ -215,19 +229,19 @@ define([
* @since 6.0
*/
_validateAst: function(ast) {
- var eslintErrors = [], error;
+ var eslintErrors = [], error, parseErrors = [], problems = [];
try {
eslintErrors = eslint.verify(ast, config);
+ parseErrors = this._extractParseErrors(ast);
+ problems = this._filterProblems(parseErrors, eslintErrors).map(toProblem);
} catch (e) {
error = e;
}
- var parseErrors = this._extractParseErrors(ast);
- var problems = this._filterProblems(parseErrors, eslintErrors).map(toProblem);
if (error && !parseErrors.length) {
// Warn about ESLint failure
problems.push({
start: 0,
- description: "ESLint could not validate this file because an error occurred: " + error.toString(),
+ description: "Orion could not validate this file because an error occurred: " + error.toString(),
severity: "error" //$NON-NLS-0$
});
}
@@ -277,8 +291,8 @@ define([
}
// TODO these option -> setting mappings are becoming hard to manage
// And they must be kept in sync with javascriptPlugin.js
- config.setOption("missing-func-decl-doc", properties.validate_func_decl); //$NON-NLS-0$
- config.setOption("missing-func-expr-doc", properties.validate_func_expr); //$NON-NLS-0$
+ config.setOption("missing-doc", properties.validate_func_decl, "decl"); //$NON-NLS-0$ // missing-func-decl-doc
+ config.setOption("missing-doc", properties.validate_func_expr, "expr"); //$NON-NLS-0$ // missing-func-expr-doc
config.setOption("eqeqeq", properties.validate_eqeqeq); //$NON-NLS-0$
config.setOption("no-redeclare", properties.validate_no_redeclare); //$NON-NLS-0$
config.setOption("no-undef", properties.validate_no_undef); //$NON-NLS-0$
diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/JsMochaSuite.html b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/JsMochaSuite.html
index abb3782..6bc0b8d 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/JsMochaSuite.html
+++ b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/JsMochaSuite.html
@@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<title>JavaScript Tools Mocha Tests</title>
+ <link rel="stylesheet" href="mocha.css" />
<link rel="stylesheet" href="js-tests/javascript/mocha.css" />
<script src="../../../../requirejs/require.js"></script>
<script>
diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/contentAssistTests.js b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/contentAssistTests.js
index 60cddc3..7a63cbd 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/contentAssistTests.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/contentAssistTests.js
@@ -2828,18 +2828,6 @@ define([
});
//jsdoc test
- it("test simple jsdoc14", function() {
- var results = computeContentAssist(
- "var xx;\n" +
- "/** @return Number*/\n" +
- "xx = function() { };\nx", "x"
- );
- return testProposals(results, [
- ["xx()", "xx : String"]
- ]);
- });
-
- //jsdoc test
it("test simple jsdoc15", function() {
var results = computeContentAssist(
"var xx;\n" +
@@ -3663,17 +3651,6 @@ define([
]);
});
- // SCRIPTED-100
- it("test obj literal with underscore", function() {
- var results = computeContentAssist(
- "var obj = { _myFun : function() { this._/**/ } }", "_");
-
- return testProposals(results, [
- // inferred as object type since invocation request is happening inside of object literal.
- ["_myFun", "_myFun : Object"]
- ]);
- });
-
// SCRIPTED-170
it("test obj literal with underscore2", function() {
var results = computeContentAssist(
diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.js b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.js
index 80655db..8b3e9a4 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/esprimaTolerantTests.js
@@ -31,7 +31,6 @@ define([
tolerant: true,
comment: true,
tokens: true,
- raw: true,
attachComments:true
});
}
@@ -204,20 +203,18 @@ define([
it('Function args 2', function() {
var data = {
source: "var ttt, uuu;\nttt(ttt, /**/)",
- errors: [{ index:27, lineNumber: 2, message: "Unexpected token )", token: ")" }],
- nodes: [{type:"VariableDeclaration",kind:"var",range:[0,13]},{type:"VariableDeclarator",range:[4,7]},{type:"Identifier",name:"ttt",range:[4,7]},{type:"VariableDeclarator",range:[9,12]},{type:"Identifier",name:"uuu",range:[9,12]},{type:"ExpressionStatement",range:[14,28]}]
+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[0,13]},{"type":"VariableDeclarator","range":[4,7]},{"type":"Identifier","name":"ttt","range":[4,7]},{"type":"VariableDeclarator","range":[9,12]},{"type":"Identifier","name":"uuu","range":[9,12]},{"type":"ExpressionStatement","range":[14,28]}],
+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"},{"type":"Identifier","range":[4,7],"value":"ttt"},{"type":"Punctuator","range":[7,8],"value":","},{"type":"Identifier","range":[9,12],"value":"uuu"},{"type":"Punctuator","range":[12,13],"value":";"},{"type":"Identifier","range":[14,17],"value":"ttt"},{"type":"Punctuator","range":[17,18],"value":"("},{"type":"Identifier","range":[18,21],"value":"ttt"},{"type":"Punctuator","range":[21,22],"value":","},{"type":"Punctuator","range":[27,28],"value":")"}],
+ errors: [{"lineNumber":2,"index":27,"message":"Unexpected token )","token":")"}]
};
runTest(data);
});
it('Function args 3', function() {
var data = {
source: "var ttt, uuu;\nttt(ttt, /**/, uuu)",
- errors: [
- { index: 27, message: "Unexpected token ,", token: "," },
- { index: 29, message: "Unexpected identifier", token: "uuu" },
- { index: 32, message: "Unexpected token )", token: ")" }
- ],
- nodes: [{type:"VariableDeclaration",kind:"var",range:[0,13]},{type:"VariableDeclarator",range:[4,7]},{type:"Identifier",name:"ttt",range:[4,7]},{type:"VariableDeclarator",range:[9,12]},{type:"Identifier",name:"uuu",range:[9,12]},{type:"ExpressionStatement",range:[14,29]},{type:"ExpressionStatement",range:[29,32]},{type:"Identifier",name:"uuu",range:[29,32]},{type:"ExpressionStatement",range:[32,33]}]
+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[0,13]},{"type":"VariableDeclarator","range":[4,7]},{"type":"Identifier","name":"ttt","range":[4,7]},{"type":"VariableDeclarator","range":[9,12]},{"type":"Identifier","name":"uuu","range":[9,12]},{"type":"ExpressionStatement","range":[14,29]},{"type":"ExpressionStatement","range":[29,32]},{"type":"Identifier","name":"uuu","range":[29,32]},{"type":"ExpressionStatement","range":[32,33]}],
+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"},{"type":"Identifier","range":[4,7],"value":"ttt"},{"type":"Punctuator","range":[7,8],"value":","},{"type":"Identifier","range":[9,12],"value":"uuu"},{"type":"Punctuator","range":[12,13],"value":";"},{"type":"Identifier","range":[14,17],"value":"ttt"},{"type":"Punctuator","range":[17,18],"value":"("},{"type":"Identifier","range":[18,21],"value":"ttt"},{"type":"Punctuator","range":[21,22],"value":","},{"type":"Punctuator","range":[27,28],"value":","},{"type":"Identifier","range":[29,32],"value":"uuu"},{"type":"Punctuator","range":[32,33],"value":")"}],
+ errors: [{"lineNumber":2,"index":27,"message":"Unexpected token ,","token":","},{"lineNumber":2,"index":29,"message":"Unexpected identifier","token":"uuu"},{"lineNumber":2,"index":32,"message":"Unexpected token )","token":")"}]
};
runTest(data);
});
@@ -1358,8 +1355,8 @@ define([
runTest({
source: 'var f = {one: "busted\n};',
nodes: [{"type":"VariableDeclaration","kind":"var","range":[0,24]},{"type":"VariableDeclarator","range":[4,23]},{"type":"Identifier","name":"f","range":[4,5]},{"type":"ObjectExpression","range":[8,23]},{"type":"Property","kind":"init","range":[9,22]},{"type":"Identifier","name":"one","range":[9,12]},{"type":"Literal","range":[14,22],"value":"busted"}],
- tokens: [{"type":"Keyword","range":[0,3],"value":"var"},{"type":"Identifier","range":[4,5],"value":"f"},{"type":"Punctuator","range":[6,7],"value":"="},{"type":"Punctuator","range":[8,9],"value":"{"},{"type":"Identifier","range":[9,12],"value":"one"},{"type":"Punctuator","range":[12,13],"value":":"},{"type":"String","range":[14,22],"value":"\"busted\n"},{"type":"Punctuator","range":[22,23],"value":"}"},{"type":"Punctuator","range":[23,24],"value":";"}],
- errors: [{"lineNumber":1,"index":22,"message":"Unexpected token ILLEGAL"}]
+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"},{"type":"Identifier","range":[4,5],"value":"f"},{"type":"Punctuator","range":[6,7],"value":"="},{"type":"Punctuator","range":[8,9],"value":"{"},{"type":"Identifier","range":[9,12],"value":"one"},{"type":"Punctuator","range":[12,13],"value":":"},{"type":"String","range":[14,22],"value":"\"busted\n"},{"type":"Punctuator","range":[22,23],"value":"}"},{"type":"Punctuator","range":[23,24],"value":";"}],
+ errors: [{"lineNumber":1,"index":22,"message":"Unexpected token ILLEGAL"}]
});
}
@@ -1392,5 +1389,68 @@ define([
});
}
});
+
+ it('escaped literal recovery 1', function() {
+ runTest({
+ source: "function f() { return {b:{ cc:3, dd:''hey\\'' e}c:2};}",
+ nodes: [{"type":"FunctionDeclaration","range":[0,42]},{"type":"Identifier","name":"f","range":[9,10]},{"type":"BlockStatement","range":[13,42]},{"type":"ReturnStatement","range":[15,42]}],
+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"},{"type":"Identifier","range":[9,10],"value":"f"},{"type":"Punctuator","range":[10,11],"value":"("},{"type":"Punctuator","range":[11,12],"value":")"},{"type":"Punctuator","range":[13,14],"value":"{"},{"type":"Keyword","range":[15,21],"value":"return"},{"type":"Punctuator","range":[22,23],"value":"{"},{"type":"Identifier","range":[23,24],"value":"b"},{"type":"Punctuator","range":[24,25],"value":":"},{"type":"Punctuator","range":[25,26],"value":"{"},{"type":"Identifier","range":[27,29],"value":"cc"},{"type":"Punctuator","range":[29,30],"value":":"},{"type":"Numeric","range":[30,31],"value":"3"},{"type":"Punctuator","range":[31,32],"value":","},{"type":"Identifier","range":[33,35],"value":"dd"},{"type":"Punctuator","range":[35,36],"value":":"},{"type":"String","range":[36,38],"value":"''"}],
+ errors: [{"lineNumber":1,"index":42,"message":"Unexpected token ILLEGAL"},{"lineNumber":1,"index":36,"message":"Unexpected string","token":""}]
+ });
+ });
+
+ it('escaped literal recovery 2', function() {
+ runTest({
+ source: "function f() { return {b:{ cc:3, dd:hey\\'' e}c:2};}",
+ nodes: [{"type":"FunctionDeclaration","range":[0,40]},{"type":"Identifier","name":"f","range":[9,10]},{"type":"BlockStatement","range":[13,40]},{"type":"ReturnStatement","range":[15,40]}],
+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"},{"type":"Identifier","range":[9,10],"value":"f"},{"type":"Punctuator","range":[10,11],"value":"("},{"type":"Punctuator","range":[11,12],"value":")"},{"type":"Punctuator","range":[13,14],"value":"{"},{"type":"Keyword","range":[15,21],"value":"return"},{"type":"Punctuator","range":[22,23],"value":"{"},{"type":"Identifier","range":[23,24],"value":"b"},{"type":"Punctuator","range":[24,25],"value":":"},{"type":"Punctuator","range":[25,26],"value":"{"},{"type":"Identifier","range":[27,29],"value":"cc"},{"type":"Punctuator","range":[29,30],"value":":"},{"type":"Numeric","range":[30,31],"value":"3"},{"type":"Punctuator","range":[31,32],"value":","},{"type":"Identifier","range":[33,35],"value":"dd"},{"type":"Punctuator","range":[35,36],"value":":"}],
+ errors: [{"lineNumber":1,"index":35,"message":"Unexpected token :","token":":"},{"lineNumber":1,"index":40,"message":"Unexpected token ILLEGAL"}]
+ });
+ });
+
+ it('escaped literal recovery 3', function() {
+ runTest({
+ source: "function f() { return {b:{ cc:3, dd:hey\\' e}c:2};}",
+ nodes: [{"type":"FunctionDeclaration","range":[0,40]},{"type":"Identifier","name":"f","range":[9,10]},{"type":"BlockStatement","range":[13,40]},{"type":"ReturnStatement","range":[15,40]}],
+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"},{"type":"Identifier","range":[9,10],"value":"f"},{"type":"Punctuator","range":[10,11],"value":"("},{"type":"Punctuator","range":[11,12],"value":")"},{"type":"Punctuator","range":[13,14],"value":"{"},{"type":"Keyword","range":[15,21],"value":"return"},{"type":"Punctuator","range":[22,23],"value":"{"},{"type":"Identifier","range":[23,24],"value":"b"},{"type":"Punctuator","range":[24,25],"value":":"},{"type":"Punctuator","range":[25,26],"value":"{"},{"type":"Identifier","range":[27,29],"value":"cc"},{"type":"Punctuator","range":[29,30],"value":":"},{"type":"Numeric","range":[30,31],"value":"3"},{"type":"Punctuator","range":[31,32],"value":","},{"type":"Identifier","range":[33,35],"value":"dd"},{"type":"Punctuator","range":[35,36],"value":":"}],
+ errors: [{"lineNumber":1,"index":35,"message":"Unexpected token :","token":":"},{"lineNumber":1,"index":40,"message":"Unexpected token ILLEGAL"}]
+ });
+ });
+
+ it('escaped literal recovery 4', function() {
+ runTest({
+ source: "function f() { return {b:{ cc:3, dd:'hey\\' e}c:2};}",
+ nodes: [{"type":"FunctionDeclaration","range":[0,51]},{"type":"Identifier","name":"f","range":[9,10]},{"type":"BlockStatement","range":[13,51]},{"type":"ReturnStatement","range":[15,51]}],
+ tokens: [{"type":"Keyword","range":[0,8],"value":"function"},{"type":"Identifier","range":[9,10],"value":"f"},{"type":"Punctuator","range":[10,11],"value":"("},{"type":"Punctuator","range":[11,12],"value":")"},{"type":"Punctuator","range":[13,14],"value":"{"},{"type":"Keyword","range":[15,21],"value":"return"},{"type":"Punctuator","range":[22,23],"value":"{"},{"type":"Identifier","range":[23,24],"value":"b"},{"type":"Punctuator","range":[24,25],"value":":"},{"type":"Punctuator","range":[25,26],"value":"{"},{"type":"Identifier","range":[27,29],"value":"cc"},{"type":"Punctuator","range":[29,30],"value":":"},{"type":"Numeric","range":[30,31],"value":"3"},{"type":"Punctuator","range":[31,32],"value":","},{"type":"Identifier","range":[33,35],"value":"dd"},{"type":"Punctuator","range":[35,36],"value":":"},{"type":"String","range":[36,51],"value":"'hey\\' e}c:2};}"}],
+ errors: [{"lineNumber":1,"index":51,"message":"Unexpected token ILLEGAL"},{"lineNumber":1,"index":51,"message":"Missing expected ','"},{"lineNumber":1,"index":51,"message":"Unexpected end of input"}]
+ });
+ });
+
+ it('escaped literal recovery 5', function() {
+ runTest({
+ source: "var v = {a b:{cc:3, dd:'hey' e} c:2};function f() {return {a b:{cc:3, dd:hey\\' e} c:2};}",
+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[0,37]},{"type":"VariableDeclarator","range":[4,36]},{"type":"Identifier","name":"v","range":[4,5]},{"type":"ObjectExpression","range":[8,36]},{"type":"Property","kind":"init","range":[12,31]},{"type":"Identifier","name":"b","range":[12,12]},{"type":"ObjectExpression","range":[13,31]},{"type":"Property","kind":"init","range":[14,18]},{"type":"Identifier","name":"cc","range":[14,16]},{"type":"Literal","range":[17,18],"value":3},{"type":"Property","kind":"init","range":[20,28]},{"type":"Identifier","name":"dd","range":[20,22]},{"type":"Literal","range":[23,28],"value":"hey"},{"type":"Property","kind":"init","range":[32,35]},{"type":"Identifier","name":"c","range":[32,33]},{"type":"Literal","range":[34,35],"value":2},{"type":"FunctionDeclaration","range":[37,77]},{"type":"Identifier","name":"f","range":[46,47]},{"type":"BlockStatement","range":[50,77]},{"type":"ReturnStatement","range":[51,77]}],
+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"},{"type":"Identifier","range":[4,5],"value":"v"},{"type":"Punctuator","range":[6,7],"value":"="},{"type":"Punctuator","range":[8,9],"value":"{"},{"type":"Identifier","range":[9,10],"value":"a"},{"type":"Identifier","range":[11,12],"value":"b"},{"type":"Punctuator","range":[12,13],"value":":"},{"type":"Punctuator","range":[13,14],"value":"{"},{"type":"Identifier","range":[14,16],"value":"cc"},{"type":"Punctuator","range":[16,17],"value":":"},{"type":"Numeric","range":[17,18],"value":"3"},{"type":"Punctuator","range":[18,19],"value":","},{"type":"Identifier","range":[20,22],"value":"dd"},{"type":"Punctuator","range":[22,23],"value":":"},{"type":"String","range":[23,28],"value":"'hey'"},{"type":"Identifier","range":[29,30],"value":"e"},{"type":"Punctuator","range":[30,31],"value":"}"},{"type":"Identifier","range":[32,33],"value":"c"},{"type":"Punctuator","range":[33,34],"value":":"},{"type":"Numeric","range":[34,35],"value":"2"},{"type":"Punctuator","range":[35,36],"value":"}"},{"type":"Punctuator","range":[36,37],"value":";"},{"type":"Keyword","range":[37,45],"value":"function"},{"type":"Identifier","range":[46,47],"value":"f"},{"type":"Punctuator","range":[47,48],"value":"("},{"type":"Punctuator","range":[48,49],"value":")"},{"type":"Punctuator","range":[50,51],"value":"{"},{"type":"Keyword","range":[51,57],"value":"return"},{"type":"Punctuator","range":[58,59],"value":"{"},{"type":"Identifier","range":[59,60],"value":"a"},{"type":"Identifier","range":[61,62],"value":"b"},{"type":"Punctuator","range":[62,63],"value":":"},{"type":"Punctuator","range":[63,64],"value":"{"},{"type":"Identifier","range":[64,66],"value":"cc"},{"type":"Punctuator","range":[66,67],"value":":"},{"type":"Numeric","range":[67,68],"value":"3"},{"type":"Punctuator","range":[68,69],"value":","},{"type":"Identifier","range":[70,72],"value":"dd"},{"type":"Punctuator","range":[72,73],"value":":"}],
+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token a","token":"a"},{"lineNumber":1,"index":28,"message":"Missing expected ','"},{"lineNumber":1,"index":29,"message":"Unexpected token e","token":"e"},{"lineNumber":1,"index":31,"message":"Missing expected ','"},{"lineNumber":1,"index":59,"message":"Unexpected token a","token":"a"},{"lineNumber":1,"index":72,"message":"Unexpected token :","token":":"},{"lineNumber":1,"index":77,"message":"Unexpected token ILLEGAL"}]
+ });
+ });
+
+ it('escaped literal recovery 6', function() {
+ runTest({
+ source: "var v = {a b:{cc:3, dd:'hey' e} c:2};function f() {return {a b:{cc:3, dd:'hey\\' e} c:2};}",
+ nodes: [{"type":"VariableDeclaration","kind":"var","range":[0,37]},{"type":"VariableDeclarator","range":[4,36]},{"type":"Identifier","name":"v","range":[4,5]},{"type":"ObjectExpression","range":[8,36]},{"type":"Property","kind":"init","range":[12,31]},{"type":"Identifier","name":"b","range":[12,12]},{"type":"ObjectExpression","range":[13,31]},{"type":"Property","kind":"init","range":[14,18]},{"type":"Identifier","name":"cc","range":[14,16]},{"type":"Literal","range":[17,18],"value":3},{"type":"Property","kind":"init","range":[20,28]},{"type":"Identifier","name":"dd","range":[20,22]},{"type":"Literal","range":[23,28],"value":"hey"},{"type":"Property","kind":"init","range":[32,35]},{"type":"Identifier","name":"c","range":[32,33]},{"type":"Literal","range":[34,35],"value":2},{"type":"FunctionDeclaration","range":[37,89]},{"type":"Identifier","name":"f","range":[46,47]},{"type":"BlockStatement","range":[50,89]},{"type":"ReturnStatement","range":[51,89]}],
+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"},{"type":"Identifier","range":[4,5],"value":"v"},{"type":"Punctuator","range":[6,7],"value":"="},{"type":"Punctuator","range":[8,9],"value":"{"},{"type":"Identifier","range":[9,10],"value":"a"},{"type":"Identifier","range":[11,12],"value":"b"},{"type":"Punctuator","range":[12,13],"value":":"},{"type":"Punctuator","range":[13,14],"value":"{"},{"type":"Identifier","range":[14,16],"value":"cc"},{"type":"Punctuator","range":[16,17],"value":":"},{"type":"Numeric","range":[17,18],"value":"3"},{"type":"Punctuator","range":[18,19],"value":","},{"type":"Identifier","range":[20,22],"value":"dd"},{"type":"Punctuator","range":[22,23],"value":":"},{"type":"String","range":[23,28],"value":"'hey'"},{"type":"Identifier","range":[29,30],"value":"e"},{"type":"Punctuator","range":[30,31],"value":"}"},{"type":"Identifier","range":[32,33],"value":"c"},{"type":"Punctuator","range":[33,34],"value":":"},{"type":"Numeric","range":[34,35],"value":"2"},{"type":"Punctuator","range":[35,36],"value":"}"},{"type":"Punctuator","range":[36,37],"value":";"},{"type":"Keyword","range":[37,45],"value":"function"},{"type":"Identifier","range":[46,47],"value":"f"},{"type":"Punctuator","range":[47,48],"value":"("},{"type":"Punctuator","range":[48,49],"value":")"},{"type":"Punctuator","range":[50,51],"value":"{"},{"type":"Keyword","range":[51,57],"value":"return"},{"type":"Punctuator","range":[58,59],"value":"{"},{"type":"Identifier","range":[59,60],"value":"a"},{"type":"Identifier","range":[61,62],"value":"b"},{"type":"Punctuator","range":[62,63],"value":":"},{"type":"Punctuator","range":[63,64],"value":"{"},{"type":"Identifier","range":[64,66],"value":"cc"},{"type":"Punctuator","range":[66,67],"value":":"},{"type":"Numeric","range":[67,68],"value":"3"},{"type":"Punctuator","range":[68,69],"value":","},{"type":"Identifier","range":[70,72],"value":"dd"},{"type":"Punctuator","range":[72,73],"value":":"},{"type":"String","range":[73,89],"value":"'hey\\' e} c:2};}"}],
+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token a","token":"a"},{"lineNumber":1,"index":28,"message":"Missing expected ','"},{"lineNumber":1,"index":29,"message":"Unexpected token e","token":"e"},{"lineNumber":1,"index":31,"message":"Missing expected ','"},{"lineNumber":1,"index":59,"message":"Unexpected token a","token":"a"},{"lineNumber":1,"index":89,"message":"Unexpected token ILLEGAL"},{"lineNumber":1,"index":89,"message":"Missing expected ','"},{"lineNumber":1,"index":89,"message":"Unexpected end of input"}]
+ });
+ });
+
+ it('escaped literal recovery 7', function() {
+ runTest({
+ source: "var v = {a b:{cc:3, dd:\\'hey' e} c:2};function f() {return {a b:{cc:3, dd:hey\\' e} c:2};}",
+ nodes: [],
+ tokens: [{"type":"Keyword","range":[0,3],"value":"var"},{"type":"Identifier","range":[4,5],"value":"v"},{"type":"Punctuator","range":[6,7],"value":"="},{"type":"Punctuator","range":[8,9],"value":"{"},{"type":"Identifier","range":[9,10],"value":"a"},{"type":"Identifier","range":[11,12],"value":"b"},{"type":"Punctuator","range":[12,13],"value":":"},{"type":"Punctuator","range":[13,14],"value":"{"},{"type":"Identifier","range":[14,16],"value":"cc"},{"type":"Punctuator","range":[16,17],"value":":"},{"type":"Numeric","range":[17,18],"value":"3"},{"type":"Punctuator","range":[18,19],"value":","},{"type":"Identifier","range":[20,22],"value":"dd"},{"type":"Punctuator","range":[22,23],"value":":"}],
+ errors: [{"lineNumber":1,"index":9,"message":"Unexpected token a","token":"a"},{"lineNumber":1,"index":22,"message":"Unexpected token :","token":":"}]
+ });
+ });
});
});
diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/finderTests.js b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/finderTests.js
index 2857806..92f1313 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/finderTests.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/js-tests/javascript/finderTests.js
@@ -211,6 +211,59 @@ define([
tearDown();
}
});
+
+ /**
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=427303
+ * @since 6.0
+ */
+ it('test_findNodeAndParents1', function() {
+ try {
+ editorContext.text = "function F1(p1, p2) {\n"+
+ "\tvar out = p1;\n"+
+ "};";
+ return astManager.getAST(editorContext).then(function(ast) {
+ var node = Finder.findNode(9, ast, {parents:true});
+ if(!node) {
+ assert.fail("Should have found a node");
+ }
+ else {
+ assert.equal(node.type, 'FunctionDeclaration', 'Should have found a FunctionDeclaration node');
+ assert.equal(node.parents.length, 1, 'Should have found one parent');
+ assert.equal(node.parents[0].type, 'Program', 'The program node should be the only parent');
+ }
+ });
+ }
+ finally {
+ tearDown();
+ }
+ });
+
+ /**
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=427303
+ * @since 6.0
+ */
+ it('test_findNodeAndParents2', function() {
+ try {
+ editorContext.text = "function F1(p1, p2) {\n"+
+ "\tvar out = p1;\n"+
+ "};";
+ return astManager.getAST(editorContext).then(function(ast) {
+ var node = Finder.findNode(14, ast, {parents:true});
+ if(!node) {
+ assert.fail("Should have found a node");
+ }
+ else {
+ assert.equal(node.type, 'Identifier', 'Should have found a Identifier node');
+ assert.equal(node.parents.length, 2, 'Should have found five parents');
+ assert.equal(node.parents[0].type, 'Program', 'Should have found the parent Program node as the first parent');
+ assert.equal(node.parents[1].type, 'FunctionDeclaration', 'Should have found the parent function decl as the second parent');
+ }
+ });
+ }
+ finally {
+ tearDown();
+ }
+ });
/**
* Find a token in a broken AST
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=426399
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js b/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js
index ab8dcce..77d4a5f 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js
@@ -12,11 +12,11 @@
/*global window define orion XMLHttpRequest confirm*/
/*jslint sub:true*/
-define(['i18n!orion/navigate/nls/messages', 'require', 'orion/webui/littlelib', 'orion/i18nUtil', 'orion/uiUtils', 'orion/fileUtils', 'orion/commands',
+define(['i18n!orion/navigate/nls/messages', 'require', 'orion/webui/littlelib', 'orion/i18nUtil', 'orion/uiUtils', 'orion/fileUtils', 'orion/commands', 'orion/fileDownloader',
'orion/commandRegistry', 'orion/extensionCommands', 'orion/contentTypes', 'orion/compare/compareUtils',
'orion/Deferred', 'orion/webui/dialogs/DirectoryPrompterDialog', 'orion/webui/dialogs/SFTPConnectionDialog',
'orion/EventTarget', 'orion/form'],
- function(messages, require, lib, i18nUtil, mUIUtils, mFileUtils, mCommands, mCommandRegistry, mExtensionCommands, mContentTypes, mCompareUtils, Deferred, DirPrompter, SFTPDialog, EventTarget, form){
+ function(messages, require, lib, i18nUtil, mUIUtils, mFileUtils, mCommands, mFileDownloader, mCommandRegistry, mExtensionCommands, mContentTypes, mCompareUtils, Deferred, DirPrompter, SFTPDialog, EventTarget, form){
/**
* Utility methods
@@ -759,6 +759,31 @@ define(['i18n!orion/navigate/nls/messages', 'require', 'orion/webui/littlelib',
});
commandService.addCommand(compareWithCommand);
+ var downloadSingleFileCommand = new mCommands.Command({
+ name : messages["Download"],
+ tooltip: messages["Download_tooltips"],
+ id: "eclipse.downloadSingleFile", //$NON-NLS-0$
+ visibleWhen: function(item) {
+ if (!explorer || !explorer.isCommandsVisible()) {
+ return false;
+ }
+ if (Array.isArray(item)) {
+ if(item.length === 1 && !item[0].Directory){
+ return true;
+ }
+ }
+ return false;
+ },
+ callback: function(data) {
+ var statusService = serviceRegistry.getService("orion.page.message"); //$NON-NLS-0$
+ var downloader = new mFileDownloader.FileDownloader(fileClient, statusService, progressService);
+ var items = Array.isArray(data.items) ? data.items : [data.items];
+ var contentType = contentTypeService.getFilenameContentType(items[0].Name);
+ downloader.downloadFromLocation(items[0], contentType);
+ }
+ });
+ commandService.addCommand(downloadSingleFileCommand);
+
var deleteCommand = new mCommands.Command({
name: messages["Delete"],
imageClass: "core-sprite-delete", //$NON-NLS-0$
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/fileDownloader.js b/bundles/org.eclipse.orion.client.ui/web/orion/fileDownloader.js
new file mode 100644
index 0000000..2bdd9ab
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/fileDownloader.js
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * @license
+ * Copyright (c) 2013, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+/*jslint browser:true devel:true sub:true*/
+/*global define window document URL*/
+define([
+ 'i18n!orion/navigate/nls/messages',
+ 'orion/i18nUtil',
+ 'orion/URL-shim'
+], function(messages, i18nUtil) {
+
+ var orion_download_initiator = document.createElementNS("http://www.w3.org/1999/xhtml", "a");
+
+ function downloadSupported() {
+ return (typeof orion_download_initiator.download !== "undefined") || (typeof window.navigator !== "undefined" && window.navigator.msSaveBlob);
+ }
+
+ function _makeError(error) {
+ var newError = {
+ Severity: "Error", //$NON-NLS-0$
+ Message: messages.noResponse
+ };
+ if (error.status === 0) {
+ return newError; // might do better here
+ } else if (error.responseText) {
+ var responseText = error.responseText;
+ try {
+ var parsedError = JSON.parse(responseText);
+ newError.Severity = parsedError.Severity || newError.Severity;
+ newError.Message = parsedError.Message || newError.Message;
+ } catch (e) {
+ newError.Message = responseText;
+ }
+ } else {
+ try {
+ newError.Message = JSON.stringify(error);
+ } catch (e) {
+ // best effort - fallthrough
+ }
+ }
+ return newError;
+ }
+
+ function handleError(statusService, error) {
+ if (!statusService) {
+ window.console.log(error);
+ return;
+ }
+ if (!error.Severity) {
+ error = _makeError(error);
+ }
+ statusService.setProgressResult(error);
+ }
+
+ /**
+ * @name orion.download.FileDownloader
+ * @class
+ * @description
+ * <p>Requires service {@link orion.core.ContentTypeRegistry}</p>
+ *
+ * @param {orion.fileClient.FileClient} [fileClient] The file client that supports readBlob API.
+ * @param {orion.status.StatusReportingService} [statusService=null] Optional. If defined status is reported while downloading.
+ * @param {orion.progress.ProgressService} [progressService=null] Optional. If defined progress is reported while downloading.
+ */
+ function FileDownloader(fileClient, statusService, progressService) {
+ this.fileClinet = fileClient;
+ this.statusService = statusService;
+ this.progressService = progressService;
+ }
+ FileDownloader.prototype = /** @lends orion.download.FileDownloader.prototype */ {
+ _isSupported: function(forceDownload) {
+ if(!forceDownload && !downloadSupported()) {
+ if(this.statusService && this.statusService.setProgressResult) {
+ this.statusService.setProgressResult({Message: messages["Download not supported"], Severity: "Error"});
+ }
+ return false;
+ }
+ return true;
+ },
+ downloadFromLocation: function(fileMetaData, contentType, forceDownload) {
+ if(!this._isSupported(forceDownload)) {
+ return;
+ }
+ var progressService = this.progressService;
+ var progress = function(deferred, msgKey, uri) {
+ if (!progressService) { return deferred; }
+ return progressService.progress(deferred, i18nUtil.formatMessage(msgKey, uri));
+ };
+ var errorHandler = function(error) {
+ //clearTimeout();
+ var statusService = null;
+ if(this.serviceRegistry) {
+ statusService = this.serviceRegistry.getService("orion.page.message"); //$NON-NLS-0$
+ } else if(this.statusService) {
+ statusService = this.statusService;
+ }
+ handleError(statusService, error);
+ this._setNoInput();
+ }.bind(this);
+ if(this.statusService && this.statusService.setProgressResult) {
+ this.statusService.setProgressResult({Message: messages["Downloading..."]});
+ }
+ progress(this.fileClinet.readBlob(fileMetaData.Location), messages["Downloading..."], fileMetaData.Location).then(function(contents) {
+ if(this.statusService && this.statusService.setProgressMessage) {
+ this.statusService.setProgressMessage("");
+ }
+ this.downloadFromBlob(contents, fileMetaData.Name, contentType, forceDownload);
+ }.bind(this), errorHandler);
+ },
+ downloadFromBlob: function(blobContents, fileName, contentType, forceDownload) {
+ if(!this._isSupported(forceDownload)) {
+ return;
+ }
+ var cType = (contentType && contentType.id) ? contentType.id : "application/octet-stream";
+ var blobObj, downloadLink = document.createElementNS("http://www.w3.org/1999/xhtml", "a"); //$NON-NLS-1$ //$NON-NLS-0$
+ if(typeof downloadLink.download !== "undefined") {//Chrome and FireFox
+ blobObj= new Blob([blobContents],{type: cType});
+ var objectURLLink = URL.createObjectURL(blobObj);
+ downloadLink.href = objectURLLink;
+ downloadLink.download = fileName;
+ var event = document.createEvent("MouseEvents");
+ event.initMouseEvent(
+ "click", true, false, window, 0, 0, 0, 0, 0
+ , false, false, false, false, 0, null
+ );
+ downloadLink.dispatchEvent(event);
+ } else if(typeof window.navigator !== "undefined" && window.navigator.msSaveOrOpenBlob) {//IE 9+
+ blobObj= new Blob([blobContents],{type: cType});
+ window.navigator.msSaveBlob(blobObj, fileName);
+ }
+ }
+ };
+ return {
+ FileDownloader: FileDownloader,
+ downloadSupported: downloadSupported
+ };
+});
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js b/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js
index 65972fd..fcd9f8e 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js
@@ -745,40 +745,53 @@ define([
commandRegistry.addCommand(openResourceCommand);
commandRegistry.registerCommandContribution("globalActions", "orion.openResource", 100, null, true, new KeyBinding.KeyBinding('f', true, true)); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
-
- // Toggle trim command
- var toggleBanner = new mCommands.Command({
- name: messages["Toggle banner and footer"],
- tooltip: messages["Hide or show the page banner and footer"],
- id: "orion.toggleTrim", //$NON-NLS-0$
- callback: function () {
- var header = lib.node("banner"); //$NON-NLS-0$
- var footer = lib.node("footer"); //$NON-NLS-0$
- var sideMenu = lib.node("sideMenu"); //$NON-NLS-0$
- var content = lib.$(".content-fixedHeight"); //$NON-NLS-0$
- var maximized = header.style.visibility === "hidden"; //$NON-NLS-0$
- if (maximized) {
- header.style.visibility = "visible"; //$NON-NLS-0$
- footer.style.visibility = "visible"; //$NON-NLS-0$
- content.classList.remove("content-fixedHeight-maximized"); //$NON-NLS-0$
- if (sideMenu) {
- sideMenu.classList.remove("sideMenu-maximized"); //$NON-NLS-0$
- }
- } else {
- header.style.visibility = "hidden"; //$NON-NLS-0$
- footer.style.visibility = "hidden"; //$NON-NLS-0$
- content.classList.add("content-fixedHeight-maximized"); //$NON-NLS-0$
- if (sideMenu) {
- sideMenu.classList.add("sideMenu-maximized"); //$NON-NLS-0$
- }
+ var noBanner = false;
+ var toggleBannerFunc = function () {
+ if (noBanner) {
+ return false;
+ }
+ var header = lib.node("banner"); //$NON-NLS-0$
+ var footer = lib.node("footer"); //$NON-NLS-0$
+ var sideMenu = lib.node("sideMenu"); //$NON-NLS-0$
+ var content = lib.$(".content-fixedHeight"); //$NON-NLS-0$
+ var maximized = header.style.visibility === "hidden"; //$NON-NLS-0$
+ if (maximized) {
+ header.style.visibility = "visible"; //$NON-NLS-0$
+ footer.style.visibility = "visible"; //$NON-NLS-0$
+ content.classList.remove("content-fixedHeight-maximized"); //$NON-NLS-0$
+ if (sideMenu) {
+ sideMenu.classList.remove("sideMenu-maximized"); //$NON-NLS-0$
+ }
+ } else {
+ header.style.visibility = "hidden"; //$NON-NLS-0$
+ footer.style.visibility = "hidden"; //$NON-NLS-0$
+ content.classList.add("content-fixedHeight-maximized"); //$NON-NLS-0$
+ if (sideMenu) {
+ sideMenu.classList.add("sideMenu-maximized"); //$NON-NLS-0$
}
- getGlobalEventTarget().dispatchEvent({type: "toggleTrim", maximized: !maximized}); //$NON-NLS-0$
- return true;
}
- });
- commandRegistry.addCommand(toggleBanner);
- commandRegistry.registerCommandContribution("globalActions", "orion.toggleTrim", 100, null, true, new KeyBinding.KeyBinding("m", true, true)); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ getGlobalEventTarget().dispatchEvent({type: "toggleTrim", maximized: !maximized}); //$NON-NLS-0$
+ return true;
+ };
+
+ var noTrim = window.orionNoTrim || false;
+ if (noTrim) {
+ toggleBannerFunc();
+ noBanner = true;
+ sideMenu.hideMenu();
+ } else {
+ // Toggle trim command
+ var toggleBanner = new mCommands.Command({
+ name: messages["Toggle banner and footer"],
+ tooltip: messages["Hide or show the page banner and footer"],
+ id: "orion.toggleTrim", //$NON-NLS-0$
+ callback: toggleBannerFunc
+ });
+ commandRegistry.addCommand(toggleBanner);
+ commandRegistry.registerCommandContribution("globalActions", "orion.toggleTrim", 100, null, true, new KeyBinding.KeyBinding("m", true, true)); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
+ }
+
// Open configuration page, Ctrl+Shift+F1
var configDetailsCommand = new mCommands.Command({
name: messages["System Configuration Details"],
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/navigate/nls/root/messages.js b/bundles/org.eclipse.orion.client.ui/web/orion/navigate/nls/root/messages.js
index 43221ee..60de166 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/navigate/nls/root/messages.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/navigate/nls/root/messages.js
@@ -113,5 +113,9 @@ define({
"Uploading the following file failed: ": "Uploading the following file failed: ",
"Enter project name:": "Enter project name:",
"Creating project ": "Creating project ",
- "NoFile": "Use the ${0} menu to create new files and folders. Click a file to start coding." //$NON-NLS-1$ //$NON-NLS-0$
+ "NoFile": "Use the ${0} menu to create new files and folders. Click a file to start coding.",
+ "Download": "Download",
+ "Download_tooltips": "Download the file contents as the displayed name",
+ "Downloading...": "Reading file contents...",
+ "Download not supported": "Contents export is not supported in this browser. Please use supported browsers such as Chrome, Firefox and Internet Explorer."
});
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/webui/SideMenu.js b/bundles/org.eclipse.orion.client.ui/web/orion/webui/SideMenu.js
index bf97837..c9dcd44 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/webui/SideMenu.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/webui/SideMenu.js
@@ -116,6 +116,10 @@ define([
pageContent.style.left = left;
}
},
+ hideMenu: function (){
+ localStorage.setItem(this.LOCAL_STORAGE_NAME, this.CLOSED_STATE);
+ this.setPageContentLeft("0"); //$NON-NLS-0$
+ },
toggleSideMenu: function(){
var sideMenuNavigation = this.getDisplayState();
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js
index 38ce5d2..1ebfa31 100644
--- a/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js
+++ b/bundles/org.eclipse.orion.client.ui/web/orion/widgets/nav/common-nav.js
@@ -289,8 +289,9 @@ define([
commandRegistry.registerCommandContribution(fileActionsScope, "orion.importSFTP", 3, "orion.menuBarFileGroup/orion.importGroup"); //$NON-NLS-1$ //$NON-NLS-0$
// Export actions
- commandRegistry.registerCommandContribution(fileActionsScope, "eclipse.downloadFile", 1, "orion.menuBarFileGroup/orion.exportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
- commandRegistry.registerCommandContribution(fileActionsScope, "eclipse.exportSFTPCommand", 2, "orion.menuBarFileGroup/orion.exportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(fileActionsScope, "eclipse.downloadSingleFile", 1, "orion.menuBarFileGroup/orion.exportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(fileActionsScope, "eclipse.downloadFile", 2, "orion.menuBarFileGroup/orion.exportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(fileActionsScope, "eclipse.exportSFTPCommand", 3, "orion.menuBarFileGroup/orion.exportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
// Edit actions
commandRegistry.registerCommandContribution(editActionsScope, "eclipse.renameResource", 1, "orion.menuBarEditGroup/orion.renameGroup", false, renameBinding); //$NON-NLS-1$ //$NON-NLS-0$
@@ -332,8 +333,9 @@ define([
commandRegistry.registerCommandContribution(contextMenuActionsScope, "orion.importZipURL", 2, "orion.commonNavContextMenuEditGroup/orion.ImportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
commandRegistry.registerCommandContribution(contextMenuActionsScope, "orion.importSFTP", 3, "orion.commonNavContextMenuEditGroup/orion.ImportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
- commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.downloadFile", 1, "orion.commonNavContextMenuEditGroup/orion.ExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
- commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.exportSFTPCommand", 2, "orion.commonNavContextMenuEditGroup/orion.ExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.downloadSingleFile", 1, "orion.commonNavContextMenuEditGroup/orion.ExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.downloadFile", 2, "orion.commonNavContextMenuEditGroup/orion.ExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
+ commandRegistry.registerCommandContribution(contextMenuActionsScope, "eclipse.exportSFTPCommand", 3, "orion.commonNavContextMenuEditGroup/orion.ExportGroup"); //$NON-NLS-1$ //$NON-NLS-0$
commandRegistry.addCommandGroup(viewActionsScope, "eclipse.openWith", 1000, messages["OpenWith"], "orion.menuBarViewGroup", null, null, null, "dropdownSelection"); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
commandRegistry.addCommandGroup(viewActionsScope, "eclipse.fileCommandExtensions", 1000, messages["OpenRelated"], "orion.menuBarViewGroup"); //$NON-NLS-1$ //$NON-NLS-0$
diff --git a/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js b/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js
index 1ad100a..c63c3fe 100644
--- a/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js
+++ b/bundles/org.eclipse.orion.client.ui/web/plugins/filePlugin/fileImpl.js
@@ -577,36 +577,40 @@ define(["orion/Deferred", "orion/xhr", "orion/URL-shim", "orion/operation", "ori
}
};
- function _call2(method, url, headers, body) {
- var d = new Deferred(); // create a promise
- var xhr = new XMLHttpRequest();
- try {
- xhr.open(method, cleanseUrl(url));
- if (headers) {
- Object.keys(headers).forEach(function(header){
- xhr.setRequestHeader(header, headers[header]);
- });
- }
- xhr.responseType = "arraybuffer";
- xhr.send(body);
- xhr.onload = function() {
- d.resolve({
- status: xhr.status,
- statusText: xhr.statusText,
- headers: xhr.getAllResponseHeaders(),
- response: xhr.response //builder.getBlob()
- });
- };
- } catch (e) {
- d.reject(e);
+ function _handleError(error) {
+ var errorMessage = "Unknown Error";
+ if(error.status && error.status === 404) {
+ errorMessage = "File not found.";
+ } else if (error.xhr && error.xhr.statusText){
+ errorMessage = error.xhr.statusText;
}
- return d; // return the promise immediately
+ var errorObj = {Severity: "Error", Message: errorMessage};
+ error.responseText = JSON.stringify(errorObj);
+ return new Deferred().reject(error);
+ }
+
+ function _call2(method, url, headerData, body) {
+ var options = {
+ //timeout: 15000,
+ responseType: "arraybuffer",
+ headers: headerData ? headerData : {"Orion-Version": "1"},
+ data: body,
+ log: false
+ };
+ return _xhr(method, url, options).then(function(result) {
+ return result.response;
+ }, function(error) { return _handleError(error);}).then(function(result) {
+ if (this.makeAbsolute) {
+ _normalizeLocations(result);
+ }
+ return result;
+ }.bind(this));
}
if (window.Blob) {
FileServiceImpl.prototype.readBlob = function(location) {
return _call2("GET", location).then(function(result) {
- return result.response;
+ return result;
});
};
diff --git a/bundles/org.eclipse.orion.client.webtools/bundle.properties b/bundles/org.eclipse.orion.client.webtools/bundle.properties
index f964a1f..2d05243 100644
--- a/bundles/org.eclipse.orion.client.webtools/bundle.properties
+++ b/bundles/org.eclipse.orion.client.webtools/bundle.properties
@@ -1,3 +1,12 @@
-#Properties file for org.eclipse.orion.client.javascript
-Bundle-Vendor = Eclipse.org
-Bundle-Name = Orion Web Tools \ No newline at end of file
+###############################################################################
+# Copyright (c) 2014 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+Bundle-Vendor = Eclipse.org - Orion
+Bundle-Name = Orion Client Web Tools \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/cssValidatorTests.js b/bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/cssValidatorTests.js
index 80ec3d7..54e6467 100644
--- a/bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/cssValidatorTests.js
+++ b/bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/cssValidatorTests.js
@@ -8,54 +8,47 @@
*
* Contributors: IBM Corporation - initial API and implementation
******************************************************************************/
-/*global console:true define*/
+/*jslint amd:true mocha:true*/
define([
'chai/chai',
'orion/Deferred',
- 'webtools/cssValidator'
-], function(chai, Deferred, CssValidator) {
- var assert = chai.assert;
+ 'webtools/cssValidator',
+ 'mocha/promocha'
+], function(chai, Deferred, CssValidator, mochapromise) {
+ var assert = chai.assert;
+// var it = mochapromise.it;
var validator = new CssValidator.CssValidator();
-
- var context = {
- text: "",
+
+ describe("CSS validator", function() {
+ var context = {
+ text: "",
+ /**
+ * gets the text
+ */
+ getText: function() {
+ return new Deferred().resolve(this.text);
+ }
+ };
+
/**
- * gets the text
+ * Resets the test state between runs
*/
- getText: function() {
- return new Deferred().resolve(this.text);
- }
- };
-
- /**
- * @name tearDown
- * @description Resets the test state between runs, must explicitly be called per-test
- * @function
- * @public
- */
- function tearDown() {
- context.text = "";
- }
-
- var Tests = {};
-
- /**
- * Tests a bad property decl
- */
- Tests.test_bad_prop1 = function() {
+ beforeEach(function() {
+ context.text = "";
+ });
+
+ /**
+ * Tests a bad property decl
+ */
+ it("should flag a bad property decl", function(/*done*/) {
context.text = "h1:{f: 22px}";
return validator.computeProblems(context).then(function(result) {
- try {
- var problems = result.problems;
- assert(problems != null, 'There should be CSS problems');
- assert(problems.length === 1, 'There should only be one CSS problem');
- assert.equal(problems[0].description, 'Unknown property \'f\'.', 'problem text is wrong');
- }
- finally {
- tearDown();
- }
+ assert.ok(false);
+ var problems = result.problems;
+ assert(problems != null, 'There should be CSS problems');
+ assert(problems.length === 1, 'There should only be one CSS problem');
+ assert.equal(problems[0].description, 'Unknown property \'f\'.', 'problem text is wrong');
});
- };
-
- return Tests;
+ });
+ });
}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/webtoolsMochaTests.html b/bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/webtoolsMochaTests.html
new file mode 100644
index 0000000..f66c01a
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.webtools/web/js-tests/webtools/webtoolsMochaTests.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Webtools Mocha Tests</title>
+ <link rel="stylesheet" href="../../mocha/mocha.css" />
+ <script src="../../requirejs/require.js"></script>
+ <script>
+ /*jslint amd:true*/
+ /*global mocha*/
+ require({
+ baseUrl: "../../",
+ paths: {
+ text: "requirejs/text",
+ i18n: "requirejs/i18n",
+ }
+ });
+ require(["mocha/mocha"], function() {
+ mocha.setup("bdd");
+ require([
+ "js-tests/webtools/cssValidatorTests"
+ ], function(){
+ mocha.run();
+ });
+ });
+ </script>
+</head>
+<body>
+ <h3>Webtools Mocha Tests</h3>
+ <div id="mocha"></div>
+</body>
+</html> \ No newline at end of file
diff --git a/features/org.eclipse.orion.client-feature/feature.xml b/features/org.eclipse.orion.client-feature/feature.xml
index 06348a2..cf95b53 100644
--- a/features/org.eclipse.orion.client-feature/feature.xml
+++ b/features/org.eclipse.orion.client-feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.orion.client.feature"
label="%featureName"
- version="2.0.0.qualifier"
+ version="6.0.0.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="1.0.0.qualifier">
diff --git a/features/org.eclipse.orion.client-feature/pom.xml b/features/org.eclipse.orion.client-feature/pom.xml
index 96d587e..f933b76 100644
--- a/features/org.eclipse.orion.client-feature/pom.xml
+++ b/features/org.eclipse.orion.client-feature/pom.xml
@@ -17,7 +17,7 @@
<groupId>org.eclipse.orion.feature</groupId>
<artifactId>org.eclipse.orion.client.feature</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>6.0.0-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
<parent>
@@ -26,4 +26,4 @@
<version>1.0.0-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
-</project> \ No newline at end of file
+</project>
diff --git a/pom.xml b/pom.xml
index 32c3eb9..9cb2ad8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,6 +9,7 @@
Contributors:
Matthias Sohn - initial implementation
+ IBM - Updated for Orion 6.0
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -56,13 +57,14 @@
<properties>
<orion-version>1.0.0-SNAPSHOT</orion-version>
- <tycho-version>0.18.1</tycho-version>
- <tycho-extras-version>0.18.1</tycho-extras-version>
+ <tycho-version>0.20.0</tycho-version>
+ <tycho-extras-version>0.20.0</tycho-extras-version>
<tycho.scmUrl>scm:git:http://git.eclipse.org/gitroot/orion/org.eclipse.orion.client.git</tycho.scmUrl>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <java-version>1.6</java-version>
+ <java-version>1.7</java-version>
<requirejsHome>${basedir}/target/requirejs/</requirejsHome>
<jsdocHome>${basedir}/target/jsdoc</jsdocHome>
+ <antrun-version>1.7</antrun-version>
</properties>
<distributionManagement>
@@ -122,7 +124,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
+ <version>3.1</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
@@ -221,14 +223,14 @@
<version>${tycho-version}</version>
<configuration>
<format>'v'yyyyMMdd-HHmm</format>
- <sourceReferences>
- <generate>true</generate>
- </sourceReferences>
+ <timestampProvider>jgit</timestampProvider>
+ <jgit.ignore>pom.xml</jgit.ignore>
+ <jgit.dirtyWorkingTree>warning</jgit.dirtyWorkingTree>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.tycho.extras</groupId>
- <artifactId>tycho-sourceref-jgit</artifactId>
+ <artifactId>tycho-buildtimestamp-jgit</artifactId>
<version>${tycho-extras-version}</version>
</dependency>
</dependencies>
@@ -244,7 +246,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
- <version>1.7</version>
+ <version>${antrun-version}</version>
</plugin>
</plugins>
</pluginManagement>