forked from phoedos/pmd
starting to work on type resolution
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@342 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -61,6 +61,13 @@ public class TypeSetTest extends TestCase {
|
||||
public void testPrimitiveTypeResolver() throws Throwable {
|
||||
TypeSet.Resolver r = new TypeSet.PrimitiveTypeResolver();
|
||||
assertEquals(int.class, r.resolve("int"));
|
||||
assertEquals(byte.class, r.resolve("byte"));
|
||||
assertEquals(long.class, r.resolve("long"));
|
||||
}
|
||||
|
||||
public void testVoidTypeResolver() throws Throwable {
|
||||
TypeSet.Resolver r = new TypeSet.VoidResolver();
|
||||
assertEquals(void.class, r.resolve("void"));
|
||||
}
|
||||
public void testExplicitImportResolver() throws Throwable {
|
||||
Set imports = new HashSet();
|
||||
|
@ -93,7 +93,16 @@ public class TypeSet {
|
||||
}
|
||||
}
|
||||
|
||||
private String pkg;
|
||||
public static class VoidResolver implements Resolver {
|
||||
public Class resolve(String name) throws ClassNotFoundException {
|
||||
if (name.equals("void")) {
|
||||
return void.class;
|
||||
}
|
||||
throw new ClassNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
private String pkg;
|
||||
private Set imports = new HashSet();
|
||||
private List resolvers = new ArrayList();
|
||||
|
||||
@ -129,6 +138,8 @@ public class TypeSet {
|
||||
}
|
||||
|
||||
private void buildResolvers() {
|
||||
resolvers.add(new PrimitiveTypeResolver());
|
||||
resolvers.add(new VoidResolver());
|
||||
resolvers.add(new ExplicitImportResolver(imports));
|
||||
resolvers.add(new CurrentPackageResolver(pkg));
|
||||
resolvers.add(new ImplicitImportResolver());
|
||||
|
Reference in New Issue
Block a user