Author: byron
Date: Sat Mar 14 23:59:44 2009
New Revision: 754562

URL: http://svn.apache.org/viewvc?rev=754562&view=rev
Log:
Added method to retrieve macro definitions for use by IDEs

Modified:
    
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java
    
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
    
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroManager.java
    
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java

Modified: 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java?rev=754562&r1=754561&r2=754562&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/RuntimeInstance.java
 Sat Mar 14 23:59:44 2009
@@ -50,6 +50,7 @@
 import org.apache.velocity.exception.VelocityException;
 import org.apache.velocity.runtime.directive.Directive;
 import org.apache.velocity.runtime.directive.Macro;
+import org.apache.velocity.runtime.directive.VelocimacroProxy;
 import org.apache.velocity.runtime.directive.Scope;
 import org.apache.velocity.runtime.directive.StopCommand;
 import org.apache.velocity.runtime.log.Log;
@@ -1632,6 +1633,16 @@
     }
 
     /**
+     * Return a list of VelocimacroProxies that are defined by the given
+     * template name.
+     */    
+    public List<VelocimacroProxy> getVelocimacros(String templateName)
+    {
+        return vmFactory.getVelocimacros(templateName);
+    }
+    
+    
+    /**
      * Adds a new Velocimacro. Usually called by Macro only while parsing.
      * 
      * Called by org.apache.velocity.runtime.directive.processAndRegister

Modified: 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroFactory.java?rev=754562&r1=754561&r2=754562&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroFactory.java
 Sat Mar 14 23:59:44 2009
@@ -556,6 +556,15 @@
      }
 
      /**
+      * Return a list of VelocimacroProxies that are defined by the given
+      * template name.
+      */     
+     public List<VelocimacroProxy> getVelocimacros(String sourceTemplate)
+     {
+       return vmManager.getVelocimacros(sourceTemplate);
+     }
+     
+     /**
       * @since 1.6
       */
      public Directive getVelocimacro(String vmName, String sourceTemplate, 
String renderingTemplate)

Modified: 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroManager.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroManager.java?rev=754562&r1=754561&r2=754562&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroManager.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/VelocimacroManager.java
 Sat Mar 14 23:59:44 2009
@@ -19,6 +19,7 @@
  * under the License.    
  */
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
@@ -87,6 +88,26 @@
     }
 
     /**
+     * Return a list of VelocimacroProxies that are defined by the given
+     * template name.
+     */
+    public List<VelocimacroProxy> getVelocimacros(String templateName)
+    {
+      Map local = getNamespace(templateName, false);
+      ArrayList<VelocimacroProxy> macros = new ArrayList<VelocimacroProxy>(16);
+      if (local != null)
+      {
+        for (Object mo : local.values())
+        {
+          MacroEntry me = (MacroEntry)mo;
+          macros.add(me.vp);          
+        }
+      }
+      
+      return macros;      
+    }
+    
+    /**
      * Adds a VM definition to the cache.
      * 
      * Called by VelocimacroFactory.addVelociMacro (after parsing and 
discovery in Macro directive)

Modified: 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java?rev=754562&r1=754561&r2=754562&view=diff
==============================================================================
--- 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
 (original)
+++ 
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
 Sat Mar 14 23:59:44 2009
@@ -107,6 +107,14 @@
     }
 
     /**
+     * Return the list of macro arguments associated with this macro
+     */
+    public List<Macro.MacroArg> getMacroArgs()
+    {
+      return macroArgs;
+    }
+    
+    /**
      * @param tree
      */
     public void setNodeTree(SimpleNode tree)


Reply via email to