Package ch.uzh.ifi.seal.changedistiller.structuredifferencing

Examples of ch.uzh.ifi.seal.changedistiller.structuredifferencing.StructureDiffNode


     *
     * @param candidate
     *            to add to the container
     */
    public void addCandidate(RefactoringCandidate candidate) {
        StructureDiffNode node = candidate.getDiffNode();
        if (node.isAddition()) {
            if (node.getRight().isClassOrInterface()) {
                fAddedInnerClasses.add(candidate);
            } else if (node.getRight().isMethodOrConstructor()) {
                fAddedMethods.add(candidate);
            } else if (node.getRight().isField()) {
                fAddedFields.add(candidate);
            }
        } else if (node.isDeletion()) {
            if (node.getLeft().isClassOrInterface()) {
                fDeletedInnerClasses.add(candidate);
            } else if (node.getLeft().isMethodOrConstructor()) {
                fDeletedMethods.add(candidate);
            } else if (node.getLeft().isField()) {
                fDeletedFields.add(candidate);
            }
        }
    }
View Full Code Here


  private void extractDifferences() {
    StructureDifferencer structureDifferencer = new StructureDifferencer();
        structureDifferencer.extractDifferences(
                fLeftASTHelper.createStructureTree(),
                fRightASTHelper.createStructureTree());
        StructureDiffNode structureDiff = structureDifferencer.getDifferences();
        if (structureDiff != null) {
          fChanges = new LinkedList<SourceCodeChange>();
            // first node is (usually) the compilation unit
            processRootChildren(structureDiff);
        } else {
View Full Code Here

    public void addedMethodShouldBeFound() throws Exception {
        createLeftStructureTree("public class Foo {}");
        createRightStructureTree("public class Foo { void method(int a) { a = 24; } }");
        createDifferences();
        assertThat(fDiffs.getChildren().size(), is(1));
        StructureDiffNode methodAddition = fDiffs.getChildren().get(0).getChildren().get(0);
        assertThat(methodAddition.getDiffType(), is(DiffType.ADDITION));
        assertThat(methodAddition.getChildren(), is(Collections.EMPTY_LIST));
        assertThat(methodAddition.getLeft(), is(nullValue()));
        assertThat(methodAddition.getRight().getName(), is("method(int)"));
    }
View Full Code Here

    public void deletedMethodShouldBeFound() throws Exception {
        createLeftStructureTree("public class Foo { void method(int a) { a = 24; } }");
        createRightStructureTree("public class Foo {}");
        createDifferences();
        assertThat(fDiffs.getChildren().size(), is(1));
        StructureDiffNode methodDeletion = fDiffs.getChildren().get(0).getChildren().get(0);
        assertThat(methodDeletion.getDiffType(), is(DiffType.DELETION));
        assertThat(methodDeletion.getChildren(), is(Collections.EMPTY_LIST));
        assertThat(methodDeletion.getLeft().getName(), is("method(int)"));
        assertThat(methodDeletion.getRight(), is(nullValue()));
    }
View Full Code Here

    public void changedMethodShouldBeFound() throws Exception {
        createLeftStructureTree("public class Foo { void method(int a) { a = 24; } }");
        createRightStructureTree("public class Foo { void method(int a) { a = 21; } }");
        createDifferences();
        assertThat(fDiffs.getChildren().size(), is(1));
        StructureDiffNode methodChange = fDiffs.getChildren().get(0).getChildren().get(0);
        assertThat(methodChange.getDiffType(), is(DiffType.CHANGE));
        assertThat(methodChange.getChildren(), is(Collections.EMPTY_LIST));
        assertThat(methodChange.getLeft().getName(), is("method(int)"));
        assertThat(methodChange.getRight().getName(), is("method(int)"));
    }
View Full Code Here

    public void addedClassShouldBeFound() throws Exception {
        createLeftStructureTree("public class Foo {  }");
        createRightStructureTree("public class Foo { class Bar {} }");
        createDifferences();
        assertThat(fDiffs.getChildren().size(), is(1));
        StructureDiffNode classAddition = fDiffs.getChildren().get(0).getChildren().get(0);
        assertThat(classAddition.getDiffType(), is(DiffType.ADDITION));
        assertThat(classAddition.getChildren(), is(Collections.EMPTY_LIST));
        assertThat(classAddition.getLeft(), is(nullValue()));
        assertThat(classAddition.getRight().getName(), is("Bar"));
    }
View Full Code Here

    public void deletedClassShouldBeFound() throws Exception {
        createLeftStructureTree("public class Foo { class Bar {} }");
        createRightStructureTree("public class Foo {  }");
        createDifferences();
        assertThat(fDiffs.getChildren().size(), is(1));
        StructureDiffNode classAddition = fDiffs.getChildren().get(0).getChildren().get(0);
        assertThat(classAddition.getDiffType(), is(DiffType.DELETION));
        assertThat(classAddition.getChildren(), is(Collections.EMPTY_LIST));
        assertThat(classAddition.getLeft().getName(), is("Bar"));
        assertThat(classAddition.getRight(), is(nullValue()));
    }
View Full Code Here

    public void addedFieldShouldBeFound() throws Exception {
        createLeftStructureTree("public class Foo {  }");
        createRightStructureTree("public class Foo { private String fName; }");
        createDifferences();
        assertThat(fDiffs.getChildren().size(), is(1));
        StructureDiffNode classAddition = fDiffs.getChildren().get(0).getChildren().get(0);
        assertThat(classAddition.getDiffType(), is(DiffType.ADDITION));
        assertThat(classAddition.getChildren(), is(Collections.EMPTY_LIST));
        assertThat(classAddition.getLeft(), is(nullValue()));
        assertThat(classAddition.getRight().getName(), is("fName : String"));
    }
View Full Code Here

    public void deletedFieldShouldBeFound() throws Exception {
        createLeftStructureTree("public class Foo { private String fName; }");
        createRightStructureTree("public class Foo {  }");
        createDifferences();
        assertThat(fDiffs.getChildren().size(), is(1));
        StructureDiffNode classAddition = fDiffs.getChildren().get(0).getChildren().get(0);
        assertThat(classAddition.getDiffType(), is(DiffType.DELETION));
        assertThat(classAddition.getChildren(), is(Collections.EMPTY_LIST));
        assertThat(classAddition.getLeft().getName(), is("fName : String"));
        assertThat(classAddition.getRight(), is(nullValue()));
    }
View Full Code Here

    @Test
    public void changedMethodInInnerClassShouldBeFound() throws Exception {
        createLeftStructureTree("public class Foo { class Bar { void method() {} } }");
        createRightStructureTree("public class Foo { class Bar { void method() { int a = 12; } } }");
        createDifferences();
        StructureDiffNode changedMethod = fDiffs.getChildren().get(0).getChildren().get(0).getChildren().get(0);
        assertThat(changedMethod.getDiffType(), is(DiffType.CHANGE));
        assertThat(changedMethod.getChildren(), is(Collections.EMPTY_LIST));
        assertThat(changedMethod.getLeft().getName(), is("method()"));
        assertThat(changedMethod.getRight().getName(), is("method()"));
    }
View Full Code Here

TOP

Related Classes of ch.uzh.ifi.seal.changedistiller.structuredifferencing.StructureDiffNode

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.