This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


The following commit(s) were added to refs/heads/develop by this push:
     new 0ea4001e5 ParametersEmitter: implement Friendly Call Frames for 
sourcemaps
0ea4001e5 is described below

commit 0ea4001e55ebe1930de4c52b1669e7d96f13b112
Author: Josh Tynjala <[email protected]>
AuthorDate: Thu Aug 8 10:27:50 2024 -0700

    ParametersEmitter: implement Friendly Call Frames for sourcemaps
    
    Chrome has a feature called Friendly Call Frames where the name mapping at 
a function's ( character determines how the function name is displayed in 
Chrome's debugger.
---
 .../internal/codegen/js/jx/ParametersEmitter.java  | 26 +++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/ParametersEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/ParametersEmitter.java
index 6351f3321..b4f3cba39 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/ParametersEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/ParametersEmitter.java
@@ -23,7 +23,10 @@ import org.apache.royale.compiler.codegen.ISubEmitter;
 import org.apache.royale.compiler.codegen.js.IJSEmitter;
 import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
 import org.apache.royale.compiler.internal.codegen.js.JSSubEmitter;
+import org.apache.royale.compiler.tree.as.IASNode;
+import org.apache.royale.compiler.tree.as.IClassNode;
 import org.apache.royale.compiler.tree.as.IContainerNode;
+import org.apache.royale.compiler.tree.as.IFunctionNode;
 import org.apache.royale.compiler.tree.as.IParameterNode;
 
 public class ParametersEmitter extends JSSubEmitter implements
@@ -37,7 +40,28 @@ public class ParametersEmitter extends JSSubEmitter 
implements
     @Override
     public void emit(IContainerNode node)
     {
-        startMapping(node);
+        String symbolName = null;
+        IASNode parentNode = node.getParent();
+        if (parentNode instanceof IFunctionNode)
+        {
+            // Chrome has a feature called "Friendly Call Frames" that 
+            // recognizes the original name of the function if it is included
+            // in the source map at the location of the function signature's
+            // opening "(" character
+            // reference: https://github.com/babel/babel/issues/14907
+            IFunctionNode functionNode = (IFunctionNode) parentNode;
+            String functionName = functionNode.getName();
+            if (functionName != null && functionName.length() > 0)
+            {
+                symbolName = functionName;
+                IClassNode classNode = (IClassNode) 
functionNode.getAncestorOfType(IClassNode.class);
+                if (classNode != null)
+                {
+                    symbolName = classNode.getShortName() + "." + symbolName;
+                }
+            }
+        }
+        startMapping(node, symbolName);
         write(ASEmitterTokens.PAREN_OPEN);
         endMapping(node);
 

Reply via email to