aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rennie2013-12-02 21:37:18 (EST)
committerGerrit Code Review @ Eclipse.org2013-12-03 13:08:06 (EST)
commitca4dba4ff46af26efa9776534dbfceda916cc179 (patch)
tree8ff2aac75f057db94bb3f21e2607fa3317b72ee4
parentd09b86b94457a23bae6210a911df8d5dee28917a (diff)
downloadorg.eclipse.orion.client-ca4dba4ff46af26efa9776534dbfceda916cc179.zip
org.eclipse.orion.client-ca4dba4ff46af26efa9776534dbfceda916cc179.tar.gz
org.eclipse.orion.client-ca4dba4ff46af26efa9776534dbfceda916cc179.tar.bz2
Bug 422994 - Use the Syntax.* values from estraverserefs/changes/30/19230/2
Change-Id: I0cd24727054a1dbd83220106979692c812645477 Signed-off-by: Mike Rennie <Michael_Rennie@ca.ibm.com>
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/occurrences.js43
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js24
2 files changed, 36 insertions, 31 deletions
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/occurrences.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/occurrences.js
index df73cc3..d7f8b7e 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/occurrences.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/occurrences.js
@@ -45,14 +45,14 @@ define([
*/
enter: function(node) {
switch(node.type) {
- case 'Program':
+ case Estraverse.Syntax.Program:
this.occurrences = [];
this.defscope = null;
this.defnode = null;
this.scopes.push({range: node.range});
break;
- case 'FunctionDeclaration':
+ case Estraverse.Syntax.FunctionDeclaration:
this.checkId(node.id, this.FUNCTION, true);
//we want the parent scope for a declaration, otherwise we leave it right away
this.scopes.push({range: node.range});
@@ -64,7 +64,7 @@ define([
}
}
break;
- case 'FunctionExpression':
+ case Estraverse.Syntax.FunctionExpression:
if (node.params) {
this.scopes.push({range: node.range});
for (var j = 0; j < node.params.length; j++) {
@@ -74,49 +74,49 @@ define([
}
}
break;
- case 'AssignmentExpression':
+ case Estraverse.Syntax.AssignmentExpression:
var leftNode = node.left;
this.checkId(leftNode);
- if (leftNode.type === 'MemberExpression') { //$NON-NLS-0$
+ if (leftNode.type === Estraverse.Syntax.MemberExpression) {
this.checkId(leftNode.object);
}
this.checkId(node.right);
break;
- case 'ArrayExpression':
+ case Estraverse.Syntax.ArrayExpression:
if (node.elements) {
for (var k = 0; k < node.elements.length; k++) {
this.checkId(node.elements[k]);
}
}
break;
- case 'MemberExpression':
+ case Estraverse.Syntax.MemberExpression:
this.checkId(node.object);
if (node.computed) { //computed = true for [], false for . notation
this.checkId(node.property);
}
break;
- case 'BinaryExpression':
+ case Estraverse.Syntax.BinaryExpression:
this.checkId(node.left);
this.checkId(node.right);
break;
- case 'UnaryExpression':
+ case Estraverse.Syntax.UnaryExpression:
this.checkId(node.argument);
break;
- case 'IfStatement':
+ case Estraverse.Syntax.IfStatement:
this.checkId(node.test);
break;
- case 'SwitchStatement':
+ case Estraverse.Syntax.SwitchStatement:
this.checkId(node.discriminant);
break;
- case 'UpdateExpression':
+ case Estraverse.Syntax.UpdateExpression:
this.checkId(node.argument);
break;
- case 'ConditionalExpression':
+ case Estraverse.Syntax.ConditionalExpression:
this.checkId(node.test);
this.checkId(node.consequent);
this.checkId(node.alternate);
break;
- case 'CallExpression':
+ case Estraverse.Syntax.CallExpression:
this.checkId(node.callee, this.FUNCTION, false);
if (node.arguments) {
for (var l = 0; l < node.arguments.length; l++) {
@@ -124,10 +124,10 @@ define([
}
}
break;
- case 'ReturnStatement':
+ case Estraverse.Syntax.ReturnStatement:
this.checkId(node.argument);
break;
- case 'ObjectExpression':
+ case Estraverse.Syntax.ObjectExpression:
if(node.properties) {
var len = node.properties.length;
for (var m = 0; m < len; m++) {
@@ -135,10 +135,10 @@ define([
}
}
break;
- case 'VariableDeclarator': //$NON-NLS-0$
+ case Estraverse.Syntax.VariableDeclarator:
this.checkId(node.id, this.GENERAL, true);
break;
- case 'NewExpression':
+ case Estraverse.Syntax.NewExpression:
this.checkId(node.callee, this.FUNCTION, false);
break;
}
@@ -153,7 +153,8 @@ define([
* @param {Object} node The AST node that ended its visitation
*/
leave: function(node) {
- if(node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') {
+ if(node.type === Estraverse.Syntax.FunctionDeclaration ||
+ node.type === Estraverse.Syntax.FunctionExpression) {
//if we leave the defining scope
var scope = this.scopes.pop();
if(this.defscope) {
@@ -189,7 +190,7 @@ define([
* @returns {Boolean} <code>true</code> if we should skip the next nodes, <code>false</code> otherwise
*/
checkId: function(node, kind, candefine) {
- if (node && node.type === 'Identifier') { //$NON-NLS-0$
+ if (node && node.type === Estraverse.Syntax.Identifier) {
if (node.name === this.context.word) {
if(candefine) {
if(this.defscope && this.defnode) {
@@ -293,4 +294,4 @@ define([
return {
JavaScriptOccurrences: JavaScriptOccurrences
};
-}); \ No newline at end of file
+});
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 014ca2e..5b59f2a 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js
@@ -42,20 +42,20 @@ define([
enter: function(node) {
var item;
var that = this;
- if(node.type === 'FunctionDeclaration') {
+ if(node.type === Estraverse.Syntax.FunctionDeclaration) {
item = this.addElement(Signatures.computeSignature(node));
if(item) {
this.scope.push(item);
}
}
- else if(node.type === 'FunctionExpression') {
+ else if(node.type === Estraverse.Syntax.FunctionExpression) {
item = this.addElement(Signatures.computeSignature(node));
if(item) {
this.scope.push(item);
}
delete node.sig;
}
- else if(node.type === 'ObjectExpression') {
+ else if(node.type === Estraverse.Syntax.ObjectExpression) {
item = this.addElement(Signatures.computeSignature(node));
if(item) {
this.scope.push(item);
@@ -64,7 +64,8 @@ define([
if(node.properties) {
node.properties.forEach(function(property) {
if(property.value) {
- if(property.value.type === 'FunctionExpression' || property.value.type === 'ObjectExpression') {
+ if(property.value.type === Estraverse.Syntax.FunctionExpression ||
+ property.value.type === Estraverse.Syntax.ObjectExpression) {
property.value.sig = Signatures.computeSignature(property);
}
else {
@@ -74,20 +75,21 @@ define([
});
}
}
- else if(node.type === 'VariableDeclaration') {
+ else if(node.type === Estraverse.Syntax.VariableDeclaration) {
if(node.declarations) {
node.declarations.forEach(function(declaration) {
if(declaration.init) {
- if(declaration.init.type === 'ObjectExpression') {
+ if(declaration.init.type === Estraverse.Syntax.ObjectExpression) {
declaration.init.sig = Signatures.computeSignature(declaration);
}
}
});
}
}
- else if(node.type === 'AssignmentExpression') {
+ else if(node.type === Estraverse.Syntax.AssignmentExpression) {
if(node.left && node.right) {
- if(node.right.type === 'ObjectExpression' || node.right.type === 'FunctionExpression') {
+ if(node.right.type === Estraverse.Syntax.ObjectExpression ||
+ node.right.type === Estraverse.Syntax.FunctionExpression) {
node.right.sig = Signatures.computeSignature(node);
}
}
@@ -103,7 +105,9 @@ define([
* @param {Object} node The AST node that ended its visitation
*/
leave: function(node) {
- if(node.type === 'ObjectExpression' || node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression') {
+ if(node.type === Estraverse.Syntax.ObjectExpression ||
+ node.type === Estraverse.Syntax.FunctionDeclaration ||
+ node.type === Estraverse.Syntax.FunctionExpression) {
this.scope.pop();
}
},
@@ -202,4 +206,4 @@ define([
return {
JSOutliner: JSOutliner
};
-}); \ No newline at end of file
+});