aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rennie2013-12-16 23:30:09 (EST)
committerGerrit Code Review @ Eclipse.org2013-12-17 11:21:37 (EST)
commit38dcc66b705f837637adb0ad20ac1e652aa0a2e9 (patch)
tree8c3eedb5e84e54275ced09529b4bfde5a387dd9c
parent5a451bd6d2f65e7ff8c17465247cde1afab45008 (diff)
downloadorg.eclipse.orion.client-38dcc66b705f837637adb0ad20ac1e652aa0a2e9.zip
org.eclipse.orion.client-38dcc66b705f837637adb0ad20ac1e652aa0a2e9.tar.gz
org.eclipse.orion.client-38dcc66b705f837637adb0ad20ac1e652aa0a2e9.tar.bz2
Bug 424149 - String identifiers in object expressions are failingrefs/changes/89/19889/2
signature resultion Change-Id: Ib229b0146bd09554659f81e146c85f614ad92245 Signed-off-by: Mike Rennie <Michael_Rennie@ca.ibm.com>
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/signatures.js27
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/js-tests/outlinerTests.js72
2 files changed, 93 insertions, 6 deletions
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/signatures.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/signatures.js
index 0b3ac56..94ed9cc 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/signatures.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/signatures.js
@@ -113,8 +113,13 @@ define([
else if(astnode.type === 'Property') {
if(astnode.value) {
if(astnode.value.type === 'FunctionExpression') {
- if(astnode.key && astnode.key.name) {
- name = astnode.key.name + '(';
+ if(astnode.key) {
+ if(astnode.key.name) {
+ name = astnode.key.name + '(';
+ }
+ else if(astnode.key.value) {
+ name = astnode.key.value + '(';
+ }
}
else {
name = 'function(';
@@ -126,12 +131,22 @@ define([
name += ')';
}
else if(astnode.value.type === 'ObjectExpression') {
- if(astnode.key && astnode.key.name) {
- name = astnode.key.name + ' {...}';
+ if(astnode.key) {
+ if(astnode.key.name) {
+ name = astnode.key.name + ' {...}';
+ }
+ else if(astnode.key.value) {
+ name = astnode.key.value + ' {...}';
+ }
}
}
- else if(astnode.key && astnode.key.name) {
- name = astnode.key.name;
+ else if(astnode.key) {
+ if(astnode.key.name) {
+ name = astnode.key.name;
+ }
+ else if(astnode.key.value) {
+ name = astnode.key.value;
+ }
}
}
}
diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/outlinerTests.js b/bundles/org.eclipse.orion.client.javascript/web/js-tests/outlinerTests.js
index 8f8b28e..42b53a6 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/outlinerTests.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/js-tests/outlinerTests.js
@@ -124,6 +124,78 @@ define([
}
});
};
+
+ /**
+ * Tests an object property that is a literal wwhose value is a function
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424149
+ */
+ Tests.test_objproperty_literal1 = function() {
+ context.text = "var obj = {\n"+
+ "\t\"item\": function(p1, p2) {}\n"+
+ "};";
+ return outliner.computeOutline(context).then(function(outline) {
+ try {
+ if(!outline || outline.length < 1) {
+ Assert.fail("There should be one outline element");
+ }
+ if(!outline[0].children || outline[0].children.length < 1) {
+ Assert.fail("There should be one child outline element");
+ }
+ assertElement(outline[0].children[0], "item(p1, p2)", 13, 19);
+ }
+ finally {
+ tearDown();
+ }
+ });
+ };
+
+ /**
+ * Tests an object property that is a literal whose value has not been set
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424149
+ */
+ Tests.test_objproperty_literal2 = function() {
+ context.text = "var obj = {\n"+
+ "\t\"item\": null\n"+
+ "};";
+ return outliner.computeOutline(context).then(function(outline) {
+ try {
+ if(!outline || outline.length < 1) {
+ Assert.fail("There should be one outline element");
+ }
+ if(!outline[0].children || outline[0].children.length < 1) {
+ Assert.fail("There should be one child outline element");
+ }
+ assertElement(outline[0].children[0], "item", 13, 19);
+ }
+ finally {
+ tearDown();
+ }
+ });
+ };
+
+ /**
+ * Tests an object property that is a literal whose value is another object expression
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424149
+ */
+ Tests.test_objproperty_literal3 = function() {
+ context.text = "var obj = {\n"+
+ "\t\"item\": {}\n"+
+ "};";
+ return outliner.computeOutline(context).then(function(outline) {
+ try {
+ if(!outline || outline.length < 1) {
+ Assert.fail("There should be one outline element");
+ }
+ if(!outline[0].children || outline[0].children.length < 1) {
+ Assert.fail("There should be one child outline element");
+ }
+ assertElement(outline[0].children[0], "item {...}", 13, 19);
+ }
+ finally {
+ tearDown();
+ }
+ });
+ };
return Tests;
}); \ No newline at end of file