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:
Tom Copeland
2002-07-13 01:18:48 +00:00
parent 3667089c97
commit e0b3946ee8
2 changed files with 19 additions and 1 deletions

View File

@ -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();

View File

@ -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());