Package org.apache.sling.scripting.sightly.impl.compiler.optimization

## Class UnusedVariableRemoval

- java.lang.Object
- - org.apache.sling.scripting.sightly.impl.compiler.visitor.UniformVisitor
  - - org.apache.sling.scripting.sightly.impl.compiler.visitor.TrackingVisitor<org.apache.sling.scripting.sightly.impl.compiler.optimization.UnusedVariableRemoval.VariableActivity>
    - - org.apache.sling.scripting.sightly.impl.compiler.optimization.UnusedVariableRemoval

All Implemented Interfaces:
  `CommandVisitor`, `EmitterVisitor`

    public final class UnusedVariableRemoval
    extends TrackingVisitor<org.apache.sling.scripting.sightly.impl.compiler.optimization.UnusedVariableRemoval.VariableActivity>
    implements EmitterVisitor

This optimization removes variables which are bound but never used in the command stream.

### Field Summary

Fields
`static StreamTransformer` `TRANSFORMER`

### Fields inherited from class org.apache.sling.scripting.sightly.impl.compiler.visitor.TrackingVisitor

`tracker`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected org.apache.sling.scripting.sightly.impl.compiler.optimization.UnusedVariableRemoval.VariableActivity` `assignDefault​(Command command)`
`PushStream` `getOutputStream()` Get the output stream
`protected void` `onCommand​(Command command)`
`void` `visit​(VariableBinding.End variableBindingEnd)` Process a `VariableBinding.End` command.
`void` `visit​(VariableBinding.Start variableBindingStart)` Process a `VariableBinding.Start` command.

### Methods inherited from class org.apache.sling.scripting.sightly.impl.compiler.visitor.TrackingVisitor

`visit, visit`

### Methods inherited from class org.apache.sling.scripting.sightly.impl.compiler.visitor.UniformVisitor

`visit, visit, visit, visit, visit, visit, visit, visit`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.sling.scripting.sightly.compiler.commands.CommandVisitor

`visit, visit, visit, visit, visit, visit, visit, visit, visit, visit`

### Field Detail

#### TRANSFORMER

    public static final StreamTransformer TRANSFORMER

### Method Detail

#### getOutputStream

    public PushStream getOutputStream()

Description copied from interface: `EmitterVisitor`
Get the output stream

Specified by:
  `getOutputStream` in interface `EmitterVisitor`
Returns:
  the output stream of this visitor

#### visit

    public void visit​(VariableBinding.Start variableBindingStart)

Description copied from interface: `CommandVisitor`
Process a `VariableBinding.Start` command.

Specified by:
  `visit` in interface `CommandVisitor`
Overrides:
  `visit` in class `TrackingVisitor<org.apache.sling.scripting.sightly.impl.compiler.optimization.UnusedVariableRemoval.VariableActivity>`
Parameters:
  `variableBindingStart` - the command

#### visit

    public void visit​(VariableBinding.End variableBindingEnd)

Description copied from interface: `CommandVisitor`
Process a `VariableBinding.End` command.

Specified by:
  `visit` in interface `CommandVisitor`
Overrides:
  `visit` in class `TrackingVisitor<org.apache.sling.scripting.sightly.impl.compiler.optimization.UnusedVariableRemoval.VariableActivity>`
Parameters:
  `variableBindingEnd` - the command

#### assignDefault

    protected org.apache.sling.scripting.sightly.impl.compiler.optimization.UnusedVariableRemoval.VariableActivity assignDefault​(Command command)

Specified by:
  `assignDefault` in class `TrackingVisitor<org.apache.sling.scripting.sightly.impl.compiler.optimization.UnusedVariableRemoval.VariableActivity>`

#### onCommand

    protected void onCommand​(Command command)

Specified by:
  `onCommand` in class `UniformVisitor`