Skip to content
Snippets Groups Projects
Select Git revision
  • cfdd9ff32441ba428b25361dfdfad868b2223f3b
  • master default protected
  • update/angular
  • bugfix/ragdoc
  • 1-add-relast2uml-to-statemachine
5 results

Util.jadd

Blame
  • Util.jadd 1.07 KiB
    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    import java.util.*;
    import java.util.stream.Collectors;
    
    aspect Logging {
      static Logger ASTNode.logger = LogManager.getLogger(ASTNode.class);
    }
    
    aspect JastAddAPIExtension {
    
      /**
       * removes the object from the AST, i.e. removes the reference from its parent to the object
       *
       * Please note that any intrinsic non-containment relations to the object are not removed.
       * @return true, if the object had a parent.
       */
      public boolean ASTNode.removeSelf() {
        if (getParent() == null) {
          return false;
        } else {
          for (int childIndex = 0; childIndex < getParent().numChildren(); childIndex++) {
            if (getParent().getChild(childIndex) == this) {
              getParent().removeChild(childIndex);
              return true;
            }
          }
        }
        throw new RuntimeException("unable to remove child, because it was not contained in its parent!");
      }
    
      public String Element.customID() {
        return getLabel();
      }
    
      public String Element.toString() {
        return getLabel();
      }
    }