int numProc = compilationUnits.length;
long time = System.currentTimeMillis();
StringBuffer results = new StringBuffer();
if (compilationUnits != null) {
try {
ASTParser parser = ASTParser.newParser(AST.JLS3);
if (useClosure){
debug("Beginning Type Closure");
numProc = 0;
for (int k = 0; k < compilationUnits.length; k++){
analysis.addToVisitList(compilationUnits[k]);
IJavaProject project = compilationUnits[k].getJavaProject();
analysis.projects.add(project);
}
//un-comment this to add standard library definitions to analysis scope
if (useJavalib){
IJavaProject project = getJavaProject("javalib");
analysis.projects.add(project);
}
if (useJavalibPartial){
IJavaProject project = getJavaProject("javalibPartial");
analysis.projects.add(project);
}
Vector closure = new Vector();
while (analysis.typesLeftToVisit()){
ICompilationUnit c = analysis.nextTypeToVisit();
closure.add(c);
parser.setSource(c);
parser.setResolveBindings(true);
CompilationUnit compilationUnit = null;
try{
compilationUnit = (CompilationUnit) parser.createAST(null);
} catch (Exception e){
throw new RuntimeException("Exception encountered during JDT parse of " + getName(c) + ":\n" + e);
}
String fileName = c.getUnderlyingResource().getName();
TypeClosureVisitor visitor = new TypeClosureVisitor(analysis, compilationUnit, fileName);
compilationUnit.accept(visitor);
}
numProc = closure.size();
debug("Found " + numProc + " classes");
//put transitive closure of compilation units into compilationUnits
compilationUnits = (ICompilationUnit[])closure.toArray(compilationUnits);
}
if (runTest){
for (int k = 0; k < compilationUnits.length; ++k) {
parser.setSource(compilationUnits[k]);
parser.setResolveBindings(true);
CompilationUnit compilationUnit = (CompilationUnit) parser.createAST(null);
String fileName = compilationUnits[k].getUnderlyingResource().getName();
TestVisitor visitor = new TestVisitor(compilationUnit, fileName, analysis);
compilationUnit.accept(visitor);
}
} else {
//first pass creates qtypes for all declarations
//and creates constraints between types and supertypes
debug("Beginning Declaration Visitor");
for (int k = 0; k < compilationUnits.length; ++k) {
parser.setSource(compilationUnits[k]);
parser.setResolveBindings(true);
CompilationUnit compilationUnit = (CompilationUnit) parser.createAST(null);
String fileName = compilationUnits[k].getUnderlyingResource().getName();
debug(" " + fileName);
DeclarationVisitor visitor = new DeclarationVisitor(compilationUnit, fileName, analysis, originalSet.contains(compilationUnits[k]));
compilationUnit.accept(visitor);
}
//second pass creates general constraints between qualifiers
debug("Beginning Constraint Visitor");
for (int k = 0; k < compilationUnits.length; ++k) {
parser.setSource(compilationUnits[k]);
parser.setResolveBindings(true);
CompilationUnit compilationUnit = (CompilationUnit) parser.createAST(null);
String fileName = compilationUnits[k].getUnderlyingResource().getName();
debug(" " + fileName);
ConstraintVisitor visitor = new ConstraintVisitor(compilationUnit, fileName, analysis, originalSet.contains(compilationUnits[k]));
compilationUnit.accept(visitor);
}