Search in sources :

Example 16 with DefaultJavaPrettyPrinter

use of spoon.reflect.visitor.DefaultJavaPrettyPrinter in project spoon by INRIA.

the class QualifiedThisRefTest method testQualifiedThisRef.

@Test
public void testQualifiedThisRef() {
    DefaultJavaPrettyPrinter printer = new DefaultJavaPrettyPrinter(factory.getEnvironment());
    CtType<?> ctClass = factory.Type().get(QualifiedThisRef.class);
    Collection<CtImport> imports = printer.computeImports(ctClass);
    final List<CtType<?>> ctTypes = new ArrayList<>();
    ctTypes.add(ctClass);
    printer.getElementPrinterHelper().writeHeader(ctTypes, imports);
    printer.scan(ctClass);
    Assert.assertTrue(printer.getResult().contains("Object o = this"));
    Assert.assertTrue(printer.getResult().contains("Object o2 = QualifiedThisRef.this"));
}
Also used : CtImport(spoon.reflect.declaration.CtImport) CtType(spoon.reflect.declaration.CtType) ArrayList(java.util.ArrayList) DefaultJavaPrettyPrinter(spoon.reflect.visitor.DefaultJavaPrettyPrinter) Test(org.junit.Test)

Aggregations

DefaultJavaPrettyPrinter (spoon.reflect.visitor.DefaultJavaPrettyPrinter)16 Test (org.junit.Test)11 Launcher (spoon.Launcher)6 Environment (spoon.compiler.Environment)4 CtClass (spoon.reflect.declaration.CtClass)3 CtType (spoon.reflect.declaration.CtType)3 PrettyPrinter (spoon.reflect.visitor.PrettyPrinter)3 NamedElementFilter (spoon.reflect.visitor.filter.NamedElementFilter)3 ArrayList (java.util.ArrayList)2 CtImport (spoon.reflect.declaration.CtImport)2 CtPackage (spoon.reflect.declaration.CtPackage)2 Factory (spoon.reflect.factory.Factory)2 DefaultTokenWriter (spoon.reflect.visitor.DefaultTokenWriter)2 ElementPrinterHelper (spoon.reflect.visitor.ElementPrinterHelper)2 PrinterHelper (spoon.reflect.visitor.PrinterHelper)2 TokenWriter (spoon.reflect.visitor.TokenWriter)2 JavaOutputProcessor (spoon.support.JavaOutputProcessor)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 INameEnvironment (org.eclipse.jdt.internal.compiler.env.INameEnvironment)1