List of usage examples for org.eclipse.jdt.core.dom IMethodBinding getAnnotations
public IAnnotationBinding[] getAnnotations();
From source file:cc.kave.eclipse.namefactory.NodeFactory.java
License:Apache License
private static boolean hasOverrideAnnotation(IMethodBinding method) { for (IAnnotationBinding iAnnotationBinding : method.getAnnotations()) { if (iAnnotationBinding.getName().equals("Override")) return true; }/*ww w. j a v a2s . com*/ return false; }
From source file:edu.cmu.cs.crystal.annotations.AnnotationDatabase.java
License:Open Source License
private AnnotationSummary createMethodSummary(IMethodBinding binding) { int paramCount = binding.getParameterTypes().length; String[] paramNames = new String[paramCount]; for (int i = 0; i < paramCount; i++) { paramNames[i] = "arg" + i; }//from ww w. j ava 2 s . c o m AnnotationSummary result = new AnnotationSummary(paramNames); result.addAllReturn(createAnnotations(binding.getAnnotations())); try { for (int i = 0; i < paramCount; i++) { result.addAllParameter(createAnnotations(binding.getParameterAnnotations(i)), i); } } catch (NullPointerException e) { if (log.isLoggable(Level.WARNING)) log.log(Level.WARNING, "Bug in JDT (Eclipse 3.4M5) triggered in " + binding + ". Not all annotations on parameters might be available.", e); } return result; }
From source file:edu.cmu.cs.plural.track.StateTestAnnotation.java
License:Open Source License
public static boolean isDynamicStateTest(IMethodBinding method) { for (IAnnotationBinding a : method.getAnnotations()) { if ("StateTest".equals(a.getName())) return true; }// w ww. j av a2s . c om return false; }
From source file:edu.cmu.cs.plural.track.StateTestAnnotation.java
License:Open Source License
/** * /*www. ja v a 2 s.c o m*/ * @param method * @param value * @return * @deprecated Use {@link IndicatesAnnotation#getBooleanIndicatorOnReceiverIfAny(AnnotationSummary, boolean) instead. */ public static IndicatesAnnotation createBooleanIndicatorIfPossible(IMethodBinding method, boolean value) { for (IAnnotationBinding a : method.getAnnotations()) { if ("StateTest".equals(a.getName())) { for (IMemberValuePairBinding p : a.getAllMemberValuePairs()) { if ("value".equals(p.getName())) { Object indicatorAnnos = p.getValue(); if (indicatorAnnos instanceof Object[]) { for (Object o : (Object[]) indicatorAnnos) { IndicatesAnnotation result = IndicatesAnnotation .createBooleanIndicatorIfPossible((IAnnotationBinding) o, value); if (result != null) return result; } } else return IndicatesAnnotation .createBooleanIndicatorIfPossible((IAnnotationBinding) indicatorAnnos, value); } } } } return null; }
From source file:fr.labri.harmony.rta.junit.jdt.JDTVisitorRTA.java
License:Open Source License
public boolean visit(TypeDeclaration td) { ITypeBinding tb = td.resolveBinding(); if (tb != null) { String id = tb.getQualifiedName(); currentClass = getJavaClass(id); if (currentTypeHashcode != -1) previousHashCode = currentTypeHashcode; currentTypeHashcode = td.toString().hashCode(); if (!currentClasses.containsKey(currentTypeHashcode)) currentClasses.put(currentTypeHashcode, currentClass); //currentClass.getChildrenClass().clear(); currentClass.getParentClass().clear(); currentClass.getClassPublicFieldInstancied().clear(); currentClass.getClassPrivateFieldInstancied().clear(); currentClass.getMethods().clear(); if (tb.isInterface()) currentClass.setInterface(true); else//from w ww.j av a 2s. c o m currentClass.setInterface(false); } if (tb.getSuperclass() != null && !tb.getSuperclass().getQualifiedName().equals("java.lang.Object")) { JavaClass jc = getJavaClass(tb.getSuperclass().getQualifiedName()); if (jc != null) { jc.getChildrenClass().add(currentClass); currentClass.getParentClass().add(jc); } } for (ITypeBinding t : tb.getInterfaces()) { JavaClass jc = getJavaClass(t.getQualifiedName()); jc.getChildrenClass().add(currentClass); currentClass.getParentClass().add(jc); } if (isTestFile) { if (tb != null) { for (ITypeBinding t : Bindings.getAllSuperTypes(tb)) { for (IMethodBinding mb : t.getDeclaredMethods()) { //is it a test class ? if (mb != null) { for (IAnnotationBinding a : mb.getAnnotations()) { if (a.getName().toString().contains("Test")) { //System.out.println(tb.getQualifiedName()+" inherits "+getMethodBindingId(mb)); if (!method_inheritance.containsKey(tb.getQualifiedName())) method_inheritance.put(tb.getQualifiedName(), new HashSet<String>()); method_inheritance.get(tb.getQualifiedName()).add(getMethodBindingId(mb)); } } } } } } } return true; }
From source file:jmockit.assist.MockUtil.java
License:Open Source License
public static boolean isMockMethod(final IMethodBinding meth) { return meth != null && ASTUtil.isAnnotationPresent(meth.getAnnotations(), MOCK); }
From source file:jmockit.assist.MockUtil.java
License:Open Source License
public static boolean isReentrantMockMethod(final IMethodBinding meth) { IAnnotationBinding ann = ASTUtil.findAnnotation(meth.getAnnotations(), MOCK); if (ann != null) { for (IMemberValuePairBinding pair : ann.getDeclaredMemberValuePairs()) { if ("reentrant".equals(pair.getName())) { return Boolean.valueOf(pair.getValue().toString()); }/* w ww .j a va2s . co m*/ } } return false; }
From source file:org.autorefactor.refactoring.rules.DeadCodeEliminationRefactoring.java
License:Open Source License
private boolean hasSignificantAnnotations(IMethodBinding methodBinding) { for (IAnnotationBinding annotation : methodBinding.getAnnotations()) { ITypeBinding annotationType = annotation.getAnnotationType(); if (!hasType(annotationType, "java.lang.Override", "java.lang.SuppressWarnings")) { return true; }// ww w . j a v a 2s . c o m } return false; }
From source file:org.autorefactor.refactoring.rules.SuperCallRatherThanUselessOverridingRefactoring.java
License:Open Source License
private boolean hasSignificantAnnotations(final IMethodBinding methodBinding) { for (final IAnnotationBinding annotation : methodBinding.getAnnotations()) { final ITypeBinding annotationType = annotation.getAnnotationType(); if (!hasType(annotationType, "java.lang.Override", "java.lang.SuppressWarnings")) { return true; }/*from w w w . j av a2 s . co m*/ } return false; }
From source file:org.eclipse.che.plugin.java.testing.JavaTestAnnotations.java
License:Open Source License
/** * Find method which annotated as test method. * * @param type type which contains methods * @return {@code true} if least one has test annotation otherwise returns {@code false} *//* w w w . ja v a 2 s. co m*/ public boolean annotatesAtLeastOneMethod(ITypeBinding type) { while (type != null) { IMethodBinding[] declaredMethods = type.getDeclaredMethods(); for (int i = 0; i < declaredMethods.length; i++) { IMethodBinding curr = declaredMethods[i]; if (annotates(curr.getAnnotations())) { return true; } } type = type.getSuperclass(); } return false; }