function collectShortcuts(body) {

	function checkAssignment(name, valueNode) {
		if ( valueNode.type === Syntax.Literal ) {
			currentModule.localNames[name] = {
				value: valueNode.value,
				raw: valueNode.raw
			};
			debug("compile time constant found ", name, valueNode.value);
		} else if ( valueNode.type === Syntax.MemberExpression ) {
			const _import = getLeftmostName(valueNode);
			const local = _import && currentModule.localNames[_import];
			if ( typeof local === 'object' && local.module ) {
				currentModule.localNames[name] = {
					module: local.module,
					path: getObjectName(valueNode).split('.').slice(1).join('.') // TODO chaining if local has path
				};
				debug(`  found local shortcut: ${name} ${currentModule.localNames[name]}`);
			}
		} else if ( isRequireSyncCall(valueNode) || isProbingRequireCall(valueNode) ) {
			if ( valueNode.arguments[0]
				 && valueNode.arguments[0].type === Syntax.Literal
				 && typeof valueNode.arguments[0].value === 'string' ) {
				currentModule.localNames[name] = {
					module: valueNode.arguments[0].value
					// no (or empty) path
				};
				debug(`  found local import: ${name} = ${valueNode.callee.property.name}('${valueNode.arguments[0].value}')`);
			}
		} else if ( isExtendCall(valueNode) ) {
			currentModule.localNames[name] = {
				"class": valueNode.arguments[0].value
				// no (or empty) path
			};
			debug(`  found local class definition: ${name} = .extend('${valueNode.arguments[0].value}', ...)`);
		}
	}

	if ( body.type === Syntax.BlockStatement ) {
		body.body.forEach(function ( stmt ) {
			// console.log(stmt);
			if ( stmt.type === Syntax.FunctionDeclaration ) {
				if ( stmt.id && stmt.id.type === Syntax.Identifier && stmt.loc && stmt.loc.start ) {
					const loc = stmt.loc.start.line + ":" + stmt.loc.start.column;
					currentModule.localNamesByLoc[loc] =
					currentModule.localNames[stmt.id.name] = {
						"function": stmt
					};
				}
			} else if ( stmt.type === Syntax.VariableDeclaration ) {
				stmt.declarations.forEach((decl) => {
					if ( decl.init ) {
						checkAssignment(decl.id.name, decl.init);
					}
				});
			} else if ( stmt.type === Syntax.ExpressionStatement
						&& stmt.expression.type === Syntax.AssignmentExpression
						&& stmt.expression.left.type === Syntax.Identifier ) {
				checkAssignment(stmt.expression.left.name, stmt.expression.right);
			} else if ( stmt.type === Syntax.ReturnStatement ) {
				if ( stmt.argument && stmt.argument.type === Syntax.Identifier ) {
					currentModule.defaultExport = stmt.argument.name;
				} else if ( stmt.argument && isExtendCall(stmt.argument) ) {
					debug(`  found default export class definition: return .extend('${stmt.argument.arguments[0].value}', ...)`);
					currentModule.defaultExportClass = stmt.argument.arguments[0].value;
				}
			}
		});
	}

	if ( currentModule.defaultExport && currentModule.localNames[currentModule.defaultExport] ) {
		currentModule.localNames[currentModule.defaultExport].export = "";
	}
}
/**
 * Searches the given body for variable declarations that can be evaluated statically,
 * either because they refer to known AMD module imports (e.g. shortcut variables)
 * or because they have a (design time) constant value.
 *
 * @param {ASTNode} body AST node of a function body that shall be searched for shortcuts
 */
Searches the given body for variable declarations that can be evaluated statically,
either because they refer to known AMD module imports
or because they have a (design time) constant value.

