Search in sources :

Example 1 with MinimalImportScanner

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

the class ImportScannerTest method testTargetTypeNull.

@Test
public void testTargetTypeNull() throws Exception {
    Launcher spoon = new Launcher();
    Factory factory = spoon.createFactory();
    CtFieldReference fieldRef = factory.createFieldReference();
    fieldRef.setStatic(true);
    ImportScanner importScanner = new MinimalImportScanner();
    importScanner.computeImports(fieldRef);
    Collection<CtImport> imports = importScanner.getAllImports();
    assertEquals(0, imports.size());
}
Also used : CtImport(spoon.reflect.declaration.CtImport) Launcher(spoon.Launcher) Factory(spoon.reflect.factory.Factory) CtFieldReference(spoon.reflect.reference.CtFieldReference) MinimalImportScanner(spoon.reflect.visitor.MinimalImportScanner) ImportScanner(spoon.reflect.visitor.ImportScanner) MinimalImportScanner(spoon.reflect.visitor.MinimalImportScanner) Test(org.junit.Test)

Example 2 with MinimalImportScanner

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

the class ImportScannerTest method testComputeMinimalImportsInClass.

@Test
public void testComputeMinimalImportsInClass() throws Exception {
    String packageName = "spoon.test.testclasses";
    String className = "SampleImportClass";
    String qualifiedName = packageName + "." + className;
    Factory aFactory = build(packageName, className).getFactory();
    CtType<?> theClass = aFactory.Type().get(qualifiedName);
    ImportScanner importContext = new MinimalImportScanner();
    importContext.computeImports(theClass);
    Collection<CtImport> imports = importContext.getAllImports();
    assertTrue(imports.isEmpty());
}
Also used : CtImport(spoon.reflect.declaration.CtImport) Factory(spoon.reflect.factory.Factory) MinimalImportScanner(spoon.reflect.visitor.MinimalImportScanner) ImportScanner(spoon.reflect.visitor.ImportScanner) MinimalImportScanner(spoon.reflect.visitor.MinimalImportScanner) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 CtImport (spoon.reflect.declaration.CtImport)2 Factory (spoon.reflect.factory.Factory)2 ImportScanner (spoon.reflect.visitor.ImportScanner)2 MinimalImportScanner (spoon.reflect.visitor.MinimalImportScanner)2 Launcher (spoon.Launcher)1 CtFieldReference (spoon.reflect.reference.CtFieldReference)1