|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.emf.codegen.merge.java.facade.FacadeHelper
org.eclipse.emf.codegen.merge.java.facade.ast.ASTFacadeHelper
public class ASTFacadeHelper
Nested Class Summary | |
---|---|
static class |
ASTFacadeHelper.ASTRewriteWithRemove
Deprecated. Just use ASTRewrite directly. |
Field Summary | |
---|---|
protected static boolean |
DEBUG
Debug output setting |
protected java.util.Map<?,?> |
javaCoreOptions
Map of options set by default from JavaCore.getOptions() |
protected java.util.Map<org.eclipse.jdt.core.dom.ASTNode,java.lang.String> |
nodeContents
Map of nodes to node contents. |
protected ASTNodeConverter |
nodeConverter
|
Fields inherited from class org.eclipse.emf.codegen.merge.java.facade.FacadeHelper |
---|
CLASS_PREFIX, controlModel, objectToNodeMap |
Constructor Summary | |
---|---|
ASTFacadeHelper()
|
Method Summary | |
---|---|
boolean |
addChild(JNode node,
JNode child)
Adds the given orphan node (document fragment) as the last child of the specified node. |
protected ASTJField |
cloneField(ASTJField originalField,
ASTJNode<?> contextNode)
Copies the ASTJField node. |
ASTJNode<?> |
cloneNode(java.lang.Object context,
JNode node)
Creates a copy of the node to be inserted in the tree that context node belongs to. |
void |
commentOut(JNode node)
Comment out the node and its children. |
protected org.eclipse.jdt.core.dom.ASTParser |
createASTParser()
Creates and returns ASTParser . |
ASTJCompilationUnit |
createCompilationUnit(java.lang.String name,
java.lang.String contents)
|
protected ASTJNode<?> |
doConvertToNode(java.lang.Object object)
|
ASTJNode<?> |
findParent(org.eclipse.jdt.core.dom.ASTNode node)
Finds the parent node based on the parent of wrapped AST node. |
java.lang.Object |
getContext(JNode node)
Returns the context of a node. |
java.util.Map<?,?> |
getJavaCoreOptions()
Accessor for options to be used during parsing and rewriting. |
ASTNodeConverter |
getNodeConverter()
|
java.lang.String |
getOriginalContents(JCompilationUnit compilationUnit)
Returns the original, unmodified, content of the compilation unit. |
static java.lang.String |
getTypeErasure(org.eclipse.jdt.core.dom.ArrayType arrayType)
|
static java.lang.String |
getTypeErasure(org.eclipse.jdt.core.dom.ParameterizedType parameterizedType)
|
static java.lang.String |
getTypeErasure(org.eclipse.jdt.core.dom.PrimitiveType primitiveType)
|
static java.lang.String |
getTypeErasure(org.eclipse.jdt.core.dom.QualifiedType qualifiedType)
|
static java.lang.String |
getTypeErasure(org.eclipse.jdt.core.dom.SimpleType simpleType)
|
static java.lang.String |
getTypeErasure(org.eclipse.jdt.core.dom.Type type)
Converts Type to string representation, erasing type parameters information. |
boolean |
insertSibling(JNode node,
JNode newSibling,
boolean before)
Inserts the given orphan node as a sibling of the specified node, immediately before or after it. |
void |
logError(java.lang.String string)
Adds a new entry to the log using ERROR level. |
void |
logError(java.lang.String string,
java.lang.Exception e)
Adds a new entry to the log using ERROR level. |
void |
logInfo(java.lang.String string)
Adds a new entry to the log using INFO level. |
boolean |
remove(JNode node)
Removes the given node. |
void |
reset()
|
java.lang.String |
toString(org.eclipse.jdt.core.dom.ASTNode node)
Gets the original contents of the node. |
static java.lang.String |
toString(org.eclipse.jdt.core.dom.Name name)
Converts Name to string representation. |
java.lang.String |
toString(java.lang.Object object)
|
void |
updateObjectToNodeMap(ASTJNode<?> node)
Updates wrapped objects to nodes map. |
protected void |
useCurrentOption(java.util.Map<java.lang.Object,java.lang.String> options,
java.lang.String option)
|
Methods inherited from class org.eclipse.emf.codegen.merge.java.facade.FacadeHelper |
---|
applyFormatRules, canMerge, canYieldWrongJavadoc, convertToNode, dispose, disposeNode, fixInterfaceBrace, getChildren, getClassPrefix, getCompilationUnit, getControlModel, getFirstChild, getMainType, getNext, getObjectToNodeMap, getPackage, getPrevious, getSibiling, isDisposed, isSibilingTraversalExpensive, setControlModel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final boolean DEBUG
protected ASTNodeConverter nodeConverter
protected java.util.Map<?,?> javaCoreOptions
JavaCore.getOptions()
protected java.util.Map<org.eclipse.jdt.core.dom.ASTNode,java.lang.String> nodeContents
Constructor Detail |
---|
public ASTFacadeHelper()
Method Detail |
---|
public static java.lang.String toString(org.eclipse.jdt.core.dom.Name name)
Name
to string representation.
name
-
null
if name parameter is null
public static java.lang.String getTypeErasure(org.eclipse.jdt.core.dom.ArrayType arrayType)
public static java.lang.String getTypeErasure(org.eclipse.jdt.core.dom.ParameterizedType parameterizedType)
public static java.lang.String getTypeErasure(org.eclipse.jdt.core.dom.PrimitiveType primitiveType)
public static java.lang.String getTypeErasure(org.eclipse.jdt.core.dom.SimpleType simpleType)
public static java.lang.String getTypeErasure(org.eclipse.jdt.core.dom.QualifiedType qualifiedType)
public static java.lang.String getTypeErasure(org.eclipse.jdt.core.dom.Type type)
Type
to string representation, erasing type parameters information.
This method is used to create a method signature, and match methods by signature.
type
-
public void reset()
reset
in class FacadeHelper
protected org.eclipse.jdt.core.dom.ASTParser createASTParser()
ASTParser
.
public ASTJCompilationUnit createCompilationUnit(java.lang.String name, java.lang.String contents)
createCompilationUnit
in class FacadeHelper
public java.lang.String getOriginalContents(JCompilationUnit compilationUnit)
FacadeHelper
getOriginalContents
in class FacadeHelper
public java.util.Map<?,?> getJavaCoreOptions()
If options are null
, uses options provided by
getDefaultJavaCoreOptions()
.
getDefaultJavaCoreOptions()
protected void useCurrentOption(java.util.Map<java.lang.Object,java.lang.String> options, java.lang.String option)
public ASTNodeConverter getNodeConverter()
getNodeConverter
in class FacadeHelper
null
if nonepublic java.lang.Object getContext(JNode node)
FacadeHelper
getContext
in class FacadeHelper
public ASTJNode<?> cloneNode(java.lang.Object context, JNode node)
Note that in this implementation the original and returned cloned node can not be modified.
Calls to get...()
methods on the cloned node will not return the original content.
The returned node can only be inserted in the same tree that context node belongs to.
cloneNode
in class FacadeHelper
context
- ASTJNode that belongs to the same tree that cloned node will be inserted tonode
- node that needs to be cloned
FacadeHelper.cloneNode(java.lang.Object, org.eclipse.emf.codegen.merge.java.facade.JNode)
protected ASTJField cloneField(ASTJField originalField, ASTJNode<?> contextNode)
The copied field should not be modified (using set methods) nor read (using get methods), and can only be inserted into the same tree that context node belongs to.
If the source field has only 1 variable, returned field is replaced by contents of original field declaration. The returned field will have no internal structure.
If the source field has multiple variables declared in it, the returned field will contain only 1 variable. Annotations, javadoc and initializer are replaced by original contents with formatting preserved. Other parts of the declaration is not guaranteed to have formatting preserved. The copied field will have source ranges for all nodes relative to the source file, hence, get methods might return incorrect contents.
originalField
- contextNode
- public ASTJNode<?> findParent(org.eclipse.jdt.core.dom.ASTNode node)
JNode
protected ASTJNode<?> doConvertToNode(java.lang.Object object)
doConvertToNode
in class FacadeHelper
public void updateObjectToNodeMap(ASTJNode<?> node)
node
- public boolean addChild(JNode node, JNode child)
FacadeHelper
addChild
in class FacadeHelper
node
- the parent of the child to be addedchild
- the new child node
FacadeHelper.insertSibling(JNode, JNode, boolean)
,
FacadeHelper.remove(JNode)
public boolean remove(JNode node)
Most get...()
operations on the removed node will not give the correct results
even after insertion of the node.
remove
in class FacadeHelper
node
- the node to be removed
FacadeHelper.remove(org.eclipse.emf.codegen.merge.java.facade.JNode)
public void commentOut(JNode node)
FacadeHelper
JNode.getChildren()
commentOut
in class FacadeHelper
public boolean insertSibling(JNode node, JNode newSibling, boolean before)
FacadeHelper
insertSibling
in class FacadeHelper
node
- the node that will be after the new siblingnewSibling
- the new sibling nodebefore
- whether the sibling should be added before the nodeFacadeHelper.addChild(JNode, JNode)
,
FacadeHelper.remove(JNode)
public java.lang.String toString(java.lang.Object object)
toString
in class FacadeHelper
public java.lang.String toString(org.eclipse.jdt.core.dom.ASTNode node)
The contents of the node in AST implementation includes only the node itself without the leading or trailing whitespace. If the node has a Javadoc comment, it is included in the contents. No other leading or trailing comments are included in the node contents.
The given node must be one of the nodes of the AST tree created by createCompilationUnit(String, String)
.
Note that contents is cached on the first access. Therefore, returned contents will not reflect any changes to the nodes.
node
- node to get contents for
public void logInfo(java.lang.String string)
string
- to add to the logpublic void logError(java.lang.String string)
string
- to add to the logpublic void logError(java.lang.String string, java.lang.Exception e)
string
- to add to the loge
- exception to record
|
Copyright 2001-2006 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |