aboutsummaryrefslogtreecommitdiffstats
path: root/common/tests/src/com/android/util
Commit message (Collapse)AuthorAgeFilesLines
* Fix lint column offset handling, and add columns to API checkTor Norbye2012-01-301-0/+50
| | | | | | | | | | | | | | | | | | | | The Lint API specifies that columns should be 0-based (like line numbers), but in a number of places this was not the case; it was 1-based instead (both in the detector code and in the output code, which is why things looked okay). This changeset cleans this up such that the columns are properly 0-based (and adds unit tests for it). The Location API has a mechanism to search in the source code for tokens, which is useful for bytecode detectors where we only have line numbers. This changeset adds tokens to the API detectors such that it identifies the corresponding method, class or field reference in the source, not just the corresponding line. It also improves the pattern search to also look backwards a few lines, since some bytecode references appear a few lines later than the source code reference (at the nearest executable code; this is the case for parameter local variables for example). Change-Id: I3adac20d5f0075e0a919be15dfb68658d5b7bb11
* Replace unit test unicode chars with unicode escape charsTor Norbye2012-01-201-1/+2
| | | | Change-Id: I37a4f3a9d9d8fd7870f08e56a595b52d7ff89add
* Tweak encoding sniffer to look for \r to avoid looking at whole docTor Norbye2012-01-061-39/+61
| | | | Change-Id: I189118b8612661e3c9aef4aaca0feeb7ac522f5b
* Extract positional XML parser into common and fix encoding issuesTor Norbye2012-01-051-0/+243
The XML DOM parser used by the lint CLI driver (which tracks positions) is needed outside of lint, so pull it out of the lint/cli project, and refactor it such that it does not directly reference the lint Position APIs (but can utilize them when subclassed in lint). In addition, handle non-UTF-8 file encodings. XML files can be encoded in other character sets, and can specify this via the encoding attribute in the XML prologue. Until now, the CLI lint runner would just read the XML file contents in using the default encoding and parse this. Now there's a new utility method which takes a byte[] and infers the desired encoding and uses that to convert the byte[] into a string using the correct encoding. (We can't just pass an InputStream and let the SAX parser handle this on its own because the XML parser needs to access the character stream in order to assign correct node offsets.) This code now also handles the byte order mark more cleanly. There are some new unit tests too to check the new encoding, BOM and offset handling. Change-Id: Ib0badbbe72172e3408c6d5af2413be51280a7724