You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by go...@apache.org on 2013/05/08 03:08:45 UTC

git commit: [flex-falcon] [refs/heads/develop] - Added an interface for MXMLManifestManager

Updated Branches:
  refs/heads/develop 8a0242be5 -> c4431151d


Added an interface for MXMLManifestManager


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

Branch: refs/heads/develop
Commit: c4431151db9fb1f3d3028e035c1ccbbd6e849450
Parents: 8a0242b
Author: Gordon Smith <go...@apache.org>
Authored: Tue May 7 16:52:30 2013 -0700
Committer: Gordon Smith <go...@apache.org>
Committed: Tue May 7 16:52:30 2013 -0700

----------------------------------------------------------------------
 .../internal/mxml/MXMLManifestManager.java         |  250 +++++++--------
 .../compiler/internal/projects/FlexProject.java    |    5 +-
 .../flex/compiler/mxml/IMXMLManifestManager.java   |   82 +++++
 3 files changed, 196 insertions(+), 141 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4431151/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLManifestManager.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLManifestManager.java b/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLManifestManager.java
index 36681d4..4b57b48 100644
--- a/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLManifestManager.java
+++ b/compiler/src/org/apache/flex/compiler/internal/mxml/MXMLManifestManager.java
@@ -37,6 +37,7 @@ import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
 
+import org.apache.flex.compiler.mxml.IMXMLManifestManager;
 import org.apache.flex.compiler.mxml.IMXMLNamespaceMapping;
 import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.compiler.problems.ManifestProblem;
@@ -54,52 +55,8 @@ import com.google.common.collect.SetMultimap;
  * with the project.
  * This manager must be recreated whenever the library path, or a manifest file, changes.
  */
-public class MXMLManifestManager
+public class MXMLManifestManager implements IMXMLManifestManager
 {
-    // This inner class is a simple duple struct used to keep track
-    // of all the manifest mappings for a particular tag.
-    // For example, <whatever:Foo> might map to a.b.Foo in
-    // X.swc and Y.swc but c.d.Foo in Z.swc.
-    // We keep track of all of this so that we can create compiler
-    // problems describing where the inconsistencies are.
-    private static class ProblemEntry
-    {
-        ProblemEntry(String className, String fileName)
-        {
-            this.className = className;
-            this.fileName = fileName;
-        }
-        
-        @SuppressWarnings("unused")
-        public String className;
-        
-        @SuppressWarnings("unused")
-        public String fileName;
-    }
-    
-    /**
-     * Information about a class in a namespace mapping.
-     *
-     */
-    private static class ClassInfo
-    {
-        /**
-         * Constructor.
-         * 
-         * @param className fully qualified class name.
-         * @param fromManifest true if the class name came from a manifest
-         * file entry, false otherwise.
-         */
-        ClassInfo(String className, boolean fromManifest)
-        {
-            this.className = className;
-            this.fromManifest = fromManifest;
-        }
-        
-        public String className;
-        public boolean fromManifest;
-    }
-    
     /**
      * Helper method to get the class name from the
      * class info. Takes are of checking if the class
@@ -157,6 +114,85 @@ public class MXMLManifestManager
     private HashMap<XMLName, ArrayList<ProblemEntry>> problemMap =
         new HashMap<XMLName, ArrayList<ProblemEntry>>();
     
+    //
+    // Object overrides
+    //
+    
+    /**
+     * For debugging only.
+     * Lists all of the MXML-tag-to-ActionScript-classname mappings,
+     * in sorted order. Useful for debugging manifest problems.
+     */
+    @Override
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        TreeSet<XMLName> keys = new TreeSet<XMLName>(lookupMap.keySet()); 
+        for (XMLName key : keys)
+        {
+            sb.append(key);
+            sb.append(" -> ");
+            sb.append(lookupMap.get(key));
+            sb.append(", lookupOnly = ");
+            sb.append(isLookupOnly(key));
+            sb.append('\n');
+        }
+        
+        return sb.toString();
+    }
+    
+    //
+    // IMXMLManifestManager implementations
+    //
+    
+    @Override
+    public String resolve(XMLName tagName)
+    {
+        return getClassName(lookupMap.get(tagName));
+    }
+    
+    @Override
+    public boolean isLookupOnly(XMLName tagName)
+    {
+        return lookupOnlyMap.get(tagName) != null;
+    }
+    
+    @Override
+    public Collection<XMLName> getTagNamesForClass(String className)
+    {
+        Collection<XMLName> result = reverseLookupMap.get(className);
+        if (result == null)
+            return Collections.emptySet();
+        else
+            return Collections.unmodifiableCollection(result);
+    }
+    
+    @Override
+    public Collection<String> getQualifiedNamesForNamespaces(Set<String> namespaceURIs, 
+            boolean manifestEntriesOnly)
+    {
+        HashSet<String> qualifiedNames = new HashSet<String>();
+        for (Map.Entry<XMLName, ClassInfo> entry : lookupMap.entrySet())
+        {
+            if (namespaceURIs.contains(entry.getKey().getXMLNamespace()))
+            {
+                ClassInfo classInfo = entry.getValue();
+                if (classInfo != null && 
+                    (!manifestEntriesOnly || 
+                     (manifestEntriesOnly && classInfo.fromManifest)))
+                {
+                    qualifiedNames.add(classInfo.className);                                            
+                }
+            }
+        }
+        return qualifiedNames;
+    }
+    
+    //
+    // Other methods
+    //
+    
     private void addSWC(ISWC swc)
     {
         File swcFile = swc.getSWCFile();
@@ -334,111 +370,47 @@ public class MXMLManifestManager
     }
     
     /**
-     * Uses the manifest information to map an MXML tag
-     * to a ActionScript classname.
-     * 
-     * @param tagName An {@code XMLName} representing an MXML tag,
-     * such as a <code>"Button"</code> tag
-     * in the namespace <code>"library://ns.adobe.com/flex/spark"</code>.
-     * 
-     * @return A fully-qualified ActionScript classname,
-     * such as <code>"spark.controls.Button"</code>
-     */
-    public String resolve(XMLName tagName)
-    {
-        return getClassName(lookupMap.get(tagName));
-    }
-    
-    /**
-     * Determine if a manifest entry is "lookupOnly"  or not.
-     * 
-     * @param tagName An {@code XMLName} representing an MXML tag,
-     * such as a <code>"Button"</code> tag
-     * in the namespace <code>"library://ns.adobe.com/flex/spark"</code>.
-
-     * @return true if tag name's manifest entry has it's lookup
-     * property set to true, false otherwise. 
-     */
-    public boolean isLookupOnly(XMLName tagName)
-    {
-        return lookupOnlyMap.get(tagName) != null;
-    }
-    
-    /**
-     * Uses the manifest information to find all the MXML tags that map to a
-     * specified fully-qualified ActionScript classname, such as as
-     * <code>"spark.controls.Button"</code>
-     * 
-     * @param className Fully-qualified ActionScript classname, such as as
-     * <code>"spark.controls.Button"</code>
-     * @return A collection of {@link XMLName}'s representing a MXML tags, such
-     * as a <code>"Button"</code> tag in the namespace
-     * <code>"library://ns.adobe.com/flex/spark"</code>.
-     */
-    public Collection<XMLName> getTagNamesForClass(String className)
-    {
-        Collection<XMLName> result = reverseLookupMap.get(className);
-        if (result == null)
-            return Collections.emptySet();
-        else
-            return Collections.unmodifiableCollection(result);
-    }
-    
-    /**
-     * Find all the qualified names in the manifest information that have a
-     * corresponding MXML tag whose namespace is in the specified set of
-     * namespaces.
-     * 
-     * @param namespaceURIs Set set of MXML tag namespace URIs such as:
-     * <code>"library://ns.adobe.com/flex/spark"</code>
-     * @param manifestEntriesOnly determines if all the qualified names are 
-     * returned or if only the entries from manifest files are returned.
-     * @return A collection of qualified names (
-     * <code>spark.components.Button</code> for example ) that have correponding
-     * MXML tags in the manifest information whose namespaces are in the
-     * specified set of namespaces.
+     * This inner class stores information about a class in a namespace mapping.
      */
