geirm 01/01/24 09:04:46
Modified: src/java/org/apache/velocity/runtime/directive
VMProxyArg.java
Log:
Added error logging to help people cope with the new VM implementation.
Previously, you could get away with
#foo( bar )
when you really meant
#foo( "bar" )
The difference is that we only allow 'words' as directive args when they are
a 'helper' word, like 'in' found in #foreach( $a in $b )
So now, it logs it, and the arg is rendered as the context arg for the VM, so
the user visually knows something is wrong.
We could allow it, but wrapping the word into a string lit,
but I think we should nip this now.
Revision Changes Path
1.3 +18 -4
jakarta-velocity/src/java/org/apache/velocity/runtime/directive/VMProxyArg.java
Index: VMProxyArg.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/runtime/directive/VMProxyArg.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- VMProxyArg.java 2001/01/14 14:57:57 1.2
+++ VMProxyArg.java 2001/01/24 17:04:42 1.3
@@ -109,7 +109,7 @@
* into a local context.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Geir Magnusson Jr.</a>
- * @version $Id: VMProxyArg.java,v 1.2 2001/01/14 14:57:57 geirm Exp $
+ * @version $Id: VMProxyArg.java,v 1.3 2001/01/24 17:04:42 geirm Exp $
*/
public class VMProxyArg
{
@@ -379,7 +379,7 @@
}
else
{
- Runtime.error(" VMProxyArg.getObject() : unsupported type : (" +
callerReference +") " + nodeTree.getType() );
+ Runtime.error("Unsupported VM arg type : VM arg = " + callerReference +"
type = " + type + "( VMProxyArg.getObject() )");
}
return retObject;
@@ -470,11 +470,25 @@
staticObject = new Integer(callerReference);
break;
}
+
+ case ParserTreeConstants.JJTWORD :
+ {
+ /*
+ * this is technically an error...
+ */
+
+ Runtime.error("Unsupported arg type : " + callerReference
+ + " You most likely intended to call a VM with a
string literal, so enclose with ' or \" characters. (VMProxyArg.setup())");
+ constant = true;
+ staticObject = new String( callerReference );
+
+ break;
+ }
default :
{
- Runtime.error(" VMProxyArg.setup() : unsupported type : ("
- + callerReference +") " + nodeTree.getType() +
" : " + nodeTree );
+ Runtime.error(" VMProxyArg.setup() : unsupported type : "
+ + callerReference );
}
}
}