aboutsummaryrefslogtreecommitdiffstats
path: root/lint/cli
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-09-10 13:33:34 -0700
committerTor Norbye <tnorbye@google.com>2012-09-10 13:33:34 -0700
commitff3d4a45bbccff920d2632a4331ac9df3a534fef (patch)
tree1062d704c095e1ac5d1fd1206e87f8c9b39b2be5 /lint/cli
parent7ce6049cd1d368d7cd08ac5e22f855f23b2110a7 (diff)
downloadsdk-ff3d4a45bbccff920d2632a4331ac9df3a534fef.zip
sdk-ff3d4a45bbccff920d2632a4331ac9df3a534fef.tar.gz
sdk-ff3d4a45bbccff920d2632a4331ac9df3a534fef.tar.bz2
Don't report unused resources in projects with errors
If a project contains errors in the source code, lint won't be able to parse the source code, and in that case it might draw the wrong conclusions about unused resources. This can also happen if there's an actual bug in the Java parser, which is sometimes the case; see for example http://code.google.com/p/projectlombok/issues/detail?id=415 http://code.google.com/p/projectlombok/issues/detail?id=311 In both cases, when we encounter a failure to parse a Java file, we record the fact that not all Java files were properly processed, and rules, such as the UnusedResource detector, can (and now does) use this to for example skip reporting unused resources in this case since it is operating with incomplete data. Change-Id: I00991c10d05965ce151fb0dd322f32229dcd12cd
Diffstat (limited to 'lint/cli')
-rw-r--r--lint/cli/src/com/android/tools/lint/LombokParser.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/lint/cli/src/com/android/tools/lint/LombokParser.java b/lint/cli/src/com/android/tools/lint/LombokParser.java
index 2c263c6..bc841e2 100644
--- a/lint/cli/src/com/android/tools/lint/LombokParser.java
+++ b/lint/cli/src/com/android/tools/lint/LombokParser.java
@@ -48,6 +48,8 @@ public class LombokParser implements IJavaParser {
// Don't analyze files containing errors
List<ParseProblem> problems = source.getProblems();
if (problems != null && problems.size() > 0) {
+ context.getDriver().setHasParserErrors(true);
+
/* Silently ignore the errors. There are still some bugs in Lombok/Parboiled
* (triggered if you run lint on the AOSP framework directory for example),
* and having these show up as fatal errors when it's really a tool bug
@@ -61,7 +63,7 @@ public class LombokParser implements IJavaParser {
// See http://code.google.com/p/projectlombok/issues/detail?id=313
String message = problem.getMessage();
context.report(
- IssueRegistry.PARSER_ERROR, location,
+ com.android.tools.lint.client.api.IssueRegistry.PARSER_ERROR, location,
message,
null);