1   package com.stateofflow.eclipse.metrics.builder.list;
2   
3   import java.io.IOException;
4   
5   import org.eclipse.core.resources.IProject;
6   import org.eclipse.core.resources.IResourceDelta;
7   import org.eclipse.core.runtime.CoreException;
8   import org.eclipse.jdt.core.IJavaProject;
9   import org.eclipse.jdt.core.JavaModelException;
10  
11  import com.stateofflow.eclipse.metrics.properties.exclusions.ExcludedResources;
12  import com.stateofflow.eclipse.metrics.util.ProgressMonitor;
13  
14  public class CompilationUnitListFactory {
15      public CompilationUnitList createFullCompilationUnitList(final IJavaProject project, final ProgressMonitor monitor) throws CoreException, IOException {
16          final CompilationUnitList list = new CompilationUnitList();
17          new FullListBuilder(project, createJavaElementListBuilder(list, project)).build(monitor.newChild(1));
18          return list;
19      }
20  
21      public CompilationUnitList createResourceDeltaCompilationUnitList(final IJavaProject project, final IResourceDelta delta, final ProgressMonitor monitor) throws JavaModelException, IOException {
22          final CompilationUnitList list = new CompilationUnitList();
23          new ResourceDeltaListBuilder(project, createJavaElementListBuilder(list, project)).build(delta, monitor.newChild(1));
24          return list;
25      }
26  
27      private JavaElementListBuilder createJavaElementListBuilder(final CompilationUnitList list, final IJavaProject javaProject) throws IOException {
28          return new JavaElementListBuilder(javaProject, list, getExcludedResources(javaProject.getProject()));
29      }
30  
31      private ExcludedResources getExcludedResources(final IProject project) throws IOException {
32          return new ExcludedResources(project.getProject());
33      }
34  }
35