Example usage for org.eclipse.jdt.core.dom ASTNode METHOD_DECLARATION

List of usage examples for org.eclipse.jdt.core.dom ASTNode METHOD_DECLARATION

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom ASTNode METHOD_DECLARATION.

Prototype

int METHOD_DECLARATION

To view the source code for org.eclipse.jdt.core.dom ASTNode METHOD_DECLARATION.

Click Source Link

Document

Node type constant indicating a node of type MethodDeclaration.

Usage

From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java

License:Open Source License

public static boolean isStatic(BodyDeclaration bodyDeclaration) {
    if (isNestedInterfaceOrAnnotation(bodyDeclaration))
        return true;
    int nodeType = bodyDeclaration.getNodeType();
    if (!(nodeType == ASTNode.METHOD_DECLARATION || nodeType == ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION)
            && isInterfaceOrAnnotationMember(bodyDeclaration))
        return true;
    if (bodyDeclaration instanceof EnumConstantDeclaration)
        return true;
    if (bodyDeclaration instanceof EnumDeclaration
            && bodyDeclaration.getParent() instanceof AbstractTypeDeclaration)
        return true;
    return Modifier.isStatic(bodyDeclaration.getModifiers());
}

From source file:br.ufal.cideei.util.MethodDeclarationSootMethodBridge.java

License:Open Source License

/**
 * Gets the parent method.//  ww  w.j a v  a 2 s .  c o  m
 * 
 * @param node
 *            the node
 * @return the parent method
 */
public static MethodDeclaration getParentMethod(ASTNode node) {
    if (node == null) {
        return null;
    } else {
        if (node.getNodeType() == ASTNode.METHOD_DECLARATION) {
            return (MethodDeclaration) node;
        } else {
            return getParentMethod(node.getParent());
        }
    }
}

From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java

License:Open Source License

@Override
public boolean visit(final MarkerAnnotation node) {
    final ITypeBinding binding = node.resolveTypeBinding();
    if (ASTCrawler.checkForNull(binding))
        return false;
    final IElement annoteElem = ASTCrawler.convertBinding(binding);
    this.aDB.addElement(annoteElem, binding.getModifiers());

    final ASTNode annotatedNode = node.getParent();
    switch (annotatedNode.getNodeType()) {
    case ASTNode.METHOD_DECLARATION: {
        final MethodDeclaration annotatedMethod = (MethodDeclaration) annotatedNode;
        final IMethodBinding mBinding = annotatedMethod.resolveBinding();
        return this.addAnnotationRelation(annoteElem, mBinding);

    }//from  w w w .  j  av  a 2  s.  c o m
    case ASTNode.ANNOTATION_TYPE_DECLARATION: {
        final AnnotationTypeDeclaration annotatedAnnotation = (AnnotationTypeDeclaration) annotatedNode;
        final ITypeBinding tBinding = annotatedAnnotation.resolveBinding();
        return this.addAnnotationRelation(annoteElem, tBinding);
    }
    case ASTNode.VARIABLE_DECLARATION_STATEMENT: {
        return processVariableDeclarationStatement(annoteElem, (VariableDeclarationStatement) annotatedNode);
    }
    case ASTNode.VARIABLE_DECLARATION_FRAGMENT: {
        return processVariableDeclarationFragment(annoteElem, (VariableDeclarationFragment) annotatedNode);
    }
    case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: {
        AnnotationTypeMemberDeclaration atmd = (AnnotationTypeMemberDeclaration) annotatedNode;
        IMethodBinding methodBinding = atmd.resolveBinding();
        return this.addAnnotationRelation(annoteElem, methodBinding);
    }

    case ASTNode.PACKAGE_DECLARATION: {
        final PackageDeclaration packDecl = (PackageDeclaration) annotatedNode;
        final IPackageBinding pBinding = packDecl.resolveBinding();
        return this.addAnnotationRelation(annoteElem, pBinding);
    }

    case ASTNode.SINGLE_VARIABLE_DECLARATION: {
        final SingleVariableDeclaration svd = (SingleVariableDeclaration) annotatedNode;
        final IVariableBinding vBinding = svd.resolveBinding();
        return this.addAnnotationRelation(annoteElem, vBinding);
    }
    case ASTNode.TYPE_DECLARATION: {
        final TypeDeclaration tDecl = (TypeDeclaration) annotatedNode;
        final ITypeBinding tBinding = tDecl.resolveBinding();
        return this.addAnnotationRelation(annoteElem, tBinding);
    }
    case ASTNode.ENUM_DECLARATION: {
        final EnumDeclaration eDecl = (EnumDeclaration) annotatedNode;
        final ITypeBinding tBinding = eDecl.resolveBinding();
        return this.addAnnotationRelation(annoteElem, tBinding);
    }

    case ASTNode.FIELD_DECLARATION: {
        final FieldDeclaration fieldDecl = (FieldDeclaration) annotatedNode;
        for (final Object obj : fieldDecl.fragments()) {
            final VariableDeclarationFragment vdf = (VariableDeclarationFragment) obj;
            final IVariableBinding vBinding = vdf.resolveBinding();
            return this.addAnnotationRelation(annoteElem, vBinding);
        }
    }

    default: {
        throw new IllegalStateException("Illegal annotated node type: " + annotatedNode);
    }
    }
}

