use of com.android.tools.klint.detector.api.Project in project kotlin by JetBrains.
the class LintDriver method registerCustomDetectors.
private void registerCustomDetectors(Collection<Project> projects) {
// Look at the various projects, and if any of them provide a custom
// lint jar, "add" them (this will replace the issue registry with
// a CompositeIssueRegistry containing the original issue registry
// plus JarFileIssueRegistry instances for each lint jar
Set<File> jarFiles = Sets.newHashSet();
for (Project project : projects) {
jarFiles.addAll(mClient.findRuleJars(project));
for (Project library : project.getAllLibraries()) {
jarFiles.addAll(mClient.findRuleJars(library));
}
}
jarFiles.addAll(mClient.findGlobalRuleJars());
if (!jarFiles.isEmpty()) {
List<IssueRegistry> registries = Lists.newArrayListWithExpectedSize(jarFiles.size());
registries.add(mRegistry);
for (File jarFile : jarFiles) {
try {
JarFileIssueRegistry registry = JarFileIssueRegistry.get(mClient, jarFile);
if (registry.hasLegacyDetectors()) {
mRunCompatChecks = true;
}
if (myCustomIssues == null) {
myCustomIssues = Sets.newHashSet();
}
myCustomIssues.addAll(registry.getIssues());
registries.add(registry);
} catch (Throwable e) {
mClient.log(e, "Could not load custom rule jar file %1$s", jarFile);
}
}
if (registries.size() > 1) {
// the first item is mRegistry itself
mRegistry = new CompositeIssueRegistry(registries);
}
}
}
use of com.android.tools.klint.detector.api.Project in project kotlin by JetBrains.
the class LintDriver method checkProject.
private void checkProject(@NonNull Project project, @NonNull Project main) {
File projectDir = project.getDir();
Context projectContext = new Context(this, project, null, projectDir);
fireEvent(EventType.SCANNING_PROJECT, projectContext);
List<Project> allLibraries = project.getAllLibraries();
Set<Project> allProjects = new HashSet<Project>(allLibraries.size() + 1);
allProjects.add(project);
allProjects.addAll(allLibraries);
mCurrentProjects = allProjects.toArray(new Project[allProjects.size()]);
mCurrentProject = project;
for (Detector check : mApplicableDetectors) {
check.beforeCheckProject(projectContext);
if (mCanceled) {
return;
}
}
assert mCurrentProject == project;
runFileDetectors(project, main);
if (!Scope.checkSingleFile(mScope)) {
List<Project> libraries = project.getAllLibraries();
for (Project library : libraries) {
Context libraryContext = new Context(this, library, project, projectDir);
fireEvent(EventType.SCANNING_LIBRARY_PROJECT, libraryContext);
mCurrentProject = library;
for (Detector check : mApplicableDetectors) {
check.beforeCheckLibraryProject(libraryContext);
if (mCanceled) {
return;
}
}
assert mCurrentProject == library;
runFileDetectors(library, main);
if (mCanceled) {
return;
}
assert mCurrentProject == library;
for (Detector check : mApplicableDetectors) {
check.afterCheckLibraryProject(libraryContext);
if (mCanceled) {
return;
}
}
}
}
mCurrentProject = project;
for (Detector check : mApplicableDetectors) {
check.afterCheckProject(projectContext);
if (mCanceled) {
return;
}
}
if (mCanceled) {
mClient.report(projectContext, // Must provide an issue since API guarantees that the issue parameter
IssueRegistry.CANCELLED, Severity.INFORMATIONAL, Location.create(project.getDir()), "Lint canceled by user", TextFormat.RAW);
}
mCurrentProjects = null;
}
Aggregations