Return-Path: X-Original-To: apmail-flex-commits-archive@www.apache.org Delivered-To: apmail-flex-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E570710FC9 for ; Tue, 8 Oct 2013 21:50:16 +0000 (UTC) Received: (qmail 60536 invoked by uid 500); 8 Oct 2013 21:50:06 -0000 Delivered-To: apmail-flex-commits-archive@flex.apache.org Received: (qmail 60511 invoked by uid 500); 8 Oct 2013 21:50:06 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 60145 invoked by uid 99); 8 Oct 2013 21:50:02 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Oct 2013 21:50:02 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 85D778B2491; Tue, 8 Oct 2013 21:50:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aharui@apache.org To: commits@flex.apache.org Date: Tue, 08 Oct 2013 21:50:08 -0000 Message-Id: In-Reply-To: <10f1331c756a41138c9d513838ed5b5a@git.apache.org> References: <10f1331c756a41138c9d513838ed5b5a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [08/14] git commit: [flex-falcon] [refs/heads/develop] - handle properties of type Vector or Array that don't have explicit fx:Vector or fx:Array subtags handle properties of type Vector or Array that don't have explicit fx:Vector or fx:Array subtags Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/c5ea8ecb Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/c5ea8ecb Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/c5ea8ecb Branch: refs/heads/develop Commit: c5ea8ecb8aea4e2b2097a35de9b8cb961c493499 Parents: 838cbbe Author: Alex Harui Authored: Wed Oct 2 20:52:57 2013 -0700 Committer: Alex Harui Committed: Tue Oct 8 13:50:58 2013 -0700 ---------------------------------------------------------------------- .../tree/mxml/MXMLPropertySpecifierNode.java | 91 +++++++++++++++++++- 1 file changed, 89 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c5ea8ecb/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java ---------------------------------------------------------------------- diff --git a/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java b/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java index 3815d94..5ffd3aa 100644 --- a/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java +++ b/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLPropertySpecifierNode.java @@ -19,6 +19,7 @@ package org.apache.flex.compiler.internal.tree.mxml; +import java.util.ArrayList; import java.util.Collection; import java.util.EnumSet; import java.util.List; @@ -36,6 +37,7 @@ import org.apache.flex.compiler.internal.projects.FlexProject; import org.apache.flex.compiler.internal.scopes.ASScope; import org.apache.flex.compiler.internal.scopes.MXMLFileScope; import org.apache.flex.compiler.internal.tree.as.NodeBase; +import org.apache.flex.compiler.internal.tree.mxml.MXMLNodeBase.MXMLNodeInfo; import org.apache.flex.compiler.mxml.IMXMLTagAttributeData; import org.apache.flex.compiler.mxml.IMXMLTagData; import org.apache.flex.compiler.mxml.IMXMLTextData; @@ -257,6 +259,59 @@ class MXMLPropertySpecifierNode extends MXMLSpecifierNodeBase implements IMXMLPr } /** + * This override makes sure that array and vectors have a child tag + * of fx:Array or fx:Vector, or fakes that condition. + */ + @Override + protected void initializeFromTag(MXMLTreeBuilder builder, IMXMLTagData tag) + { + MXMLNodeInfo info = createNodeInfo(builder); + + String propertyTypeName = getPropertyTypeName(builder); + + if (propertyTypeName.contains(IASLanguageConstants.Vector + ".<") || + propertyTypeName.equals(IASLanguageConstants.Array)) + { + // Process each content unit. + for (IMXMLUnitData unit = tag.getFirstChildUnit(); unit != null; unit = unit.getNextSiblingUnit()) + { + if (unit instanceof IMXMLTagData) + { + IMXMLTagData unitTag = (IMXMLTagData)unit; + IDefinition definition = builder.getFileScope().resolveTagToDefinition(unitTag); + if (propertyTypeName.contains(IASLanguageConstants.Vector + ".<") && + !definition.getQualifiedName().contains(IASLanguageConstants.Vector + ".<")) + { + initializeDefaultProperty(builder, (IVariableDefinition)getDefinition(), + getListOfUnits(tag)); + return; + } + else if (propertyTypeName.equals(IASLanguageConstants.Array) && + !definition.getQualifiedName().equals(IASLanguageConstants.Array)) + { + initializeDefaultProperty(builder, (IVariableDefinition)getDefinition(), + getListOfUnits(tag)); + return; + } + } + } + } + super.initializeFromTag(builder, tag); + } + + List getListOfUnits(IMXMLTagData tag) + { + ArrayList list = new ArrayList(); + + // Process each content unit. + for (IMXMLUnitData unit = tag.getFirstChildUnit(); unit != null; unit = unit.getNextSiblingUnit()) + { + list.add(unit); + } + return list; + } + + /** * This override handles text specifying a default property. */ @Override @@ -298,14 +353,16 @@ class MXMLPropertySpecifierNode extends MXMLSpecifierNodeBase implements IMXMLPr ((MXMLDeferredInstanceNode)instanceNode).initializeDefaultProperty( builder, defaultPropertyDefinition, contentUnits); } - else if (propertyTypeName.equals(IASLanguageConstants.Array)) + else if (propertyTypeName.equals(IASLanguageConstants.Array) && + oneChildIsNotArray(builder, contentUnits)) { // Create an implicit array node. instanceNode = new MXMLArrayNode(this); ((MXMLArrayNode)instanceNode).initializeDefaultProperty( builder, defaultPropertyDefinition, contentUnits); } - else if (propertyTypeName.contains(IASLanguageConstants.Vector + ".<")) + else if (propertyTypeName.contains(IASLanguageConstants.Vector + ".<") && + oneChildIsNotVector(builder, contentUnits)) { // Create an implicit array node. instanceNode = new MXMLVectorNode(this); @@ -325,6 +382,36 @@ class MXMLPropertySpecifierNode extends MXMLSpecifierNodeBase implements IMXMLPr } } } + + private boolean oneChildIsNotArray(MXMLTreeBuilder builder, List contentUnits) + { + if (contentUnits.size() != 1) + return true; + + if (contentUnits.get(0) instanceof IMXMLTagData) + { + IMXMLTagData tag = (IMXMLTagData)contentUnits.get(0); + IDefinition definition = builder.getFileScope().resolveTagToDefinition(tag); + if (definition.getQualifiedName().equals(IASLanguageConstants.Array)) + return false; + } + return true; + } + + private boolean oneChildIsNotVector(MXMLTreeBuilder builder, List contentUnits) + { + if (contentUnits.size() != 1) + return true; + + if (contentUnits.get(0) instanceof IMXMLTagData) + { + IMXMLTagData tag = (IMXMLTagData)contentUnits.get(0); + IDefinition definition = builder.getFileScope().resolveTagToDefinition(tag); + if (definition.getQualifiedName().contains(IASLanguageConstants.Vector + ".<")) + return false; + } + return true; + } /** * This override handles a child tag in a property tag, such as