From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java

License:Open Source License

@Override
public boolean visit(final NormalAnnotation node) {
    final ITypeBinding binding = node.resolveTypeBinding();
    if (ASTCrawler.checkForNull(binding))
        return false;
    final IElement annoteElem = ASTCrawler.convertBinding(binding);
    this.aDB.addElement(annoteElem, binding.getModifiers());

    final ASTNode annotatedNode = node.getParent();
    switch (annotatedNode.getNodeType()) {
    case ASTNode.METHOD_DECLARATION: {
        final MethodDeclaration annotatedMethod = (MethodDeclaration) annotatedNode;
        final IMethodBinding mBinding = annotatedMethod.resolveBinding();
        return this.addAnnotationRelation(annoteElem, mBinding);

    }//from w ww .  ja v a 2 s . c  o m
    case ASTNode.ANNOTATION_TYPE_DECLARATION: {
        final AnnotationTypeDeclaration annotatedAnnotation = (AnnotationTypeDeclaration) annotatedNode;
        final ITypeBinding tBinding = annotatedAnnotation.resolveBinding();
        return this.addAnnotationRelation(annoteElem, tBinding);
    }
    case ASTNode.VARIABLE_DECLARATION_STATEMENT: {
        return processVariableDeclarationStatement(annoteElem, (VariableDeclarationStatement) annotatedNode);
    }
    case ASTNode.VARIABLE_DECLARATION_FRAGMENT: {
        return processVariableDeclarationFragment(annoteElem, (VariableDeclarationFragment) annotatedNode);
    }

    case ASTNode.PACKAGE_DECLARATION: {
        final PackageDeclaration packDecl = (PackageDeclaration) annotatedNode;
        final IPackageBinding pBinding = packDecl.resolveBinding();
        return this.addAnnotationRelation(annoteElem, pBinding);
    }

    case ASTNode.SINGLE_VARIABLE_DECLARATION: {
        final SingleVariableDeclaration svd = (SingleVariableDeclaration) annotatedNode;
        final IVariableBinding vBinding = svd.resolveBinding();
        return this.addAnnotationRelation(annoteElem, vBinding);
    }
    case ASTNode.TYPE_DECLARATION: {
        final TypeDeclaration tDecl = (TypeDeclaration) annotatedNode;
        final ITypeBinding tBinding = tDecl.resolveBinding();
        return this.addAnnotationRelation(annoteElem, tBinding);
    }
    case ASTNode.ENUM_DECLARATION: {
        final EnumDeclaration eDecl = (EnumDeclaration) annotatedNode;
        final ITypeBinding tBinding = eDecl.resolveBinding();
        return this.addAnnotationRelation(annoteElem, tBinding);
    }
    case ASTNode.FIELD_DECLARATION: {
        final FieldDeclaration fieldDecl = (FieldDeclaration) annotatedNode;
        for (final Object obj : fieldDecl.fragments()) {
            final VariableDeclarationFragment vdf = (VariableDeclarationFragment) obj;
            final IVariableBinding vBinding = vdf.resolveBinding();
            return this.addAnnotationRelation(annoteElem, vBinding);
        }
    }
    default: {
        throw new IllegalStateException("Illegal annotated node type: " + annotatedNode);
    }
    }
}

