Updated Branches: refs/heads/develop a2bb8c296 -> 549384b2d
FLEX-34049: Allow the ouput symbols to be escaped when called from an IDE Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/549384b2 Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/549384b2 Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/549384b2 Branch: refs/heads/develop Commit: 549384b2d591d69d3ab00d0838aa8c5643f8f1a7 Parents: a2bb8c2 Author: Frédéric Thomas <[email protected]> Authored: Sun Jan 19 15:26:39 2014 +0000 Committer: Frédéric Thomas <[email protected]> Committed: Sun Jan 19 15:28:59 2014 +0000 ---------------------------------------------------------------------- .../java/flex/tools/debugger/cli/DebugCLI.java | 42 ++++++------ .../tools/debugger/cli/ExpressionCache.java | 68 +++++++++++++++++--- .../tools/debugger/cli/ExpressionContext.java | 8 +-- .../flex/tools/debugger/cli/Extensions.java | 2 +- 4 files changed, 89 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/549384b2/modules/debugger/src/java/flex/tools/debugger/cli/DebugCLI.java ---------------------------------------------------------------------- diff --git a/modules/debugger/src/java/flex/tools/debugger/cli/DebugCLI.java b/modules/debugger/src/java/flex/tools/debugger/cli/DebugCLI.java index f2a751d..83b603c 100644 --- a/modules/debugger/src/java/flex/tools/debugger/cli/DebugCLI.java +++ b/modules/debugger/src/java/flex/tools/debugger/cli/DebugCLI.java @@ -241,7 +241,8 @@ public class DebugCLI implements Runnable, SourceLocator StringTokenizer m_currentTokenizer; String m_currentToken; String m_currentLine; - public String m_repeatLine; + public String m_repeatLine; + private boolean m_isIde; /** * The module that the next "list" command should display if no @@ -402,6 +403,7 @@ public class DebugCLI implements Runnable, SourceLocator public static LocalizationManager getLocalizationManager() { return m_localizationManager; } public Session getSession() { return m_session; } public FileInfoCache getFileCache() { return m_fileInfo; } + public boolean isIde() { return m_isIde; } /** * Convert a module to class name. This is used @@ -451,12 +453,16 @@ public class DebugCLI implements Runnable, SourceLocator if (i+1 < args.length) m_cdPath = args[i++]; } - else if (arg.equals("-p")) //$NON-NLS-1$ - { - // consume the port - if (i+1 < args.length) - m_connectPort = args[++i]; - } + else if (arg.equals("-p")) //$NON-NLS-1$ + { + // consume the port + if (i+1 < args.length) + m_connectPort = args[++i]; + } + else if (arg.equals("-ide")) //$NON-NLS-1$ + { + m_isIde = true; + } else { err("Unknown command-line argument: " + arg); @@ -1225,7 +1231,7 @@ public class DebugCLI implements Runnable, SourceLocator if (showThis && dis != null) { - ExpressionCache.appendVariable(sb, dis); + m_exprCache.appendVariable(sb, dis); sb.append("."); //$NON-NLS-1$ } @@ -1240,7 +1246,7 @@ public class DebugCLI implements Runnable, SourceLocator Variable v = var[j]; sb.append(v.getName()); sb.append('='); - ExpressionCache.appendVariableValue(sb, v.getValue()); + m_exprCache.appendVariableValue(sb, v.getValue()); if ((j+1)<var.length) sb.append(", "); //$NON-NLS-1$ } @@ -1297,7 +1303,7 @@ public class DebugCLI implements Runnable, SourceLocator if ( !v.isAttributeSet(VariableAttribute.IS_LOCAL) && !v.isAttributeSet(VariableAttribute.IS_ARGUMENT) ) { - ExpressionCache.appendVariable(sb, vars[i]); + m_exprCache.appendVariable(sb, vars[i]); sb.append(m_newline); } } @@ -1353,7 +1359,7 @@ public class DebugCLI implements Runnable, SourceLocator Variable[] vars = frames[num].getArguments(m_session); for(int i=0; i<vars.length; i++) { - ExpressionCache.appendVariable(sb, vars[i]); + m_exprCache.appendVariable(sb, vars[i]); sb.append(m_newline); } } @@ -1392,7 +1398,7 @@ public class DebugCLI implements Runnable, SourceLocator // see if variable is local if ( v.isAttributeSet(VariableAttribute.IS_LOCAL) ) { - ExpressionCache.appendVariable(sb, v); + m_exprCache.appendVariable(sb, v); sb.append(m_newline); } } @@ -1428,7 +1434,7 @@ public class DebugCLI implements Runnable, SourceLocator for(int i=0; i<scopes.length; i++) { Variable scope = scopes[i]; - ExpressionCache.appendVariable(sb, scope); + m_exprCache.appendVariable(sb, scope); sb.append(m_newline); } } @@ -3626,7 +3632,7 @@ public class DebugCLI implements Runnable, SourceLocator else if (isLookupMembers) sb.append(result); else - ExpressionCache.appendVariableValue(sb, result); + m_exprCache.appendVariableValue(sb, result); out( sb.toString() ); @@ -4054,11 +4060,11 @@ public class DebugCLI implements Runnable, SourceLocator // sb.append(val.getName()); if (fullName) sb.append(name); - ExpressionCache.appendVariableValue(sb, key.getValue(), key.getName()); + m_exprCache.appendVariableValue(sb, key.getValue(), key.getName()); sb.append("."); //$NON-NLS-1$ sb.append(memName); sb.append(" = "); //$NON-NLS-1$ - ExpressionCache.appendVariableValue(sb, val.getValue(), val.getName()); + m_exprCache.appendVariableValue(sb, val.getValue(), val.getName()); sb.append(m_newline); } return sb; @@ -6185,10 +6191,10 @@ public class DebugCLI implements Runnable, SourceLocator Object result = m_exprCache.evaluate(a.getExpression()).value; if (result instanceof Variable) - ExpressionCache.appendVariableValue(sb, ((Variable)result).getValue()); + m_exprCache.appendVariableValue(sb, ((Variable)result).getValue()); else if (result instanceof Value) - ExpressionCache.appendVariableValue(sb, (Value) result); + m_exprCache.appendVariableValue(sb, (Value) result); else if (result instanceof InternalProperty) sb.append( ((InternalProperty)result).valueOf() ); http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/549384b2/modules/debugger/src/java/flex/tools/debugger/cli/ExpressionCache.java ---------------------------------------------------------------------- diff --git a/modules/debugger/src/java/flex/tools/debugger/cli/ExpressionCache.java b/modules/debugger/src/java/flex/tools/debugger/cli/ExpressionCache.java index 91a518a..02d73d0 100644 --- a/modules/debugger/src/java/flex/tools/debugger/cli/ExpressionCache.java +++ b/modules/debugger/src/java/flex/tools/debugger/cli/ExpressionCache.java @@ -198,7 +198,7 @@ public class ExpressionCache /** * Formatting function for variable */ - public static void appendVariable(StringBuilder sb, Variable v) + public void appendVariable(StringBuilder sb, Variable v) { //sb.append('\''); String name = v.getName(); @@ -218,7 +218,7 @@ public class ExpressionCache * @param o * the value to format. */ - public static void appendVariableValue(StringBuilder sb, final Object o) + public void appendVariableValue(StringBuilder sb, final Object o) { Value v; @@ -304,9 +304,9 @@ public class ExpressionCache appendVariableValue(sb, v); } - public static void appendVariableValue(StringBuilder sb, Value val) { appendVariableValue(sb,val,""); } //$NON-NLS-1$ + public void appendVariableValue(StringBuilder sb, Value val) { appendVariableValue(sb,val,""); } //$NON-NLS-1$ - public static void appendVariableValue(StringBuilder sb, Value val, String variableName) + public void appendVariableValue(StringBuilder sb, Value val, String variableName) { int type = val.getType(); String typeName = val.getTypeName(); @@ -387,7 +387,7 @@ public class ExpressionCache } sb.append(start); - sb.append(s); + sb.append(escapeIfIde(s)); sb.append(end); break; } @@ -403,7 +403,7 @@ public class ExpressionCache if (System.getProperty("fdbunit") == null) //$NON-NLS-1$ { sb.append(" "); //$NON-NLS-1$ - sb.append(val.getValueAsObject()); // object id + sb.append(escapeIfIde(String.valueOf(val.getValueAsObject()))); // object id } if (typeName != null && !typeName.equals(className)) { @@ -437,7 +437,7 @@ public class ExpressionCache sb.append(getLocalizationManager().getLocalizedTextString("function")); //$NON-NLS-1$ sb.append(' '); - sb.append(val.getValueAsObject()); + sb.append(escapeIfIde(String.valueOf(val.getValueAsObject()))); if (typeName != null && !typeName.equals(variableName)) { sb.append(", name='"); //$NON-NLS-1$ @@ -453,7 +453,7 @@ public class ExpressionCache sb.append("["); //$NON-NLS-1$ sb.append(className); sb.append(" "); //$NON-NLS-1$ - sb.append(val.getValueAsObject()); + sb.append(escapeIfIde(String.valueOf(val.getValueAsObject()))); if (typeName != null && !typeName.equals(className)) { sb.append(", named='"); //$NON-NLS-1$ @@ -538,4 +538,56 @@ public class ExpressionCache if (v.isAttributeSet(VariableAttribute.NAMESPACE_SCOPE)) sb.append(", " + getLocalizationManager().getLocalizedTextString("variableAttribute_hasNamespace")); //$NON-NLS-1$ //$NON-NLS-2$ } + + private String escapeIfIde(String s) + { + return m_cli != null && m_cli.isIde() ? escape(s) : s; + } + + public static String escape(final String str) { + final StringBuilder buffer = new StringBuilder(); + + for (int idx = 0; idx < str.length(); idx++) { + char ch = str.charAt(idx); + switch (ch) { + case '\b': + buffer.append("\\b"); + break; + + case '\t': + buffer.append("\\t"); + break; + + case '\n': + buffer.append("\\n"); + break; + + case '\f': + buffer.append("\\f"); + break; + + case '\r': + buffer.append("\\r"); + break; + + case '\\': + buffer.append("\\\\"); + break; + + default: + if (Character.isISOControl(ch)) { + String hexCode = Integer.toHexString(ch).toUpperCase(); + buffer.append("\\u"); + int paddingCount = 4 - hexCode.length(); + while (paddingCount-- > 0) { + buffer.append(0); + } + buffer.append(hexCode); + } else { + buffer.append(ch); + } + } + } + return buffer.toString(); + } } http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/549384b2/modules/debugger/src/java/flex/tools/debugger/cli/ExpressionContext.java ---------------------------------------------------------------------- diff --git a/modules/debugger/src/java/flex/tools/debugger/cli/ExpressionContext.java b/modules/debugger/src/java/flex/tools/debugger/cli/ExpressionContext.java index 0ffa84b..fe08b1a 100644 --- a/modules/debugger/src/java/flex/tools/debugger/cli/ExpressionContext.java +++ b/modules/debugger/src/java/flex/tools/debugger/cli/ExpressionContext.java @@ -242,9 +242,9 @@ public class ExpressionContext implements Context StringBuilder sb = new StringBuilder(); if (var != null) - ExpressionCache.appendVariable(sb, var); + m_cache.appendVariable(sb, var); else - ExpressionCache.appendVariableValue(sb, val); + m_cache.appendVariableValue(sb, val); boolean attrs = m_cache.propertyEnabled(DebugCLI.DISPLAY_ATTRIBUTES); if (attrs && var != null) @@ -263,7 +263,7 @@ public class ExpressionContext implements Context if (classname.equals(mems[i].getDefiningClass())) { sb.append(m_newline + " "); //$NON-NLS-1$ - ExpressionCache.appendVariable(sb, mems[i]); + m_cache.appendVariable(sb, mems[i]); if (attrs) ExpressionCache.appendVariableAttributes(sb, mems[i]); } @@ -275,7 +275,7 @@ public class ExpressionContext implements Context for(int i=0; i<mems.length; i++) { sb.append(m_newline + " "); //$NON-NLS-1$ - ExpressionCache.appendVariable(sb, mems[i]); + m_cache.appendVariable(sb, mems[i]); if (attrs) ExpressionCache.appendVariableAttributes(sb, mems[i]); } http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/549384b2/modules/debugger/src/java/flex/tools/debugger/cli/Extensions.java ---------------------------------------------------------------------- diff --git a/modules/debugger/src/java/flex/tools/debugger/cli/Extensions.java b/modules/debugger/src/java/flex/tools/debugger/cli/Extensions.java index a29dd80..aeedd72 100644 --- a/modules/debugger/src/java/flex/tools/debugger/cli/Extensions.java +++ b/modules/debugger/src/java/flex/tools/debugger/cli/Extensions.java @@ -293,7 +293,7 @@ public class Extensions sb.append(name); sb.append(" = "); //$NON-NLS-1$ Value v = ((PlayerSession)session).getValue(id, name); - ExpressionCache.appendVariableValue(sb, v); + cli.m_exprCache.appendVariableValue(sb, v); cli.out( sb.toString() ); } catch(NullPointerException npe)
