diff options
author | Tor Norbye <tnorbye@google.com> | 2012-11-05 16:21:56 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-11-05 16:21:56 -0800 |
commit | 0a237be0dafcb6440fab90d71273acefddbcb1fc (patch) | |
tree | 0838b7a6ffa85d4151a171d66252e4a1b2fff17f /lint/libs/lint_api | |
parent | ad66ec63987fcab69b98bc1e6f816dd18fbbb0cb (diff) | |
download | sdk-0a237be0dafcb6440fab90d71273acefddbcb1fc.zip sdk-0a237be0dafcb6440fab90d71273acefddbcb1fc.tar.gz sdk-0a237be0dafcb6440fab90d71273acefddbcb1fc.tar.bz2 |
39153: lint shows project folder instead of project name
Change-Id: I415c42e19573bf733de672625a1200e62204ec77
Diffstat (limited to 'lint/libs/lint_api')
3 files changed, 40 insertions, 4 deletions
diff --git a/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java b/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java index 2a68ddf..461e64f 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintClient.java @@ -568,12 +568,33 @@ public abstract class LintClient { return project; } - - project = Project.create(this, dir, referenceDir); + project = createProject(dir, referenceDir); mDirToProject.put(canonicalDir, project); return project; } + /** + * Create a project for the given directory + * @param dir the root directory of the project + * @param referenceDir See {@link Project#getReferenceDir()}. + * @return a new project + */ + @NonNull + protected Project createProject(@NonNull File dir, @NonNull File referenceDir) { + return Project.create(this, dir, referenceDir); + } + + /** + * Returns the name of the given project + * + * @param project the project to look up + * @return the name of the project + */ + @NonNull + public String getProjectName(@NonNull Project project) { + return project.getDir().getName(); + } + private IAndroidTarget[] mTargets; /** diff --git a/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintDriver.java b/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintDriver.java index fc9487d..463562b 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintDriver.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/client/api/LintDriver.java @@ -1763,6 +1763,12 @@ public class LintDriver { @NonNull String superClassName) { return mDelegate.isSubclassOf(project, name, superClassName); } + + @Override + @NonNull + public String getProjectName(@NonNull Project project) { + return mDelegate.getProjectName(project); + } } /** diff --git a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Project.java b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Project.java index eb41807..eb04231 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Project.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Project.java @@ -617,14 +617,23 @@ public class Project { @NonNull public String getName() { if (mName == null) { - // TODO: Consider reading the name from .project (if it's an Eclipse project) - mName = mDir.getName(); + mName = mClient.getProjectName(this); } return mName; } /** + * Sets the name of the project + * + * @param name the name of the project, never null + */ + public void setName(@NonNull String name) { + assert !name.isEmpty(); + mName = name; + } + + /** * Sets whether lint should report issues in this project. See * {@link #getReportIssues()} for a full description of what that means. * |