flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [35/50] [abbrv] git commit: [flex-falcon] [refs/heads/develop] - re-apply 549384b2d591d69d3ab00d0838aa8c5643f8f1a7 from Flex SDK
Date Tue, 02 Jun 2015 17:05:38 GMT
re-apply 549384b2d591d69d3ab00d0838aa8c5643f8f1a7 from Flex SDK


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/5f713883
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/5f713883
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/5f713883

Branch: refs/heads/develop
Commit: 5f71388324b817f319fa4e359fba21aa4e18b824
Parents: beb60a1
Author: Alex Harui <aharui@apache.org>
Authored: Mon Jun 1 13:41:59 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Jun 1 13:41:59 2015 -0700

----------------------------------------------------------------------
 .../src/flex/tools/debugger/cli/DebugCLI.java   | 33 ++++++----
 .../tools/debugger/cli/ExpressionCache.java     | 68 +++++++++++++++++---
 .../tools/debugger/cli/ExpressionContext.java   |  8 +--
 .../src/flex/tools/debugger/cli/Extensions.java |  2 +-
 4 files changed, 85 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5f713883/debugger/src/flex/tools/debugger/cli/DebugCLI.java
----------------------------------------------------------------------
diff --git a/debugger/src/flex/tools/debugger/cli/DebugCLI.java b/debugger/src/flex/tools/debugger/cli/DebugCLI.java
index efb1187..49554f0 100644
--- a/debugger/src/flex/tools/debugger/cli/DebugCLI.java
+++ b/debugger/src/flex/tools/debugger/cli/DebugCLI.java
@@ -325,7 +325,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
@@ -493,7 +494,9 @@ public class DebugCLI implements Runnable, SourceLocator
 	public FileInfoCache getFileCache()	{ 
 			return m_fileInfo;
 	}
-
+	
+	public boolean              isIde()         { return m_isIde; }
+	
 	/**
 	 * Convert a module to class name.  This is used
 	 * by the ExpressionCache to find variables
@@ -548,6 +551,10 @@ public class DebugCLI implements Runnable, SourceLocator
 					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); //$NON-NLS-1$
@@ -1381,7 +1388,7 @@ public class DebugCLI implements Runnable, SourceLocator
 
 			if (showThis && dis != null)
 			{
-				ExpressionCache.appendVariable(sb, dis, ctx.getIsolateId());
+				m_exprCache.appendVariable(sb, dis, ctx.getIsolateId());
 				sb.append("."); //$NON-NLS-1$
 			}
 
@@ -1396,7 +1403,7 @@ public class DebugCLI implements Runnable, SourceLocator
 					Variable v = var[j];
 					sb.append(v.getName());
 					sb.append('=');
-					ExpressionCache.appendVariableValue(sb, v.getValue(), ctx.getIsolateId());
+					m_exprCache.appendVariableValue(sb, v.getValue(), ctx.getIsolateId());
 					if ((j+1)<var.length)
 						sb.append(", "); //$NON-NLS-1$
 				}
@@ -1453,7 +1460,7 @@ public class DebugCLI implements Runnable, SourceLocator
 				if ( !v.isAttributeSet(VariableAttribute.IS_LOCAL) &&
 					 !v.isAttributeSet(VariableAttribute.IS_ARGUMENT) )
 				{
-					ExpressionCache.appendVariable(sb, vars[i], m_activeIsolate);
+					m_exprCache.appendVariable(sb, vars[i], m_activeIsolate);
 					sb.append(m_newline);
 				}
 			}
@@ -1509,7 +1516,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_activeIsolate);
+				m_exprCache.appendVariable(sb, vars[i], m_activeIsolate);
 				sb.append(m_newline);
 			}
 		}
@@ -1548,7 +1555,7 @@ public class DebugCLI implements Runnable, SourceLocator
 				// see if variable is local
 				if ( v.isAttributeSet(VariableAttribute.IS_LOCAL) )
 				{
-					ExpressionCache.appendVariable(sb, v, m_activeIsolate);
+					m_exprCache.appendVariable(sb, v, m_activeIsolate);
 					sb.append(m_newline);
 				}
 			}
@@ -1584,7 +1591,7 @@ public class DebugCLI implements Runnable, SourceLocator
 			for(int i=0; i<scopes.length; i++)
 			{
 				Variable scope = scopes[i];
-				ExpressionCache.appendVariable(sb, scope, m_activeIsolate);
+				m_exprCache.appendVariable(sb, scope, m_activeIsolate);
 				sb.append(m_newline);
 			}
 		}
@@ -3997,7 +4004,7 @@ public class DebugCLI implements Runnable, SourceLocator
 			else if (isLookupMembers)
 				sb.append(result);
 			else
-				ExpressionCache.appendVariableValue(sb, result, m_activeIsolate);
+				m_exprCache.appendVariableValue(sb, result, m_activeIsolate);
 
 			out( sb.toString() );
 
@@ -4426,11 +4433,11 @@ public class DebugCLI implements Runnable, SourceLocator
 //			sb.append(val.getName());
 			if (fullName)
 				sb.append(name);
-			ExpressionCache.appendVariableValue(sb, key.getValue(), key.getName(), key.getIsolateId());
+			m_exprCache.appendVariableValue(sb, key.getValue(), key.getName(), key.getIsolateId());
 			sb.append("."); //$NON-NLS-1$
 			sb.append(memName);
 			sb.append(" = "); //$NON-NLS-1$
-			ExpressionCache.appendVariableValue(sb, val.getValue(), val.getName(), val.getIsolateId());
+			m_exprCache.appendVariableValue(sb, val.getValue(), val.getName(), val.getIsolateId());
 			sb.append(m_newline);
 		}
 		return sb;
@@ -6640,10 +6647,10 @@ public class DebugCLI implements Runnable, SourceLocator
 					Object result = m_exprCache.evaluate(a.getExpression(), a.getIsolateId()).value;
 
 					if (result instanceof Variable)
-						ExpressionCache.appendVariableValue(sb, ((Variable)result).getValue(), a.getIsolateId());
+						m_exprCache.appendVariableValue(sb, ((Variable)result).getValue(), a.getIsolateId());
 
 					else if (result instanceof Value)
-						ExpressionCache.appendVariableValue(sb, (Value) result, a.getIsolateId());
+						m_exprCache.appendVariableValue(sb, (Value) result, a.getIsolateId());
 
 					else if (result instanceof InternalProperty)
 						sb.append( ((InternalProperty)result).valueOf() );

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5f713883/debugger/src/flex/tools/debugger/cli/ExpressionCache.java
----------------------------------------------------------------------
diff --git a/debugger/src/flex/tools/debugger/cli/ExpressionCache.java b/debugger/src/flex/tools/debugger/cli/ExpressionCache.java
index 4c6291a..95698d5 100644
--- a/debugger/src/flex/tools/debugger/cli/ExpressionCache.java
+++ b/debugger/src/flex/tools/debugger/cli/ExpressionCache.java
@@ -197,7 +197,7 @@ public class ExpressionCache
 	/**
 	 * Formatting function for variable
 	 */
