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 1599080bd More improvements to source maps
1599080bd is described below
commit 1599080bdc848a1e0e8c0f0a4b15ede30e17079a
Author: Josh Tynjala <[email protected]>
AuthorDate: Tue Aug 6 16:01:57 2024 -0700
More improvements to source maps
Private fields/methods and custom namespaced fields methods weren't being
handled correctly in all cases
---
.../internal/codegen/js/jx/IdentifierEmitter.java | 16 +++-
.../codegen/js/jx/MemberAccessEmitter.java | 19 +++--
.../internal/codegen/js/jx/MethodEmitter.java | 6 +-
.../codegen/js/royale/JSRoyaleEmitter.java | 5 +-
.../js/sourcemaps/TestSourceMapExpressions.java | 74 ++++++++++++++++-
.../js/sourcemaps/TestSourceMapFieldMembers.java | 96 ++++++++++++++++++++++
.../js/sourcemaps/TestSourceMapMethodMembers.java | 90 ++++++++++++++++++++
.../js/sourcemaps/TestSourceMapStatements.java | 8 ++
8 files changed, 301 insertions(+), 13 deletions(-)
diff --git
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java
index cab686677..0bd622e27 100644
---
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java
+++
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java
@@ -260,21 +260,27 @@ public class IdentifierEmitter extends JSSubEmitter
implements
else if (isCustomNamespace)
{
String ns =
((INamespaceResolvedReference)(nodeDef.getNamespaceReference())).resolveAETNamespace(getProject()).getName();
+ if (accessWithNS)
+ {
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ }
startMapping(node, node.getName());
- write(JSRoyaleEmitter.formatNamespacedProperty(ns,
qname, accessWithNS));
+ write(JSRoyaleEmitter.formatNamespacedProperty(ns,
qname, false));
endMapping(node);
}
else
{
+ String originalQname = null;
if (!(nodeDef.getParent() instanceof
IPackageDefinition))
{
qname = node.getName();
if (nodeDef != null && !isStatic &&
(nodeDef.getParent() instanceof ClassDefinition) && (!(nodeDef instanceof
IParameterDefinition)) && nodeDef.isPrivate() &&
getProject().getAllowPrivateNameConflicts())
{
+ originalQname = qname;
qname =
getEmitter().formatPrivateName(nodeDef.getParent().getQualifiedName(), qname);
}
}
- startMapping(node);
+ startMapping(node, originalQname);
write(qname);
endMapping(node);
}
@@ -309,8 +315,12 @@ public class IdentifierEmitter extends JSSubEmitter
implements
else if (isCustomNamespace)
{
String ns =
((INamespaceResolvedReference)nodeDef.getNamespaceReference()).resolveAETNamespace(getProject()).getName();
+ if (accessWithNS)
+ {
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ }
startMapping(node, node.getName());
- write(JSRoyaleEmitter.formatNamespacedProperty(ns,
qname, accessWithNS));
+ write(JSRoyaleEmitter.formatNamespacedProperty(ns,
qname, false));
endMapping(node);
}
else
diff --git
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
index 80d5ab4b2..3a5f933f1 100644
---
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
+++
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
@@ -26,9 +26,6 @@ import
org.apache.royale.compiler.constants.IASKeywordConstants;
import org.apache.royale.compiler.constants.IASLanguageConstants;
import org.apache.royale.compiler.constants.INamespaceConstants;
import org.apache.royale.compiler.definitions.*;
-import org.apache.royale.compiler.definitions.IDefinition;
-import org.apache.royale.compiler.definitions.INamespaceDefinition;
-import org.apache.royale.compiler.definitions.IPackageDefinition;
import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
import org.apache.royale.compiler.internal.codegen.js.JSEmitterTokens;
import org.apache.royale.compiler.internal.codegen.js.JSSubEmitter;
@@ -412,8 +409,13 @@ public class MemberAccessEmitter extends JSSubEmitter
implements
// output bracket access with QName
writeLeftSide(node, leftNode, rightNode);
//exception: variable member access needs to have literal
output, because there is no guarantee that string access will work in release
mode after renaming
- if (((NamespaceAccessExpressionNode)
rightNode).resolve(getProject()) instanceof IVariableDefinition) {
-
write(JSRoyaleEmitter.formatNamespacedProperty(d.toString(), r.getName(),true));
+ if (naen.resolve(getProject()) instanceof IVariableDefinition) {
+ startMapping(node, leftNode);
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ endMapping(node);
+ startMapping(naen, r.getName());
+
write(JSRoyaleEmitter.formatNamespacedProperty(d.toString(), r.getName(),
false));
+ endMapping(naen);
} else {
write(ASEmitterTokens.SQUARE_OPEN);
write(ASEmitterTokens.NEW);
@@ -471,7 +473,12 @@ public class MemberAccessEmitter extends JSSubEmitter
implements
{
//exception: variable member access needs to have
literal output, because there is no guarantee that string access will work in
release mode after renaming
if (naen.resolve(getProject()) instanceof
IVariableDefinition) {
-
write(JSRoyaleEmitter.formatNamespacedProperty(d.toString(), r.getName(),true));
+ startMapping(node, leftNode);
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ endMapping(node);
+ startMapping(naen, r.getName());
+
write(JSRoyaleEmitter.formatNamespacedProperty(d.toString(), r.getName(),
false));
+ endMapping(naen);
} else {
write(ASEmitterTokens.SQUARE_OPEN);
write(ASEmitterTokens.NEW);
diff --git
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/MethodEmitter.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/MethodEmitter.java
index 719a96b65..b133f6a02 100644
---
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/MethodEmitter.java
+++
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/MethodEmitter.java
@@ -92,7 +92,6 @@ public class MethodEmitter extends JSSubEmitter implements
}
else
{
- startMapping(nameNode);
ITypeDefinition typeDef = EmitterUtils.getTypeDefinition(node);
if (typeDef != null)
{
@@ -100,6 +99,7 @@ public class MethodEmitter extends JSSubEmitter implements
}
if (qname != null && !qname.equals(""))
{
+ startMapping(nameNode);
if (isConstructor && fjs.getModel().isExterns &&
typeDef.getBaseName().equals(qname))
{
writeToken(ASEmitterTokens.VAR);
@@ -113,10 +113,12 @@ public class MethodEmitter extends JSSubEmitter implements
write(JSEmitterTokens.PROTOTYPE);
}
if (!fjs.isCustomNamespace(fn))
+ {
write(ASEmitterTokens.MEMBER_ACCESS);
+ }
}
+ endMapping(nameNode);
}
- endMapping(nameNode);
if (!isConstructor)
{
fjs.emitMemberName(node);
diff --git
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
index a7bd7ce69..f93859e48 100644
---
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
+++
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
@@ -873,8 +873,11 @@ public class JSRoyaleEmitter extends JSEmitter implements
IJSRoyaleEmitter
INamespaceDefinition nsDef =
(INamespaceDefinition)ns.resolve(project);
formatQualifiedName(nsDef.getQualifiedName()); // register
with used names
String s = nsDef.getURI();
+ startMapping(nameNode);
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ endMapping(nameNode);
startMapping(nameNode, node.getName());
- write(formatNamespacedProperty(s, node.getName(), true));
+ write(formatNamespacedProperty(s, node.getName(), false));
endMapping(nameNode);
return;
}
diff --git
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapExpressions.java
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapExpressions.java
index 98978dbbb..6fc4efa27 100644
---
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapExpressions.java
+++
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapExpressions.java
@@ -28,15 +28,23 @@ import
org.apache.royale.compiler.tree.as.IDynamicAccessNode;
import org.apache.royale.compiler.tree.as.IFunctionCallNode;
import org.apache.royale.compiler.tree.as.IIterationFlowNode;
import org.apache.royale.compiler.tree.as.IMemberAccessExpressionNode;
+import org.apache.royale.compiler.tree.as.INamespaceAccessExpressionNode;
import org.apache.royale.compiler.tree.as.IReturnNode;
import org.apache.royale.compiler.tree.as.ITernaryOperatorNode;
import org.apache.royale.compiler.tree.as.IThrowNode;
import org.apache.royale.compiler.tree.as.IUnaryOperatorNode;
-
import org.junit.Test;
public class TestSourceMapExpressions extends SourceMapTestBase
{
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+
+ project.setAllowPrivateNameConflicts(true);
+ }
+
//----------------------------------
// Primary expression keywords
//----------------------------------
@@ -599,6 +607,70 @@ public class TestSourceMapExpressions extends
SourceMapTestBase
assertMapping(node, 0, 6, 0, 6, 0, 7); // d
}
+ @Test
+ public void testVisitMemberAccess_3()
+ {
+ IMemberAccessExpressionNode node = (IMemberAccessExpressionNode)
getNode(
+ "import custom.custom_namespace;use namespace
custom_namespace;public class B {custom_namespace var b:Number; public function
test() { var a:B = this;a.custom_namespace::b; }}",
+ IMemberAccessExpressionNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitMemberAccessExpression(node);
+ // a.http_$$ns_apache_org$2017$custom$namespace__b
+ assertMapping(node, 0, 0, 0, 0, 0, 1); // a
+ assertMapping(node, 0, 1, 0, 1, 0, 2); // .
+ assertMapping(node, 0, 2, 0, 2, 0, 47, "b"); // custom_namespace::b
+ }
+
+ @Test
+ public void testVisitMemberAccess_4()
+ {
+ INamespaceAccessExpressionNode node = (INamespaceAccessExpressionNode)
getNode(
+ "import custom.custom_namespace;use namespace
custom_namespace;public class B {custom_namespace var b:Number; public function
test() { custom_namespace::b; }}",
+ INamespaceAccessExpressionNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitNamespaceAccessExpression(node);
+ // this.http_$$ns_apache_org$2017$custom$namespace__b
+ assertMapping(node, 0, 18, 0, 0, 0, 5); // this.
+ assertMapping(node, 0, 18, 0, 5, 0, 50, "b"); // custom_namespace::b
+ }
+
+ @Test
+ public void testVisitMemberAccess_5()
+ {
+ IMemberAccessExpressionNode node = (IMemberAccessExpressionNode)
getNode(
+ "import custom.custom_namespace;use namespace
custom_namespace;public class B {custom_namespace var b:Number; public function
test() { this.custom_namespace::b; }}",
+ IMemberAccessExpressionNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitMemberAccessExpression(node);
+ // this.http_$$ns_apache_org$2017$custom$namespace__b
+ assertMapping(node, 0, 0, 0, 0, 0, 4); // this
+ assertMapping(node, 0, 4, 0, 4, 0, 5); // .
+ assertMapping(node, 0, 5, 0, 5, 0, 50, "b"); // custom_namespace::b
+ }
+
+ @Test
+ public void testVisitMemberAccess_6()
+ {
+ IMemberAccessExpressionNode node = (IMemberAccessExpressionNode)
getNode(
+ "public class B {private var b:Number; public function test()
{ this.b; }}",
+ IMemberAccessExpressionNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitMemberAccessExpression(node);
+ // this.B_b
+ assertMapping(node, 0, 0, 0, 0, 0, 4); // this
+ assertMapping(node, 0, 4, 0, 4, 0, 5); // .
+ assertMapping(node, 0, 5, 0, 5, 0, 8, "b"); // B_b
+ }
+
+ @Test
+ public void testVisitMemberAccess_7()
+ {
+ IReturnNode node = (IReturnNode) getNode(
+ "public class B {private var b:Number; public function test()
{ return b; }}",
+ IReturnNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitReturn(node);
+ // return this.B_b
+ assertMapping(node, 0, 0, 0, 0, 0, 7); // return
+ assertMapping(node, 0, 7, 0, 7, 0, 12); // this.
+ assertMapping(node, 0, 7, 0, 12, 0, 15, "b"); // B_b
+ }
+
@Test
public void testVisitBinaryOperator_In()
{
diff --git
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapFieldMembers.java
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapFieldMembers.java
index 7c5455fb1..f86b938d2 100644
---
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapFieldMembers.java
+++
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapFieldMembers.java
@@ -21,12 +21,21 @@ package
org.apache.royale.compiler.internal.codegen.js.sourcemaps;
import org.apache.royale.compiler.driver.IBackend;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
import org.apache.royale.compiler.internal.test.SourceMapTestBase;
+import org.apache.royale.compiler.tree.as.IMemberAccessExpressionNode;
import org.apache.royale.compiler.tree.as.IVariableNode;
import org.junit.Test;
public class TestSourceMapFieldMembers extends SourceMapTestBase
{
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+
+ project.setAllowPrivateNameConflicts(true);
+ }
+
@Test
public void testField()
{
@@ -83,6 +92,28 @@ public class TestSourceMapFieldMembers extends
SourceMapTestBase
assertMapping(node, 0, 14, 4, 29, 4, 32); // 420
}
+ @Test
+ public void testField_withPrivate()
+ {
+ IVariableNode node = getField("private var foo;");
+ asBlockWalker.visitVariable(node);
+ ///**\n * @private\n * @type {*}\n
*/\nRoyaleTest_A.prototype.RoyaleTest_A_foo
+ assertMapping(node, 0, 12, 4, 0, 4, 23); // RoyaleTest_A.prototype.
+ assertMapping(node, 0, 12, 4, 23, 4, 39, "foo"); // RoyaleTest_A_foo
+ }
+
+ @Test
+ public void testField_withCustomNamespace()
+ {
+ IVariableNode node = (IVariableNode) getNode(
+ "import custom.custom_namespace;use namespace
custom_namespace;public class RoyaleTest_A {custom_namespace var foo;}",
+ IVariableNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitVariable(node);
+ ///**\n * @type {*}\n
*/\nRoyaleTest_A.prototype.http_$$ns_apache_org$2017$custom$namespace__foo
+ assertMapping(node, 0, 21, 3, 0, 3, 23); // RoyaleTest_A.prototype.
+ assertMapping(node, 0, 21, 3, 23, 3, 70, "foo"); //
http_$$ns_apache_org$2017$custom$namespace__foo
+ }
+
@Test
public void testStaticField()
{
@@ -127,6 +158,28 @@ public class TestSourceMapFieldMembers extends
SourceMapTestBase
assertMapping(node, 0, 21, 4, 19, 4, 22); // 420
}
+ @Test
+ public void testStaticField_withPrivate()
+ {
+ IVariableNode node = getField("private static var foo;");
+ asBlockWalker.visitVariable(node);
+ ///**\n * @private\n * @type {*}\n */\nRoyaleTest_A.foo
+ assertMapping(node, 0, 19, 4, 0, 4, 13); // RoyaleTest_A.
+ assertMapping(node, 0, 19, 4, 13, 4, 16); // foo
+ }
+
+ @Test
+ public void testStaticField_withCustomNamespace()
+ {
+ IVariableNode node = (IVariableNode) getNode(
+ "import custom.custom_namespace;use namespace
custom_namespace;public class RoyaleTest_A {custom_namespace static var foo;}",
+ IVariableNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitVariable(node);
+ ///**\n * @type {*}\n
*/\nRoyaleTest_A.http_$$ns_apache_org$2017$custom$namespace__foo
+ assertMapping(node, 0, 28, 3, 0, 3, 13); // RoyaleTest_A.
+ assertMapping(node, 0, 28, 3, 13, 3, 60, "foo"); //
http_$$ns_apache_org$2017$custom$namespace__foo
+ }
+
@Test
public void testConstant()
{
@@ -171,6 +224,28 @@ public class TestSourceMapFieldMembers extends
SourceMapTestBase
assertMapping(node, 0, 16, 5, 29, 5, 32); // 420
}
+ @Test
+ public void testConstant_withPrivate()
+ {
+ IVariableNode node = getField("private const foo;");
+ asBlockWalker.visitVariable(node);
+ ///**\n * @private\n * @const\n * @type {*}\n
*/\nRoyaleTest_A.prototype.RoyaleTest_A_foo
+ assertMapping(node, 0, 14, 5, 0, 5, 23); // RoyaleTest_A.prototype.
+ assertMapping(node, 0, 14, 5, 23, 5, 39, "foo"); // RoyaleTest_A_foo
+ }
+
+ @Test
+ public void testConstant_withCustomNamespace()
+ {
+ IVariableNode node = (IVariableNode) getNode(
+ "import custom.custom_namespace;use namespace
custom_namespace;public class RoyaleTest_A {custom_namespace const foo;}",
+ IVariableNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitVariable(node);
+ ///**\n * @const\n * @type {*}\n
*/\nRoyaleTest_A.prototype.http_$$ns_apache_org$2017$custom$namespace__foo
+ assertMapping(node, 0, 23, 4, 0, 4, 23); // RoyaleTest_A.prototype.
+ assertMapping(node, 0, 23, 4, 23, 4, 70, "foo"); //
http_$$ns_apache_org$2017$custom$namespace__foo
+ }
+
@Test
public void testStaticConstant()
{
@@ -215,6 +290,27 @@ public class TestSourceMapFieldMembers extends
SourceMapTestBase
assertMapping(node, 0, 23, 5, 19, 5, 22); // 420
}
+ @Test
+ public void testStaticConstant_withPrivate()
+ {
+ IVariableNode node = getField("private static const foo;");
+ asBlockWalker.visitVariable(node);
+ ///**\n * @private\n * @const\n * @type {*}\n */\nRoyaleTest_A.foo
+ assertMapping(node, 0, 21, 5, 0, 5, 13); // RoyaleTest_A.
+ assertMapping(node, 0, 21, 5, 13, 5, 16); // foo
+ }
+
+ public void testStaticConstant_withCustomNamespace()
+ {
+ IVariableNode node = (IVariableNode) getNode(
+ "import custom.custom_namespace;use namespace
custom_namespace;public class RoyaleTest_A {custom_namespace static const
foo;}",
+ IVariableNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitVariable(node);
+ ///**\n * @const\n * @type {*}\n
*/\nRoyaleTest_A.http_$$ns_apache_org$2017$custom$namespace__foo
+ assertMapping(node, 0, 30, 4, 0, 5, 13); // RoyaleTest_A.
+ assertMapping(node, 0, 30, 4, 13, 5, 60); //
http_$$ns_apache_org$2017$custom$namespace__foo
+ }
+
protected IBackend createBackend()
{
return new RoyaleBackend();
diff --git
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapMethodMembers.java
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapMethodMembers.java
index a0933567f..2f94bc9c1 100644
---
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapMethodMembers.java
+++
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapMethodMembers.java
@@ -22,10 +22,19 @@ import org.apache.royale.compiler.driver.IBackend;
import org.apache.royale.compiler.internal.driver.js.royale.RoyaleBackend;
import org.apache.royale.compiler.internal.test.SourceMapTestBase;
import org.apache.royale.compiler.tree.as.IFunctionNode;
+import org.apache.royale.compiler.tree.as.IVariableNode;
import org.junit.Test;
public class TestSourceMapMethodMembers extends SourceMapTestBase
{
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+
+ project.setAllowPrivateNameConflicts(true);
+ }
+
@Test
public void testMethod()
{
@@ -41,6 +50,87 @@ public class TestSourceMapMethodMembers extends
SourceMapTestBase
assertMapping(node, 0, 15, 1, 0, 1, 1); // }
}
+ @Test
+ public void testMethod_withPrivate()
+ {
+ IFunctionNode node = getMethod("private function foo(){}");
+ asBlockWalker.visitFunction(node);
+ ///**\n * @private\n */\nRoyaleTest_A.prototype.RoyaleTest_A_foo =
function() {\n}
+ assertMapping(node, 0, 17, 3, 0, 3, 23); // RoyaleTest_A.prototype.
+ assertMapping(node, 0, 17, 3, 23, 3, 39, "foo"); // RoyaleTest_A_foo
+ assertMapping(node, 0, 0, 3, 39, 3, 50); // = function
+ assertMapping(node, 0, 20, 3, 50, 3, 51); // (
+ assertMapping(node, 0, 21, 3, 51, 3, 52); // )
+ assertMapping(node, 0, 22, 3, 53, 3, 54); // {
+ assertMapping(node, 0, 23, 4, 0, 4, 1); // }
+ }
+
+ @Test
+ public void testMethod_withCustomNamespace()
+ {
+ IFunctionNode node = (IFunctionNode) getNode(
+ "import custom.custom_namespace;use namespace
custom_namespace;public class RoyaleTest_A {custom_namespace function foo(){}}",
+ IFunctionNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitFunction(node);
+ ///**\n
*/\nRoyaleTest_A.prototype.http_$$ns_apache_org$2017$custom$namespace__foo =
function() {\n}
+ assertMapping(node, 0, 26, 2, 0, 2, 22); // RoyaleTest_A.prototype
+ assertMapping(node, 0, 26, 2, 22, 2, 23); // .
+ assertMapping(node, 0, 26, 2, 23, 2, 70, "foo"); //
http_$$ns_apache_org$2017$custom$namespace__foo
+ assertMapping(node, 0, 0, 2, 70, 2, 81); // = function
+ assertMapping(node, 0, 29, 2, 81, 2, 82); // (
+ assertMapping(node, 0, 30, 2, 82, 2, 83); // )
+ assertMapping(node, 0, 31, 2, 84, 2, 85); // {
+ assertMapping(node, 0, 32, 3, 0, 3, 1); // }
+ }
+
+ @Test
+ public void testStaticMethod()
+ {
+ IFunctionNode node = getMethod("static function foo(){}");
+ asBlockWalker.visitFunction(node);
+ //RoyaleTest_A.foo = function() {\n}
+ assertMapping(node, 0, 16, 0, 0, 0, 13); // RoyaleTest_A.
+ assertMapping(node, 0, 16, 0, 13, 0, 16); // foo
+ assertMapping(node, 0, 0, 0, 16, 0, 27); // = function
+ assertMapping(node, 0, 19, 0, 27, 0, 28); // (
+ assertMapping(node, 0, 20, 0, 28, 0, 29); // )
+ assertMapping(node, 0, 21, 0, 30, 0, 31); // {
+ assertMapping(node, 0, 22, 1, 0, 1, 1); // }
+ }
+
+ @Test
+ public void testStaticMethod_withPrivate()
+ {
+ IFunctionNode node = getMethod("private static function foo(){}");
+ asBlockWalker.visitFunction(node);
+ ///**\n * @private\n */\nRoyaleTest_A.foo = function() {\n}
+ assertMapping(node, 0, 24, 3, 0, 3, 13); // RoyaleTest_A.
+ assertMapping(node, 0, 24, 3, 13, 3, 16); // foo
+ assertMapping(node, 0, 0, 3, 16, 3, 27); // = function
+ assertMapping(node, 0, 27, 3, 27, 3, 28); // (
+ assertMapping(node, 0, 28, 3, 28, 3, 29); // )
+ assertMapping(node, 0, 29, 3, 30, 3, 31); // {
+ assertMapping(node, 0, 30, 4, 0, 4, 1); // }
+ }
+
+ @Test
+ public void testStaticMethod_withCustomNamespace()
+ {
+ IFunctionNode node = (IFunctionNode) getNode(
+ "import custom.custom_namespace;use namespace
custom_namespace;public class RoyaleTest_A {custom_namespace static function
foo(){}}",
+ IFunctionNode.class, WRAP_LEVEL_PACKAGE);
+ asBlockWalker.visitFunction(node);
+ ///**\n
*/\nRoyaleTest_A.http_$$ns_apache_org$2017$custom$namespace__foo = function()
{\n}
+ assertMapping(node, 0, 33, 2, 0, 2, 12); // RoyaleTest_A.
+ assertMapping(node, 0, 33, 2, 12, 2, 13); // .
+ assertMapping(node, 0, 33, 2, 13, 2, 60, "foo"); //
http_$$ns_apache_org$2017$custom$namespace__foo
+ assertMapping(node, 0, 0, 2, 60, 2, 71); // = function
+ assertMapping(node, 0, 36, 2, 71, 2, 72); // (
+ assertMapping(node, 0, 37, 2, 72, 2, 73); // )
+ assertMapping(node, 0, 38, 2, 74, 2, 75); // {
+ assertMapping(node, 0, 39, 3, 0, 3, 1); // }
+ }
+
protected IBackend createBackend()
{
return new RoyaleBackend();
diff --git
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
index 8d3b4929d..8803d2245 100644
---
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
+++
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
@@ -36,6 +36,14 @@ import org.junit.Test;
public class TestSourceMapStatements extends SourceMapTestBase
{
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+
+ project.setAllowPrivateNameConflicts(true);
+ }
+
//----------------------------------
// var declaration
//----------------------------------