public class JMerger
extends java.lang.Object
run(java.lang.Object)
,
which is called just like main during headless workbench invocation.Modifier and Type | Class and Description |
---|---|
class |
JMerger.PullTargetVisitor |
class |
JMerger.PushSourceVisitor |
Modifier and Type | Field and Description |
---|---|
protected JControlModel |
controlModel |
static boolean |
DEBUG |
static java.lang.String |
DEFAULT_FACADE_HELPER_CLASS |
protected boolean |
fixInterfaceBrace |
protected static java.util.regex.Pattern |
interfaceBracePattern |
protected boolean |
isBlocked |
protected static java.lang.Object[] |
NO_ARGUMENTS |
protected boolean |
noAbstractTypeConversion |
protected java.util.Map<JNode,java.util.List<JNode>> |
orderedSourceChildrenMap |
protected JCompilationUnit |
sourceCompilationUnit |
protected JPatternDictionary |
sourcePatternDictionary |
protected java.util.Map<JNode,JNode> |
sourceToTargetMap |
protected boolean |
targetCompilationChanged |
protected JCompilationUnit |
targetCompilationUnit |
protected boolean |
targetCompilationUnitExists |
protected JPatternDictionary |
targetPatternDictionary |
protected java.util.Map<JNode,JNode> |
targetToSourceMap |
Constructor and Description |
---|
JMerger()
This creates an empty instances, an when used as a runnable.
|
JMerger(JControlModel controlModel) |
Modifier and Type | Method and Description |
---|---|
protected void |
applyPullRules(JNode sourceNode,
JNode targetNode) |
protected void |
applySortRules(JNode sourceNode) |
protected boolean |
applySweepRules(JNode targetNode) |
protected boolean |
areCompatible(JNode sourceNode,
JNode targetNode)
Checks if two nodes are compatible and can be merged.
|
protected JNode |
convertTarget(JAbstractType targetAbstractType,
java.lang.Class<? extends JAbstractType> sourceClass)
Converts the target abstract type to be compatible with the given source node class
|
JCompilationUnit |
createCompilationUnitForContents(java.lang.String contents) |
JCompilationUnit |
createCompilationUnitForInputStream(java.io.InputStream inputStream) |
JCompilationUnit |
createCompilationUnitForInputStream(java.io.InputStream inputStream,
java.lang.String encoding) |
JCompilationUnit |
createCompilationUnitForURI(java.lang.String uri)
Creates a JCompilationUnit from a URI.
|
JCompilationUnit |
createCompilationUnitForURI(java.lang.String uri,
java.lang.String encoding)
Creates a JCompilationUnit from a URI.
|
protected FacadeVisitor |
createPullTargetVisitor() |
protected FacadeVisitor |
createPushSourceVisitor() |
java.lang.String |
execute(Monitor monitor,
java.lang.String[] arguments)
Utility for headless operations.
|
JControlModel |
getControlModel() |
JCompilationUnit |
getSourceCompilationUnit() |
java.lang.String |
getSourceCompilationUnitContents() |
JPatternDictionary |
getSourcePatternDictionary() |
JCompilationUnit |
getTargetCompilationUnit() |
java.lang.String |
getTargetCompilationUnitContents() |
JPatternDictionary |
getTargetPatternDictionary() |
protected JNode |
insertClone(JNode sourceNode) |
boolean |
isFixInterfaceBrace() |
protected boolean |
isPushMarkedUp(JNode node)
Checks if the node is marked up for pushing.
|
protected void |
map(JNode sourceNode,
JNode targetNode)
Maps the specified source and target nodes.
|
protected void |
mapChildren(JNode sourceNode,
JNode targetNode) |
void |
merge() |
protected void |
pullTargetCompilationUnit() |
protected void |
pushSourceCompilationUnit() |
void |
remerge() |
void |
reset()
Resets this JMerger.
|
java.lang.Object |
run(java.lang.Object object)
This is called with the command line arguments of a headless workbench invocation.
|
void |
setFixInterfaceBrace(boolean fixInterfaceBrace) |
void |
setSourceCompilationUnit(JCompilationUnit sourceCompilationUnit) |
void |
setSourcePatternDictionary(JPatternDictionary sourcePatternDictionary) |
void |
setTargetCompilationUnit(JCompilationUnit targetCompilationUnit) |
void |
setTargetPatternDictionary(JPatternDictionary targetPatternDictionary) |
protected void |
sortTargetCompilationUnit() |
protected void |
sweepTargetCompilationUnit() |
public static final boolean DEBUG
public static final java.lang.String DEFAULT_FACADE_HELPER_CLASS
protected static final java.lang.Object[] NO_ARGUMENTS
protected static java.util.regex.Pattern interfaceBracePattern
protected JControlModel controlModel
protected JCompilationUnit sourceCompilationUnit
protected JCompilationUnit targetCompilationUnit
protected JPatternDictionary sourcePatternDictionary
protected JPatternDictionary targetPatternDictionary
protected java.util.Map<JNode,java.util.List<JNode>> orderedSourceChildrenMap
protected boolean fixInterfaceBrace
protected boolean isBlocked
protected boolean targetCompilationUnitExists
protected boolean targetCompilationChanged
protected boolean noAbstractTypeConversion
public JMerger()
public JMerger(JControlModel controlModel)
public void reset()
public void merge()
public void remerge()
public JCompilationUnit createCompilationUnitForInputStream(java.io.InputStream inputStream)
public JCompilationUnit createCompilationUnitForInputStream(java.io.InputStream inputStream, java.lang.String encoding)
public JCompilationUnit createCompilationUnitForURI(java.lang.String uri)
public JCompilationUnit createCompilationUnitForURI(java.lang.String uri, java.lang.String encoding)
public JCompilationUnit createCompilationUnitForContents(java.lang.String contents)
public JControlModel getControlModel()
public JCompilationUnit getSourceCompilationUnit()
public void setSourceCompilationUnit(JCompilationUnit sourceCompilationUnit)
public java.lang.String getSourceCompilationUnitContents()
public JCompilationUnit getTargetCompilationUnit()
public void setTargetCompilationUnit(JCompilationUnit targetCompilationUnit)
public java.lang.String getTargetCompilationUnitContents()
public JPatternDictionary getSourcePatternDictionary()
public void setSourcePatternDictionary(JPatternDictionary sourcePatternDictionary)
public JPatternDictionary getTargetPatternDictionary()
public void setTargetPatternDictionary(JPatternDictionary targetPatternDictionary)
public boolean isFixInterfaceBrace()
public void setFixInterfaceBrace(boolean fixInterfaceBrace)
protected void pullTargetCompilationUnit()
protected FacadeVisitor createPullTargetVisitor()
protected void pushSourceCompilationUnit()
protected FacadeVisitor createPushSourceVisitor()
protected void sortTargetCompilationUnit()
protected void sweepTargetCompilationUnit()
protected void applySortRules(JNode sourceNode)
protected boolean applySweepRules(JNode targetNode)
protected boolean areCompatible(JNode sourceNode, JNode targetNode)
This method must always return false
if target node
can have children that can not be added to source node.
sourceNode
- targetNode
- true
if nodes can be merged, false
otherwiseprotected JNode convertTarget(JAbstractType targetAbstractType, java.lang.Class<? extends JAbstractType> sourceClass)
targetAbstractType
- sourceClass
- the class to which to convert the node.null
when conversion not possible, converted node otherwiseprotected boolean isPushMarkedUp(JNode node)
Node is considered marked up by default if there are no push rules for this node class.
The first push rule that matches the node makes the node marked up, and no further checking is performed.
If the push rule does not match the node, but the push rule is defined for the same node class, then the node will not be marked up, unless any of the following push rules will match the node.
node
- true
if node should be pushed, false
otherwiseprotected void map(JNode sourceNode, JNode targetNode)
sourceNode
- targetNode
- public java.lang.Object run(java.lang.Object object)
public java.lang.String execute(Monitor monitor, java.lang.String[] arguments)