-	public static void appendVariable(StringBuilder sb, Variable v, int isolateId)
+	public void appendVariable(StringBuilder sb, Variable v, int isolateId)
 	{
 		//sb.append('\'');
 		String name = v.getName();
@@ -217,7 +217,7 @@ public class ExpressionCache
 	 * @param o
 	 *            the value to format.
 	 */
-	public static void appendVariableValue(StringBuilder sb, final Object o, final int isolateId)
+	public void appendVariableValue(StringBuilder sb, final Object o, final int isolateId)
 	{
 		Value v;
 
@@ -307,9 +307,9 @@ public class ExpressionCache
 		appendVariableValue(sb, v, isolateId);
 	}
 
-	public static void appendVariableValue(StringBuilder sb, Value val, final int isolateId)
{ appendVariableValue(sb,val,"", isolateId); } //$NON-NLS-1$
+	public void appendVariableValue(StringBuilder sb, Value val, final int isolateId) { appendVariableValue(sb,val,"",
isolateId); } //$NON-NLS-1$
 
-	public static void appendVariableValue(StringBuilder sb, Value val, String variableName,
final int isolateId)
+	public void appendVariableValue(StringBuilder sb, Value val, String variableName, final
int isolateId)
 	{
 		int type = val.getType();
 		String typeName = val.getTypeName();
@@ -390,7 +390,7 @@ public class ExpressionCache
 				}
 
                 sb.append(start);
-                sb.append(s);
+                sb.append(escapeIfIde(s));
                 sb.append(end);
                 break;
             }
@@ -406,7 +406,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))
                 {
@@ -440,7 +440,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$
@@ -456,7 +456,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$
@@ -541,4 +541,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-falcon/blob/5f713883/debugger/src/flex/tools/debugger/cli/ExpressionContext.java
----------------------------------------------------------------------
diff --git a/debugger/src/flex/tools/debugger/cli/ExpressionContext.java b/debugger/src/flex/tools/debugger/cli/ExpressionContext.java
index 75eabba..2bed5ee 100644
--- a/debugger/src/flex/tools/debugger/cli/ExpressionContext.java
+++ b/debugger/src/flex/tools/debugger/cli/ExpressionContext.java
@@ -248,9 +248,9 @@ public class ExpressionContext implements Context
   		StringBuilder sb = new StringBuilder();
 
   		if (var != null)
-  			ExpressionCache.appendVariable(sb, var, m_isolateId);
+  			m_cache.appendVariable(sb, var, m_isolateId);
   		else
-  			ExpressionCache.appendVariableValue(sb, val, m_isolateId);
+  			m_cache.appendVariableValue(sb, val, m_isolateId);
 
 		boolean attrs = m_cache.propertyEnabled(DebugCLI.DISPLAY_ATTRIBUTES);
 		if (attrs && var != null)
@@ -269,7 +269,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_isolateId);
+			  			m_cache.appendVariable(sb, mems[i], m_isolateId);
 						if (attrs)
 							ExpressionCache.appendVariableAttributes(sb, mems[i]);
 					}
@@ -281,7 +281,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_isolateId);
+	  			m_cache.appendVariable(sb, mems[i], m_isolateId);
 				if (attrs)
 					ExpressionCache.appendVariableAttributes(sb, mems[i]);
 	  		}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5f713883/debugger/src/flex/tools/debugger/cli/Extensions.java
----------------------------------------------------------------------
diff --git a/debugger/src/flex/tools/debugger/cli/Extensions.java b/debugger/src/flex/tools/debugger/cli/Extensions.java
index a71994e..d5a6bae 100644
--- a/debugger/src/flex/tools/debugger/cli/Extensions.java
+++ b/debugger/src/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, isolateId);
-			ExpressionCache.appendVariableValue(sb, v, isolateId);
+			cli.m_exprCache.appendVariableValue(sb, v, isolateId);
 			cli.out( sb.toString() );
 		}
 		catch(NullPointerException npe)


Mime
View raw message