aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rennie2013-11-25 11:34:32 (EST)
committerGerrit Code Review @ Eclipse.org2013-11-25 13:36:16 (EST)
commit51b044d2d0b38ebc17b5ae0e7eabdc614994eae3 (patch)
treeb1ef1962e5464951cd77fb95a3225a87da210404
parent4116b680a2f56158a552686358315d2ec0166157 (diff)
downloadorg.eclipse.orion.client-51b044d2d0b38ebc17b5ae0e7eabdc614994eae3.zip
org.eclipse.orion.client-51b044d2d0b38ebc17b5ae0e7eabdc614994eae3.tar.gz
org.eclipse.orion.client-51b044d2d0b38ebc17b5ae0e7eabdc614994eae3.tar.bz2
Bug 422492 - Outliner gets scoping confused for object expressionsv20131125-1836refs/changes/37/18837/2
Change-Id: Ib8b809dad8a1a4598a7213b491dbf7097031e9a4 Signed-off-by: Mike Rennie <Michael_Rennie@ca.ibm.com>
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js39
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/signatures.js3
2 files changed, 14 insertions, 28 deletions
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 3011e0f..85d95ce 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js
@@ -49,37 +49,23 @@ define([
}
}
else if(node.type === 'FunctionExpression') {
- if(!node.seen) {
- item = this.addElement(Signatures.computeSignature(node));
- if(item) {
- this.scope.push(item);
- }
- }
- else {
- //scrub the flag from the AST node
- delete node.seen;
+ item = this.addElement(Signatures.computeSignature(node));
+ if(item) {
+ this.scope.push(item);
}
+ delete node.sig;
}
else if(node.type === 'ObjectExpression') {
- if(!node.seen) {
- item = this.addElement(Signatures.computeSignature(node));
- if(item) {
- this.scope.push(item);
- }
- }
- else {
- //scrub the flag from the AST node
- delete node.seen;
+ item = this.addElement(Signatures.computeSignature(node));
+ if(item) {
+ this.scope.push(item);
}
+ delete node.sig;
if(node.properties) {
node.properties.forEach(function(property) {
if(property.value) {
if(property.value.type === 'FunctionExpression' || property.value.type === 'ObjectExpression') {
- item = that.addElement(Signatures.computeSignature(property));
- if(item) {
- that.scope.push(item);
- }
- property.value.seen = 1;
+ property.value.sig = Signatures.computeSignature(property);
}
else {
that.addElement(Signatures.computeSignature(property));
@@ -93,11 +79,7 @@ define([
node.declarations.forEach(function(declaration) {
if(declaration.init) {
if(declaration.init.type === 'ObjectExpression') {
- item = that.addElement(Signatures.computeSignature(declaration));
- if(item) {
- that.scope.push(item);
- }
- declaration.init.seen = 1;
+ declaration.init.sig = Signatures.computeSignature(declaration);
}
}
});
@@ -126,6 +108,7 @@ define([
* @private
* @memberof javascript.Visitor.prototype
* @param {Object} sig The signature object
+ * @param {Boolean} seen If the element has been seen before, if so do not add it to the outline
*/
addElement: function(sig) {
if(sig) {
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 4e2e98e..4f7764f 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/signatures.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/signatures.js
@@ -27,6 +27,9 @@ define([
*/
computeSignature: function(astnode) {
if(astnode) {
+ if(astnode.sig) {
+ return astnode.sig;
+ }
var val = this.getNameFrom(astnode);
return {
sig: val,