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

gregdove 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 73caf20  Fix logic for setting variations of 
royalesuppresscompleximplicitcoercion. Added supporting compiler tests.
73caf20 is described below

commit 73caf20e03b72bb9e1717f2339c14cb79c6082b9
Author: greg-dove <[email protected]>
AuthorDate: Tue Jun 18 13:14:04 2019 +1200

    Fix logic for setting variations of royalesuppresscompleximplicitcoercion. 
Added supporting compiler tests.
---
 .../compiler/internal/codegen/js/JSEmitter.java    | 10 +++-
 .../codegen/js/royale/JSRoyaleDocEmitter.java      |  6 +-
 .../codegen/js/royale/TestRoyaleExpressions.java   | 65 ++++++++++++++++++++++
 3 files changed, 74 insertions(+), 7 deletions(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
index a60ffbc..d6a9745 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
@@ -775,8 +775,14 @@ public class JSEmitter extends ASEmitter implements 
IJSEmitter
             {
                 JSRoyaleDocEmitter royaleDocEmitter = (JSRoyaleDocEmitter) 
docEmitter;
                 //check for local toggle
-                needsCoercion = royaleDocEmitter.getLocalSettingAsBoolean(
-                        
JSRoyaleEmitterTokens.SUPPRESS_COMPLEX_IMPLICIT_COERCION, needsCoercion);
+                if (needsCoercion) needsCoercion = 
!(royaleDocEmitter.getLocalSettingAsBoolean(
+                        
JSRoyaleEmitterTokens.SUPPRESS_COMPLEX_IMPLICIT_COERCION, false));
+                else {
+                    if 
(royaleDocEmitter.hasLocalSetting(JSRoyaleEmitterTokens.SUPPRESS_COMPLEX_IMPLICIT_COERCION.getToken()))
 {
+                        needsCoercion = 
!(royaleDocEmitter.getLocalSettingAsBoolean(
+                                
JSRoyaleEmitterTokens.SUPPRESS_COMPLEX_IMPLICIT_COERCION, false));
+                    }
+                }
                 if (needsCoercion) {
                     //check for individual specified suppression
                     
diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java
index e32b148..2d8379c 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java
@@ -351,9 +351,6 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
         }
     }
     
-    /**
-     *
-     */
     private void loadLocalSettings(String doc, String settingToken, String 
defaultSetting)
     {
         if (localSettings == null) localSettings = new HashMap<String, 
List<String>>();
@@ -383,8 +380,7 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
                 settings.add(settingItem);
                 //System.out.println("---Adding setting 
"+settingToken+":"+settingItem);
             }
-
-            index = doc.indexOf(settingToken, index + endIndex);
+            index = doc.indexOf(settingToken, index +  settingToken.length());
         }
     }
     
diff --git 
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
 
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
index 48ec475..8ee8ab9 100644
--- 
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
+++ 
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
@@ -1552,6 +1552,71 @@ public class TestRoyaleExpressions extends 
TestGoogExpressions
         asBlockWalker.visitFunction(node);
         assertOut("/**\n * @export\n * @param {Object} o\n * @return 
{number}\n */\nfoo.bar.B.prototype.b = function(o) {\n  var /** @type 
{foo.bar.B} */ a = null;\n  a = /* implicit cast */ 
org.apache.royale.utils.Language.as(org.apache.royale.utils.Language.as(o, 
this.memberVar), foo.bar.B, true);\n}");
     }