@param {ASTNode} body AST node of a function body that shall be searched for shortcuts
Searches the given body for variable declarations that can be evaluated statically either because they refer to known AMD module imports or because they have a ( design time ) constant value . @param { ASTNode } body AST node of a function body that shall be searched for shortcuts
function collectShortcuts(body) {
	function checkAssignment(name, valueNode) {
		if ( valueNode.type === Syntax.Literal ) {
			currentModule.localNames[name] = {
				value: valueNode.value,
				raw: valueNode.raw
			};
			debug("compile time constant found ", name, valueNode.value);
		} else if ( valueNode.type === Syntax.MemberExpression ) {
			const _import = getLeftmostName(valueNode);
			const local = _import && currentModule.localNames[_import];
			if ( typeof local === 'object' && local.module ) {
				currentModule.localNames[name] = {
					module: local.module,
					path: getObjectName(valueNode).split('.').slice(1).join('.') 
				};
				debug(`  found local shortcut: ${name} ${currentModule.localNames[name]}`);
			}
		} else if ( isRequireSyncCall(valueNode) || isProbingRequireCall(valueNode) ) {
			if ( valueNode.arguments[0]
				 && valueNode.arguments[0].type === Syntax.Literal
				 && typeof valueNode.arguments[0].value === 'string' ) {
				currentModule.localNames[name] = {
					module: valueNode.arguments[0].value
				};
				debug(`  found local import: ${name} = ${valueNode.callee.property.name}('${valueNode.arguments[0].value}')`);
			}
		} else if ( isExtendCall(valueNode) ) {
			currentModule.localNames[name] = {
				"class": valueNode.arguments[0].value
			};
			debug(`  found local class definition: ${name} = .extend('${valueNode.arguments[0].value}', ...)`);
		}
	}
	if ( body.type === Syntax.BlockStatement ) {
		body.body.forEach(function ( stmt ) {
			if ( stmt.type === Syntax.FunctionDeclaration ) {
				if ( stmt.id && stmt.id.type === Syntax.Identifier && stmt.loc && stmt.loc.start ) {
					const loc = stmt.loc.start.line + ":" + stmt.loc.start.column;
					currentModule.localNamesByLoc[loc] =
					currentModule.localNames[stmt.id.name] = {
						"function": stmt
					};
				}
			} else if ( stmt.type === Syntax.VariableDeclaration ) {
				stmt.declarations.forEach((decl) => {
					if ( decl.init ) {
						checkAssignment(decl.id.name, decl.init);
					}
				});
			} else if ( stmt.type === Syntax.ExpressionStatement
						&& stmt.expression.type === Syntax.AssignmentExpression
						&& stmt.expression.left.type === Syntax.Identifier ) {
				checkAssignment(stmt.expression.left.name, stmt.expression.right);
			} else if ( stmt.type === Syntax.ReturnStatement ) {
				if ( stmt.argument && stmt.argument.type === Syntax.Identifier ) {
					currentModule.defaultExport = stmt.argument.name;
				} else if ( stmt.argument && isExtendCall(stmt.argument) ) {
					debug(`  found default export class definition: return .extend('${stmt.argument.arguments[0].value}', ...)`);
					currentModule.defaultExportClass = stmt.argument.arguments[0].value;
				}
			}
		});
	}
	if ( currentModule.defaultExport && currentModule.localNames[currentModule.defaultExport] ) {
		currentModule.localNames[currentModule.defaultExport].export = "";
	}
}
function collectShortcuts ( body ) { function checkAssignment ( name , valueNode ) { if ( valueNode . type === Syntax . Literal ) { currentModule . localNames [ name ] = { value : valueNode . value , raw : valueNode . raw } ; debug ( "compile time constant found " , name , valueNode . value ) ; } else if ( valueNode . type === Syntax . MemberExpression ) { const _import = getLeftmostName ( valueNode ) ; const local = _import && currentModule . localNames [ _import ] ; if ( typeof local === 'object' && local . module ) { currentModule . localNames [ name ] = { module : local . module , path : getObjectName ( valueNode ) . split ( '.' ) . slice ( 1 ) . join ( '.' ) } ; debug ( ` ${ name } ${ currentModule . localNames [ name ] } ` ) ; } } else if ( isRequireSyncCall ( valueNode ) || isProbingRequireCall ( valueNode ) ) { if ( valueNode . arguments [ 0 ] && valueNode . arguments [ 0 ] . type === Syntax . Literal && typeof valueNode . arguments [ 0 ] . value === 'string' ) { currentModule . localNames [ name ] = { module : valueNode . arguments [ 0 ] . value } ; debug ( ` ${ name } ${ valueNode . callee . property . name } ${ valueNode . arguments [ 0 ] . value } ` ) ; } } else if ( isExtendCall ( valueNode ) ) { currentModule . localNames [ name ] = { "class" : valueNode . arguments [ 0 ] . value } ; debug ( ` ${ name } ${ valueNode . arguments [ 0 ] . value } ` ) ; } } if ( body . type === Syntax . BlockStatement ) { body . body . forEach ( function ( stmt ) { if ( stmt . type === Syntax . FunctionDeclaration ) { if ( stmt . id && stmt . id . type === Syntax . Identifier && stmt . loc && stmt . loc . start ) { const loc = stmt . loc . start . line + ":" + stmt . loc . start . column ; currentModule . localNamesByLoc [ loc ] = currentModule . localNames [ stmt . id . name ] = { "function" : stmt } ; } } else if ( stmt . type === Syntax . VariableDeclaration ) { stmt . declarations . forEach ( ( decl ) => { if ( decl . init ) { checkAssignment ( decl . id . name , decl . init ) ; } } ) ; } else if ( stmt . type === Syntax . ExpressionStatement && stmt . expression . type === Syntax . AssignmentExpression && stmt . expression . left . type === Syntax . Identifier ) { checkAssignment ( stmt . expression . left . name , stmt . expression . right ) ; } else if ( stmt . type === Syntax . ReturnStatement ) { if ( stmt . argument && stmt . argument . type === Syntax . Identifier ) { currentModule . defaultExport = stmt . argument . name ; } else if ( stmt . argument && isExtendCall ( stmt . argument ) ) { debug ( ` ${ stmt . argument . arguments [ 0 ] . value } ` ) ; currentModule . defaultExportClass = stmt . argument . arguments [ 0 ] . value ; } } } ) ; } if ( currentModule . defaultExport && currentModule . localNames [ currentModule . defaultExport ] ) { currentModule . localNames [ currentModule . defaultExport ] . export = "" ; } }
Searches the given body for variable declarations that can be evaluated statically,
 either because they refer to known AMD module imports (e.g.
Searches the given body for variable declarations that can be evaluated statically either because they refer to known AMD module imports ( e . g .
// TODO chaining if local has path // no (or empty) path // no (or empty) path // console.log(stmt);