List of usage examples for org.eclipse.jdt.internal.compiler.ast MethodDeclaration isDefaultMethod
@Override public boolean isDefaultMethod()
From source file:spoon.support.compiler.jdt.JDTTreeBuilder.java
License:Open Source License
@Override public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) { CtMethod<Object> m = factory.Core().createMethod(); m.setSimpleName(new String(methodDeclaration.selector)); m.setType(references.getTypeReference(methodDeclaration.returnType.resolvedType)); m.setModifiers(getModifiers(methodDeclaration.modifiers)); m.setDefaultMethod(methodDeclaration.isDefaultMethod()); if (methodDeclaration.thrownExceptions != null) { for (TypeReference r : methodDeclaration.thrownExceptions) { CtTypeReference<? extends Throwable> tr = references.getTypeReference(r.resolvedType); m.addThrownType(tr);//w w w .j ava2s .c o m } } // this may happen when working if (methodDeclaration.binding != null) { // with incomplete classpath for (TypeBinding b : methodDeclaration.binding.typeVariables) { m.addFormalTypeParameter(references.getBoundedTypeReference(b)); } } if (scope != null) { m.setDocComment(getJavaDoc(methodDeclaration.javadoc, scope.referenceCompilationUnit())); } else if (methodDeclaration.scope != null) { m.setDocComment( getJavaDoc(methodDeclaration.javadoc, methodDeclaration.scope.referenceCompilationUnit())); } else { // null scope for "+methodDeclaration } context.enter(m, methodDeclaration); if (methodDeclaration.annotations != null) { for (Annotation a : methodDeclaration.annotations) { // TODO Sorry for that but there is a bug in JDT : https://bugs.eclipse.org/bugs/show_bug.cgi?id=459528 if (isContainsInTypeAnnotation(methodDeclaration.returnType.resolvedType, a)) { a.traverse(this, methodDeclaration.scope); } } } if (methodDeclaration.arguments != null) { for (Argument a : methodDeclaration.arguments) { a.traverse(this, methodDeclaration.scope); } } // Create block if (!methodDeclaration.isAbstract() && (methodDeclaration.modifiers & ClassFileConstants.AccNative) == 0) { CtBlock<?> b = factory.Core().createBlock(); context.enter(b, methodDeclaration); } if (methodDeclaration.statements != null) { for (Statement s : methodDeclaration.statements) { s.traverse(this, methodDeclaration.scope); } } return false; }