+    
+     @Test
+     public void testVisitAsMemberVariableSuppressComplexImplicitCoercionA()
+     {
+         IFunctionNode node = (IFunctionNode) getNode(
+                 "public class B {private var memberVar:Class; /**\n * 
@royalesuppresscompleximplicitcoercion\n */\n public function b(o:Object):int { 
var a:B = null; a = o as memberVar; }}",
+                 IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+         asBlockWalker.visitFunction(node);
+         assertOut("/**\n * @royalesuppresscompleximplicitcoercion\n * 
@export\n * @param {Object} o\n * @return {number}\n */\nfoo.bar.B.prototype.b 
= function(o) {\n  var /** @type {foo.bar.B} */ a = null;\n  a = 
org.apache.royale.utils.Language.as(o, this.memberVar);\n}");
+     }
+    
+     @Test
+     public void testVisitAsMemberVariableSuppressComplexImplicitCoercionB()
+     {
+         IFunctionNode node = (IFunctionNode) getNode(
+                 "public class B {private var memberVar:Class; /**\n * 
@royalesuppresscompleximplicitcoercion true\n */\n public function 
b(o:Object):int { var a:B = null; a = o as memberVar; }}",
+                 IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+         asBlockWalker.visitFunction(node);
+         assertOut("/**\n * @royalesuppresscompleximplicitcoercion true\n * 
@export\n * @param {Object} o\n * @return {number}\n */\nfoo.bar.B.prototype.b 
= function(o) {\n  var /** @type {foo.bar.B} */ a = null;\n  a = 
org.apache.royale.utils.Language.as(o, this.memberVar);\n}");
+     }
+    
+     @Test
+     public void testVisitAsMemberVariableSuppressComplexImplicitCoercionC()
+     {
+         IFunctionNode node = (IFunctionNode) getNode(
+                 "public class B {private var memberVar:Class; /**\n * 
@royalesuppresscompleximplicitcoercion foo.bar.B\n */\n public function 
b(o:Object):int { var a:B = null; a = o as memberVar; }}",
+                 IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+         asBlockWalker.visitFunction(node);
+         assertOut("/**\n * @royalesuppresscompleximplicitcoercion foo.bar.B\n 
* @export\n * @param {Object} o\n * @return {number}\n 
*/\nfoo.bar.B.prototype.b = function(o) {\n  var /** @type {foo.bar.B} */ a = 
null;\n  a = org.apache.royale.utils.Language.as(o, this.memberVar);\n}");
+     }
+    
+    
+     @Test
+     public void testVisitAsMemberVariableSuppressComplexImplicitCoercionD()
+     {
+         //using config level setting to suppress the output by default
+         try{
+             project.config.setJsComplexImplicitCoercions(null,false);
+         } catch (ConfigurationException e) {
+             e.printStackTrace();
+         }
+         
+         IFunctionNode node = (IFunctionNode) getNode(
+                 "public class B {private var memberVar:Class; public function 
b(o:Object):int { var a:B = null; a = o as memberVar; }}",
+                 IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+         asBlockWalker.visitFunction(node);
+         assertOut("/**\n * @export\n * @param {Object} o\n * @return 
{number}\n */\nfoo.bar.B.prototype.b = function(o) {\n  var /** @type 
{foo.bar.B} */ a = null;\n  a = org.apache.royale.utils.Language.as(o, 
this.memberVar);\n}");
+     }
+    
+     @Test
+     public void testVisitAsMemberVariableSuppressComplexImplicitCoercionE()
+     {
+         //using config level setting to suppress the output by default
+         try{
+             project.config.setJsComplexImplicitCoercions(null,false);
+         } catch (ConfigurationException e) {
+             e.printStackTrace();
+         }
+         //reverse the config level suppression (with 'false')
+         IFunctionNode node = (IFunctionNode) getNode(
+                 "public class B {private var memberVar:Class; /**\n * 
@royalesuppresscompleximplicitcoercion false\n */\n public function 
b(o:Object):int { var a:B = null; a = o as memberVar; }}",
+                 IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+         asBlockWalker.visitFunction(node);
+         assertOut("/**\n * @royalesuppresscompleximplicitcoercion false\n * 
@export\n * @param {Object} o\n * @return {number}\n */\nfoo.bar.B.prototype.b 
= function(o) {\n  var /** @type {foo.bar.B} */ a = null;\n  a = /* implicit 
cast */ 
org.apache.royale.utils.Language.as(org.apache.royale.utils.Language.as(o, 
this.memberVar), foo.bar.B, true);\n}");
+     }
 
     @Test
     public void testVisitJSDoc()

Reply via email to