Package com.android.tools.lint.detector.api

Examples of com.android.tools.lint.detector.api.Project


        // runner won't know about.
        LintCliClient client = new LintCliClient(mFlags) {
            @NonNull
            @Override
            protected Project createProject(@NonNull File dir, @NonNull File referenceDir) {
                Project project = super.createProject(dir, referenceDir);
                if (project.isGradleProject()) {
                    @SuppressWarnings("SpellCheckingInspection")
                    String message = String.format("\"%1$s\" is a Gradle project. To correctly "
                            + "analyze Gradle projects, you should run \"gradlew :lint\" instead.",
                            project.getName());
                    Location location = Location.create(project.getDir());
                    Context context = new Context(mDriver, project, project, project.getDir());
                    if (context.isEnabled(IssueRegistry.LINT_ERROR)) {
                        report(context,
                               IssueRegistry.LINT_ERROR,
                               project.getConfiguration().getSeverity(IssueRegistry.LINT_ERROR),
                               location, message, null);
                    }
                }
                return project;
            }
View Full Code Here


            canonicalDir = dir.getCanonicalFile();
        } catch (IOException ioe) {
            // pass
        }

        Project project = mDirToProject.get(canonicalDir);
        if (project != null) {
            return project;
        }

        project = createProject(dir, referenceDir);
View Full Code Here

        // runner won't know about.
        LintCliClient client = new LintCliClient(mFlags) {
            @NonNull
            @Override
            protected Project createProject(@NonNull File dir, @NonNull File referenceDir) {
                Project project = super.createProject(dir, referenceDir);
                if (project.isGradleProject()) {
                    @SuppressWarnings("SpellCheckingInspection")
                    String message = String.format("\"%1$s\" is a Gradle project. To correctly "
                            + "analyze Gradle projects, you should run \"gradlew :lint\" instead.",
                            project.getName());
                    Location location = Location.create(project.getDir());
                    Context context = new Context(mDriver, project, project, project.getDir());
                    if (context.isEnabled(IssueRegistry.LINT_ERROR)) {
                        report(context,
                               IssueRegistry.LINT_ERROR,
                               project.getConfiguration().getSeverity(IssueRegistry.LINT_ERROR),
                               location, message, null);
                    }
                }
                return project;
            }
View Full Code Here

            }
        }

        for (Map.Entry<File, Project> entry : fileToProject.entrySet()) {
            File file = entry.getKey();
            Project project = entry.getValue();
            if (!file.equals(project.getDir())) {
                if (file.isDirectory()) {
                    try {
                        File dir = file.getCanonicalFile();
                        if (dir.equals(project.getDir())) {
                            continue;
                        }
                    } catch (IOException ioe) {
                        // pass
                    }
                }

                project.addFile(file);
            }
        }

        // Partition the projects up such that we only return projects that aren't
        // included by other projects (e.g. because they are library projects)

        Collection<Project> allProjects = fileToProject.values();
        Set<Project> roots = new HashSet<Project>(allProjects);
        for (Project project : allProjects) {
            roots.removeAll(project.getAllLibraries());
        }

        // Report issues for all projects that are explicitly referenced. We need to
        // do this here, since the project initialization will mark all library
        // projects as no-report projects by default.
        for (Project project : allProjects) {
            // Report issues for all projects explicitly listed or found via a directory
            // traversal -- including library projects.
            project.setReportIssues(true);
        }

        if (LintUtils.assertionsEnabled()) {
            // Make sure that all the project directories are unique. This ensures
            // that we didn't accidentally end up with different project instances
            // for a library project discovered as a directory as well as one
            // initialized from the library project dependency list
            IdentityHashMap<Project, Project> projects =
                    new IdentityHashMap<Project, Project>();
            for (Project project : roots) {
                projects.put(project, project);
                for (Project library : project.getAllLibraries()) {
                    projects.put(library, library);
                }
            }
            Set<File> dirs = new HashSet<File>();
            for (Project project : projects.keySet()) {
                assert !dirs.contains(project.getDir());
                dirs.add(project.getDir());
            }
        }

        return roots;
    }
View Full Code Here

            canonicalDir = dir.getCanonicalFile();
        } catch (IOException ioe) {
            // pass
        }

        Project project = mDirToProject.get(canonicalDir);
        if (project != null) {
            return project;
        }

        project = createProject(dir, referenceDir);
View Full Code Here

        // runner won't know about.
        LintCliClient client = new LintCliClient(mFlags) {
            @NonNull
            @Override
            protected Project createProject(@NonNull File dir, @NonNull File referenceDir) {
                Project project = super.createProject(dir, referenceDir);
                if (project.isGradleProject()) {
                    @SuppressWarnings("SpellCheckingInspection")
                    String message = String.format("\"%1$s\" is a Gradle project. To correctly "
                            + "analyze Gradle projects, you should run \"gradlew :lint\" instead.",
                            project.getName());
                    Location location = Location.create(project.getDir());
                    Context context = new Context(mDriver, project, project, project.getDir());
                    if (context.isEnabled(IssueRegistry.LINT_ERROR)) {
                        report(context,
                               IssueRegistry.LINT_ERROR,
                               project.getConfiguration().getSeverity(IssueRegistry.LINT_ERROR),
                               location, message, null);
                    }
                }
                return project;
            }

            @Override
            public Configuration getConfiguration(@NonNull Project project) {
                if (project.isGradleProject()) {
                    // Don't report any issues when analyzing a Gradle project from the
                    // non-Gradle runner; they are likely to be false, and will hide the real
                    // problem reported above
                   return new CliConfiguration(getConfiguration(), project, true) {
                       @NonNull
View Full Code Here

TOP

Related Classes of com.android.tools.lint.detector.api.Project

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.