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.

WildChildFinder.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* *******************************************************************
  2. * Copyright (c) 2019 Contributors
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v 2.0
  6. * which accompanies this distribution and is available at
  7. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  8. *
  9. * ******************************************************************/
  10. package org.aspectj.weaver.patterns;
  11. /**
  12. * @author Tuomas Kiviaho
  13. */
  14. public class WildChildFinder extends AbstractPatternNodeVisitor {
  15. private boolean wildChild;
  16. public WildChildFinder() {
  17. super();
  18. }
  19. public boolean containedWildChild() {
  20. return wildChild;
  21. }
  22. @Override
  23. public Object visit(WildAnnotationTypePattern node, Object data) {
  24. node.getTypePattern().accept(this, data);
  25. return node;
  26. }
  27. @Override
  28. public Object visit(WildTypePattern node, Object data) {
  29. this.wildChild = true;
  30. return super.visit(node, data);
  31. }
  32. @Override
  33. public Object visit(AndTypePattern node, Object data) {
  34. node.getLeft().accept(this, data);
  35. if (!this.wildChild) {
  36. node.getRight().accept(this, data);
  37. }
  38. return node;
  39. }
  40. @Override
  41. public Object visit(OrTypePattern node, Object data) {
  42. node.getLeft().accept(this, data);
  43. if (!this.wildChild) {
  44. node.getRight().accept(this, data);
  45. }
  46. return node;
  47. }
  48. public Object visit(NotTypePattern node, Object data) {
  49. node.getNegatedPattern().accept(this, data);
  50. return node;
  51. }
  52. @Override
  53. public Object visit(AnyWithAnnotationTypePattern node, Object data) {
  54. node.getAnnotationPattern().accept(this, data);
  55. return node;
  56. }
  57. }