From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java

License:Open Source License

@Override
public boolean visit(final SingleMemberAnnotation node) {
    final ITypeBinding binding = node.resolveTypeBinding();
    if (ASTCrawler.checkForNull(binding))
        return false;
    final IElement annoteElem = ASTCrawler.convertBinding(binding);
    this.aDB.addElement(annoteElem, binding.getModifiers());

    final ASTNode annotatedNode = node.getParent();
    switch (annotatedNode.getNodeType()) {
    case ASTNode.METHOD_DECLARATION: {
        final MethodDeclaration annotatedMethod = (MethodDeclaration) annotatedNode;
        final IMethodBinding mBinding = annotatedMethod.resolveBinding();
        return this.addAnnotationRelation(annoteElem, mBinding);

    }//  w w w.  ja  v  a2 s .  com
    case ASTNode.ANNOTATION_TYPE_DECLARATION: {
        final AnnotationTypeDeclaration annotatedAnnotation = (AnnotationTypeDeclaration) annotatedNode;
        final ITypeBinding tBinding = annotatedAnnotation.resolveBinding();
        return this.addAnnotationRelation(annoteElem, tBinding);
    }

    case ASTNode.VARIABLE_DECLARATION_STATEMENT: {
        VariableDeclarationStatement vds = (VariableDeclarationStatement) annotatedNode;
        return processVariableDeclarationStatement(annoteElem, vds);
    }

    case ASTNode.VARIABLE_DECLARATION_FRAGMENT: {
        return processVariableDeclarationFragment(annoteElem, (VariableDeclarationFragment) annotatedNode);
    }

    case ASTNode.PACKAGE_DECLARATION: {
        final PackageDeclaration packDecl = (PackageDeclaration) annotatedNode;
        final IPackageBinding pBinding = packDecl.resolveBinding();
        return this.addAnnotationRelation(annoteElem, pBinding);
    }

    case ASTNode.SINGLE_VARIABLE_DECLARATION: {
        final SingleVariableDeclaration svd = (SingleVariableDeclaration) annotatedNode;
        final IVariableBinding vBinding = svd.resolveBinding();
        return this.addAnnotationRelation(annoteElem, vBinding);
    }
    case ASTNode.TYPE_DECLARATION: {
        final TypeDeclaration tDecl = (TypeDeclaration) annotatedNode;
        final ITypeBinding tBinding = tDecl.resolveBinding();
        return this.addAnnotationRelation(annoteElem, tBinding);
    }
    case ASTNode.ENUM_DECLARATION: {
        final EnumDeclaration eDecl = (EnumDeclaration) annotatedNode;
        final ITypeBinding tBinding = eDecl.resolveBinding();
        return this.addAnnotationRelation(annoteElem, tBinding);
    }
    case ASTNode.FIELD_DECLARATION: {
        final FieldDeclaration fieldDecl = (FieldDeclaration) annotatedNode;
        for (final Object obj : fieldDecl.fragments()) {
            final VariableDeclarationFragment vdf = (VariableDeclarationFragment) obj;
            final IVariableBinding vBinding = vdf.resolveBinding();
            return this.addAnnotationRelation(annoteElem, vBinding);
        }
    }
    default: {
        throw new IllegalStateException("Illegal annotated node type: " + annotatedNode);
    }
    }
}

From source file:ca.mcgill.cs.swevo.ppa.inference.ReturnInferenceStrategy.java

License:Open Source License

public void inferTypes(ASTNode node) {
    ReturnStatement returnStmt = (ReturnStatement) node;

    Expression exp = returnStmt.getExpression();

    if (exp == null || !indexer.isIndexable(exp) || indexer.isSafe(exp)) {
        return;/*ww  w.j  av  a 2  s  .  c  o m*/
    }

    MethodDeclaration mDeclaration = (MethodDeclaration) PPAASTUtil.getSpecificParentType(returnStmt,
            ASTNode.METHOD_DECLARATION);
    if (mDeclaration != null) {
        IMethodBinding methodBinding = mDeclaration.resolveBinding();
        if (methodBinding != null) {
            ITypeBinding newBinding = methodBinding.getReturnType();
            ITypeBinding oldBinding = exp.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(exp), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.RETURN_STRATEGY);
            ppaEngine.reportTypeFact(typeFact);
        }
    }
}

