class CreateSyntheticBlocks extends java.lang.Object implements CompilerPass
Modifier and Type | Class and Description |
---|---|
private class |
CreateSyntheticBlocks.Callback |
private static class |
CreateSyntheticBlocks.Marker |
Modifier and Type | Field and Description |
---|---|
private AbstractCompiler |
compiler |
private java.lang.String |
endMarkerName
Name of the end marker.
|
(package private) static DiagnosticType |
INVALID_MARKER_USAGE |
private java.util.Deque<Node> |
markerStack
Markers can be nested.
|
private java.lang.String |
startMarkerName
Name of the start marker.
|
(package private) static DiagnosticType |
UNMATCHED_END_MARKER |
(package private) static DiagnosticType |
UNMATCHED_START_MARKER |
private java.util.List<CreateSyntheticBlocks.Marker> |
validMarkers |
Constructor and Description |
---|
CreateSyntheticBlocks(AbstractCompiler compiler,
java.lang.String startMarkerName,
java.lang.String endMarkerName) |
Modifier and Type | Method and Description |
---|---|
private void |
addBlocks(CreateSyntheticBlocks.Marker marker) |
private static Node |
childAfter(Node parent,
Node siblingBefore)
Like Node.getNext, that null is used to signal the child before the
block.
|
private void |
moveSiblingExclusive(Node src,
Node dest,
Node start,
Node end)
Move the Nodes between start and end from the source block to the
destination block.
|
void |
process(Node externs,
Node root)
Process the JS with root node root.
|
private static Node |
removeChildAfter(Node parent,
Node siblingBefore)
Like removeChildAfter, the firstChild is removed
|
static final DiagnosticType UNMATCHED_START_MARKER
static final DiagnosticType UNMATCHED_END_MARKER
static final DiagnosticType INVALID_MARKER_USAGE
private final AbstractCompiler compiler
private final java.lang.String startMarkerName
private final java.lang.String endMarkerName
private final java.util.Deque<Node> markerStack
private final java.util.List<CreateSyntheticBlocks.Marker> validMarkers
public CreateSyntheticBlocks(AbstractCompiler compiler, java.lang.String startMarkerName, java.lang.String endMarkerName)
public void process(Node externs, Node root)
CompilerPass
process
in interface CompilerPass
externs
- Top of external JS treeroot
- Top of JS treeprivate void addBlocks(CreateSyntheticBlocks.Marker marker)
marker
- The marker to add synthetic blocks for.private void moveSiblingExclusive(Node src, Node dest, @Nullable Node start, @Nullable Node end)
private static Node childAfter(Node parent, @Nullable Node siblingBefore)