/** * Generecized version of the equivalent JDT method. * * @param node the node on which to call the equivalent JDT method * @return a List of types * @see MethodDeclaration#thrownExceptionTypes() */ @SuppressWarnings("unchecked") public static List<Type> thrownExceptionTypes(MethodDeclaration node) { return node.thrownExceptionTypes(); }
private boolean isCheckedExceptionThrown(final MethodDeclaration uniqueConstructor) { if (uniqueConstructor.thrownExceptionTypes() != null) { for (final Object type : uniqueConstructor.thrownExceptionTypes()) { if (isChecked((Type) type)) { return true; } } } return false; }
protected static void copyThrownExceptions(final MethodDeclaration oldMethod, final MethodDeclaration newMethod) { final AST ast= newMethod.getAST(); for (int index= 0, n= oldMethod.thrownExceptionTypes().size(); index < n; index++) newMethod.thrownExceptionTypes().add(ASTNode.copySubtree(ast, (Type) oldMethod.thrownExceptionTypes().get(index))); }
protected static void copyThrownExceptions(final MethodDeclaration oldMethod, final MethodDeclaration newMethod) { final AST ast= newMethod.getAST(); for (int index= 0, n= oldMethod.thrownExceptionTypes().size(); index < n; index++) newMethod.thrownExceptionTypes().add(ASTNode.copySubtree(ast, (Type) oldMethod.thrownExceptionTypes().get(index))); }
/** * Add exception related features. * * @param md * @param features */ private void addExceptionFeatures(final MethodDeclaration md, final Set<String> features) { checkArgument(activeFeatures.contains(AvailableFeatures.EXCEPTIONS)); for (final Object exception : md.thrownExceptionTypes()) { final SimpleType ex = (SimpleType) exception; features.add("thrownException:" + ex.toString()); } }
private void addExceptionsToNewConstructor(MethodDeclaration newConstructor, ImportRewrite importRewrite) { IMethodBinding constructorBinding= getSuperConstructorBinding(); if (constructorBinding == null) return; ITypeBinding[] exceptions= constructorBinding.getExceptionTypes(); for (int i= 0; i < exceptions.length; i++) { Type exceptionType= importRewrite.addImport(exceptions[i], fAnonymousInnerClassNode.getAST()); newConstructor.thrownExceptionTypes().add(exceptionType); } }
private void copyExceptions(MethodDeclaration intermediary, CompilationUnitRewrite imRewrite, ImportRewriteContext context) { ITypeBinding[] exceptionTypes= fTargetMethodBinding.getExceptionTypes(); for (int i= 0; i < exceptionTypes.length; i++) { Type exceptionType= imRewrite.getImportRewrite().addImport(exceptionTypes[i], imRewrite.getAST(), context); intermediary.thrownExceptionTypes().add(exceptionType); } }
private void changeExceptions() { for (Iterator<ExceptionInfo> iter= fExceptionInfos.iterator(); iter.hasNext();) { ExceptionInfo info= iter.next(); if (info.isOld()) continue; if (info.isDeleted()) removeExceptionFromNodeList(info, fMethDecl.thrownExceptionTypes()); else addExceptionToNodeList(info, getASTRewrite().getListRewrite(fMethDecl, MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY)); } }
private void copyExceptions(MethodDeclaration intermediary, CompilationUnitRewrite imRewrite, ImportRewriteContext context) { ITypeBinding[] exceptionTypes= fTargetMethodBinding.getExceptionTypes(); for (int i= 0; i < exceptionTypes.length; i++) { Type exceptionType= imRewrite.getImportRewrite().addImport(exceptionTypes[i], imRewrite.getAST(), context, TypeLocation.EXCEPTION); intermediary.thrownExceptionTypes().add(exceptionType); } }
private void changeExceptions() { for (Iterator<ExceptionInfo> iter= fExceptionInfos.iterator(); iter.hasNext();) { ExceptionInfo info= iter.next(); if (info.isOld()) continue; if (info.isDeleted()) removeExceptionFromNodeList(info, fMethDecl.thrownExceptionTypes()); else addExceptionToNodeList(info, getASTRewrite().getListRewrite(fMethDecl, MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY)); } }
private void addExceptionsToNewConstructor(MethodDeclaration newConstructor, ImportRewrite importRewrite) { IMethodBinding constructorBinding= getSuperConstructorBinding(); if (constructorBinding == null) return; ITypeBinding[] exceptions= constructorBinding.getExceptionTypes(); for (int i= 0; i < exceptions.length; i++) { Type exceptionType= importRewrite.addImport(exceptions[i], fAnonymousInnerClassNode.getAST()); newConstructor.thrownExceptionTypes().add(exceptionType); } }
public static void createThrownExceptions(MethodDeclaration decl, IMethodBinding method, ImportRewrite imports, ImportRewriteContext context, AST ast) { ITypeBinding[] excTypes= method.getExceptionTypes(); if (ast.apiLevel() >= AST.JLS8) { List<Type> thrownExceptions= decl.thrownExceptionTypes(); for (int i= 0; i < excTypes.length; i++) { Type excType= imports.addImport(excTypes[i], ast, context, TypeLocation.EXCEPTION); thrownExceptions.add(excType); } } else { List<Name> thrownExceptions= getThrownExceptions(decl); for (int i= 0; i < excTypes.length; i++) { String excTypeName= imports.addImport(excTypes[i], context); thrownExceptions.add(ASTNodeFactory.newName(ast, excTypeName)); } } }
private static void createThrownExceptions(MethodDeclaration decl, IMethodBinding method, ImportRewrite imports, ImportRewriteContext context, AST ast) { ITypeBinding[] excTypes= method.getExceptionTypes(); if (ast.apiLevel() >= AST.JLS8) { List<Type> thrownExceptions= decl.thrownExceptionTypes(); for (int i= 0; i < excTypes.length; i++) { Type excType= imports.addImport(excTypes[i], ast, context); thrownExceptions.add(excType); } } else { List<Name> thrownExceptions= getThrownExceptions(decl); for (int i= 0; i < excTypes.length; i++) { String excTypeName= imports.addImport(excTypes[i], context); thrownExceptions.add(ASTNodeFactory.newName(ast, excTypeName)); } } }
private static void addExceptionToThrows(AST ast, MethodDeclaration methodDeclaration, ASTRewrite rewrite, Type type2) { ITypeBinding binding= type2.resolveBinding(); if (binding == null || isNotYetThrown(binding, methodDeclaration.thrownExceptionTypes())) { Type newType= (Type) ASTNode.copySubtree(ast, type2); ListRewrite listRewriter= rewrite.getListRewrite(methodDeclaration, MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY); listRewriter.insertLast(newType, null); } }
private static void addExceptionToThrows(AST ast, MethodDeclaration methodDeclaration, ASTRewrite rewrite, Type type2) { ITypeBinding binding = type2.resolveBinding(); if (binding == null || isNotYetThrown(binding, methodDeclaration.thrownExceptionTypes())) { Type newType = (Type) ASTNode.copySubtree(ast, type2); ListRewrite listRewriter = rewrite.getListRewrite(methodDeclaration, MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY); listRewriter.insertLast(newType, null); } }
private static void addExceptionToThrows(AST ast, MethodDeclaration methodDeclaration, ASTRewrite rewrite, Type type2) { ITypeBinding binding= type2.resolveBinding(); if (binding == null || isNotYetThrown(binding, methodDeclaration.thrownExceptionTypes())) { Type newType= (Type) ASTNode.copySubtree(ast, type2); ListRewrite listRewriter= rewrite.getListRewrite(methodDeclaration, MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY); listRewriter.insertLast(newType, null); } }
@Override public void endVisit(MethodDeclaration node) { if (skipNode(node)) { return; } GenericSequentialFlowInfo info = processSequential(node, node.getReturnType2()); process(info, node.parameters()); process(info, node.thrownExceptionTypes()); process(info, node.getBody()); }
@Override public void endVisit(MethodDeclaration node) { if (skipNode(node)) return; GenericSequentialFlowInfo info= processSequential(node, node.getReturnType2()); process(info, node.parameters()); process(info, node.thrownExceptionTypes()); process(info, node.getBody()); }
@Override public void endVisit(MethodDeclaration node) { if (skipNode(node)) return; GenericSequentialFlowInfo info= processSequential(node, node.getReturnType2()); process(info, node.parameters()); process(info, node.thrownExceptionTypes()); process(info, node.getBody()); }
final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == MODIFIERS2_PROPERTY) { return modifiers(); } if (property == TYPE_PARAMETERS_PROPERTY) { return typeParameters(); } if (property == PARAMETERS_PROPERTY) { return parameters(); } if (property == THROWN_EXCEPTIONS_PROPERTY) { return thrownExceptions(); } if (property == THROWN_EXCEPTION_TYPES_PROPERTY) { return thrownExceptionTypes(); } if (property == EXTRA_DIMENSIONS2_PROPERTY) { return extraDimensions(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }