Package ch.uzh.ifi.seal.changedistiller.model.entities

Examples of ch.uzh.ifi.seal.changedistiller.model.entities.SourceCodeChange


        }
        return result;
    }

    private SourceCodeChange handleTypeDeclarationChange(Delete delete) {
        SourceCodeChange result = null;
        if (delete.getChangedEntity().getType() == JavaEntityType.JAVADOC) {
            delete.setChangeType(ChangeType.DOC_DELETE);
            result = delete;
        }
        return result;
View Full Code Here


        }
        return result;
    }

    private SourceCodeChange handleTypeDeclarationChange(Insert insert) {
        SourceCodeChange result = null;
        if (insert.getChangedEntity().getType() == JavaEntityType.JAVADOC) {
            Delete del =
                    findDeleteOperation(
                            insert.getRootEntity().getType(),
                            insert.getRootEntity().getUniqueName(),
                            insert.getParentEntity().getType(),
                            insert.getParentEntity().getUniqueName(),
                            insert.getChangedEntity().getType(),
                            null);
            if (del != null) {
                result =
                        new Update(
                                insert.getRootEntity(),
                                del.getChangedEntity(),
                                insert.getChangedEntity(),
                                insert.getParentEntity());
                result.setChangeType(ChangeType.DOC_UPDATE);
                fDeletes.remove(del);
            } else {
                insert.setChangeType(ChangeType.DOC_INSERT);
                result = insert;
            }
View Full Code Here

        }
        return result;
    }

    private SourceCodeChange handleTypeDeclarationChange(Update update) {
        SourceCodeChange result = null;
        if (update.getChangedEntity().getType() == JavaEntityType.JAVADOC) {
            update.setChangeType(ChangeType.DOC_UPDATE);
            result = update;
        }
        return result;
View Full Code Here

        }
        return result;
    }

    private SourceCodeChange handleMethodSignatureChange(Insert insert) {
        SourceCodeChange result = null;

        if (insert.getChangedEntity().getType() == JavaEntityType.JAVADOC) {
            Delete del =
                    findDeleteOperation(
                            insert.getRootEntity().getType(),
                            insert.getRootEntity().getUniqueName(),
                            insert.getParentEntity().getType(),
                            insert.getParentEntity().getUniqueName(),
                            insert.getChangedEntity().getType(),
                            null);
            if (del != null) {
                result =
                        new Update(
                                insert.getRootEntity(),
                                del.getChangedEntity(),
                                insert.getChangedEntity(),
                                insert.getParentEntity());
                result.setChangeType(ChangeType.DOC_UPDATE);
                fDeletes.remove(del);
            } else {
                insert.setChangeType(ChangeType.DOC_INSERT);
                result = insert;
            }
View Full Code Here

        }
        return result;
    }

    private SourceCodeChange extractReturnChange(Insert insert) {
        SourceCodeChange result = null;
        // may lead to incorrect result (never happened so far); better: check for each
        // possible kind of type
        if (insert.getChangedEntity().getType().isType()) {
            if (insert.getChangedEntity().getUniqueName().endsWith(VOID_RETURN)) {
                Delete del =
                        findSpDeleteOperation(
                                insert.getRootEntity().getType(),
                                insert.getRootEntity().getUniqueName(),
                                insert.getParentEntity().getType(),
                                insert.getParentEntity().getUniqueName());

                del.setChangeType(ChangeType.RETURN_TYPE_DELETE);
                result = del;
            } else {
                Delete del = null;
                boolean check = true;
                // if a non-void type deletion in method declaration occurred
                // => RETURN_TYPE_CHANGE
                for (Iterator<Delete> it = fDeletes.iterator(); it.hasNext() && check;) {
                    del = it.next();
                    if ((insert.getRootEntity().getType() == del.getRootEntity().getType())
                            && insert.getRootEntity().getUniqueName().equals(del.getRootEntity().getUniqueName())
                            && (del.getParentEntity().getType() == JavaEntityType.METHOD_DECLARATION)
                            && del.getParentEntity().getUniqueName().equals(insert.getParentEntity().getUniqueName())
                            && del.getChangedEntity().getType().isType()
                            && !del.getChangedEntity().getUniqueName().matches(".*: void")) {
                        check = false;
                    }
                }
                if (!check) {
                    result =
                            new Update(
                                    insert.getRootEntity(),
                                    del.getChangedEntity(),
                                    insert.getChangedEntity(),
                                    insert.getParentEntity());
                    result.setChangeType(ChangeType.RETURN_TYPE_CHANGE);
                    fDeletes.remove(del);
                } else {
                    insert.setChangeType(ChangeType.RETURN_TYPE_INSERT);
                    result = insert;
                }
View Full Code Here

        }
        return result;
    }

    private SourceCodeChange extractParameterChange(Insert insert) {
        SourceCodeChange result = null;
        if (insert.getChangedEntity().getType() == JavaEntityType.PARAMETER) {
            // SingleVariableDeclaration has changed, but the type node (child)
            // remains the same => PARAMETER_RENAMING
            Move mov =
                    findMoveOperation(
                            insert.getRootEntity().getType(),
                            insert.getRootEntity().getUniqueName(),
                            JavaEntityType.PARAMETER,
                            null,
                            JavaEntityType.PARAMETER,
                            insert.getChangedEntity().getUniqueName(),
                            null,
                            null);

            Delete del =
                    findDeleteOperation(
                            insert.getRootEntity().getType(),
                            insert.getRootEntity().getUniqueName(),
                            JavaEntityType.PARAMETERS,
                            "",
                            JavaEntityType.PARAMETER,
                            insert.getChangedEntity().getUniqueName());
            // parameter renaming
            if (mov != null) {
                Delete d =
                        findDeleteOperation(
                                insert.getRootEntity().getType(),
                                insert.getRootEntity().getUniqueName(),
                                JavaEntityType.PARAMETERS,
                                "",
                                JavaEntityType.PARAMETER,
                                mov.getParentEntity().getUniqueName());
                if (d == null) {
                    insert.setChangeType(ChangeType.PARAMETER_INSERT);
                    result = insert;
                } else {
                    result =
                            new Update(
                                    insert.getRootEntity(),
                                    insert.getChangedEntity(),
                                    d.getChangedEntity(),
                                    insert.getParentEntity());
                    result.setChangeType(ChangeType.PARAMETER_RENAMING);
                    fMoves.remove(mov);
                    fDeletes.remove(d);
                }

                // SingleVariableDeclaration remains the same but the type
                // node (child) are not equal => PARAMETER_TYPE_CHANGE
            } else if (del != null) {
                Delete dell =
                        findDeleteOperation(
                                insert.getRootEntity().getType(),
                                insert.getRootEntity().getUniqueName(),
                                del.getChangedEntity().getType(),
                                del.getChangedEntity().getUniqueName(),
                                null,
                                null);
                if (dell == null) {
                    insert.setChangeType(ChangeType.PARAMETER_INSERT);
                    result = insert;
                } else {

                    // WTF how to remove the insert?

                    Insert i =
                            findInsertOperation(insert.getRootEntity().getType(), insert.getRootEntity()
                                    .getUniqueName(), insert.getChangedEntity().getType(), insert.getChangedEntity()
                                    .getUniqueName(), null, null);
                    if (i == null) {
                        insert.setChangeType(ChangeType.PARAMETER_INSERT);
                        result = insert;
                    } else {
                        result =
                                new Update(
                                        insert.getRootEntity(),
                                        dell.getChangedEntity(),
                                        i.getChangedEntity(),
                                        insert.getChangedEntity());
                        result.setChangeType(ChangeType.PARAMETER_TYPE_CHANGE);
                        fDeletes.remove(del);
                        fDeletes.remove(dell);
                        fInsertsToDelete.add(i);
                    }
                }
View Full Code Here

        }
        return result;
    }

    private SourceCodeChange extractModifiersChange(Insert insert) {
        SourceCodeChange result = null;

        if (insert.getChangedEntity().getUniqueName().equals(FINAL)) {
            return handleFinalChange(insert);
        } else if (insert.getChangedEntity().getUniqueName().equals(PUBLIC)) {
            result = extractIncreasingAccessibilityChange(insert);
View Full Code Here

        }
        return insert;
    }

    private SourceCodeChange handleNormalInsert(Insert insert) {
        SourceCodeChange result = null;
        if (insert.getChangedEntity().getType() == JavaEntityType.ELSE_STATEMENT) {
            insert.setChangeType(ChangeType.ALTERNATIVE_PART_INSERT);
            result = insert;
        } else if ((insert.getChangedEntity().getType() == JavaEntityType.BLOCK_COMMENT)
                || (insert.getChangedEntity().getType() == JavaEntityType.LINE_COMMENT)) {
View Full Code Here

        return result;
    }

    private SourceCodeChange extractIncreasingAccessibilityChange(Insert insert) {
        insert.setChangeType(ChangeType.INCREASING_ACCESSIBILITY_CHANGE);
        SourceCodeChange result = null;

        Delete delProtected =
                findDeleteOperation(
                        insert.getRootEntity().getType(),
                        insert.getRootEntity().getUniqueName(),
                        JavaEntityType.MODIFIERS,
                        "",
                        JavaEntityType.MODIFIER,
                        PROTECTED);
        Delete delPrivate =
                findDeleteOperation(
                        insert.getRootEntity().getType(),
                        insert.getRootEntity().getUniqueName(),
                        JavaEntityType.MODIFIERS,
                        "",
                        JavaEntityType.MODIFIER,
                        PRIVATE);
        if (delProtected != null) {
            result =
                    new Update(
                            insert.getRootEntity(),
                            delProtected.getChangedEntity(),
                            insert.getChangedEntity(),
                            insert.getParentEntity());
            result.setChangeType(ChangeType.INCREASING_ACCESSIBILITY_CHANGE);
            fDeletes.remove(delProtected);
        } else if (delPrivate != null) {
            result =
                    new Update(
                            insert.getRootEntity(),
                            delPrivate.getChangedEntity(),
                            insert.getChangedEntity(),
                            insert.getParentEntity());
            result.setChangeType(ChangeType.INCREASING_ACCESSIBILITY_CHANGE);
            fDeletes.remove(delPrivate);
        } else {
            result = insert;
        }
        return result;
View Full Code Here

        return result;
    }

    private SourceCodeChange extractDecreasingAccessibilityChange(Insert insert) {
        insert.setChangeType(ChangeType.DECREASING_ACCESSIBILITY_CHANGE);
        SourceCodeChange result = null;

        Delete delProtected =
                findDeleteOperation(
                        insert.getRootEntity().getType(),
                        insert.getRootEntity().getUniqueName(),
                        JavaEntityType.MODIFIERS,
                        "",
                        JavaEntityType.MODIFIER,
                        PROTECTED);
        Delete delPublic =
                findDeleteOperation(
                        insert.getRootEntity().getType(),
                        insert.getRootEntity().getUniqueName(),
                        JavaEntityType.MODIFIERS,
                        "",
                        JavaEntityType.MODIFIER,
                        PUBLIC);
        if (delProtected != null) {
            result =
                    new Update(
                            insert.getRootEntity(),
                            delProtected.getChangedEntity(),
                            insert.getChangedEntity(),
                            insert.getParentEntity());
            result.setChangeType(ChangeType.DECREASING_ACCESSIBILITY_CHANGE);
            fDeletes.remove(delProtected);
        } else if (delPublic != null) {
            result =
                    new Update(
                            insert.getRootEntity(),
                            delPublic.getChangedEntity(),
                            insert.getChangedEntity(),
                            insert.getParentEntity());
            fDeletes.remove(delPublic);
            result.setChangeType(ChangeType.DECREASING_ACCESSIBILITY_CHANGE);
        } else {
            result = insert;
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of ch.uzh.ifi.seal.changedistiller.model.entities.SourceCodeChange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.