aboutsummaryrefslogtreecommitdiffstats
path: root/lint/libs
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-11-02 15:07:23 -0700
committerTor Norbye <tnorbye@google.com>2012-11-02 15:07:23 -0700
commit70fe541e71472cfcee236d40d2cce8a9b3f23b79 (patch)
tree1e271076753cc7c44070dce71a71358c224adba8 /lint/libs
parent47366b5973be3cf146815c4560a54ca7ef681a9f (diff)
downloadsdk-70fe541e71472cfcee236d40d2cce8a9b3f23b79.zip
sdk-70fe541e71472cfcee236d40d2cce8a9b3f23b79.tar.gz
sdk-70fe541e71472cfcee236d40d2cce8a9b3f23b79.tar.bz2
Don't warn about missing classes before a build
The missing class detector warns about classes declared in the manifest, but not found on disk. In order not to warn before you've built the project, it only does this if it has seen at least one class. However, it turned out that it would also look at library jars, such that a not-built project using the support library would be considered to have classes, and would therefore flag newly added activities. Change-Id: Iaf01fe3e3626bdb31d535c00aea584793d6f72b9
Diffstat (limited to 'lint/libs')
-rw-r--r--lint/libs/lint_checks/src/com/android/tools/lint/checks/MissingClassDetector.java4
-rw-r--r--lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/MissingClassDetectorTest.java13
2 files changed, 16 insertions, 1 deletions
diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/MissingClassDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/MissingClassDetector.java
index 336f820..891a8af 100644
--- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/MissingClassDetector.java
+++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/MissingClassDetector.java
@@ -245,7 +245,9 @@ public class MissingClassDetector extends LayoutDetector implements ClassScanner
@Override
public void checkClass(@NonNull ClassContext context, @NonNull ClassNode classNode) {
- mHaveClasses = true;
+ if (!context.isFromClassLibrary()) {
+ mHaveClasses = true;
+ }
String curr = classNode.name;
if (mReferencedClasses != null && mReferencedClasses.containsKey(curr)) {
mReferencedClasses.remove(curr);
diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/MissingClassDetectorTest.java b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/MissingClassDetectorTest.java
index 3c6e8cb..4edf345 100644
--- a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/MissingClassDetectorTest.java
+++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/MissingClassDetectorTest.java
@@ -254,4 +254,17 @@ public class MissingClassDetectorTest extends AbstractCheckTest {
"registration/Bar.java.txt=>src/test/pkg/Foo/Bar.java"
));
}
+
+ public void testNoClassesWithLibraries() throws Exception {
+ mScopes = null;
+ assertEquals(
+ "No warnings.",
+
+ lintProject(
+ "bytecode/AndroidManifestWrongRegs.xml=>AndroidManifest.xml",
+ "bytecode/.classpath=>.classpath",
+ "bytecode/GetterTest.jar.data=>libs/foo.jar"
+ ));
+ }
+
}