Search in sources :

Example 16 with Detector

use of com.android.tools.klint.detector.api.Detector 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;
}
Also used : ClassContext(com.android.tools.klint.detector.api.ClassContext) XmlContext(com.android.tools.klint.detector.api.XmlContext) JavaContext(com.android.tools.klint.detector.api.JavaContext) ResourceContext(com.android.tools.klint.detector.api.ResourceContext) Context(com.android.tools.klint.detector.api.Context) Project(com.android.tools.klint.detector.api.Project) ResourceXmlDetector(com.android.tools.klint.detector.api.ResourceXmlDetector) Detector(com.android.tools.klint.detector.api.Detector) File(java.io.File) PsiFile(com.intellij.psi.PsiFile) HashSet(java.util.HashSet)

Aggregations

Detector (com.android.tools.klint.detector.api.Detector)16 ResourceXmlDetector (com.android.tools.klint.detector.api.ResourceXmlDetector)11 File (java.io.File)7 XmlContext (com.android.tools.klint.detector.api.XmlContext)6 PsiFile (com.intellij.psi.PsiFile)6 ClassContext (com.android.tools.klint.detector.api.ClassContext)5 Context (com.android.tools.klint.detector.api.Context)5 JavaContext (com.android.tools.klint.detector.api.JavaContext)5 ResourceContext (com.android.tools.klint.detector.api.ResourceContext)5 ArrayList (java.util.ArrayList)5 Scope (com.android.tools.klint.detector.api.Scope)3 List (java.util.List)3 Issue (com.android.tools.klint.detector.api.Issue)2 EnumMap (java.util.EnumMap)2 EnumSet (java.util.EnumSet)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ClassNode (org.jetbrains.org.objectweb.asm.tree.ClassNode)2 InsnList (org.jetbrains.org.objectweb.asm.tree.InsnList)2 NonNull (com.android.annotations.NonNull)1