From source file:ca.uvic.chisel.diver.sequencediagrams.sc.java.editors.JavaMessageGrouper.java

License:Open Source License

public IMessageGrouping[] calculateGroups(UMLSequenceViewer viewer, Object activationElement,
        Object[] children) {/*from   ww w . java 2s  .  com*/
    HashMap<ASTNode, MappedMessageGrouping> groups = new HashMap<ASTNode, MappedMessageGrouping>();
    if (!(activationElement instanceof IAdaptable)) {
        return new IMessageGrouping[0];
    }
    ASTNode activationNode = (ASTNode) ((IAdaptable) activationElement).getAdapter(ASTNode.class);
    if (!(activationNode instanceof MethodDeclaration)) {
        return new IMessageGrouping[0];
    }
    for (int i = 0; i < children.length; i++) {
        if (children[i] instanceof IAdaptable) {
            ASTNode messageNode = (ASTNode) ((IAdaptable) children[i]).getAdapter(ASTNode.class);
            if (messageNode != null) {
                ASTNode blockParent = findBlockParent(messageNode);

                List<MappedMessageGrouping> blocks = new LinkedList<MappedMessageGrouping>();
                while (blockParent != null && blockParent.getNodeType() != ASTNode.METHOD_DECLARATION) {

                    if (blockParent != null && blockParent.getNodeType() == ASTNode.IF_STATEMENT) {
                        IfStatement ifStatement = (IfStatement) blockParent;
                        ASTNode block = checkIfSide(ifStatement, messageNode);
                        if (block != null && block.equals(ifStatement.getElseStatement())) {
                            //add a block for the else statement as well
                            MappedMessageGrouping blockNode = groups.get(block);
                            if (blockNode == null) {
                                blockNode = new MappedMessageGrouping(activationElement, i, 0, "", block);
                                groups.put(block, blockNode);
                            }
                            blocks.add(blockNode);
                        }
                    }
                    MappedMessageGrouping blockNode = groups.get(blockParent);
                    if (blockNode == null) {
                        blockNode = new MappedMessageGrouping(activationElement, i, 0, "", blockParent);
                        groups.put(blockParent, blockNode);
                    }
                    blocks.add(blockNode);
                    blockParent = findBlockParent(blockParent);
                }
                for (MappedMessageGrouping blockNode : blocks) {
                    blockNode.setLength(blockNode.getLength() + 1);
                }
            }
        }
    }
    ArrayList<MappedMessageGrouping> groupList = new ArrayList<MappedMessageGrouping>(groups.values());
    Collections.sort(groupList, new Comparator<MappedMessageGrouping>() {
        public int compare(MappedMessageGrouping o1, MappedMessageGrouping o2) {
            ASTNode n1 = (ASTNode) o1.getKey();
            ASTNode n2 = (ASTNode) o2.getKey();
            int diff = n1.getStartPosition() - n2.getStartPosition();
            if (diff == 0) {
                diff = (n1.getStartPosition() + n1.getLength()) - (n2.getStartPosition() + n2.getLength());
            }
            if (diff == 0) {
                IfStatement ifStatement = null;
                //make sure that else statements are contained in if statements
                if (n1 instanceof IfStatement) {
                    ifStatement = (IfStatement) n1;
                } else if (n2 instanceof IfStatement) {
                    ifStatement = (IfStatement) n2;
                }
                if (ifStatement != null) {
                    if (n2.equals(ifStatement.getElseStatement())) {
                        return -1;
                    } else if (n1.equals(ifStatement.getElseStatement())) {
                        return 1;
                    }
                }
            }
            return diff;
        }
    });
    for (MappedMessageGrouping blockNode : groupList) {
        updateGrouping(blockNode);
    }
    return groupList.toArray(new IMessageGrouping[groupList.size()]);
}

From source file:ca.uvic.chisel.diver.sequencediagrams.sc.java.editors.JavaMessageGrouper.java

License:Open Source License

/**
 * @param messageNode//w w  w  .j a va 2  s .  c o m
 * @return
 */
