flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cd...@apache.org
Subject [34/44] git commit: [flex-falcon] [refs/heads/feature-autobuild/maven-archetypes] - handle text/html as default property. If text is specified as default property, but html is provided and an html property exists the html property will be set. This sol
Date Fri, 21 Oct 2016 15:17:12 GMT
handle text/html as default property.  If text is specified as default property, but html is
provided and an html property exists the html property will be set.  This solution needs to
be tested and generalized against mixed text and html tags


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

Branch: refs/heads/feature-autobuild/maven-archetypes
Commit: 9c05264f858675cf080882177426e4e73338e44e
Parents: cd0908b
Author: Alex Harui <aharui@apache.org>
Authored: Sat Oct 15 23:26:52 2016 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Sat Oct 15 23:27:57 2016 -0700

----------------------------------------------------------------------
 .../compiler/internal/mxml/MXMLTagData.java     | 37 ++++++++++++++++++++
 .../compiler/internal/mxml/MXMLTextData.java    |  2 +-
 .../tree/mxml/MXMLClassReferenceNodeBase.java   | 18 ++++++++++
 .../tree/mxml/MXMLPropertySpecifierNode.java    | 15 ++++++++
 4 files changed, 71 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9c05264f/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLTagData.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLTagData.java
b/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLTagData.java
index 2b5eec3..5ddd780 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLTagData.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLTagData.java
@@ -1132,4 +1132,41 @@ public class MXMLTagData extends MXMLUnitData implements IMXMLTagData
 
         return sb.toString();
     }
+    
+    public String stringify()
+    {
+    	StringBuilder sb = new StringBuilder();
+        sb.append('<');
+        if (isCloseTag())
+            sb.append('/');
+        sb.append(getName());
+
+        // Verify the attributes.
+        for (IMXMLTagAttributeData attribute : getAttributeDatas())
+        {
+        	sb.append(" ");
+            sb.append(attribute.getName());
+            sb.append("=\"");
+            sb.append(attribute.getRawValue());
+            sb.append("\"");
+        }
+        if (isEmptyTag())
+            sb.append('/');
+        sb.append('>');
+        for (IMXMLUnitData unit = getFirstChildUnit(); unit != null; unit = unit.getNextSiblingUnit())
+        {
+            if (unit.isText())
+                sb.append(((IMXMLTextData)unit).getCompilableText());
+            else if (unit instanceof MXMLTagData)
+            	sb.append(((MXMLTagData)unit).stringify());
+        }
+        if (!isEmptyTag())
+        {
+            sb.append('<');
+            sb.append('/');
+            sb.append(getName());
+            sb.append('>');
+        }
+        return sb.toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9c05264f/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLTextData.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLTextData.java
b/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLTextData.java
index 2a35c19..5411912 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLTextData.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLTextData.java
@@ -39,7 +39,7 @@ public class MXMLTextData extends MXMLUnitData implements IMXMLTextData
     /**
      * Constructor.
      */
-    MXMLTextData(MXMLToken textToken)
+    public MXMLTextData(MXMLToken textToken)
     {
         text = textToken.getText();
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9c05264f/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
b/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
index 0d3aab9..fc8ed36 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLClassReferenceNodeBase.java
@@ -489,6 +489,24 @@ abstract class MXMLClassReferenceNodeBase extends MXMLNodeBase implements
IMXMLC
             }
             else
             {
+                IVariableDefinition defaultPropertyDefinition = getDefaultPropertyDefinition(builder);
+                if (defaultPropertyDefinition != null && !processedDefaultProperty
&& defaultPropertyDefinition.getBaseName().equals("text"))
+                {
+                	String uri = childTag.getURI();
+                	if (uri.equals("http://www.w3.org/1999/xhtml"))
+                	{
+                        IVariableDefinition htmlDef = (IVariableDefinition)project.resolveSpecifier(classReference,
"html");
+                        if (htmlDef != null)
+                        {
+                        	defaultPropertyDefinition = this.defaultPropertyDefinition = htmlDef;
+	                        processDefaultPropertyContentUnit(builder, childTag, info);
+	                        // seems strange we have to finish default property processing
+	                        // by calling nonDefaultProperty code
+	                        processNonDefaultPropertyContentUnit(builder, info);
+	                        return;
+                        }
+                	}
+                }
                 // Handle child tags that are something other than property/style/event tags
                 // or instance tags.
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9c05264f/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java
b/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java
index 8429c21..f4a43f1 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java
@@ -31,8 +31,12 @@ import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.definitions.ITypeDefinition;
 import org.apache.flex.compiler.definitions.IVariableDefinition;
 import org.apache.flex.compiler.internal.definitions.ClassDefinition;
+import org.apache.flex.compiler.internal.mxml.MXMLData;
 import org.apache.flex.compiler.internal.mxml.MXMLDialect.TextParsingFlags;
+import org.apache.flex.compiler.internal.mxml.MXMLTagData;
+import org.apache.flex.compiler.internal.mxml.MXMLTextData;
 import org.apache.flex.compiler.internal.parsing.ISourceFragment;
+import org.apache.flex.compiler.internal.parsing.mxml.MXMLToken;
 import org.apache.flex.compiler.internal.projects.FlexProject;
 import org.apache.flex.compiler.internal.scopes.ASScope;
 import org.apache.flex.compiler.internal.scopes.MXMLFileScope;
@@ -42,6 +46,7 @@ import org.apache.flex.compiler.mxml.IMXMLTagAttributeData;
 import org.apache.flex.compiler.mxml.IMXMLTagData;
 import org.apache.flex.compiler.mxml.IMXMLTextData;
 import org.apache.flex.compiler.mxml.IMXMLUnitData;
+import org.apache.flex.compiler.parsing.MXMLTokenTypes;
 import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.compiler.problems.MXMLUnresolvedTagProblem;
 import org.apache.flex.compiler.tree.ASTNodeID;
@@ -378,6 +383,16 @@ class MXMLPropertySpecifierNode extends MXMLSpecifierNodeBase implements
IMXMLPr
                 instanceNode.setClassReference(project, (ClassDefinition)definition); //
TODO Move this logic to initializeFromTag().
                 instanceNode.initializeFromTag(builder, tag);
             }
+            else if (definition == null && defaultPropertyDefinition.getBaseName().equals("html"))
+            {
+            	String text = ((MXMLTagData)tag).stringify();
+            	MXMLToken textToken = new MXMLToken(MXMLTokenTypes.TOKEN_TEXT, 
+            										tag.getStart(), tag.getEnd(),
+            										tag.getLine(), tag.getColumn(), text);
+            	MXMLTextData textData = new MXMLTextData(textToken);
+            	textData.setLocation((MXMLData) tag.getParent(), tag.getIndex());
+            	initializeFromText(builder, textData, createNodeInfo(builder));
+            }
         }
     }
     


Mime
View raw message