下面列出了org.eclipse.jdt.core.dom.VariableDeclarationExpression#getLocationInParent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void endVisit(VariableDeclarationExpression node) {
if (getSelection().getEndVisitSelectionMode(node) == Selection.SELECTED && getFirstSelectedNode() == node) {
if (node.getLocationInParent() == TryStatement.RESOURCES_PROPERTY) {
invalidSelection(RefactoringCoreMessages.ExtractMethodAnalyzer_resource_in_try_with_resources, JavaStatusContext.create(fCUnit, getSelection()));
}
}
checkTypeInDeclaration(node.getType());
super.endVisit(node);
}
@Override
public boolean visit(VariableDeclarationExpression node) {
if (node.getLocationInParent() == TryStatement.RESOURCES_PROPERTY) {
Type type = node.getType();
ITypeBinding resourceTypeBinding = type.resolveBinding();
if (resourceTypeBinding != null) {
IMethodBinding methodBinding = Bindings.findMethodInHierarchy(resourceTypeBinding, "close", new ITypeBinding[0]); //$NON-NLS-1$
if (methodBinding != null) {
addExceptions(methodBinding.getExceptionTypes(), node.getAST());
}
}
}
return super.visit(node);
}
@Override
public void endVisit(VariableDeclarationExpression node) {
if (getSelection().getEndVisitSelectionMode(node) == Selection.SELECTED && getFirstSelectedNode() == node) {
if (node.getLocationInParent() == TryStatement.RESOURCES_PROPERTY) {
invalidSelection(RefactoringCoreMessages.ExtractMethodAnalyzer_resource_in_try_with_resources, JavaStatusContext.create(fCUnit, getSelection()));
}
}
checkTypeInDeclaration(node.getType());
super.endVisit(node);
}
@Override
public boolean visit(VariableDeclarationExpression node) {
if (node.getLocationInParent() == TryStatement.RESOURCES_PROPERTY) {
Type type= node.getType();
ITypeBinding resourceTypeBinding= type.resolveBinding();
if (resourceTypeBinding != null) {
IMethodBinding methodBinding= Bindings.findMethodInHierarchy(resourceTypeBinding, "close", new ITypeBinding[0]); //$NON-NLS-1$
if (methodBinding != null) {
addExceptions(methodBinding.getExceptionTypes(), node.getAST());
}
}
}
return super.visit(node);
}