You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Utils.java 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* *******************************************************************
  2. * Copyright (c) 2008 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://eclipse.org/legal/epl-v10.html
  8. *
  9. * ******************************************************************/
  10. package org.aspectj.weaver;
  11. /**
  12. *
  13. * @author Andy Clement
  14. */
  15. public class Utils {
  16. /**
  17. * Check if the annotations contain a SuppressAjWarnings annotation and if that annotation specifies that the given lint message
  18. * (identified by its key) should be ignored.
  19. *
  20. */
  21. public static boolean isSuppressing(AnnotationAJ[] anns, String lintkey) {
  22. if (anns == null) {
  23. return false;
  24. }
  25. // Go through the annotation types on the advice
  26. for (int i = 0; i < anns.length; i++) {
  27. if (UnresolvedType.SUPPRESS_AJ_WARNINGS.getSignature().equals(anns[i].getTypeSignature())) {
  28. // Two possibilities:
  29. // 1. there are no values specified (i.e. @SuppressAjWarnings)
  30. // 2. there are values specified (i.e. @SuppressAjWarnings("A") or @SuppressAjWarnings({"A","B"})
  31. String value = anns[i].getStringFormOfValue("value");
  32. // Slightly lazy, just doing a string indexof
  33. if (value == null || value.indexOf(lintkey) != -1) {
  34. return true;
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. }