add isDirective method,

This commit is contained in:
Sebastian McKenzie 2015-06-13 02:21:22 +01:00
parent 844c10cac0
commit b5b6bf4ad5

View File

@ -146,6 +146,18 @@ export function isCompletionRecord(allowInsideFunction?) {
return true; return true;
} }
/**
* Description
*/
export function isDirective() {
if (this.isExpressionStatement()) {
return this.get("expression").isLiteral();
} else {
return this.isLiteral() && this.parentPath.isExpressionStatement();
}
}
/** /**
* Check whether or not the current `key` allows either a single statement or block statement * Check whether or not the current `key` allows either a single statement or block statement
* so we can explode it if necessary. * so we can explode it if necessary.
@ -229,7 +241,7 @@ export function getSource() {
* Description * Description
*/ */
export function willIMaybeExecutesBefore(target) { export function willIMaybeExecuteBefore(target) {
return this._guessExecutionStatusRelativeTo(target) !== "after"; return this._guessExecutionStatusRelativeTo(target) !== "after";
} }
@ -249,6 +261,8 @@ export function _guessExecutionStatusRelativeTo(target) {
} }
var targetPaths = getAncestry(target); var targetPaths = getAncestry(target);
//if (targetPaths.indexOf(this) >= 0) return "after";
var selfPaths = getAncestry(this); var selfPaths = getAncestry(this);
// get ancestor where the branches intersect // get ancestor where the branches intersect
@ -281,7 +295,7 @@ export function _guessExecutionStatusRelativeTo(target) {
// otherwise we're associated by a parent node, check which key comes before the other // otherwise we're associated by a parent node, check which key comes before the other
var targetKeyPosition = t.VISITOR_KEYS[targetRelationship.type].indexOf(targetRelationship.key); var targetKeyPosition = t.VISITOR_KEYS[targetRelationship.type].indexOf(targetRelationship.key);
var selfKeyPosition = t.VISITOR_KEYS[selfRelationship.type].indexOf(selfRelationship.key); var selfKeyPosition = t.VISITOR_KEYS[selfRelationship.type].indexOf(selfRelationship.key);
return targetKeyPosition > selfKeyPosition ? "before" : "after"; return targetKeyPosition > selfKeyPosition ? "before" : "after";
} }