use of org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo in project che by eclipse.
the class ChangeSignatureProcessor method createExceptionInfoList.
private RefactoringStatus createExceptionInfoList() {
if (fExceptionInfos == null || fExceptionInfos.isEmpty()) {
fExceptionInfos = new ArrayList<ExceptionInfo>(0);
try {
ASTNode nameNode = NodeFinder.perform(fBaseCuRewrite.getRoot(), fMethod.getNameRange());
if (nameNode == null || !(nameNode instanceof Name) || !(nameNode.getParent() instanceof MethodDeclaration))
return null;
MethodDeclaration methodDeclaration = (MethodDeclaration) nameNode.getParent();
List<Type> exceptions = methodDeclaration.thrownExceptionTypes();
List<ExceptionInfo> result = new ArrayList<ExceptionInfo>(exceptions.size());
for (int i = 0; i < exceptions.size(); i++) {
Type type = exceptions.get(i);
ITypeBinding typeBinding = type.resolveBinding();
if (typeBinding == null)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ChangeSignatureRefactoring_no_exception_binding);
IJavaElement element = typeBinding.getJavaElement();
result.add(ExceptionInfo.createInfoForOldException(element, typeBinding));
}
fExceptionInfos = result;
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
return null;
}
use of org.eclipse.jdt.internal.corext.refactoring.ExceptionInfo in project che by eclipse.
the class ChangeSignatureProcessor method getOldMethodThrows.
private String getOldMethodThrows() {
//$NON-NLS-1$
final String throwsString = " throws ";
StringBuffer buff = new StringBuffer(throwsString);
for (Iterator<ExceptionInfo> iter = fExceptionInfos.iterator(); iter.hasNext(); ) {
ExceptionInfo info = iter.next();
if (!info.isAdded()) {
buff.append(info.getElement().getElementName());
//$NON-NLS-1$
buff.append(", ");
}
}
if (buff.length() == throwsString.length())
//$NON-NLS-1$
return "";
buff.delete(buff.length() - 2, buff.length());
return buff.toString();
}
Aggregations