package org.aspectj.ajdt.internal.core.builder;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import org.aspectj.weaver.bcel.UnwovenClassFile;
import org.eclipse.jdt.core.compiler.CharOperation;
public class StatefulNameEnvironment implements INameEnvironment {
Map classesFromName;
+ Set packageNames;
INameEnvironment baseEnvironment;
public StatefulNameEnvironment(INameEnvironment baseEnvironment, Map classesFromName) {
this.classesFromName = classesFromName;
this.baseEnvironment = baseEnvironment;
+
+ packageNames = new HashSet();
+ for (Iterator i = classesFromName.keySet().iterator(); i.hasNext(); ) {
+ String className = (String)i.next();
+ addAllPackageNames(className);
+ }
+// System.err.println(packageNames);
+ }
+
+ private void addAllPackageNames(String className) {
+ int dot = className.indexOf('.');
+ while (dot != -1) {
+ packageNames.add(className.substring(0, dot));
+ dot = className.indexOf('.', dot+1);
+ }
}
public void cleanup() {
private NameEnvironmentAnswer findType(String name) {
UnwovenClassFile cf = (UnwovenClassFile)classesFromName.get(name);
+ //System.err.println("find: " + name + " found: " + cf);
+
if (cf == null) return null;
try {
}
public boolean isPackage(char[][] parentPackageName, char[] packageName) {
- //!!! need to use cache here too
- return baseEnvironment.isPackage(parentPackageName, packageName);
+ if (baseEnvironment.isPackage(parentPackageName, packageName)) return true;
+ String fullPackageName = new String(CharOperation.concatWith(parentPackageName, packageName, '.'));
+ return packageNames.contains(fullPackageName);
}
}