-    public Collection<String> getQualifiedNamesForNamespaces(Set<String> namespaceURIs, 
-            boolean manifestEntriesOnly)
+    private static class ClassInfo
     {
-        HashSet<String> qualifiedNames = new HashSet<String>();
-        for (Map.Entry<XMLName, ClassInfo> entry : lookupMap.entrySet())
+        /**
+         * Constructor.
+         * 
+         * @param className fully qualified class name.
+         * @param fromManifest true if the class name came from a manifest
+         * file entry, false otherwise.
+         */
+        ClassInfo(String className, boolean fromManifest)
         {
-            if (namespaceURIs.contains(entry.getKey().getXMLNamespace()))
-            {
-                ClassInfo classInfo = entry.getValue();
-                if (classInfo != null && 
-                    (!manifestEntriesOnly || 
-                     (manifestEntriesOnly && classInfo.fromManifest)))
-                {
-                    qualifiedNames.add(classInfo.className);                                            
-                }
-            }
+            this.className = className;
+            this.fromManifest = fromManifest;
         }
-        return qualifiedNames;
+        
+        public String className;
+        public boolean fromManifest;
     }
     
     /**
-     * For debugging only.
-     * Lists all of the MXML-tag-to-ActionScript-classname mappings,
-     * in sorted order. Useful for debugging manifest problems.
+     * This inner class is a simple duple struct used to keep track
+     * of all the manifest mappings for a particular tag.
+     * For example, <whatever:Foo> might map to a.b.Foo in
+     * X.swc and Y.swc but c.d.Foo in Z.swc.
+     * We keep track of all of this so that we can create compiler
+     * problems describing where the inconsistencies are.
      */
