Package ch.uzh.ifi.seal.changedistiller.treedifferencing

Examples of ch.uzh.ifi.seal.changedistiller.treedifferencing.Node


    protected void assertThat(Object actual, Matcher matcher) {
        MatcherAssert.assertThat(actual, matcher);
    }

    protected void createRootNode(EntityType label, String value) {
        fRoot = new Node(label, value);
        fRoot.setEntity(new SourceCodeEntity(value, label, new SourceRange()));
    }
View Full Code Here


        CommentCleaner visitor = new CommentCleaner(sCompilation.getSource());
        for (Comment comment : comments) {
            visitor.process(comment);
        }
        sComments = visitor.getComments();
        sRoot = new Node(JavaEntityType.METHOD, "foo");
        sRoot.setEntity(new SourceCodeEntity("foo", JavaEntityType.METHOD, new SourceRange()));
        AbstractMethodDeclaration method = CompilationUtils.findMethod(sCompilation.getCompilationUnit(), "foo");
        JavaMethodBodyConverter bodyT = sInjector.getInstance(JavaMethodBodyConverter.class);
        bodyT.initialize(sRoot, method, sComments, sCompilation.getScanner());
        method.traverse(bodyT, (ClassScope) null);
View Full Code Here

        method.traverse(bodyT, (ClassScope) null);
    }

    @Test
    public void proximityRatingShouldAssociateCommentToClosestEntity() throws Exception {
        Node node = findNode("boolean check = (number > 0);");
        assertCorrectAssociation(node, "// check if number is greater than -1", JavaEntityType.LINE_COMMENT);
    }
View Full Code Here

        assertCorrectAssociation(node, "// check if number is greater than -1", JavaEntityType.LINE_COMMENT);
    }

    @Test
    public void undecidedProximityRatingShouldAssociateCommentToNextEntity() throws Exception {
        Node node = findNode("check");
        assertCorrectAssociation(
                node,
                "// check the interesting number" + LF + "        // and some new else",
                JavaEntityType.LINE_COMMENT);
    }
View Full Code Here

    // logic partly taken from org.eclipse.jdt.core.dom.ASTConverter
    private void visitModifiers(int modifierMask) {
        push(JavaEntityType.MODIFIERS, "", -1, -1);
        if (modifierMask != 0) {
            Node modifiers = fNodeStack.peek();
            fScanner.tokenizeWhiteSpace = false;
            try {
                int token;
                while ((token = fScanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
                    switch (token) {
View Full Code Here

    private void pushValuedNode(ASTNode node, String value) {
        push(fASTHelper.convertNode(node), value, node.sourceStart(), node.sourceEnd());
    }

    private void push(EntityType label, String value, int start, int end) {
        Node n = new Node(label, value.trim());
        n.setEntity(new SourceCodeEntity(value.trim(), label, new SourceRange(start, end)));
        getCurrentParent().add(n);
        fNodeStack.push(n);
    }
View Full Code Here

    private List<TreeEditOperation> fEditScript;

    @Before
    @Override
    public void setup() throws Exception {
        fRootLeft = new Node(JavaEntityType.ROOT_NODE, "method()");
        fRootRight = new Node(JavaEntityType.ROOT_NODE, "method()");
        fDifferencer = new TreeDifferencer();
    }
View Full Code Here

        assertThat(fEditScript.isEmpty(), is(true));
    }

    @Test
    public void insertedNodeShouldProduceInsertOperation() throws Exception {
        Node methodInvocation = addToRight(METHOD_INVOCATION, "foo.bar();");
        createEditScript();
        assertThat(fEditScript.size(), is(1));
        TreeEditOperation operation = fEditScript.get(0);
        assertThat(operation.getOperationType(), is(OperationType.INSERT));
        InsertOperation insert = (InsertOperation) operation;
        assertThat(insert.getParentNode(), is(fRootLeft));
        assertThat(insert.getNodeToInsert().getLabel(), is(methodInvocation.getLabel()));
        assertThat(insert.getNodeToInsert().getValue(), is(methodInvocation.getValue()));
    }
View Full Code Here

        assertThat(insert.getNodeToInsert().getValue(), is(methodInvocation.getValue()));
    }

    @Test
    public void deletedNodeShouldProduceDeleteOperation() throws Exception {
        Node methodInvocation = addToLeft(METHOD_INVOCATION, "foo.bar();");
        createEditScript();
        assertThat(fEditScript.size(), is(1));
        TreeEditOperation operation = fEditScript.get(0);
        assertThat(operation.getOperationType(), is(OperationType.DELETE));
        DeleteOperation delete = (DeleteOperation) operation;
View Full Code Here

        assertThat(delete.getNodeToDelete(), is(methodInvocation));
    }

    @Test
    public void movedNodeShouldProduceMoveOperation() throws Exception {
        Node methodInvocation = addToLeft(METHOD_INVOCATION, "foo.bar();");
        Node ifStatementLeft = addToLeft(JavaEntityType.IF_STATEMENT, "foo != null");
        addToNode(ifStatementLeft, ASSIGNMENT, "b = a;");
        Node ifStatementRight = addToRight(JavaEntityType.IF_STATEMENT, "foo != null");
        addToNode(ifStatementRight, METHOD_INVOCATION, "foo.bar();");
        addToNode(ifStatementRight, ASSIGNMENT, "b = a;");
        createEditScript();
        assertThat(fEditScript.size(), is(1));
        TreeEditOperation operation = fEditScript.get(0);
        assertThat(operation.getOperationType(), is(OperationType.MOVE));
        MoveOperation move = (MoveOperation) operation;
        assertThat(move.getOldParent(), is(fRootLeft));
        assertThat(move.getNewParent().getLabel(), is(ifStatementRight.getLabel()));
        assertThat(move.getNewParent().getValue(), is(ifStatementRight.getValue()));
        assertThat(move.getNodeToMove(), is(methodInvocation));
        assertThat(move.getNewNode().getLabel(), is(methodInvocation.getLabel()));
        assertThat(move.getNewNode().getValue(), is(methodInvocation.getValue()));
    }
View Full Code Here

TOP

Related Classes of ch.uzh.ifi.seal.changedistiller.treedifferencing.Node

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.