You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2019/03/01 07:28:19 UTC

[royale-compiler] 01/02: Fix public var warning when var has metadata (which does not include Bindable)

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

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

commit 1faaf572d18305d14fa022695c7d910034e85a2e
Author: greg-dove <gr...@gmail.com>
AuthorDate: Tue Feb 26 12:02:40 2019 +1300

    Fix public var warning when var has metadata (which does not include Bindable)
---
 .../compiler/problems/PublicVarWarningProblem.java |  6 +++++
 .../codegen/js/royale/JSRoyaleDocEmitter.java      | 28 +++++++++++++++-------
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/compiler-common/src/main/java/org/apache/royale/compiler/problems/PublicVarWarningProblem.java b/compiler-common/src/main/java/org/apache/royale/compiler/problems/PublicVarWarningProblem.java
index 02fddc8..6a4ce55 100644
--- a/compiler-common/src/main/java/org/apache/royale/compiler/problems/PublicVarWarningProblem.java
+++ b/compiler-common/src/main/java/org/apache/royale/compiler/problems/PublicVarWarningProblem.java
@@ -41,4 +41,10 @@ public class PublicVarWarningProblem extends CompilerProblem
     {
         super(site);
     }
+    
+    public PublicVarWarningProblem(String sourcePath, int start, int end, int line, int column, int endLine, int endColumn)
+    {
+        super(sourcePath, start, end, line, column, endLine, endColumn);
+    }
+    
 }
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 24873c8..8cfd1c9 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
@@ -44,13 +44,7 @@ import org.apache.royale.compiler.internal.scopes.ASScope;
 import org.apache.royale.compiler.problems.PublicVarWarningProblem;
 import org.apache.royale.compiler.projects.ICompilerProject;
 import org.apache.royale.compiler.tree.ASTNodeID;
-import org.apache.royale.compiler.tree.as.IASNode;
-import org.apache.royale.compiler.tree.as.IClassNode;
-import org.apache.royale.compiler.tree.as.IDefinitionNode;
-import org.apache.royale.compiler.tree.as.IExpressionNode;
-import org.apache.royale.compiler.tree.as.IFunctionNode;
-import org.apache.royale.compiler.tree.as.IParameterNode;
-import org.apache.royale.compiler.tree.as.IVariableNode;
+import org.apache.royale.compiler.tree.as.*;
 import org.apache.royale.compiler.tree.metadata.IMetaTagNode;
 import org.apache.royale.compiler.tree.metadata.IMetaTagsNode;
 
@@ -453,8 +447,26 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
             }
             if (warnPublicVars && !node.isConst() && !bindable && ns.contentEquals("public"))
             {
+                IASNode warningNode = node;
+                //find "public" child node, which may not be the start of the IVariableNode node because of associated metadata
+                int childCount = node.getChildCount();
+                int index = 0;
+                while (index < childCount) {
+                    IASNode child = node.getChild(index);
+                    if (child instanceof IIdentifierNode && ((IIdentifierNode) child).getName().equals("public")) {
+                        warningNode = child;
+                        break;
+                    }
+                    index++;
+                }
+                
                 if (!suppressedWarning(node, fjp))
-                	fjp.getProblems().add(new PublicVarWarningProblem(node));
+                	fjp.getProblems().add(new PublicVarWarningProblem(node.getSourcePath(),
+                            node.getStart(), node.getEnd(),
+                            warningNode.getLine(), warningNode.getColumn(),
+                            node.getEndLine(), node.getEndColumn()));
+               
+
             }
             emitPublic(node);
         }