Permalink
Browse files

#51 debug functions improved.

  • Loading branch information...
1 parent 1dd97ee commit 33acdbe041227e54517894f065dc1da45a3d6a92 @MindScriptAct committed Dec 26, 2013
@@ -253,15 +253,27 @@ public class CommandMap {
/**
* Returns text of all command classes that are mapped to constants. (for debugging)
+ * @param verbose if set to true, will return readable string, false will return pairs of message type and command class definition separated by '>', all pairs are separated by ';'.
* @return Text with all mapped commands.
*/
- public function listMappings():String {
+ public function listMappings(verbose:Boolean = true):String {
var retVal:String = "";
- retVal = "===================== CommandMap Mappings: =====================\n";
+ if (verbose) {
+ retVal = "===================== CommandMap Mappings: =====================\n";
+ }
for (var key:String in classRegistry) {
- retVal += "SENDING MESSAGE:'" + key + "'\t> EXECUTES > " + classRegistry[key] + "\n";
+ if (verbose) {
+ retVal += "SENDING MESSAGE:'" + key + "'\t> EXECUTES > " + classRegistry[key] + "\n";
+ } else {
+ if (retVal) {
+ retVal += ";"
+ }
+ retVal += key + ">" + getQualifiedClassName(classRegistry[key]);
+ }
+ }
+ if (verbose) {
+ retVal += "================================================================\n";
}
- retVal += "================================================================\n";
return retVal;
}
@@ -334,11 +346,6 @@ public class CommandMap {
commandClass = classRegistry[messageType];
if (commandClass) {
- // debug this action
- CONFIG::debug {
- MvcExpress.debug(new TraceCommandMap_handleCommandExecute(moduleName, command, commandClass, messageType, params));
- }
-
//////////////////////////////////////////////
////// INLINE FUNCTION runCommand() START
@@ -366,6 +373,11 @@ public class CommandMap {
command.messageType = messageType;
+ // debug this action
+ CONFIG::debug {
+ MvcExpress.debug(new TraceCommandMap_handleCommandExecute(moduleName, command, commandClass, messageType, params));
+ }
+
if (command is PooledCommand) {
// init pool if needed.
if (!pooledCommands) {
@@ -411,15 +411,35 @@ public class MediatorMap implements IMediatorMap {
/**
* Returns String of all view classes that are mapped to mediator classes. (for debugging)
+ * @param verbose if set to true, will return readable string, false will return pairs of view class definition and mediator class list(separated by ',') definition separated by '>', all pairs are separated by ';'.
* @return Text with all mapped mediators.
*/
- public function listMappings():String {
+ public function listMappings(verbose:Boolean = true):String {
var retVal:String = "";
- retVal = "==================== MediatorMap Mappings: =====================\n";
+ if (verbose) {
+ retVal = "==================== MediatorMap Mappings: =====================\n";
+ }
for (var viewClass:Object in mediatorMappingRegistry) {
- retVal += "VIEW:'" + viewClass + "'\t> MEDIATED BY > " + mediatorMapOrderRegistry[viewClass] + "\n";
+ if (verbose) {
+ retVal += "VIEW:'" + viewClass + "'\t> MEDIATED BY > " + mediatorMapOrderRegistry[viewClass] + "\n";
+ } else {
+ if (retVal) {
+ retVal += ";";
+ }
+ retVal += getQualifiedClassName(viewClass) + ">";
+ var mediators:Vector.<Class> = mediatorMapOrderRegistry[viewClass];
+ var mediatorCount:int = mediators.length;
+ for (var i:int = 0; i < mediatorCount; i++) {
+ if (i > 0) {
+ retVal += ",";
+ }
+ retVal += getQualifiedClassName(mediators[i]);
+ }
+ }
+ }
+ if (verbose) {
+ retVal += "================================================================\n";
}
- retVal += "================================================================\n";
return retVal;
}
@@ -405,13 +405,24 @@ public class ProxyMap implements IProxyMap {
* Returns text of all mapped proxy objects, and keys they are mapped to. (for debugging)
* @return Text string with all mapped proxies.
*/
- public function listMappings():String {
+ public function listMappings(verbose:Boolean = true):String {
var retVal:String = "";
- retVal = "====================== ProxyMap Mappings: ======================\n";
+ if (verbose) {
+ retVal = "====================== ProxyMap Mappings: ======================\n";
+ }
for (var key:Object in injectObjectRegistry) {
- retVal += "PROXY OBJECT:'" + injectObjectRegistry[key] + "'\t\t\t(MAPPED TO:" + key + ")\n";
+ if (verbose) {
+ retVal += "PROXY OBJECT:'" + injectObjectRegistry[key] + "'\t\t\t(MAPPED TO:" + key + ")\n";
+ } else {
+ if (retVal) {
+ retVal += ";";
+ }
+ retVal += getQualifiedClassName(injectObjectRegistry[key]).split("::")[1] + ">" + key;
+ }
+ }
+ if (verbose) {
+ retVal += "================================================================\n";
}
- retVal += "================================================================\n";
return retVal;
}
@@ -18,7 +18,6 @@ public class HandlerVO {
public var isExecutable:Boolean;
/** FOR INTERNAL USE ONLY. Variable to store class there handler came from. (for debugging only) */
- CONFIG::debug
public var handlerClassName:String;
}
@@ -1,6 +1,7 @@
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
package mvcexpress.core.messenger {
import flash.utils.Dictionary;
+import flash.utils.getQualifiedClassName;
import mvcexpress.MvcExpress;
import mvcexpress.core.CommandMap;
@@ -80,9 +81,7 @@ public class Messenger {
}
if (!msgData) {
msgData = new HandlerVO();
- CONFIG::debug {
- msgData.handlerClassName = handlerClassName;
- }
+ msgData.handlerClassName = handlerClassName;
msgData.handler = handler;
messageList[messageList.length] = msgData;
handlerRegistry[type][handler] = msgData;
@@ -210,35 +209,55 @@ public class Messenger {
* List all message mappings.
* Intended to be used by ModuleCore.as
*/
- public function listMappings(commandMap:CommandMap):String {
+ public function listMappings(commandMap:CommandMap, verbose:Boolean = true):String {
use namespace pureLegsCore;
var retVal:String = "";
- retVal = "====================== Message Mappings: ======================\n";
- var warningText:String = "WARNING: If you want to see Classes that handles constants - you must run with CONFIG::debug compile variable set to 'true'.\n";
- CONFIG::debug {
- warningText = "";
- }
- if (warningText) {
- retVal += warningText;
+ if (verbose) {
+ retVal = "====================== Message Mappings: ======================\n";
+ var warningText:String = "WARNING: If you want to see Classes that handles constants - you must run with CONFIG::debug compile variable set to 'true'.\n";
+ CONFIG::debug {
+ warningText = "";
+ }
+ if (warningText) {
+ retVal += warningText;
+ }
}
for (var key:String in messageRegistry) {
var msgList:Vector.<HandlerVO> = messageRegistry[key];
var messageHandlers:String = "";
var msgCount:int = msgList.length;
for (var i:int = 0; i < msgCount; i++) {
var handlerVo:HandlerVO = msgList[i];
- if (handlerVo.isExecutable) {
- messageHandlers += "[EXECUTES:" + commandMap.getMessageCommand(key) + "], ";
- CONFIG::debug {
- messageHandlers += "[" + handlerVo.handlerClassName + "], ";
+ if (messageHandlers) {
+ messageHandlers += ",";
+ }
+ if (verbose) {
+ if (handlerVo.isExecutable) {
+ messageHandlers += commandMap.getMessageCommand(key);
+ } else {
+ messageHandlers += handlerVo.handlerClassName.split("::")[1];
+ }
+ } else {
+ if (handlerVo.isExecutable) {
+ messageHandlers += getQualifiedClassName(commandMap.getMessageCommand(key));
+ } else {
+ messageHandlers += handlerVo.handlerClassName;
}
}
}
-
- retVal += "SENDING MESSAGE:'" + key + "'\t> HANDLED BY: > " + messageHandlers + "\n";
+ if (verbose) {
+ retVal += "SENDING MESSAGE:'" + key + "'\t> HANDLED BY: > " + messageHandlers + "\n";
+ } else {
+ if (retVal) {
+ retVal += ";";
+ }
+ retVal += key + ">" + messageHandlers;
+ }
+ }
+ if (verbose) {
+ retVal += "================================================================";
}
- retVal += "================================================================";
return retVal;
}
@@ -208,31 +208,31 @@ public class ModuleCore {
/**
* List all message mappings.
*/
- public function listMappedMessages():String {
+ public function listMappedMessages(verbose:Boolean = true):String {
use namespace pureLegsCore;
- return messenger.listMappings(commandMap);
+ return messenger.listMappings(commandMap, verbose);
}
/**
* List all view mappings.
*/
- public function listMappedMediators():String {
- return mediatorMap.listMappings();
+ public function listMappedMediators(verbose:Boolean = true):String {
+ return mediatorMap.listMappings(verbose);
}
/**
* List all model mappings.
*/
- public function listMappedProxies():String {
- return proxyMap.listMappings();
+ public function listMappedProxies(verbose:Boolean = true):String {
+ return proxyMap.listMappings(verbose);
}
/**
* List all controller mappings.
*/
- public function listMappedCommands():String {
- return commandMap.listMappings();
+ public function listMappedCommands(verbose:Boolean = true):String {
+ return commandMap.listMappings(verbose);
}
//----------------------------------

0 comments on commit 33acdbe

Please sign in to comment.