geirm       00/12/07 19:19:00

  Modified:    src/java/org/apache/velocity/runtime/parser/node
                        ASTSetDirective.java
  Log:
  For the inline set, outputs a warning to the runtime log when the original version 
is used.
  
  Revision  Changes    Path
  1.9       +29 -1     
jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
  
  Index: ASTSetDirective.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ASTSetDirective.java      2000/12/04 02:03:59     1.8
  +++ ASTSetDirective.java      2000/12/08 03:19:00     1.9
  @@ -59,7 +59,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
  - * @version $Id: ASTSetDirective.java,v 1.8 2000/12/04 02:03:59 geirm Exp $
  + * @version $Id: ASTSetDirective.java,v 1.9 2000/12/08 03:19:00 geirm Exp $
    */
   
   package org.apache.velocity.runtime.parser.node;
  @@ -76,6 +76,8 @@
   {
       private Node right;
       private ASTReference left;
  +    boolean bDeprecated = true;
  +    String lit = "";
   
       public ASTSetDirective(int id)
       {
  @@ -106,6 +108,28 @@
   
           right = getRightHandSide();
           left = getLeftHandSide();
  +
  +        /*
  +         *   yechy but quick : so we can warn users they are using what will be 
  +         *  the deprecated version of #set
  +         *  If we see a '(', then it is [most likely] the inline kind
  +         *
  +         */
  +        Token t = getFirstToken();
  +        Token tLast = getLastToken();
  +
  +        while( t != null && t != tLast ) 
  +        {
  +            lit += t;
  +
  +            if (t.toString().indexOf("(") != -1)
  +            {
  +                bDeprecated = false;
  +                break;
  +            }
  +
  +            t = t.next;
  +        }
    
           return data;
       }        
  @@ -143,6 +167,10 @@
           else
               left.setValue(context, value);
       
  +        if (bDeprecated)
  +            Runtime.warn("Deprecated form of #set directive in " + 
context.getCurrentTemplateName() 
  +                     + " [line "+left.getLine() + "] : " + lit);
  +
           return true;
       }
   
  
  
  

Reply via email to