本文整理了Java中org.eclipse.jdt.core.dom.ASTNode.setProperty()
方法的一些代码示例,展示了ASTNode.setProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ASTNode.setProperty()
方法的具体详情如下:
包路径:org.eclipse.jdt.core.dom.ASTNode
类名称:ASTNode
方法名:setProperty
[英]Sets the named property of this node to the given value, or to null
to clear it.
Clients should employ property names that are sufficiently unique to avoid inadvertent conflicts with other clients that might also be setting properties on the same node.
Note that modifying a property is not considered a modification to the AST itself. This is to allow clients to decorate existing nodes with their own properties without jeopardizing certain things (like the validity of bindings), which rely on the underlying tree remaining static.
[中]将此节点的命名属性设置为给定值,或设置为null
以清除它。
客户端应使用足够唯一的属性名称,以避免与可能也在同一节点上设置属性的其他客户端发生意外冲突。
请注意,修改属性并不视为对AST本身的修改。这是为了允许客户端使用自己的属性来修饰现有节点,而不损害某些依赖于底层树保持静态的东西(如绑定的有效性)。
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
/**
* @param node the ASTNode
* @param constraintVariable the {@link ConstraintVariable2} to be associated with node
*/
protected static void setConstraintVariable(ASTNode node, ConstraintVariable2 constraintVariable) {
node.setProperty(CV_PROP, constraintVariable);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
/**
* @param node the ASTNode
* @param constraintVariable the {@link ConstraintVariable2} to be associated with node
*/
protected static void setConstraintVariable(ASTNode node, ConstraintVariable2 constraintVariable) {
node.setProperty(CV_PROP, constraintVariable);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
public void registerRemovedNode(ASTNode removed) {
fHasRemovedNodes= true;
removed.setProperty(PROPERTY_KEY, REMOVED);
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
/**
* @param node the ASTNode
* @param constraintVariable the {@link ConstraintVariable2} to be associated with node
*/
protected static void setConstraintVariable(ASTNode node, ConstraintVariable2 constraintVariable) {
node.setProperty(CV_PROP, constraintVariable);
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core.manipulation
public void registerRemovedNode(ASTNode removed) {
fHasRemovedNodes= true;
removed.setProperty(PROPERTY_KEY, REMOVED);
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core.manipulation
public void registerRetainedNode(ASTNode retained) {
retained.setProperty(PROPERTY_KEY, RETAINED);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
public void registerRetainedNode(ASTNode retained) {
retained.setProperty(PROPERTY_KEY, RETAINED);
}
代码示例来源:origin: JnRouvignac/AutoRefactor
/**
* Removes the provided node from the AST leaving the leading comment.
*
* @param node the node to remove
* @see ASTRewrite#remove(ASTNode, org.eclipse.text.edits.TextEditGroup)
*/
public void removeButKeepComment(ASTNode node) {
node.setProperty(UNTOUCH_COMMENT, Boolean.TRUE);
remove(node);
}
代码示例来源:origin: JnRouvignac/AutoRefactor
/**
* Replaces the provided node from the AST with the provided replacement node.
*
* @param node the node to remove
* @param replacement the replacement node
* @see ASTRewrite#replace(ASTNode, ASTNode, org.eclipse.text.edits.TextEditGroup)
*/
public void replace(ASTNode node, ASTNode replacement) {
node.setProperty(UNTOUCH_COMMENT, Boolean.TRUE);
rewrite.replace(node, replacement, null);
addRefactoredNodes(node);
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core.manipulation
@Override
public void preVisit(ASTNode node) {
Object property= node.getProperty(PROPERTY_KEY);
if (property == REMOVED) {
if (fRemovingStart == -1) {
fRemovingStart= node.getStartPosition();
} else {
/*
* Bug in client code: REMOVED node should not be nested inside another REMOVED node without
* an intermediate RETAINED node.
* Drop REMOVED property to prevent problems later (premature end of REMOVED section).
*/
node.setProperty(PROPERTY_KEY, null);
}
} else if (property == RETAINED) {
if (fRemovingStart != -1) {
removedStartsEnds.add(new int[] { fRemovingStart, node.getStartPosition() });
fRemovingStart= -1;
} else {
/*
* Bug in client code: RETAINED node should not be nested inside another RETAINED node without
* an intermediate REMOVED node and must have an enclosing REMOVED node.
* Drop RETAINED property to prevent problems later (premature restart of REMOVED section).
*/
node.setProperty(PROPERTY_KEY, null);
}
}
super.preVisit(node);
}
@Override
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
@Override
public void preVisit(ASTNode node) {
Object property= node.getProperty(PROPERTY_KEY);
if (property == REMOVED) {
if (fRemovingStart == -1) {
fRemovingStart= node.getStartPosition();
} else {
/*
* Bug in client code: REMOVED node should not be nested inside another REMOVED node without
* an intermediate RETAINED node.
* Drop REMOVED property to prevent problems later (premature end of REMOVED section).
*/
node.setProperty(PROPERTY_KEY, null);
}
} else if (property == RETAINED) {
if (fRemovingStart != -1) {
removedStartsEnds.add(new int[] { fRemovingStart, node.getStartPosition() });
fRemovingStart= -1;
} else {
/*
* Bug in client code: RETAINED node should not be nested inside another RETAINED node without
* an intermediate REMOVED node and must have an enclosing REMOVED node.
* Drop RETAINED property to prevent problems later (premature restart of REMOVED section).
*/
node.setProperty(PROPERTY_KEY, null);
}
}
super.preVisit(node);
}
@Override
代码示例来源:origin: org.jibx.config.3rdparty.org.eclipse/org.eclipse.jdt.core
public final CopySourceInfo createRangeCopy(ASTNode parent, StructuralPropertyDescriptor childProperty, ASTNode first, ASTNode last, boolean isMove, ASTNode internalPlaceholder, ASTNode replacingNode, TextEditGroup editGroup) {
CopySourceInfo copyInfo= createCopySourceInfo(null, internalPlaceholder, isMove);
internalPlaceholder.setProperty(INTERNAL_PLACEHOLDER_PROPERTY, internalPlaceholder);
NodeRangeInfo copyRangeInfo= new NodeRangeInfo(parent, childProperty, first, last, copyInfo, replacingNode, editGroup);
ListRewriteEvent listEvent= getListEvent(parent, childProperty, true);
int indexFirst= listEvent.getIndex(first, ListRewriteEvent.OLD);
if (indexFirst == -1) {
throw new IllegalArgumentException("Start node is not a original child of the given list"); //$NON-NLS-1$
}
int indexLast= listEvent.getIndex(last, ListRewriteEvent.OLD);
if (indexLast == -1) {
throw new IllegalArgumentException("End node is not a original child of the given list"); //$NON-NLS-1$
}
if (indexFirst > indexLast) {
throw new IllegalArgumentException("Start node must be before end node"); //$NON-NLS-1$
}
if (this.nodeRangeInfos == null) {
this.nodeRangeInfos= new HashMap();
}
PropertyLocation loc= new PropertyLocation(parent, childProperty);
List innerList= (List) this.nodeRangeInfos.get(loc);
if (innerList == null) {
innerList= new ArrayList(2);
this.nodeRangeInfos.put(loc, innerList);
} else {
assertNoOverlap(listEvent, indexFirst, indexLast, innerList);
}
innerList.add(copyRangeInfo);
return copyInfo;
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core
public final CopySourceInfo createRangeCopy(ASTNode parent, StructuralPropertyDescriptor childProperty, ASTNode first, ASTNode last, boolean isMove, ASTNode internalPlaceholder, ASTNode replacingNode, TextEditGroup editGroup) {
CopySourceInfo copyInfo= createCopySourceInfo(null, internalPlaceholder, isMove);
internalPlaceholder.setProperty(INTERNAL_PLACEHOLDER_PROPERTY, internalPlaceholder);
NodeRangeInfo copyRangeInfo= new NodeRangeInfo(parent, childProperty, first, last, copyInfo, replacingNode, editGroup);
ListRewriteEvent listEvent= getListEvent(parent, childProperty, true);
int indexFirst= listEvent.getIndex(first, ListRewriteEvent.OLD);
if (indexFirst == -1) {
throw new IllegalArgumentException("Start node is not a original child of the given list"); //$NON-NLS-1$
}
int indexLast= listEvent.getIndex(last, ListRewriteEvent.OLD);
if (indexLast == -1) {
throw new IllegalArgumentException("End node is not a original child of the given list"); //$NON-NLS-1$
}
if (indexFirst > indexLast) {
throw new IllegalArgumentException("Start node must be before end node"); //$NON-NLS-1$
}
if (this.nodeRangeInfos == null) {
this.nodeRangeInfos= new HashMap();
}
PropertyLocation loc= new PropertyLocation(parent, childProperty);
List innerList= (List) this.nodeRangeInfos.get(loc);
if (innerList == null) {
innerList= new ArrayList(2);
this.nodeRangeInfos.put(loc, innerList);
} else {
assertNoOverlap(listEvent, indexFirst, indexLast, innerList);
}
innerList.add(copyRangeInfo);
return copyInfo;
}
代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion
public final CopySourceInfo createRangeCopy(ASTNode parent, StructuralPropertyDescriptor childProperty, ASTNode first, ASTNode last, boolean isMove, ASTNode internalPlaceholder, ASTNode replacingNode, TextEditGroup editGroup) {
CopySourceInfo copyInfo= createCopySourceInfo(null, internalPlaceholder, isMove);
internalPlaceholder.setProperty(INTERNAL_PLACEHOLDER_PROPERTY, internalPlaceholder);
NodeRangeInfo copyRangeInfo= new NodeRangeInfo(parent, childProperty, first, last, copyInfo, replacingNode, editGroup);
ListRewriteEvent listEvent= getListEvent(parent, childProperty, true);
int indexFirst= listEvent.getIndex(first, ListRewriteEvent.OLD);
if (indexFirst == -1) {
throw new IllegalArgumentException("Start node is not a original child of the given list"); //$NON-NLS-1$
}
int indexLast= listEvent.getIndex(last, ListRewriteEvent.OLD);
if (indexLast == -1) {
throw new IllegalArgumentException("End node is not a original child of the given list"); //$NON-NLS-1$
}
if (indexFirst > indexLast) {
throw new IllegalArgumentException("Start node must be before end node"); //$NON-NLS-1$
}
if (this.nodeRangeInfos == null) {
this.nodeRangeInfos= new HashMap();
}
PropertyLocation loc= new PropertyLocation(parent, childProperty);
List innerList= (List) this.nodeRangeInfos.get(loc);
if (innerList == null) {
innerList= new ArrayList(2);
this.nodeRangeInfos.put(loc, innerList);
} else {
assertNoOverlap(listEvent, indexFirst, indexLast, innerList);
}
innerList.add(copyRangeInfo);
return copyInfo;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core
public final CopySourceInfo createRangeCopy(ASTNode parent, StructuralPropertyDescriptor childProperty, ASTNode first, ASTNode last, boolean isMove, ASTNode internalPlaceholder, ASTNode replacingNode, TextEditGroup editGroup) {
CopySourceInfo copyInfo= createCopySourceInfo(null, internalPlaceholder, isMove);
internalPlaceholder.setProperty(INTERNAL_PLACEHOLDER_PROPERTY, internalPlaceholder);
NodeRangeInfo copyRangeInfo= new NodeRangeInfo(parent, childProperty, first, last, copyInfo, replacingNode, editGroup);
ListRewriteEvent listEvent= getListEvent(parent, childProperty, true);
int indexFirst= listEvent.getIndex(first, ListRewriteEvent.OLD);
if (indexFirst == -1) {
throw new IllegalArgumentException("Start node is not a original child of the given list"); //$NON-NLS-1$
}
int indexLast= listEvent.getIndex(last, ListRewriteEvent.OLD);
if (indexLast == -1) {
throw new IllegalArgumentException("End node is not a original child of the given list"); //$NON-NLS-1$
}
if (indexFirst > indexLast) {
throw new IllegalArgumentException("Start node must be before end node"); //$NON-NLS-1$
}
if (this.nodeRangeInfos == null) {
this.nodeRangeInfos= new HashMap();
}
PropertyLocation loc= new PropertyLocation(parent, childProperty);
List innerList= (List) this.nodeRangeInfos.get(loc);
if (innerList == null) {
innerList= new ArrayList(2);
this.nodeRangeInfos.put(loc, innerList);
} else {
assertNoOverlap(listEvent, indexFirst, indexLast, innerList);
}
innerList.add(copyRangeInfo);
return copyInfo;
}
代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core
public final CopySourceInfo createRangeCopy(ASTNode parent, StructuralPropertyDescriptor childProperty, ASTNode first, ASTNode last, boolean isMove, ASTNode internalPlaceholder, ASTNode replacingNode, TextEditGroup editGroup) {
CopySourceInfo copyInfo= createCopySourceInfo(null, internalPlaceholder, isMove);
internalPlaceholder.setProperty(INTERNAL_PLACEHOLDER_PROPERTY, internalPlaceholder);
NodeRangeInfo copyRangeInfo= new NodeRangeInfo(parent, childProperty, first, last, copyInfo, replacingNode, editGroup);
ListRewriteEvent listEvent= getListEvent(parent, childProperty, true);
int indexFirst= listEvent.getIndex(first, ListRewriteEvent.OLD);
if (indexFirst == -1) {
throw new IllegalArgumentException("Start node is not a original child of the given list"); //$NON-NLS-1$
}
int indexLast= listEvent.getIndex(last, ListRewriteEvent.OLD);
if (indexLast == -1) {
throw new IllegalArgumentException("End node is not a original child of the given list"); //$NON-NLS-1$
}
if (indexFirst > indexLast) {
throw new IllegalArgumentException("Start node must be before end node"); //$NON-NLS-1$
}
if (this.nodeRangeInfos == null) {
this.nodeRangeInfos= new HashMap();
}
PropertyLocation loc= new PropertyLocation(parent, childProperty);
List innerList= (List) this.nodeRangeInfos.get(loc);
if (innerList == null) {
innerList= new ArrayList(2);
this.nodeRangeInfos.put(loc, innerList);
} else {
assertNoOverlap(listEvent, indexFirst, indexLast, innerList);
}
innerList.add(copyRangeInfo);
return copyInfo;
}
代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core
public final CopySourceInfo createRangeCopy(ASTNode parent, StructuralPropertyDescriptor childProperty, ASTNode first, ASTNode last, boolean isMove, ASTNode internalPlaceholder, ASTNode replacingNode, TextEditGroup editGroup) {
CopySourceInfo copyInfo= createCopySourceInfo(null, internalPlaceholder, isMove);
internalPlaceholder.setProperty(INTERNAL_PLACEHOLDER_PROPERTY, internalPlaceholder);
NodeRangeInfo copyRangeInfo= new NodeRangeInfo(parent, childProperty, first, last, copyInfo, replacingNode, editGroup);
ListRewriteEvent listEvent= getListEvent(parent, childProperty, true);
int indexFirst= listEvent.getIndex(first, ListRewriteEvent.OLD);
if (indexFirst == -1) {
throw new IllegalArgumentException("Start node is not a original child of the given list"); //$NON-NLS-1$
}
int indexLast= listEvent.getIndex(last, ListRewriteEvent.OLD);
if (indexLast == -1) {
throw new IllegalArgumentException("End node is not a original child of the given list"); //$NON-NLS-1$
}
if (indexFirst > indexLast) {
throw new IllegalArgumentException("Start node must be before end node"); //$NON-NLS-1$
}
if (this.nodeRangeInfos == null) {
this.nodeRangeInfos= new HashMap();
}
PropertyLocation loc= new PropertyLocation(parent, childProperty);
List innerList= (List) this.nodeRangeInfos.get(loc);
if (innerList == null) {
innerList= new ArrayList(2);
this.nodeRangeInfos.put(loc, innerList);
} else {
assertNoOverlap(listEvent, indexFirst, indexLast, innerList);
}
innerList.add(copyRangeInfo);
return copyInfo;
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
/**
* End of visit the variable declaration fragment list.
*
* @param fragments the fragments (element type: VariableDeclarationFragment
)
* @param type the type of the fragments
* @param parent the parent of the fragment list
*/
private void endVisit(final List
final ConstraintVariable2 ancestor= (ConstraintVariable2) type.getProperty(PROPERTY_CONSTRAINT_VARIABLE);
if (ancestor != null) {
IVariableBinding binding= null;
ConstraintVariable2 descendant= null;
VariableDeclarationFragment fragment= null;
for (int index= 0; index
descendant= (ConstraintVariable2) fragment.getProperty(PROPERTY_CONSTRAINT_VARIABLE);
if (descendant != null)
fModel.createSubtypeConstraint(descendant, ancestor);
binding= fragment.resolveBinding();
if (binding != null) {
descendant= fModel.createVariableVariable(binding);
if (descendant != null)
fModel.createEqualityConstraint(ancestor, descendant);
}
}
parent.setProperty(PROPERTY_CONSTRAINT_VARIABLE, ancestor);
}
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
/**
* End of visit the variable declaration fragment list.
*
* @param fragments the fragments (element type: VariableDeclarationFragment
)
* @param type the type of the fragments
* @param parent the parent of the fragment list
*/
private void endVisit(final List fragments, final Type type, final ASTNode parent) {
final ConstraintVariable2 ancestor= (ConstraintVariable2) type.getProperty(PROPERTY_CONSTRAINT_VARIABLE);
if (ancestor != null) {
IVariableBinding binding= null;
ConstraintVariable2 descendant= null;
VariableDeclarationFragment fragment= null;
for (int index= 0; index
descendant= (ConstraintVariable2) fragment.getProperty(PROPERTY_CONSTRAINT_VARIABLE);
if (descendant != null)
fModel.createSubtypeConstraint(descendant, ancestor);
binding= fragment.resolveBinding();
if (binding != null) {
descendant= fModel.createVariableVariable(binding);
if (descendant != null)
fModel.createEqualityConstraint(ancestor, descendant);
}
}
parent.setProperty(PROPERTY_CONSTRAINT_VARIABLE, ancestor);
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
/**
* End of visit the variable declaration fragment list.
*
* @param fragments the fragments (element type: VariableDeclarationFragment
)
* @param type the type of the fragments
* @param parent the parent of the fragment list
*/
private void endVisit(final List
final ConstraintVariable2 ancestor= (ConstraintVariable2) type.getProperty(PROPERTY_CONSTRAINT_VARIABLE);
if (ancestor != null) {
IVariableBinding binding= null;
ConstraintVariable2 descendant= null;
VariableDeclarationFragment fragment= null;
for (int index= 0; index
descendant= (ConstraintVariable2) fragment.getProperty(PROPERTY_CONSTRAINT_VARIABLE);
if (descendant != null)
fModel.createSubtypeConstraint(descendant, ancestor);
binding= fragment.resolveBinding();
if (binding != null) {
descendant= fModel.createVariableVariable(binding);
if (descendant != null)
fModel.createEqualityConstraint(ancestor, descendant);
}
}
parent.setProperty(PROPERTY_CONSTRAINT_VARIABLE, ancestor);
}
}