Examples of JavaCompilation


Examples of ch.uzh.ifi.seal.changedistiller.ast.java.JavaCompilation

    private final static String TEST_DATA = "src_change/";

    @Test
    public void unchangedMethodBodyShouldNotHaveAnyChanges() throws Exception {
        JavaCompilation compilation = CompilationUtils.compileFile(TEST_DATA + "TestLeft.java");
        Node rootLeft = convertMethodBody("foo", compilation);
        Node rootRight = convertMethodBody("foo", compilation);
        StructureEntityVersion structureEntity = new StructureEntityVersion(JavaEntityType.METHOD, "foo", 0);
        Distiller distiller = getDistiller(structureEntity);
        distiller.extractClassifiedSourceCodeChanges(rootLeft, rootRight);
View Full Code Here

Examples of ch.uzh.ifi.seal.changedistiller.ast.java.JavaCompilation

        assertThat(structureEntity.getSourceCodeChanges().isEmpty(), is(true));
    }

    @Test
    public void changedMethodBodyShouldHaveChanges() throws Exception {
        JavaCompilation compilationLeft = CompilationUtils.compileFile(TEST_DATA + "TestLeft.java");
        JavaCompilation compilationRight = CompilationUtils.compileFile(TEST_DATA + "TestRight.java");
        Node rootLeft = convertMethodBody("foo", compilationLeft);
        Node rootRight = convertMethodBody("foo", compilationRight);
        StructureEntityVersion structureEntity = new StructureEntityVersion(JavaEntityType.METHOD, "foo", 0);
        Distiller distiller = getDistiller(structureEntity);
        distiller.extractClassifiedSourceCodeChanges(rootLeft, rootRight);
View Full Code Here

Examples of ch.uzh.ifi.seal.changedistiller.ast.java.JavaCompilation

    private Node convertMethodDeclaration(String methodName, String sourceCode) {
        return convertMethodDeclaration(methodName, CompilationUtils.compileSource(sourceCode));
    }

    private Node convertFieldDeclaration(String fieldName, String sourceCode) {
        JavaCompilation compilation = CompilationUtils.compileSource(sourceCode);
        FieldDeclaration field = CompilationUtils.findField(compilation.getCompilationUnit(), fieldName);
        Node root = new Node(JavaEntityType.FIELD, fieldName);
        root.setEntity(new SourceCodeEntity(fieldName, JavaEntityType.FIELD, new SourceRange(
                field.declarationSourceStart,
                field.declarationSourceEnd)));
        sDeclarationConverter.initialize(root, compilation.getScanner());
        field.traverse(sDeclarationConverter, (MethodScope) null);
        return root;
    }
View Full Code Here

Examples of ch.uzh.ifi.seal.changedistiller.ast.java.JavaCompilation

        field.traverse(sDeclarationConverter, (MethodScope) null);
        return root;
    }

    private Node convertClassDeclaration(String className, String sourceCode) {
        JavaCompilation compilation = CompilationUtils.compileSource(sourceCode);
        TypeDeclaration type = CompilationUtils.findType(compilation.getCompilationUnit(), className);
        Node root = new Node(JavaEntityType.CLASS, className);
        root.setEntity(new SourceCodeEntity(className, JavaEntityType.CLASS, new SourceRange(
                type.declarationSourceStart,
                type.declarationSourceEnd)));
        sDeclarationConverter.initialize(root, compilation.getScanner());
        type.traverse(sDeclarationConverter, (ClassScope) null);
        return root;
    }
View Full Code Here

