/*
 * Validator for AST nodes
 * @lastmodifiedBy ChengFuLin(chengfulin0806@gmail.com)
 * @lastmodifiedDate 2015-08-03
 */
function ASTValidator() {
}

Object.defineProperties(ASTValidator, {
	/**
	 * Default option object for AST parser
	 * @type {Object}
	 * @memberof ASTValidator
	 * @constant
	 */
	DEFAULT_OPTION_OBJECT: {
		value: {
			range: true,
			loc: true
		},
		enumerable: true
	}
});

/**
 * Check for the node is a valid AST node or not
 * @param   {Object}  node      AST node
 * @param   {Object}  [options] Option object
 * @returns {boolean} True if it's valid, false otherwise
 */
ASTValidator.prototype.check = function (node, options) {
    'use strict';
	var opt = options || ASTValidator.DEFAULT_OPTION_OBJECT;
    return (!!node.type) && ((!opt.range)? true : node.range) && ((!opt.loc)? true : node.loc);
};

/**
 * Validate for the object is an AST node or not
 * @param {Object} node    AST node
 * @param {Object} options Option object
 * @param {string} msg     Custom error message
 * @throws "Not an AST node"
 */
ASTValidator.prototype.validate = function (node, options, msg) {
    'use strict';
    if (!this.check(node, options)) {
        throw new Error(msg || 'Not an AST node');
    }
};

/**
 * Check for the AST node is a root of a page
 * @param   {Object}    node   AST node
 * @returns {boolean}   True, if it is; false, otherwise
 */
ASTValidator.prototype.isPageAST = function (node) {
	"use strict";
	return this.check(node) && node.type === 'Program';
};

/**
 * Check if the AST node is for a named function
 * @param   {Object}    node An AST node
 * @returns {boolean}   True, if it is; false, otherwise
 */
ASTValidator.prototype.isFunctionAST = function (node) {
	"use strict";
	return this.check(node) && node.type === 'FunctionDeclaration';
};

/**
 * Check if the AST node is for an anonymous function
 * @param   {Object}    node An AST node
 * @returns {boolean}   True, if it is; false, otherwise
 */
ASTValidator.prototype.isAnonymousFunctionAST = function (node) {
	"use strict";
	return this.check(node) && node.type === 'FunctionExpression';
};

var validator = new ASTValidator();
module.exports = validator;

@@ -2104,16 +2104,1292 @@
 n';%0A%7D;%0A%0A
+/**%0A * Validate the node is an AST of a page scope or not%0A * @param   %7BObject%7D    node    An AST node%0A * @param   %7Bstring%7D    msg     Custom error message%0A * @throws  %22Not an AST of a page scope%22 %7C Custom error message%0A */%0AASTValidator.prototype.validatePageAST = function (node, msg) %7B%0A%09%22use strict%22;%0A%09if (!this.isPageAST(node)) %7B%0A%09%09throw new Error(msg %7C%7C 'Not an AST of a page scope');%0A%09%7D%0A%7D;%0A%0A/**%0A * Validate the node is an AST of a function scope or not%0A * @param   %7BObject%7D    node    An AST node%0A * @param   %7Bstring%7D    msg     Custom error message%0A * @throws  %22Not an AST of a function scope%22 %7C Custom error message%0A */%0AASTValidator.prototype.validateFunctionAST = function (node, msg) %7B%0A%09%22use strict%22;%0A%09if (!this.isFunctionAST(node)) %7B%0A%09%09throw new Error(msg %7C%7C 'Not an AST of a function scope');%0A%09%7D%0A%7D;%0A%0A/**%0A * Validate the node is an AST of an anonymous function scope or not%0A * @param   %7BObject%7D    node    An AST node%0A * @param   %7Bstring%7D    msg     Custom error message%0A * @throws  %22Not an AST of an anonymous function scope%22 %7C Custom error message%0A */%0AASTValidator.prototype.validateAnonymousFunctionAST = function (node, msg) %7B%0A%09%22use strict%22;%0A%09if (!this.isAnonymousFunctionAST(node)) %7B%0A%09%09throw new Error(msg %7C%7C 'Not an AST of an anonymous function scope');%0A%09%7D%0A%7D;%0A%0A
 var vali

Fix the bug of methods, validateFunctionAST and validateAnonymousFunctionAST