diff options
author | Tor Norbye <tnorbye@google.com> | 2012-06-18 22:33:39 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-06-22 14:42:30 -0700 |
commit | 5e290ab6060c3204be3a3eb6084db6f92c88adee (patch) | |
tree | 6edefecd33f674e453b070b38bb90813588f44e7 /lint/libs/lint_api | |
parent | 960433ddfada5e246feccdc167a0af183f30bb0a (diff) | |
download | sdk-5e290ab6060c3204be3a3eb6084db6f92c88adee.zip sdk-5e290ab6060c3204be3a3eb6084db6f92c88adee.tar.gz sdk-5e290ab6060c3204be3a3eb6084db6f92c88adee.tar.bz2 |
Add typo detector
This changeset adds a new typo detector. There
are also some lint infrastructure fixes to better
handle positions within text nodes, and to allow
Eclipse lint quickfixes to supply multiple fixes
for a single issue (such as multiple misspelling
alternative replacements.)
Change-Id: Ie26f0bafc571e02ae09ff27a7f4b221fe0c2ea5b
Diffstat (limited to 'lint/libs/lint_api')
-rw-r--r-- | lint/libs/lint_api/src/com/android/tools/lint/client/api/IDomParser.java | 14 | ||||
-rw-r--r-- | lint/libs/lint_api/src/com/android/tools/lint/detector/api/XmlContext.java | 19 |
2 files changed, 33 insertions, 0 deletions
diff --git a/lint/libs/lint_api/src/com/android/tools/lint/client/api/IDomParser.java b/lint/libs/lint_api/src/com/android/tools/lint/client/api/IDomParser.java index 871133b..1a70fac 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/client/api/IDomParser.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/client/api/IDomParser.java @@ -58,6 +58,20 @@ public interface IDomParser { Location getLocation(@NonNull XmlContext context, @NonNull Node node); /** + * Returns a {@link Location} for the given DOM node. Like + * {@link #getLocation(XmlContext, Node)}, but allows a position range that + * is a subset of the node range. + * + * @param context information about the file being parsed + * @param node the node to create a location for + * @param start the starting position within the node, inclusive + * @param end the ending position within the node, exclusive + * @return a location for the given node + */ + @NonNull + Location getLocation(@NonNull XmlContext context, @NonNull Node node, int start, int end); + + /** * Creates a light-weight handle to a location for the given node. It can be * turned into a full fledged location by * {@link com.android.tools.lint.detector.api.Location.Handle#resolve()}. diff --git a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/XmlContext.java b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/XmlContext.java index 78e8632..14e0a91 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/XmlContext.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/XmlContext.java @@ -82,6 +82,25 @@ public class XmlContext extends Context { } /** + * Creates a new location within an XML text node + * + * @param textNode the text node + * @param begin the start offset within the text node (inclusive) + * @param end the end offset within the text node (exclusive) + * @return a new location + */ + @NonNull + public Location getLocation(@NonNull Node textNode, int begin, int end) { + assert textNode.getNodeType() == Node.TEXT_NODE; + if (parser != null) { + return parser.getLocation(this, textNode, begin, end); + } + + return Location.create(file); + } + + + /** * Reports an issue applicable to a given DOM node. The DOM node is used as the * scope to check for suppress lint annotations. * |