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.

IfFinder.java 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* *******************************************************************
  2. * Copyright (c) 2006 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://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Andy Clement initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.weaver.bcel;
  13. import org.aspectj.weaver.patterns.AbstractPatternNodeVisitor;
  14. import org.aspectj.weaver.patterns.AndPointcut;
  15. import org.aspectj.weaver.patterns.IfPointcut;
  16. import org.aspectj.weaver.patterns.NotPointcut;
  17. import org.aspectj.weaver.patterns.OrPointcut;
  18. /**
  19. * Look for an if() pointcut
  20. */
  21. class IfFinder extends AbstractPatternNodeVisitor {
  22. boolean hasIf = false;
  23. public Object visit(IfPointcut node, Object data) {
  24. if (node.alwaysFalse() || node.alwaysTrue()) {
  25. // IfFalse / IfTrue
  26. } else {
  27. hasIf = true;
  28. }
  29. return node;
  30. }
  31. public Object visit(AndPointcut node, Object data) {
  32. if (!hasIf)
  33. node.getLeft().accept(this, data);
  34. if (!hasIf)
  35. node.getRight().accept(this, data);
  36. return node;
  37. }
  38. public Object visit(NotPointcut node, Object data) {
  39. if (!hasIf)
  40. node.getNegatedPointcut().accept(this, data);
  41. return node;
  42. }
  43. public Object visit(OrPointcut node, Object data) {
  44. if (!hasIf)
  45. node.getLeft().accept(this, data);
  46. if (!hasIf)
  47. node.getRight().accept(this, data);
  48. return node;
  49. }
  50. }