velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From by...@apache.org
Subject svn commit: r733416 - in /velocity/engine/trunk/src/java/org/apache/velocity: runtime/directive/RuntimeMacro.java runtime/parser/node/ASTDirective.java util/introspection/Info.java
Date Sun, 11 Jan 2009 05:26:57 GMT
Author: byron
Date: Sat Jan 10 21:26:52 2009
New Revision: 733416

URL: http://svn.apache.org/viewvc?rev=733416&view=rev
Log:
Remove unnecessary sourceTemplate member from Macro directive

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
    velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Info.java

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/RuntimeMacro.java?rev=733416&r1=733415&r2=733416&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/RuntimeMacro.java
Sat Jan 10 21:26:52 2009
@@ -53,11 +53,6 @@
     private String macroName;
 
     /**
-     * source template name
-     */
-    private String sourceTemplate;
-
-    /**
      * Literal text of the macro
      */
     private String literal = null;
@@ -77,17 +72,15 @@
      * template stored for later use.
      *
      * @param macroName name of the macro
-     * @param sourceTemplate template where macro call is made
-     */
-    public RuntimeMacro(String macroName, String sourceTemplate)
+\     */
+    public RuntimeMacro(String macroName)
     {
-        if (macroName == null || sourceTemplate == null)
+        if (macroName == null)
         {
             throw new IllegalArgumentException("Null arguments");
         }
         
         this.macroName = macroName.intern();
-        this.sourceTemplate = sourceTemplate.intern();
     }
 
     /**
@@ -196,7 +189,7 @@
         /**
          * first look in the source template
          */
-        Object o = rsvc.getVelocimacro(macroName, sourceTemplate, renderingTemplate);
+        Object o = rsvc.getVelocimacro(macroName, getTemplateName(), renderingTemplate);
 
         if( o != null )
         {
@@ -237,9 +230,8 @@
             }
             catch (TemplateInitException die)
             {
-                Info info = new Info(sourceTemplate, node.getLine(), node.getColumn());
                 throw new ParseErrorException(die.getMessage() + " at "
-                    + Log.formatFileString(info), info);
+                    + Log.formatFileString(node), new Info(node));
             }
 
             try
@@ -256,21 +248,20 @@
                  * this is also true for the following catch blocks.
                  */
                 rsvc.getLog().error("Exception in macro #" + macroName + " at " +
-                  Log.formatFileString(sourceTemplate, getLine(), getColumn()));
+                  Log.formatFileString(node));
                 throw e;
             }
             catch (IOException e)
             {
                 rsvc.getLog().error("Exception in macro #" + macroName + " at " +
-                  Log.formatFileString(sourceTemplate, getLine(), getColumn()));
+                  Log.formatFileString(node));
                 throw e;
             }
         }
         else if (strictRef)
         {
-            Info info = new Info(sourceTemplate, node.getLine(), node.getColumn());
             throw new ParseErrorException("Macro '#" + macroName + "' is not defined at "
-                + Log.formatFileString(info), info);
+                + Log.formatFileString(node), new Info(node));
         }
         
         /**

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java?rev=733416&r1=733415&r2=733416&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
(original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/parser/node/ASTDirective.java
Sat Jan 10 21:26:52 2009
@@ -129,7 +129,7 @@
                 /**
                  * Create a new RuntimeMacro
                  */
-                directive = new RuntimeMacro(directiveName, getTemplateName());
+                directive = new RuntimeMacro(directiveName);
                 directive.setLocation(getLine(), getColumn(), getTemplateName());
         
                 /**

Modified: velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Info.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Info.java?rev=733416&r1=733415&r2=733416&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Info.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/Info.java Sat Jan
10 21:26:52 2009
@@ -20,6 +20,7 @@
  */
 
 import org.apache.velocity.runtime.log.Log;
+import org.apache.velocity.runtime.parser.node.Node;
 
 /**
  *  Little class to carry in info such as template name, line and column
@@ -46,13 +47,18 @@
         this.column = column;
     }
 
+    public Info(Node node)
+    {
+      this(node.getTemplateName(), node.getLine(), node.getColumn());
+    }
+    
     /**
      * Force callers to set the location information.
      */
     private Info()
     {
     }
-
+    
     /**
      * @return The template name.
      */



Mime
View raw message