Author: nbubna
Date: Thu Mar 12 04:32:20 2009
New Revision: 752769
URL: http://svn.apache.org/viewvc?rev=752769&view=rev
Log:
remove Context.Scope and ProxyVMContext and do a little VelocimacroProxy
refactoring on the side
Removed:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/ProxyVMContext.java
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/Context.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/EvaluateContext.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/InternalContextAdapterImpl.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/InternalWrapperContext.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/VelocimacroProxy.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity615TestCase.java
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java?rev=752769&r1=752768&r2=752769&view=diff
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java
(original)
+++
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/ChainedInternalContextAdapter.java
Thu Mar 12 04:32:20 2009
@@ -256,32 +256,4 @@
{
return wrappedContext.getCurrentResource();
}
-
- /**
- * Associated the value with the given key from the given scope, the
default implementation
- * is to ignore the scope and simply place the value into the
wrappedContext.
- */
- public Object put(String key, Object value, Scope scope)
- {
- return wrappedContext.put(key, value);
- }
-
- /**
- * Retrieve the value associated with the given key from the specified
scope.
- * The default implementation is to ignore the scope and retrieve the value
- * from the wrappedContext.
- */
- public Object get(String key, Scope scope)
- {
- return wrappedContext.get(key);
- }
-
- /**
- * Return true if the context of the specifed scope contains key. The
default
- * implementation ignores scope.
- */
- public boolean containsKey(String key, Scope scope)
- {
- return wrappedContext.containsKey(key);
- }
}
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/Context.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/Context.java?rev=752769&r1=752768&r2=752769&view=diff
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/Context.java
(original)
+++
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/Context.java
Thu Mar 12 04:32:20 2009
@@ -37,9 +37,6 @@
*/
public interface Context
{
- public enum Scope {DEFAULT, LOCAL, GLOBAL}
-
-
/**
* Adds a name/value pair to the context.
*
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/EvaluateContext.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/EvaluateContext.java?rev=752769&r1=752768&r2=752769&view=diff
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/EvaluateContext.java
(original)
+++
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/EvaluateContext.java
Thu Mar 12 04:32:20 2009
@@ -183,42 +183,4 @@
return localContext.remove( key );
}
- /**
- * Put a value into the appropriate context specified by 'scope'
- */
- public Object put(String key, Object value, Scope scope)
- {
- switch (scope)
- {
- case GLOBAL: return super.put(key, value);
- case LOCAL: return localContext.put(key, value);
- default: return put(key, value); // DEFAULT scope
- }
- }
-
- /**
- * Returns a value associated with 'key' from the specified 'scope'
- */
- public Object get(String key, Scope scope)
- {
- switch (scope)
- {
- case GLOBAL: return super.get(key);
- case LOCAL: return localContext.get(key);
- default: return get(key); // DEFAULT scope
- }
- }
-
- /**
- * Returns true if the specified scope contains 'key'
- */
- public boolean containsKey(String key, Scope scope)
- {
- switch (scope)
- {
- case GLOBAL: return super.containsKey(key);
- case LOCAL: return localContext.containsKey(key);
- default: return containsKey(key); // DEFAULT scope
- }
- }
}
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/InternalContextAdapterImpl.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/InternalContextAdapterImpl.java?rev=752769&r1=752768&r2=752769&view=diff
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/InternalContextAdapterImpl.java
(original)
+++
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/InternalContextAdapterImpl.java
Thu Mar 12 04:32:20 2009
@@ -335,34 +335,6 @@
return null;
}
- /**
- * Retrieve the value associated with key.
- * This class will always be used as the global context, so we ignore
- * scope and retrieve the value from Context.
- */
- public Object get(String key, Scope scope)
- {
- return context.get(key);
- }
-
- /**
- * Put the value assocated with key into the context.
- * @see #get(String, org.apache.velocity.context.Context.Scope) for notes
about scope
- */
- public Object put(String key, Object value, Scope scope)
- {
- return context.put(key, value);
- }
-
- /**
- * Returns true if key is in the context.
- * @see #get(String, org.apache.velocity.context.Context.Scope) for notes
about scope
- */
- public boolean containsKey(String key, Scope scope)
- {
- return context.containsKey(key);
- }
-
}
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/InternalWrapperContext.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/InternalWrapperContext.java?rev=752769&r1=752768&r2=752769&view=diff
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/InternalWrapperContext.java
(original)
+++
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/context/InternalWrapperContext.java
Thu Mar 12 04:32:20 2009
@@ -1,7 +1,5 @@
package org.apache.velocity.context;
-import org.apache.velocity.context.Context.Scope;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -46,16 +44,16 @@
/**
* Retrieve the specified key value pair from the given scope.
*/
- Object put(String key, Object value, Scope scope);
+ Object put(String key, Object value);
/**
* Place key value pair into the context of the specified scope.
*/
- Object get(String key, Scope scope);
+ Object get(String key);
/**
* Tests if the key exists in the specified scope
*/
- boolean containsKey(String key, Scope scope);
+ boolean containsKey(Object key);
}
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java?rev=752769&r1=752768&r2=752769&view=diff
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java
(original)
+++
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Parse.java
Thu Mar 12 04:32:20 2009
@@ -27,7 +27,6 @@
import org.apache.velocity.Template;
import org.apache.velocity.app.event.EventHandlerUtil;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.context.ProxyVMContext;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java?rev=752769&r1=752768&r2=752769&view=diff
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java
(original)
+++
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Scope.java
Thu Mar 12 04:32:20 2009
@@ -67,6 +67,18 @@
return getStorage().entrySet();
}
+ @Override
+ public Object get(Object key)
+ {
+ Object o = super.get(key);
+ if (o == null && parent != null && !containsKey(key))
+ {
+ return parent.get(key);
+ }
+ return o;
+ }
+
+ @Override
public Object put(Object key, Object value)
{
return getStorage().put(key, value);
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=752769&r1=752768&r2=752769&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
Thu Mar 12 04:32:20 2009
@@ -24,9 +24,7 @@
import java.util.List;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.context.ProxyVMContext;
import org.apache.velocity.exception.MacroOverflowException;
-import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.Renderable;
import org.apache.velocity.runtime.RuntimeConstants;
@@ -126,8 +124,26 @@
return numMacroArgs;
}
+ /**
+ * Initialize members of VelocimacroProxy. called from MacroEntry
+ */
+ public void init(RuntimeServices rs)
+ {
+ rsvc = rs;
+
+ // this is a very expensive call (ExtendedProperties is very slow)
+ strictArguments = rs.getConfiguration().getBoolean(
+ RuntimeConstants.VM_ARGUMENTS_STRICT, false);
+
+ // get the macro call depth limit
+ maxCallDepth = rsvc.getInt(RuntimeConstants.VM_MAX_DEPTH);
+
+ // get name of the reference that refers to AST block passed to block
macro call
+ bodyReference = rsvc.getString(RuntimeConstants.VM_BODY_REFERENCE,
"bodyContent");
+ }
+
public boolean render(InternalContextAdapter context, Writer writer, Node
node)
- throws IOException, MethodInvocationException,
MacroOverflowException
+ throws IOException
{
return render(context, writer, node, null);
}
@@ -138,32 +154,93 @@
* @param context Current rendering context
* @param writer Writer for output
* @param node AST that calls the macro
- * @return True if the directive rendered successfully.
+ * @param body the macro body
+ * @return true if the directive rendered successfully.
* @throws IOException
- * @throws MethodInvocationException
- * @throws MacroOverflowException
*/
public boolean render(InternalContextAdapter context, Writer writer,
Node node, Renderable body)
- throws IOException, MethodInvocationException,
MacroOverflowException
+ throws IOException
{
- // wrap the current context and add the macro arguments
-
- // the creation of this context is a major bottleneck (incl 2x HashMap)
- final ProxyVMContext vmc = new ProxyVMContext(context);
-
int callArgNum = node.jjtGetNumChildren();
// if this macro was invoked by a call directive, we might have a body
AST here.
- // Put it into context.
- if( body != null )
+ Object oldBodyRef = null;
+ if (body != null)
{
- vmc.put(bodyReference, body);
+ oldBodyRef = context.get(bodyReference);
+ context.put(bodyReference, body);
callArgNum--; // Remove the body AST from the arg count
}
-
+
+ // is everything copacetic?
+ checkArgumentCount(node, callArgNum);
+ checkDepth(context);
+
+ // put macro arg values and save the returned old/new value pairs
+ Object[][] values = handleArgValues(context, node, callArgNum);
+ try
+ {
+ // render the velocity macro
+ context.pushCurrentMacroName(macroName);
+ nodeTree.render(context, writer);
+ context.popCurrentMacroName();
+ return true;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ String msg = "VelocimacroProxy.render() : exception VM = #" +
macroName + "()";
+ rsvc.getLog().error(msg, e);
+ throw new VelocityException(msg, e);
+ }
+ finally
+ {
+ // clean up after the args and bodyRef
+ // but only if they weren't overridden inside
+ Object current = context.get(bodyReference);
+ if (current == body)
+ {
+ if (oldBodyRef != null)
+ {
+ context.put(bodyReference, oldBodyRef);
+ }
+ else
+ {
+ context.remove(bodyReference);
+ }
+ }
+
+ for (int i = 1; i < macroArgs.size(); i++)
+ {
+ MacroArg macroArg = macroArgs.get(i);
+ current = context.get(macroArg.name);
+ if (current == values[i-1][1])
+ {
+ Object old = values[i-1][0];
+ if (old != null)
+ {
+ context.put(macroArg.name, old);
+ }
+ else
+ {
+ context.remove(macroArg.name);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Check whether the number of arguments given matches the number defined.
+ */
+ protected void checkArgumentCount(Node node, int callArgNum)
+ {
// Check if we have more calling arguments then the macro accepts
- if (callArgNum > macroArgs.size() -1)
+ if (callArgNum > macroArgs.size() - 1)
{
if (strictArguments)
{
@@ -171,27 +248,78 @@
+ macroArgs.get(0).name + " accepts at most " +
(macroArgs.size()-1)
+ " at " + Log.formatFileString(node));
}
- else // Backward compatibility logging, Mainly for
MacroForwardDefinedTestCase
+ else if (rsvc.getLog().isDebugEnabled())
{
- rsvc.getLog().debug("VM #" + macroArgs.get(0).name
- + ": too many arguments to macro. Wanted " +
(macroArgs.size()-1)
- + " got " + callArgNum);
+ // Backward compatibility logging, Mainly for
MacroForwardDefinedTestCase
+ rsvc.getLog().debug("VM #" + macroArgs.get(0).name
+ + ": too many arguments to macro. Wanted " +
(macroArgs.size()-1)
+ + " got " + callArgNum);
}
}
+ }
+
+ /**
+ * check that we aren't already at the max call depth and throws
+ * a MacroOverflowException if we are there.
+ */
+ protected void checkDepth(InternalContextAdapter context)
+ {
+ if (maxCallDepth > 0 && maxCallDepth ==
context.getCurrentMacroCallDepth())
+ {
+ String templateName = context.getCurrentTemplateName();
+ Object[] stack = context.getMacroNameStack();
+
+ StringBuffer out = new StringBuffer(100)
+ .append("Max calling depth of ").append(maxCallDepth)
+ .append(" was exceeded in macro '").append(macroName)
+ .append("' with Call Stack:");
+ for (int i = 0; i < stack.length; i++)
+ {
+ if (i != 0)
+ {
+ out.append("->");
+ }
+ out.append(stack[i]);
+ }
+ out.append(" at " + Log.formatFileString(this));
+ rsvc.getLog().error(out.toString());
+
+ // clean out the macro stack, since we just broke it
+ while (context.getCurrentMacroCallDepth() > 0)
+ {
+ context.popCurrentMacroName();
+ }
+ throw new MacroOverflowException(out.toString());
+ }
+ }
+
+ /**
+ * Gets the macro argument values and puts them in the context under
+ * the argument names. Store and return an array of old and new values
+ * paired for each argument name, for later cleanup.
+ */
+ protected Object[][] handleArgValues(InternalContextAdapter context,
+ Node node, int callArgNum)
+ {
+ Object[][] values = new Object[macroArgs.size()][2];
// Move arguments into the macro's context. Start at one to skip macro
name
for (int i = 1; i < macroArgs.size(); i++)
{
MacroArg macroArg = macroArgs.get(i);
+ values[i-1][0] = context.get(macroArg.name);
+
+ // put the new value in
+ Object newVal = null;
if (i - 1 < callArgNum)
{
// There's a calling value.
- vmc.put(macroArg.name, node.jjtGetChild(i - 1).value(context));
+ newVal = node.jjtGetChild(i - 1).value(context);
}
else if (macroArg.defaultVal != null)
{
// We don't have a calling value, but the macro defines a
default value
- vmc.put(macroArg.name, macroArg.defaultVal.value(context));
+ newVal = macroArg.defaultVal.value(context);
}
else if (strictArguments)
{
@@ -207,97 +335,25 @@
+ macroArgs.get(0).name + " but only " + callArgNum + "
where provided at "
+ Log.formatFileString(node));
}
- else // Backward compatibility logging, Mainly for
MacroForwardDefinedTestCase
+ else
{
- rsvc.getLog().debug("VM #" + macroArgs.get(0).name
- + ": too few arguments to macro. Wanted " +
(macroArgs.size()-1)
- + " got " + callArgNum);
- break;
- }
- }
-
-
- /*
- * check that we aren't already at the max call depth
- */
- if (maxCallDepth > 0 && maxCallDepth == vmc.getCurrentMacroCallDepth())
- {
- String templateName = vmc.getCurrentTemplateName();
- Object[] stack = vmc.getMacroNameStack();
-
- StringBuffer out = new StringBuffer(100)
- .append("Max calling depth of ").append(maxCallDepth)
- .append(" was exceeded in macro '").append(macroName)
- .append("' with Call Stack:");
- for (int i = 0; i < stack.length; i++)
- {
- if (i != 0)
+ // Backward compatibility logging, Mainly for
MacroForwardDefinedTestCase
+ if (rsvc.getLog().isDebugEnabled())
{
- out.append("->");
+ rsvc.getLog().debug("VM #" + macroArgs.get(0).name
+ + ": too few arguments to macro. Wanted " +
(macroArgs.size()-1)
+ + " got " + callArgNum);
}
- out.append(stack[i]);
- }
- out.append(" at " + Log.formatFileString(this));
- rsvc.getLog().error(out.toString());
-
- // clean out the macro stack, since we just broke it
- while (vmc.getCurrentMacroCallDepth() > 0)
- {
- vmc.popCurrentMacroName();
+ break;
}
- throw new MacroOverflowException(out.toString());
+ context.put(macroArg.name, newVal);
+ values[i-1][1] = newVal;
}
- try
- {
- // render the velocity macro
- vmc.pushCurrentMacroName(macroName);
- nodeTree.render(vmc, writer);
- vmc.popCurrentMacroName();
- return true;
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- String msg = "VelocimacroProxy.render() : exception VM = #" +
macroName + "()";
- rsvc.getLog().error(msg, e);
- throw new VelocityException(msg, e);
- }
- }
-
- /**
- * Initialize members of VelocimacroProxy. called from MacroEntry
- */
- public void init(RuntimeServices rs)
- {
- rsvc = rs;
-
- // this is a very expensive call (ExtendedProperties is very slow)
- strictArguments = rs.getConfiguration().getBoolean(
- RuntimeConstants.VM_ARGUMENTS_STRICT, false);
-
- // get the macro call depth limit
- maxCallDepth = rsvc.getInt(RuntimeConstants.VM_MAX_DEPTH);
-
- // get name of the reference that refers to AST block passed to block
macro call
- bodyReference = rsvc.getString(RuntimeConstants.VM_BODY_REFERENCE,
"bodyContent");
+ // return the array of replaced and new values
+ return values;
}
-
- /**
- * Build an error message for not providing the correct number of arguments
- */
- private String buildErrorMsg(Node node, int numArgsProvided)
- {
- String msg = "VM #" + macroName + ": too "
- + ((getNumArgs() > numArgsProvided) ? "few" : "many") + " arguments
to macro. Wanted "
- + getNumArgs() + " got " + numArgsProvided;
- return msg;
- }
-
}
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java?rev=752769&r1=752768&r2=752769&view=diff
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
(original)
+++
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTReference.java
Thu Mar 12 04:32:20 2009
@@ -26,7 +26,6 @@
import org.apache.velocity.app.event.EventHandlerUtil;
import org.apache.velocity.context.Context;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.context.Context.Scope;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.TemplateInitException;
import org.apache.velocity.exception.VelocityException;
@@ -229,7 +228,7 @@
* get the root object from the context
*/
- Object result = getVariableValue(context, rootString, Scope.DEFAULT);
+ Object result = getVariableValue(context, rootString);
if (result == null && !strictRef)
{
@@ -583,12 +582,12 @@
* @return true if successful, false otherwise
* @throws MethodInvocationException
*/
- public boolean setValue(InternalContextAdapter context, Object value,
Scope scope)
+ public boolean setValue(InternalContextAdapter context, Object value)
throws MethodInvocationException
{
if (jjtGetNumChildren() == 0)
{
- context.put(rootString, value, scope);
+ context.put(rootString, value);
return true;
}
@@ -598,7 +597,7 @@
* object we will apply reflection to.
*/
- Object result = getVariableValue(context, rootString, scope);
+ Object result = getVariableValue(context, rootString);
if (result == null)
{
@@ -978,12 +977,12 @@
* @return The evaluated value of the variable.
* @throws MethodInvocationException
*/
- public Object getVariableValue(InternalContextAdapter context, String
variable, Scope scope)
+ public Object getVariableValue(InternalContextAdapter context, String
variable)
{
Object obj = null;
try
{
- obj = context.get(variable, scope);
+ obj = context.get(variable);
}
catch(RuntimeException e)
{
@@ -994,7 +993,7 @@
if (obj == null && strictRef)
{
- if (!context.containsKey(variable, scope))
+ if (!context.containsKey(variable))
{
log.error("Variable $" + variable + " has not been set at "
+ Log.formatFileString(uberInfo));
Modified:
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java?rev=752769&r1=752768&r2=752769&view=diff
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
(original)
+++
velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/parser/node/ASTSetDirective.java
Thu Mar 12 04:32:20 2009
@@ -24,7 +24,6 @@
import org.apache.velocity.app.event.EventHandlerUtil;
import org.apache.velocity.context.InternalContextAdapter;
-import org.apache.velocity.context.Context.Scope;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.TemplateInitException;
import org.apache.velocity.runtime.RuntimeConstants;
@@ -186,16 +185,7 @@
EventHandlerUtil.invalidSetMethod(rsvc, context, leftReference,
rightReference, uberInfo);
}
- return left.setValue(context, value, getScope());
- }
-
- /**
- * Return the scope this set directive will operate under. We override
this method
- * with the #global and #local directives to specify the appropriate scope.
- */
- public Scope getScope()
- {
- return Scope.DEFAULT;
+ return left.setValue(context, value);
}
Modified:
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity615TestCase.java
URL:
http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity615TestCase.java?rev=752769&r1=752768&r2=752769&view=diff
==============================================================================
---
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity615TestCase.java
(original)
+++
velocity/engine/branches/2.0_Exp/src/test/org/apache/velocity/test/issues/Velocity615TestCase.java
Thu Mar 12 04:32:20 2009
@@ -39,7 +39,6 @@
engine.setProperty("velocimacro.permissions.allow.inline", "true");
engine.setProperty("velocimacro.permissions.allow.inline.to.replace.global",
"false");
engine.setProperty("velocimacro.permissions.allow.inline.local.scope",
"true");
- engine.setProperty("velocimacro.context.localscope", "false");
engine.setProperty("velocimacro.arguments.strict", "true");
}