aboutsummaryrefslogtreecommitdiffstats
path: root/lint/libs/lint_api
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-07-17 15:26:25 -0700
committerTor Norbye <tnorbye@google.com>2012-07-23 15:19:58 -0700
commit4ce0801d79e7cae499a87a3a4390dde6c88098d4 (patch)
treeb525c290a4eb9d77167d6e22b816fc56df198539 /lint/libs/lint_api
parent099c517c0d151cfb096c829e95737aa81b81ee1c (diff)
downloadsdk-4ce0801d79e7cae499a87a3a4390dde6c88098d4.zip
sdk-4ce0801d79e7cae499a87a3a4390dde6c88098d4.tar.gz
sdk-4ce0801d79e7cae499a87a3a4390dde6c88098d4.tar.bz2
35049: @SuppressLint("NewApi") doesn't work on local variables
The @SuppressLint annotation can deliberately be placed on not only classes and methods but on parameters and local variables too. For AST-based (Java source-based) lint checks, this works fine. However, some lint checks, such as the API Check, is based on analyzing the bytecode. Annotations placed on local variables and parameters do not make it into the .class file, so these annotations do not work to suppress errors when placed on local variables (or parameters). The @TargetApi annotation applies only to the bytecode based API check, so its metadata only allows the annotation to be placed on methods and classes and constructors. However, the @SuppressLint annotation needs to continue to be available for the AST-based checks. This CL adds a new lint check, a "meta" check, which actually looks for invalid @SuppressLint annotations, and warns about these. With the new lint-on-save behavior, this means you instantly get feedback if you attempt to suppress an annotation in the wrong place. (Note that the quickfix for adding annotations has always enforced this and placed annotations out at the method level, but as shown in issue 35049, developers place them there deliberately themselves.) This CL also fixes an unrelated problem (shown in issue 34198) that the add suppress annotation code could sometimes add multiple versions of the same id into the annotation. Change-Id: I5bc61c6315edfcfc20103d1e580e389dd8e6a09b
Diffstat (limited to 'lint/libs/lint_api')
-rw-r--r--lint/libs/lint_api/src/com/android/tools/lint/client/api/LintDriver.java10
1 files changed, 10 insertions, 0 deletions
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 b4e4a7d..08a5c19 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
@@ -175,6 +175,16 @@ public class LintDriver {
}
/**
+ * Returns the current {@link IssueRegistry}.
+ *
+ * @return the current {@link IssueRegistry}
+ */
+ @NonNull
+ public IssueRegistry getRegistry() {
+ return mRegistry;
+ }
+
+ /**
* Returns the project containing a given file, or null if not found. This searches
* only among the currently checked project and its library projects, not among all
* possible projects being scanned sequentially.