private static ASTNode findBlockParent(ASTNode messageNode) {
    if (messageNode.getNodeType() == ASTNode.METHOD_DECLARATION) {
        return messageNode;
    }
    //search through the tree, up through the parents to find the nearest block
    ASTNode parent = messageNode.getParent();
    while (parent != null) {
        switch (parent.getNodeType()) {
        case ASTNode.IF_STATEMENT:
        case ASTNode.WHILE_STATEMENT:
        case ASTNode.FOR_STATEMENT:
        case ASTNode.DO_STATEMENT:
        case ASTNode.ENHANCED_FOR_STATEMENT:
        case ASTNode.TRY_STATEMENT:
        case ASTNode.CATCH_CLAUSE:
        case ASTNode.METHOD_DECLARATION:
            return parent;
        default:
            //get the else blocks
            if (parent instanceof Statement) {
                Statement statement = (Statement) parent;
                if (statement.getParent() instanceof IfStatement) {
                    if (((IfStatement) statement.getParent()).getElseStatement() == statement) {
                        return statement;
                    }
                }
            }
            break;
        }
        parent = parent.getParent();
    }
    return null;
}

From source file:ca.uvic.chisel.javasketch.internal.ast.groups.ASTLoopGroupCalculator.java

License:Open Source License

/**
 * @param blockNode/*  w ww . j av a  2  s  . c o m*/
 * @param child
 * @param i
 * @param groupings
 * @return
 */
private static ASTMessageGroupingTree getGrouping(ASTNode blockNode) {
    ASTMessageGroupingTree currentGrouping = (ASTMessageGroupingTree) blockNode.getProperty(CURRENT_GROUPING);

    if (currentGrouping == null) {
        //first: if this blockNode is a method declaration, create a root group
        if (blockNode.getNodeType() == ASTNode.METHOD_DECLARATION) {
            currentGrouping = new ASTMessageGroupingTree(null, blockNode);
            blockNode.setProperty(CURRENT_GROUPING, currentGrouping);
            return currentGrouping;
        } else {
            ASTMessageGroupingTree parentGrouping = getGrouping(findBlockParent(blockNode));
            currentGrouping = new ASTMessageGroupingTree(parentGrouping, blockNode);
            blockNode.setProperty(CURRENT_GROUPING, currentGrouping);
            return currentGrouping;
        }
        //         
        //         ASTMessageGroupingTree parentGrouping = 
        //         //create a new grouping for this node and all of its parents.
        //         LinkedList<IMessageGrouping> created = new LinkedList<IMessageGrouping>();
        //         currentGrouping = new ASTMessageGroupingTree(activation, blockNode);
        //         currentGrouping.setStartIndex(i);
        //         currentGrouping.setEndIndex(i);
        //         blockNode.setProperty(CURRENT_GROUPING, currentGrouping);
        //         updateGrouping(currentGrouping);
        //         created.addFirst(currentGrouping);
        //         ASTNode parent = findBlockParent(blockNode);
        //         while (parent != null) {
        //            ASTMessageGroupingTree newGrouping = (ASTMessageGroupingTree) parent.getProperty(CURRENT_GROUPING);
        //            if (newGrouping != null) {
        //               //update it to include the new index
        //               if (newGrouping.getEndIndex() < i) {
        //                  newGrouping.setEndIndex(i);
        //               }
        //            } else {
        //               newGrouping = new ASTMessageGroupingTree(activation, parent);
        //               parent.setProperty(CURRENT_GROUPING, newGrouping);
        //               newGrouping.setStartIndex(i);
        //               newGrouping.setEndIndex(i);
        //               updateGrouping(newGrouping);
        //               created.addFirst(newGrouping);
        //            }
        //            parent = findBlockParent(parent);      
        //         }
        //         groupings.addAll(created);
    }
    return currentGrouping;
}

From source file:ca.uvic.chisel.javasketch.ui.internal.presentation.ASTMessageGrouper.java

License:Open Source License

