private void runFileDetectors(Project project, File projectDir) {
// Look up manifest information
File manifestFile = new File(project.getDir(), ANDROID_MANIFEST_XML);
if (manifestFile.exists()) {
Context context = new Context(mClient, project, manifestFile, mScope);
context.location = new Location(manifestFile, null, null);
IDomParser parser = mClient.getParser();
context.document = parser.parse(context);
if (context.document != null) {
project.readManifest(context.document);
if (mScope.contains(Scope.MANIFEST)) {
List<Detector> detectors = mScopeDetectors.get(Scope.MANIFEST);
if (detectors != null) {
XmlVisitor v = new XmlVisitor(parser, detectors);
fireEvent(EventType.SCANNING_FILE, context);
v.visitFile(context, manifestFile);
}
}
}
}
// Process both Scope.RESOURCE_FILE and Scope.ALL_RESOURCE_FILES detectors together
// in a single pass through the resource directories.
if (mScope.contains(Scope.ALL_RESOURCE_FILES) || mScope.contains(Scope.RESOURCE_FILE)) {
List<Detector> checks = union(mScopeDetectors.get(Scope.RESOURCE_FILE),
mScopeDetectors.get(Scope.ALL_RESOURCE_FILES));
if (checks.size() > 0) {
List<ResourceXmlDetector> xmlDetectors =
new ArrayList<ResourceXmlDetector>(checks.size());
for (Detector detector : checks) {
if (detector instanceof ResourceXmlDetector) {
xmlDetectors.add((ResourceXmlDetector) detector);
}
}
if (xmlDetectors.size() > 0) {
if (project.getSubset() != null) {
checkIndividualResources(project, xmlDetectors, project.getSubset());
} else {
File res = new File(projectDir, RES_FOLDER_NAME);
if (res.exists() && xmlDetectors.size() > 0) {
checkResFolder(project, res, xmlDetectors);
}
}
}
}
}
if (mCanceled) {
return;
}
if (mScope.contains(Scope.JAVA_FILE) || mScope.contains(Scope.ALL_JAVA_FILES)) {
List<Detector> checks = union(mScopeDetectors.get(Scope.JAVA_FILE),
mScopeDetectors.get(Scope.ALL_JAVA_FILES));
if (checks.size() > 0) {
List<File> sourceFolders = project.getJavaSourceFolders();
checkJava(project, sourceFolders, checks);
}
}
if (mCanceled) {
return;
}
if (mScope.contains(Scope.CLASS_FILE)) {
List<Detector> detectors = mScopeDetectors.get(Scope.CLASS_FILE);
if (detectors != null) {
List<File> binFolders = project.getJavaClassFolders();
checkClasses(project, binFolders, detectors);
}
}
if (mCanceled) {
return;
}
if (mScope.contains(Scope.PROGUARD)) {
List<Detector> detectors = mScopeDetectors.get(Scope.PROGUARD);
if (detectors != null) {
File file = new File(project.getDir(), PROGUARD_CFG);
if (file.exists()) {
Context context = new Context(mClient, project, file, mScope);
fireEvent(EventType.SCANNING_FILE, context);
context.location = new Location(file, null, null);
for (Detector detector : detectors) {
if (detector.appliesTo(context, file)) {
detector.beforeCheckFile(context);