Top Description Constructors Methods
com.google.escapevelocity

pack-priv final Class SetSpacing

extends Object
Class Inheritance
Imports
com.google.common.collect.Iterables, com.google.escapevelocity.DirectiveNode.SetNode, .Parser.CommentNode, java.util.List

Special treatment of spaces before #set directives.
Author
[email protected] (Éamonn McManus)

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static List<Node>
pack-priv static boolean
shouldRemoveLastNodeBeforeSet(List<Node> nodes)

Implements removal of spaces where appropriate before #set directives.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

SetSpacingback to summary
private SetSpacing()

Method Detail

removeInitialSpaceBeforeSetback to summary
pack-priv static List<Node> removeInitialSpaceBeforeSet(List<Node> nodes)
shouldRemoveLastNodeBeforeSetback to summary
pack-priv static boolean shouldRemoveLastNodeBeforeSet(List<Node> nodes)

Implements removal of spaces where appropriate before #set directives. The last element of the given list is removed if it consists of space and if that space occurs in a context where it is removed before #set. This hack is needed to match what appears to be special treatment in Apache Velocity of spaces before #set directives. If you have thing horizontal whitespace #set, then the whitespace is deleted if the thing is a comment (##...\n); a reference ($x or $x.foo etc); or another #set. Spaces are also removed before #set at the start of a macro definition, but that is implemented by calling removeInitialSpaceBeforeSet.

Newlines are already deleted after a directive or comment, so space will be deleted before the second #set here:

#set ($x = 17)
  #set ($y = 23)
but not here:
#set ($x = 17)

  #set ($y = 23)