public IMessageGrouping[] calculateGroups2(UMLSequenceViewer viewer, Object activationElement,
        Object[] children) {/* w  ww  .java  2  s . c om*/
    HashMap<ASTMessageGroupingTree, ASTMessageGrouping> groups = new HashMap<ASTMessageGroupingTree, ASTMessageGrouping>();
    IPreferenceStore store = SketchPlugin.getDefault().getPreferenceStore();
    ArrayList<ASTMessageGrouping> unusedGroups = new ArrayList<ASTMessageGrouper.ASTMessageGrouping>();
    boolean compactLoops = store.getBoolean(ISketchPluginPreferences.COMPACT_LOOPS_PREFERENCE);
    boolean useCombinedFragments = store.getBoolean(ISketchPluginPreferences.DISPLAY_GROUPS_PREFERENCE);
    if (!useCombinedFragments) {
        return new IMessageGrouping[0];
    }
    if (activationElement instanceof IActivation) {
        IActivation parent = (IActivation) activationElement;
        IProgramSketch sketch = SketchPlugin.getDefault().getSketch(parent);
        if (sketch != null) {
            PresentationData pd = PresentationData.connect(sketch);
            if (pd != null) {
                try {
                    ASTMessageGroupingTree tree = pd.getGroups(parent);

                    if (tree == null) {
                        return new IMessageGrouping[0];
                    }
                    LinkedList<ASTMessageGroupingTree> groupStack = new LinkedList<ASTMessageGroupingTree>();

                    //search through the tree to find all loops
                    groupStack.add(tree);
                    while (groupStack.size() > 0) {
                        ASTMessageGroupingTree node = groupStack.removeFirst();
                        if (pd.isGroupVisible(parent, node) || (!compactLoops && node.isLoop())) {
                            ASTMessageGrouping g = new ASTMessageGrouping(activationElement, node);
                            g.setOffset(-1);
                            g.setLength(0);
                            groups.put(node, g);
                            unusedGroups.add(g);
                            for (ASTMessageGroupingTree child : node.getChildren()) {
                                groupStack.add(child);
                            }
                        }
                    }

                    int unusedIndex = 0;
                    for (int i = 0; i < children.length; i++) {
                        Object child = children[i];
                        if (child instanceof IMessage) {
                            ASTMessageGroupingTree node = tree.getMessageContainer((IMessage) child);
                            ASTMessageGrouping grouping = groups.get(node);
                            int messageLineNumber = ((IMessage) child).codeLine();
                            if (grouping != null) {
                                if (grouping.getOffset() < 0) {
                                    //update all the preceding offsets to
                                    //be equal to this one.
                                    for (int u = unusedIndex; u < unusedGroups.size(); unusedIndex++, u++) {
                                        ASTMessageGrouping unused = unusedGroups.get(u);
                                        if (unused.node.getFirstCodeLine() <= messageLineNumber) {
                                            unused.setOffset(i);
                                        } else {
                                            unusedIndex = u;
                                            break;
                                        }
                                    }
                                }
                            }
                            //update all the parents for the length
                            while (node != null && node.getParent() != null) {
                                grouping = groups.get(node);
                                if (grouping != null) {
                                    grouping.setLength(i - grouping.getOffset() + 1);
                                }
                                node = node.getParent();
                            }
                        }
                    }
                    for (int i = unusedIndex; i < unusedGroups.size(); i++) {
                        ASTMessageGrouping unused = unusedGroups.get(i);
                        unused.setOffset(children.length);
                    }
                } finally {
                    pd.disconnect();
                }
            }
        }
    }
    for (Iterator<ASTMessageGrouping> i = unusedGroups.iterator(); i.hasNext();) {
        ASTMessageGrouping group = i.next();
        if (group.node.getNode().getNodeType() == ASTNode.METHOD_DECLARATION) {
            i.remove();
        } else if (group.getLength() <= 0) {
            //remove non-loop elements
            if (!group.node.isLoop()) {
                i.remove();
            } else {
                //walk up the list and remove children of empty
                //loops
                ASTMessageGroupingTree parent = group.node.getParent();

                boolean remove = false;
                while (parent != null) {
                    ASTMessageGrouping grouping = groups.get(parent);
                    if (grouping.node.isLoop() && grouping.getLength() <= 0) {
                        remove = true;
                        break;
                    }
                    parent = parent.getParent();
                }
                if (remove) {
                    i.remove();
                }
            }
        }
    }

    for (ASTMessageGrouping group : unusedGroups) {
        updateGrouping(group, group.node.getNode());
    }
    return unusedGroups.toArray(new ASTMessageGrouping[unusedGroups.size()]);
    //return result;
}