Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 238390 Details for
Bug 424202
Improve naming of return statements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
fix
org.eclipse.orion.client.outline.return.patch (text/plain), 7.80 KB, created by
Michael Rennie
on 2013-12-17 00:35:20 EST
(
hide
)
Description:
fix
Filename:
MIME Type:
Creator:
Michael Rennie
Created:
2013-12-17 00:35:20 EST
Size:
7.80 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js >index 964c374..bf1c409 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js >@@ -94,6 +94,14 @@ > } > } > } >+ else if(node.type === Estraverse.Syntax.ReturnStatement) { >+ if(node.argument) { >+ if(node.argument.type === Estraverse.Syntax.ObjectExpression || >+ node.argument.type === Estraverse.Syntax.FunctionExpression) { >+ node.argument.sig = Signatures.computeSignature(node); >+ } >+ } >+ } > }, > > /** >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 94ed9cc..f6cdd94 100644 >--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/signatures.js >+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/signatures.js >@@ -202,6 +202,14 @@ > } > } > } >+ else if(astnode.type === 'ReturnStatement') { >+ if(astnode.argument) { >+ if(astnode.argument.type === 'ObjectExpression' || >+ astnode.argument.type === 'FunctionExpression') { >+ name = 'return {...}'; >+ } >+ } >+ } > } > return name; > }, >@@ -258,6 +266,10 @@ > range = astnode.key.range; > } > } >+ else if(astnode.type === 'ReturnStatement') { >+ range[0] = astnode.range[0]; >+ range[1] = range[0] + 6; >+ } > else if(astnode.id && astnode.id.range) { > range = astnode.id.range; > } >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 42b53a6..1330be6 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 >@@ -196,6 +196,190 @@ > } > }); > }; >+ >+ /** >+ * 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(); >+ } >+ }); >+ }; >+ >+ /** >+ * Tests a return statement that is an object expression >+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424202 >+ */ >+ Tests.test_returnobj1 = function() { >+ context.text = "function f1() {\n"+ >+ "\t return {};\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], "return {...}", 18, 24); >+ } >+ finally { >+ tearDown(); >+ } >+ }); >+ }; >+ >+ /** >+ * Tests a return statement that is an function expression >+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424202 >+ */ >+ Tests.test_returnobj2 = function() { >+ context.text = "function f1() {\n"+ >+ "\t return function() {};\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], "return {...}", 18, 24); >+ } >+ finally { >+ tearDown(); >+ } >+ }); >+ }; >+ >+ /** >+ * Tests a return statement that is an object expression >+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424202 >+ */ >+ Tests.test_returnobj3 = function() { >+ context.text = "function f1() {\n"+ >+ "\t return {\n"+ >+ "\t\tf1: function() {return {};}"+ >+ "\t};"+ >+ "};"; >+ 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 level one child outline element"); >+ } >+ if(!outline[0].children[0].children || outline[0].children[0].children.length < 1) { >+ Assert.fail("There should be one level two child outline element"); >+ } >+ if(!outline[0].children[0].children[0].children || outline[0].children[0].children[0].children.length < 1) { >+ Assert.fail("There should be one level three child outline element"); >+ } >+ assertElement(outline[0].children[0].children[0].children[0], "return {...}", 45, 51); >+ } >+ finally { >+ tearDown(); >+ } >+ }); >+ }; >+ >+ /** >+ * Tests a return statement that is an object expression >+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=424202 >+ */ >+ Tests.test_returnobj4 = function() { >+ context.text = "function f1() {\n"+ >+ "\t return {\n"+ >+ "\t\tf1: function() {return function() {};}"+ >+ "\t};"+ >+ "};"; >+ 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 level one child outline element"); >+ } >+ if(!outline[0].children[0].children || outline[0].children[0].children.length < 1) { >+ Assert.fail("There should be one level two child outline element"); >+ } >+ if(!outline[0].children[0].children[0].children || outline[0].children[0].children[0].children.length < 1) { >+ Assert.fail("There should be one level three child outline element"); >+ } >+ assertElement(outline[0].children[0].children[0].children[0], "return {...}", 45, 51); >+ } >+ finally { >+ tearDown(); >+ } >+ }); >+ }; > > return Tests; > }); >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 424202
: 238390