public class ASTFacadeHelper extends FacadeHelper
| Modifier and Type | Class and Description |
|---|---|
static class |
ASTFacadeHelper.ASTRewriteWithRemove
Deprecated.
Just use ASTRewrite directly.
|
| Modifier and Type | Field and Description |
|---|---|
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<ASTNode,java.lang.String> |
nodeContents
Map of nodes to node contents.
|
protected ASTNodeConverter |
nodeConverter |
CLASS_PREFIX, compilerCompliance, controlModel, objectToNodeMap| Constructor and Description |
|---|
ASTFacadeHelper() |
| Modifier and Type | Method and Description |
|---|---|
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 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(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(ArrayType arrayType) |
static java.lang.String |
getTypeErasure(ParameterizedType parameterizedType) |
static java.lang.String |
getTypeErasure(PrimitiveType primitiveType) |
static java.lang.String |
getTypeErasure(QualifiedType qualifiedType) |
static java.lang.String |
getTypeErasure(SimpleType simpleType) |
static java.lang.String |
getTypeErasure(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(ASTNode node)
Gets the original contents of the node.
|
static java.lang.String |
toString(Name name)
Converts
Name to string representation. |
static java.lang.String |
toString(SimpleType simpleType)
Converts
SimpleType to a string representation. |
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) |
protected void |
useCurrentOption(java.util.Map<java.lang.Object,java.lang.String> options,
java.lang.String option,
java.lang.String defaultValue) |
applyFormatRules, canMerge, canYieldWrongJavadoc, convertToNode, dispose, disposeNode, fixInterfaceBrace, getChildren, getClassPrefix, getCompilationUnit, getCompilerCompliance, getControlModel, getFirstChild, getMainType, getNext, getObjectToNodeMap, getPackage, getPrevious, getSibiling, isDisposed, isSibilingTraversalExpensive, setCompilerCompliance, setControlModelprotected static final boolean DEBUG
protected ASTNodeConverter nodeConverter
protected java.util.Map<?,?> javaCoreOptions
JavaCore.getOptions()protected java.util.Map<ASTNode,java.lang.String> nodeContents
public static java.lang.String toString(Name name)
Name to string representation.name - null if name parameter is nullpublic static java.lang.String toString(SimpleType simpleType)
SimpleType to a string representation.simpleType - the simple type.null if simple type parameter is nullpublic static java.lang.String getTypeErasure(ArrayType arrayType)
public static java.lang.String getTypeErasure(ParameterizedType parameterizedType)
public static java.lang.String getTypeErasure(PrimitiveType primitiveType)
public static java.lang.String getTypeErasure(SimpleType simpleType)
public static java.lang.String getTypeErasure(QualifiedType qualifiedType)
public static java.lang.String getTypeErasure(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 FacadeHelperprotected ASTParser createASTParser()
ASTParser.public ASTJCompilationUnit createCompilationUnit(java.lang.String name, java.lang.String contents)
createCompilationUnit in class FacadeHelperpublic java.lang.String getOriginalContents(JCompilationUnit compilationUnit)
FacadeHelpergetOriginalContents in class FacadeHelperpublic 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)
protected void useCurrentOption(java.util.Map<java.lang.Object,java.lang.String> options,
java.lang.String option,
java.lang.String defaultValue)
options - option - defaultValue - public ASTNodeConverter getNodeConverter()
getNodeConverter in class FacadeHelpernull if nonepublic java.lang.Object getContext(JNode node)
FacadeHelpergetContext in class FacadeHelperpublic 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 FacadeHelpercontext - ASTJNode that belongs to the same tree that cloned node will be inserted tonode - node that needs to be clonedFacadeHelper.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(ASTNode node)
JNodeprotected ASTJNode<?> doConvertToNode(java.lang.Object object)
doConvertToNode in class FacadeHelperpublic void updateObjectToNodeMap(ASTJNode<?> node)
node - public boolean addChild(JNode node, JNode child)
FacadeHelperaddChild in class FacadeHelpernode - the parent of the child to be addedchild - the new child nodeFacadeHelper.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 FacadeHelpernode - the node to be removedFacadeHelper.remove(org.eclipse.emf.codegen.merge.java.facade.JNode)public void commentOut(JNode node)
FacadeHelperJNode.getChildren()commentOut in class FacadeHelperpublic boolean insertSibling(JNode node, JNode newSibling, boolean before)
FacadeHelperinsertSibling in class FacadeHelpernode - 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(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.
toString in class FacadeHelpernode - node to get contents forpublic 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 recordCopyright © 2019. Licensed under the Eclipse Public License v2.0. All rights reserved.
Submit a bug or feature