Example usage for org.eclipse.jdt.internal.core.dom.rewrite ASTRewriteFlattener getResult

List of usage examples for org.eclipse.jdt.internal.core.dom.rewrite ASTRewriteFlattener getResult

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.dom.rewrite ASTRewriteFlattener getResult.

Prototype

public String getResult() 

Source Link

Document

Returns the string accumulated in the visit.

Usage

From source file:org.eclipse.objectteams.otdt.ui.tests.dom.converter.GuardPredicateTest.java

License:Open Source License

public void testPredicateInRole() {
    initAST(_simpleTeam, false, CompilerOptions.VERSION_1_5);

    TypeDeclaration[] types = _typeDecl.getTypes();
    RoleTypeDeclaration role1 = (RoleTypeDeclaration) types[0];
    GuardPredicateDeclaration guard = role1.getGuardPredicate();
    assertFalse("guard predicate is non-null", guard == null);
    assertTrue("guard is base guard", guard.isBase());

    ASTRewriteFlattener _rewriteFlattener = new ASTRewriteFlattener(new RewriteEventStore());
    guard.accept(_rewriteFlattener);/*from   w w w  . java  2  s . c  om*/

    String actual = _rewriteFlattener.getResult();
    String expected = "base when (Team2.this.hasRole(base,R.class))"; //$NON-NLS-1$
    assertEquals("Wrong guard Code", expected, actual);
}

From source file:org.eclipse.objectteams.otdt.ui.tests.dom.converter.GuardPredicateTest.java

License:Open Source License

@SuppressWarnings({ "restriction" })
public void testPredicateRegression() throws JavaModelException {
    initAST(getCompilationUnit(getTestProjectDir(), "src", "predicates.teampkg", "TeamBug.java"), true,
            CompilerOptions.VERSION_1_6);

    TypeDeclaration[] types = _typeDecl.getTypes();
    RoleTypeDeclaration role1 = (RoleTypeDeclaration) types[0];
    CallinMappingDeclaration callinDecl = role1.getCallIns()[0];
    GuardPredicateDeclaration guard = callinDecl.getGuardPredicate();
    assertFalse("guard predicate is non-null", guard == null);
    assertFalse("guard is not base guard", guard.isBase());

    ASTRewriteFlattener _rewriteFlattener = new ASTRewriteFlattener(new RewriteEventStore());
    guard.accept(_rewriteFlattener);//from  www.j  a  v  a  2s .co m

    String actual = _rewriteFlattener.getResult();
    String expected = "when (true)"; //$NON-NLS-1$
    assertEquals("Wrong guard Code", expected, actual);
}

From source file:org.eclipse.objectteams.otdt.ui.tests.dom.converter.PrecedenceDeclarationTest.java

License:Open Source License

public void testPrecedenceFlattening() {
    ASTRewriteFlattener _rewriteFlattener = new ASTRewriteFlattener(new RewriteEventStore());
    _cu.accept(_rewriteFlattener);/*from ww w. j  av a 2  s  .com*/

    String actual = _rewriteFlattener.getResult();
    String expected = "package precedences.teampkg;" + "import precedences.basepkg.MyClass;"
            + "public team class Team1 {" + "public class Role1 playedBy MyClass {"
            + "roleMethod0 <- before baseMethod1;" + "callin1: roleMethod1 <- before baseMethod2;"
            + "callin2: roleMethod2 <- before baseMethod2,baseMethod4,baseMethod5;"
            + "callin3: roleMethod3 <- before baseMethod0,baseMethod4;"
            + "callinA2: roleMethod2 <- after baseMethod2;" + "callinA3: roleMethod3 <- after baseMethod3;"
            + "public void roleMethod0(){}" + "public void roleMethod1(){}" + "public void roleMethod2(){}"
            + "public void roleMethod3(){}" + "precedence callin1, callin2;" + "precedence callin3, callin2;"
            + "precedence after callinA3, callinA2;" + "}" + "public class Role2 {}"
            + "precedence Role1.callin2, Role1.callin1;" + "precedence Role2, Role1;" + "}";

    assertEquals("Wrong CU-Code", expected, actual);
}