|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jrubyparser.util.diff.SequenceMatcher
public class SequenceMatcher
The SequenceMatcher class is used to produce a list of matching nodes. It does most of the work in the diffing process.
NodeDiff| Field Summary | |
|---|---|
protected List<Change> |
diffNodes
|
protected IsJunk |
isJunk
|
protected Node |
newNode
|
protected Node |
oldNode
|
| Constructor Summary | |
|---|---|
SequenceMatcher(Node newNode,
Node oldNode)
Create a SequenceMatcher object without a function for sorting out junk. |
|
SequenceMatcher(Node newNode,
Node oldNode,
IsJunk isJunk)
SequenceMatcher compares two nodes for matching nodes. |
|
| Method Summary | |
|---|---|
int |
calcComplexity(Node node)
Returns an integer representing how many levels of nesting of children the node has. |
protected void |
checkDiffForMoves()
If a node has been moved, our initial diff will contain two changes: one insertion and one deletion. |
protected boolean |
checkForJunk(Node node)
If an isJunk object provided, check the passed in node to see if it should be skipped. |
protected void |
deletedNode(Node node)
A Node in the old AST is no longer present in the new one. |
protected void |
findChanges(Node newNode,
Node oldNode)
This method does the diffing by iterating through the nodes and calling itself recursively. |
List<Change> |
getDiffNodes()
If we already have a diff, return that, otherwise create one. |
Node |
getNewNode()
|
Node |
getOldNode()
|
protected void |
handleBlockNodes(Node childNew,
Node childOld)
BlockNodes are problematic because they are often mismatched in source code where nodes have been moved around. |
protected void |
handleMismatchedNodes(Node childNew,
Node childOld)
Here we deal with the case where two nodes are mismatched. |
protected void |
insertedNode(Node node)
A Node was inserted into the new AST. |
protected void |
modifiedNode(Node newNode,
Node oldNode)
The node in the new AST has been changed. |
void |
setNewNode(Node newNode)
|
void |
setOldNode(Node oldNode)
|
void |
setSequences(Node newNode,
Node oldNode)
|
protected void |
sortNodesIntoDiff(Node childNew,
Node childOld)
Decides what to do with nodes being diffed. |
protected Node |
stripOutNewlines(Node node)
Newlines throw off the diffing algorithm's so we skip those. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected IsJunk isJunk
protected Node newNode
protected Node oldNode
protected List<Change> diffNodes
| Constructor Detail |
|---|
public SequenceMatcher(Node newNode,
Node oldNode)
newNode - The current version of the node.oldNode - The original version of the node being checked.
public SequenceMatcher(Node newNode,
Node oldNode,
IsJunk isJunk)
SequenceMatcher compares two nodes for matching nodes.
isJunk is an object which implements the IsJunk
interface and the #checkJunk() method.
checkJunk is a method which takes a Node and determines
whether or not it should be compared against the other node.
We pass in two nodes. Later, we can use the #setSequence,
#setNewNode and #setOldNode methods to change
out one or both of the nodes and create a new set of matches.
isJunk - A callback used to let users choose nodes not to be
checked in diff.newNode - The current version of the node.oldNode - The node in the old version.IsJunk| Method Detail |
|---|
public final void setSequences(Node newNode,
Node oldNode)
public void setNewNode(Node newNode)
public void setOldNode(Node oldNode)
public Node getNewNode()
public Node getOldNode()
protected void sortNodesIntoDiff(Node childNew,
Node childOld)
childNew - The current version of the node being diffed.childOld - The original version of the node being diffed.
protected void handleMismatchedNodes(Node childNew,
Node childOld)
childNew - The current version of the node being diffed.childOld - The original version of the node being diffed.protected void insertedNode(Node node)
It is possible that it was just mismatched, but we will sort that out later.
node - recieves a Node.protected void deletedNode(Node node)
We assume it was deleted, but we will check for mismatches later.
node - Receives a Node.
protected void modifiedNode(Node newNode,
Node oldNode)
newNode - The Node from the new AST which was modified.oldNode - The original version of the Node, from the old AST.
protected void findChanges(Node newNode,
Node oldNode)
newNode - The node in the new version.oldNode - The node in the old version.
protected void handleBlockNodes(Node childNew,
Node childOld)
childNew - The current version of the node.childOld - The original version of the node.protected boolean checkForJunk(Node node)
node - A Node to be checked against provided callback.
protected Node stripOutNewlines(Node node)
node - node is a Node that needs checked to see if it is a Newline.
protected void checkDiffForMoves()
public List<Change> getDiffNodes()
public int calcComplexity(Node node)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||