diff options
author | Tor Norbye <tnorbye@google.com> | 2012-02-06 14:32:44 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-02-06 18:01:07 -0800 |
commit | 69067f399231dc28f4ff0aa02b60153ffd2d5831 (patch) | |
tree | fcb26e8f844d2819a6819a4e1741ea5f6e111533 /lint/cli | |
parent | 858b17c8539f9d9cb7202e6fa7e87bda35ca021c (diff) | |
download | sdk-69067f399231dc28f4ff0aa02b60153ffd2d5831.zip sdk-69067f399231dc28f4ff0aa02b60153ffd2d5831.tar.gz sdk-69067f399231dc28f4ff0aa02b60153ffd2d5831.tar.bz2 |
Add support for suppressing lint via XML attributes
This changeset adds support for suppressing in XML files:
(1) Lint will ignore errors found in attributes and elements if the
element (or any surrounding parent elements) specifies a
tools:ignore="id-list" attribute where the id-list matches the id
of the reported issue (or "all"). The "tools" prefix can be any
prefix bound to the namespace "http://schemas.android.com/tools"
(2) There's a new quickfix shown for XML lint warnings which offers to
add a lint suppress attribute for a given lint warning (setting
the id to the id of the warning, and adding the tools namespace
binding if necessary).
(3) The XML formatter now handles namespaces a bit better: after the
preferred attributes (id, name, style, layout params, etc) have
been handled, attributes are sorted by namespace prefix before
they are sorted by local name -- which effectively will sort any
new tools:ignore attributes to the end.
Change-Id: Id7474cde5665d9bd29bdd4e0d0cc89ed4d422aea
Diffstat (limited to 'lint/cli')
-rw-r--r-- | lint/cli/src/com/android/tools/lint/Main.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lint/cli/src/com/android/tools/lint/Main.java b/lint/cli/src/com/android/tools/lint/Main.java index ae1aa36..d319648 100644 --- a/lint/cli/src/com/android/tools/lint/Main.java +++ b/lint/cli/src/com/android/tools/lint/Main.java @@ -501,10 +501,11 @@ public class Main extends LintClient { "Lint errors can be suppressed in a variety of ways:\n" + "\n" + "1. With a @SuppressLint annotation in the Java code\n" + - "2. With a lint.xml configuration file in the project\n" + - "3. With a lint.xml configuration file passed to lint " + + "2. With a tools:ignore attribute in the XML file\n" + + "3. With a lint.xml configuration file in the project\n" + + "4. With a lint.xml configuration file passed to lint " + "via the " + ARG_CONFIG + " flag\n" + - "4. With the " + ARG_IGNORE + " flag passed to lint.\n" + + "5. With the " + ARG_IGNORE + " flag passed to lint.\n" + "\n" + "To suppress a lint warning with an annotation, add " + "a @SuppressLint(\"id\") annotation on the class, method " + @@ -514,6 +515,14 @@ public class Main extends LintClient { "\"UnusedIds\"}, or it can be \"all\" to suppress all lint " + "warnings in the given scope.\n" + "\n" + + "To suppress a lint warning in an XML file, add a " + + "tools:ignore=\"id\" attribute on the element containing " + + "the error, or one of its surrounding elements. You also " + + "need to define the namespace for the tools prefix on the " + + "root element in your document, next to the xmlns:android " + + "declaration:\n" + + "* xmlns:tools=\"http://schemas.android.com/tools\"\n" + + "\n" + "To suppress lint warnings with a configuration XML file, " + "create a file named lint.xml and place it at the root " + "directory of the project in which it applies. (If you " + |