下面列出了org.eclipse.jdt.core.dom.MethodDeclaration#BODY_PROPERTY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private ASTNode getEnclosingBodyNode() throws JavaModelException {
ASTNode node = getSelectedExpression().getAssociatedNode();
// expression must be in a method, lambda or initializer body
// make sure it is not in method or parameter annotation
StructuralPropertyDescriptor location = null;
while (node != null && !(node instanceof BodyDeclaration)) {
location = node.getLocationInParent();
node = node.getParent();
if (node instanceof LambdaExpression) {
break;
}
}
if (location == MethodDeclaration.BODY_PROPERTY || location == Initializer.BODY_PROPERTY || (location == LambdaExpression.BODY_PROPERTY && ((LambdaExpression) node).resolveMethodBinding() != null)) {
return (ASTNode) node.getStructuralProperty(location);
}
return null;
}
private ASTNode getEnclosingBodyNode() throws JavaModelException {
ASTNode node = getSelectedExpression().getAssociatedNode();
// expression must be in a method, lambda or initializer body.
// make sure it is not in method or parameter annotation
StructuralPropertyDescriptor location = null;
while (node != null && !(node instanceof BodyDeclaration)) {
location = node.getLocationInParent();
node = node.getParent();
if (node instanceof LambdaExpression) {
break;
}
}
if (location == MethodDeclaration.BODY_PROPERTY || location == Initializer.BODY_PROPERTY || (location == LambdaExpression.BODY_PROPERTY && ((LambdaExpression) node).resolveMethodBinding() != null)) {
return (ASTNode) node.getStructuralProperty(location);
}
return null;
}
private Block getEnclosingBodyNode() throws JavaModelException {
ASTNode node= getSelectedExpression().getAssociatedNode();
// expression must be in a method or initializer body
// make sure it is not in method or parameter annotation
StructuralPropertyDescriptor location= null;
while (node != null && !(node instanceof BodyDeclaration)) {
location= node.getLocationInParent();
node= node.getParent();
}
if (location == MethodDeclaration.BODY_PROPERTY || location == Initializer.BODY_PROPERTY) {
return (Block) node.getStructuralProperty(location);
}
return null;
}
@Override
protected ChildPropertyDescriptor getBodyProperty() {
return MethodDeclaration.BODY_PROPERTY;
}
@Override
protected ChildPropertyDescriptor getBodyProperty() {
return MethodDeclaration.BODY_PROPERTY;
}