Examples of ch.uzh.ifi.seal.changedistiller.ast.java.JavaCompilation

    private final static String TEST_DATA = "src_change/";

    @Test
    public void unchangedMethodDeclarationShouldNotHaveAnyChanges() throws Exception {
        JavaCompilation compilation = CompilationUtils.compileFile(TEST_DATA + "TestLeft.java");
        Node rootLeft = convertMethodDeclaration("foo", compilation);
        Node rootRight = convertMethodDeclaration("foo", compilation);
        StructureEntityVersion structureEntity = new StructureEntityVersion(JavaEntityType.METHOD, "foo", 0);
        Distiller distiller = getDistiller(structureEntity);
        distiller.extractClassifiedSourceCodeChanges(rootLeft, rootRight);
View Full Code Here

Examples of ch.uzh.ifi.seal.changedistiller.ast.java.JavaCompilation

        assertThat(structureEntity.getSourceCodeChanges().isEmpty(), is(true));
    }

    @Test
    public void changedMethodShouldHaveChanges() throws Exception {
        JavaCompilation compilationLeft = CompilationUtils.compileFile(TEST_DATA + "TestLeft.java");
        JavaCompilation compilationRight = CompilationUtils.compileFile(TEST_DATA + "TestRight.java");
        Node rootLeft = convertMethodDeclaration("foo", compilationLeft);
        Node rootRight = convertMethodDeclaration("foo", compilationRight);
        StructureEntityVersion structureEntity = new StructureEntityVersion(JavaEntityType.METHOD, "foo", 0);
        Distiller distiller = getDistiller(structureEntity);
        distiller.extractClassifiedSourceCodeChanges(rootLeft, rootRight);
View Full Code Here

Examples of ch.uzh.ifi.seal.changedistiller.ast.java.JavaCompilation

        assertThat(structureEntity.getSourceCodeChanges().size(), is(2));
    }

    @Test
    public void changedFieldShouldHaveChanges() throws Exception {
      JavaCompilation compilationLeft = CompilationUtils.compileFile(TEST_DATA + "TestLeft.java");
      JavaCompilation compilationRight = CompilationUtils.compileFile(TEST_DATA + "TestRight.java");
      Node rootLeft = convertFieldDeclaration("arrayField", compilationLeft);
      Node rootRight = convertFieldDeclaration("arrayField", compilationRight);
      StructureEntityVersion structureEntity = new StructureEntityVersion(JavaEntityType.FIELD, "arrayField", 0);
      Distiller distiller = getDistiller(structureEntity);
      distiller.extractClassifiedSourceCodeChanges(rootLeft, rootRight);
View Full Code Here

Examples of ch.uzh.ifi.seal.changedistiller.ast.java.JavaCompilation

        assertThat(changedMethod.getLeft().getName(), is("method()"));
        assertThat(changedMethod.getRight().getName(), is("method()"));
    }

    private JavaStructureNode createStructureTree(String source) {
        JavaCompilation compilation = CompilationUtils.compileSource(source);
        CompilationUnitDeclaration cu = compilation.getCompilationUnit();
        JavaStructureNode root = new JavaStructureNode(Type.CU, null, null, cu);
        cu.traverse(new JavaStructureTreeBuilder(root), (CompilationUnitScope) null);
        return root;
    }
View Full Code Here

Examples of ch.uzh.ifi.seal.changedistiller.ast.java.JavaCompilation

        assertThat(methodNode.getName(), is("method(String,int)"));
        assertThat(methodNode.getFullyQualifiedName(), is("org.foo.Clazz.method(String,int)"));
    }

    private void createStructureTree() {
        JavaCompilation compilation = CompilationUtils.compileSource(fSnippet);
        CompilationUnitDeclaration cu = compilation.getCompilationUnit();
        fRoot = new JavaStructureNode(Type.CU, null, null, cu);
        cu.traverse(new JavaStructureTreeBuilder(fRoot), (CompilationUnitScope) null);
    }
View Full Code Here

Examples of ch.uzh.ifi.seal.changedistiller.ast.java.JavaCompilation

    public static JavaCompilation compileSource(String source) {
        CompilerOptions options = getDefaultCompilerOptions();
        Parser parser = createCommentRecorderParser(options);
        ICompilationUnit cu = createCompilationunit(source, "");
        CompilationResult compilationResult = createDefaultCompilationResult(cu, options);
        return new JavaCompilation(parser.parse(cu, compilationResult), parser.scanner);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.