-    @Override
-    public String toString()
+    private static class ProblemEntry
     {
-        StringBuilder sb = new StringBuilder();
-        
-        TreeSet<XMLName> keys = new TreeSet<XMLName>(lookupMap.keySet()); 
-        for (XMLName key : keys)
+        ProblemEntry(String className, String fileName)
         {
-            sb.append(key);
-            sb.append(" -> ");
-            sb.append(lookupMap.get(key));
-            sb.append(", lookupOnly = ");
-            sb.append(isLookupOnly(key));
-            sb.append('\n');
+            this.className = className;
+            this.fileName = fileName;
         }
         
-        return sb.toString();
+        @SuppressWarnings("unused")
+        public String className;
+        
+        @SuppressWarnings("unused")
+        public String fileName;
     }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4431151/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java b/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
index f5cfd9b..0b827a0 100644
--- a/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
+++ b/compiler/src/org/apache/flex/compiler/internal/projects/FlexProject.java
@@ -66,6 +66,7 @@ import org.apache.flex.compiler.internal.targets.SWCTarget;
 import org.apache.flex.compiler.internal.tree.mxml.MXMLImplicitImportNode;
 import org.apache.flex.compiler.internal.workspaces.Workspace;
 import org.apache.flex.compiler.mxml.IMXMLLanguageConstants;
+import org.apache.flex.compiler.mxml.IMXMLManifestManager;
 import org.apache.flex.compiler.mxml.IMXMLNamespaceMapping;
 import org.apache.flex.compiler.projects.IFlexProject;
 import org.apache.flex.compiler.scopes.IDefinitionSet;
@@ -413,7 +414,7 @@ public class FlexProject extends ASProject implements IFlexProject
     // aggregated from the <component> tags in the catalog.xml files
     // inside the SWCs on the project's library path and from the <component>
     // tags in any manifest files associated with XML namespaces.
-    private MXMLManifestManager manifestManager;
+    private IMXMLManifestManager manifestManager;
 
     /**
      * The fully qualified name of the XMLUtil class.
@@ -1096,7 +1097,7 @@ public class FlexProject extends ASProject implements IFlexProject
      * 
      * @return {@link MXMLManifestManager}
      */
-    private MXMLManifestManager getMXMLManifestManager()
+    private IMXMLManifestManager getMXMLManifestManager()
     {
         if (manifestManager == null)
             manifestManager = new MXMLManifestManager(this);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c4431151/compiler/src/org/apache/flex/compiler/mxml/IMXMLManifestManager.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/mxml/IMXMLManifestManager.java b/compiler/src/org/apache/flex/compiler/mxml/IMXMLManifestManager.java
new file mode 100755
index 0000000..e25682f
--- /dev/null
+++ b/compiler/src/org/apache/flex/compiler/mxml/IMXMLManifestManager.java
@@ -0,0 +1,82 @@
+/*
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.mxml;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.apache.flex.compiler.common.XMLName;
+
+/**
+ * 
+ */
+public interface IMXMLManifestManager
+{
+    /**
+     * Uses the manifest information to map an MXML tag
+     * to a ActionScript classname.
+     * 
+     * @param tagName An {@code XMLName} representing an MXML tag,
+     * such as an {@code <s:Button>} tag.
+     * 
+     * @return A fully-qualified ActionScript classname,
+     * such as <code>"spark.controls.Button"</code>
+     */
+    String resolve(XMLName tagName);
+    
+    /**
+     * Determines if a manifest entry is "lookupOnly" or not.
+     * 
+     * @param tagName An {@code XMLName} representing an MXML tag.
+
+     * @return <code>true</code> if tag name's manifest entry has its <code>lookupOnly</code>
+     * property set to <code>true</code>, and <code>false</code> otherwise. 
+     */
+    boolean isLookupOnly(XMLName tagName);
+    
+    /**
+     * Uses the manifest information to find all the MXML tags that map to a
+     * specified fully-qualified ActionScript classname, such as as
+     * <code>"spark.controls.Button"</code>
+     * 
+     * @param className Fully-qualified ActionScript classname, such as as
+     * <code>"spark.controls.Button"</code>
+     * @return A collection of {@link XMLName}'s representing a MXML tags, such
+     * as a <code>"Button"</code> tag in the namespace
+     * <code>"library://ns.adobe.com/flex/spark"</code>.
+     */
+    Collection<XMLName> getTagNamesForClass(String className);
+    
+    /**
+     * Find all the qualified names in the manifest information that have a
+     * corresponding MXML tag whose namespace is in the specified set of
+     * namespaces.
+     * 
+     * @param namespaceURIs Set set of MXML tag namespace URIs such as:
+     * <code>"library://ns.adobe.com/flex/spark"</code>
+     * @param manifestEntriesOnly determines if all the qualified names are 
+     * returned or if only the entries from manifest files are returned.
+     * @return A collection of qualified names (
+     * <code>spark.components.Button</code> for example ) that have correponding
+     * MXML tags in the manifest information whose namespaces are in the
+     * specified set of namespaces.
+     */
+    Collection<String> getQualifiedNamesForNamespaces(Set<String> namespaceURIs, boolean manifestEntriesOnly);
+}