Fixed same package removal to not also wipe out subpackages

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5052 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Jamie Doornbos
2008-05-08 19:30:55 +00:00
parent c112a5c982
commit 8eef2df364
2 changed files with 23 additions and 7 deletions
@@ -197,7 +197,7 @@ public class GenServiceTask extends InvocationTask
imports.swapInnerClassesForParents();
// remove imports in our own package
imports.removeAll(mpackage + ".*");
imports.removeSamePackage(mpackage);
VelocityContext ctx = new VelocityContext();
ctx.put("name", name);
@@ -274,7 +274,7 @@ public class GenServiceTask extends InvocationTask
imports.removeArrays();
// remove imports in our own package
imports.removeAll(mpackage + ".*");
imports.removeSamePackage(mpackage);
ctx.put("imports", imports.toList());
@@ -316,7 +316,7 @@ public class GenServiceTask extends InvocationTask
imports.removeGlobals();
// remove imports in our own package
imports.removeAll(mpackage + ".*");
imports.removeSamePackage(mpackage);
ctx.put("imports", imports.toList());
ctx.put("listener", listener);
@@ -364,7 +364,7 @@ public class GenServiceTask extends InvocationTask
imports.translateInnerClasses();
// remove imports in our own package
imports.removeAll(sdesc.spackage + ".*");
imports.removeSamePackage(sdesc.spackage);
ctx.put("imports", imports.toList());
ctx.put("package", sdesc.spackage);
@@ -406,7 +406,7 @@ public class GenServiceTask extends InvocationTask
imports.removeGlobals();
// remove imports in our own package
imports.removeAll(sdesc.spackage + ".*");
imports.removeSamePackage(sdesc.spackage);
ctx.put("imports", imports.toList());
ctx.put("listener", listener);
@@ -468,7 +468,7 @@ public class GenServiceTask extends InvocationTask
imports.swapInnerClassesForParents();
// remove imports in our own package
imports.removeAll(dpackage + ".*");
imports.removeSamePackage(dpackage);
VelocityContext ctx = new VelocityContext();
ctx.put("name", name);
@@ -528,7 +528,7 @@ public class GenServiceTask extends InvocationTask
imports.swapInnerClassesForParents();
// remove imports in our own package
imports.removeAll(mpackage + ".*");
imports.removeSamePackage(mpackage);
VelocityContext ctx = new VelocityContext();
ctx.put("name", name);
@@ -126,6 +126,22 @@ public class ImportSet
return removeAll("[*");
}
/**
* Remove all classes that are in the same package.
* @param pkg package to remove
*/
public void removeSamePackage (String pkg)
{
Iterator<String> i = _imports.iterator();
while (i.hasNext()) {
String name = i.next();
if (name.startsWith(pkg) &&
name.indexOf('.', pkg.length() + 1) == -1) {
i.remove();
}
}
}
/**
* Replaces inner class imports (those with a '$') with an import of the parent class.
*/