| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This checkin hooks up the API check to lint, such that class
references, method calls and field access are checked with the
database and generates warnings if the project min SDK is lower than
that required by the API. It also checks layout references to ensure
that the widgets are supported by the minimum API.
NOTE: There's no flow analysis to avoid classes that are deliberately
accessing later APIs (and where the referencing class is loaded
conditionally). Therefore, for now the lint check is disabled by
default; enable with "lint --check NewApi".
Change-Id: Ia3160f81b45b5baed3caa46cdffe56735ebedd44
|
|\ |
|
| |
| |
| |
| | |
Change-Id: Ic4131738e505861c8308f386c2673d9ee304f158
|
|/
|
|
| |
Change-Id: I671fe960fe61afc80ec305e05f7ffe7cbb5933c5
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
First, stop reporting Java-related parser errors as lint
errors. Lombok fails to parse a few files (see
http://code.google.com/p/projectlombok/issues/detail?id=311) and even
when it fails, the error messages aren't useful (see
http://code.google.com/p/projectlombok/issues/detail?id=313).
Second, the XML parser could throw an exception in some circumstances,
because it passes invalid column numbers at the end of the file. This
CL guards against that (and against any other potential errors by
wrapping all exceptions during parsing as a SAXEception).
Finally, fix the positions reported in text nodes for the ExtraText
check such that it points to the line containing the extra text, not
the beginning of the text node (which is frequently the previous
line).
Change-Id: I9630ea49d30d8afdc8bd9cf2c87ca0a0306b8ec5
|
|\ \ |
|
| |/
| |
| |
| |
| |
| |
| | |
This allows lint detector code to load file resources bundled with the
tools (such as a permissions database file).
Change-Id: If740206e8e0c5feeaf0e908bf823135114c9bd0d
|
|\ \
| |/
|/| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This changeset adds a quickfix for the "Use Compound Drawable" lint
warning. That warning identifies a LinearLayout which contains exactly
one TextView and one ImageView (in either order, and the linear layout
can be in either orientation), and suggests replacing it by just the
single TextView along with a drawable attribute. The description alone
wasn't clear, so the quickfix performs the conversion automatically.
In addition to the conversion it also needs to transfer any layout
param references from the old LinearLayout to the TextView (and assign
it an id if necessary), so the quickfix is implemented as a visual
refactoring. It's also made available from the Visual Refactoring
menu.
This changeset also updates a couple of unrelated golden files in the
refactoring unit tests to track a message change a few months back.
Change-Id: Iecb544d196fdd4bcabf13a3fdb82ef1ea063f4c2
|
|\ \ |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This changeset adds support for multi-pass lint checking. A detector
can indicate that it is interested in a second pass through the source
code.
A good example of where this is needed is the Unused Resource
detector. In the first pass, it tracks declarations and references,
and at the end of the first pass it knows which resources are
unused. However, at this point it's too late to compute detailed
location information about each unused resource. Without multi-pass
checks, it would have to track detailed location information for *all*
resources, and computing locations can be costly.
With multi-pass support, it just computes the unused resource names in
the first pass, and then in the second pass it computes details about
the locations of those resources found to be unused.
This now includes *chained locations*. For example, for an unused
string, all the different translations of the unused string are
marked. These do not generate separate unused messages, it simply adds
to the location chain for the original unused warning.
This changeset also updates all the error reporters (text, HTML and
XML) to include all the locations, not just the ones with messages.
This changeset also cleans up the API a little: context classes now
track the lint runner instead of the lint client (which can point to
the lint client), and the SDK info lives with the project rather than
with the context.
Change-Id: I14ca3310bd1165b7dff655486157d770a36c4eff
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- Reads frameworks/base/api xml/txt file to build a representation of
package/class/method/field to figure out at what API level they were added.
- Writes down (and read back) this in a simpler XML format (only the info
we need).
- Simple API to query when a class/method/field was added to the API.
Change-Id: Ie854ed6d0c8c371990a913f949039f4c14c0b9cb
|
|/
|
|
| |
Change-Id: If271640953f7226ef1c03b28dd679dee34f03799
|
|
|
|
|
|
| |
Worked on Mac but not elsewhere (and should really use the ASM version of the class)
Change-Id: Iae7dcbeed445a182fa32debc4eca9c9f26a76ab4
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In order for a Custom View to be inflatable in the layout editor, it must
provide one or more of the following constructors:
* View(Context context)
* View(Context context, AttributeSet attrs)
* View(Context context, AttributeSet attrs, int defStyle)
This lint check looks for custom views and checks that they provide
one of the above constructors.
Change-Id: I294cfc42a50427f82cc797926b3e996bab52632b
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The lint check which suggests replacing root <FrameLayout>'s with a
<merge> tag was a bit simplistic. When the layout is used in a
ListView etc the replacement doesn't work.
This changeset limits the scenarios where the <FrameLayout> to <merge>
conversion suggestion is made to:
- Layouts that are <include>'ed from other layouts
- Layouts that are directly named in a setContentView() call
(This changeset also moves some code around to reuse the layout name
method from the DuplicateIdDetector and cleans up some constants)
Change-Id: Ic365f5ab2dc3cc7749ccab79f188a44829415802
|
|/
|
|
|
|
|
| |
Fix typo in the comparator code. This fixes issue
24297: lint may fail in jdk1.7 (comparison method violation)
Change-Id: I0d46c0810e28ea0493549c95e3c6f2ac88519e1c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If you specify <style name="Foo" parent="@style/Foo.Bar"/> then the
layout editor hangs with infinite recursion because as it walks up the
parent chains, it first goes from Foo.Bar (thanks to the style
definition), and from there it goes to Foo (because Foo is the implied
parent of Foo.Bar) and so on.
This changeset adds a visited set to the isTheme() method to prevent
boundless recursion in the presence of cycles.
It also adds a check for this condition to the lint style cycle
detector.
This fixes
http://code.google.com/p/android/issues/detail?id=24385
StackOverflowError when opening any layout xml file in Eclipse
Change-Id: I5c52e77ab7e81ea528f3b8fcdd052bff9447b2c9
|
|
|
|
| |
Change-Id: I2409950f2c8618148f2b7cfaf693672021b09633
|
|
|
|
| |
Change-Id: I6222f3ef2909174d9111dcfc037a2e74ad093acd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds several new Java parsetree-based lint detectors:
(1) String format checker. This checks several issues related to
formatting strings (%1$s), such as
- Is the string format valid?
- Is the string format consistent between different translations,
e.g. if argument #1 is of type "s" in locale A, is it also of
type "s" in locale B?
- Is the string format being called from Java with arguments of
the right type?
- Are strings which are not supposed to be formatted (e.g. ends
with a %) passed to String.format?
(2) View Cast checker. Looks at the views associated with specific
id's in layouts, and makes sure that any casts to views returned
by findViewById in Java is cast-compatible with the type in the
layout. For example, if you have a layout containing a <Button
id="foo">, then a cast to an EditText of findViewById(R.id.foo)
would be invalid.
(3) A security check which flags file creation calls that pass a
context of world-writeable.
(4) An "import android.R" checker. This looks for "import android.R"
in .java files and warns that this is potentially confusing.
(5) A hardcoded "/sdcard" string checker which looks for this prefix
in string literals and when found warns that the method
Environment.getExternalStorageDirectory().getPath() should be
used instead.
Change-Id: I14a4656f0ff6a58f25cde1b4bb23f6c47c47fdba
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds Java AST support to Lint. There are new interfaces
for Java parser and specialized Java detectors. Java detectors can
either visit a full parse tree, or they can register interest in
specific methods, or Android resource references, or specific AST node
types -- or a combination of these. They will then be invoked during
an AST visit with the relevant info.
This changeset also rewrites the existing detectors that were using
String-based pattern checking on Java files to using real AST
traversal instead (and it removes the custom Eclipse-specific unused
resource detector since the plain one now does the same AST-based
analysis that the Eclipse one did.)
Change-Id: I4d85f8b785bf41a88dbb29e7017b9c0f588880bc
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This changeset adds support for library projects to lint. Lint now
checks all the library projects for errors as well, and projects that
depend on global analysis (such as the unused resource detector) will
properly handle resource declarations and references across projects.
This changeset also cleans up the multi-project handling for the Lint
window in Eclipse. The "Run Lint" toolbar action, in addition to
operating on multiple selection, now has a dropdown menu for choosing
which projects to check (and there are also actions for checking all
projects, the current file, and clearing markers). Running lint on a
project will also automatically include dependent library projects.
Finally, some misc UI improvements: The Lint preference dialog
includes buttons for quickly enabling and disabling all the checks;
the Lint View includes a Project column which is shown when more than
one project is checked, and the file and linenumber columns are now
blank when the location does not correspond to a specific file.
Change-Id: I733f5258102dfb0aebbc2b75cb02b9ba6ef974e8
|
|\ \ |
|
| | |
| | |
| | |
| | | |
Change-Id: Ica0de61c68f275b8847c79feb401ce6d9bb9960d
|
|/ /
| |
| |
| |
| |
| | |
This lint check looks for usages of private resources.
Change-Id: I272706f63390c62ec17a267780a66d51733f0262
|
|\ \
| |/
|/| |
|
| |
| |
| |
| |
| |
| |
| |
| | |
This new lint check looks for XML files not using UTF-8 as the XML
file encoding. XML allows it, but it's unusual in Android apps and not
all tools handle it correctly.
Change-Id: Ie6c7d0a3a50d72261def3018463b08a5318d69a2
|
|\ \ |
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This changeset fixes issue
23747: i and İ character problem in turkish operating Systems...
and probably many other bugs in the Turkish locale.
Basically, we had a lot of String.toLowerCase() and
String.toUpperCase() calls. This performs locale sensitive
conversions, which in many cases is NOT what we want; for "machine
readable" conversions we should be using Locale.US which performs no
special cases.
For more, see
http://developer.android.com/reference/java/util/Locale.html#default_locale
Change-Id: I996b0e70fb377e8dae484c5811deb8bc9afb684c
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
| |
This new lint check looks for XML text content in resource files where
text is not expected, such as layout files. This is typically the
result of a typo.
This CL also improves the command line XML parser's position handling
such that it can handle positions on text nodes (until now it just
supported element and attribute positions), and similarly for Eclipse.
Change-Id: I6f69a8dc725a5b5b19f8ad5bb889ae25ee82600a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset adds a new @NonNull annotation, to match our existing
@Nullable annotation, and it adds configuration settings for Eclipse
3.8 / Eclipse 4.2 which configures the new null analysis there to use
our own annotations. Note that the annotations only have source
retention so there is no extra size or class-loading overhead. (To use
findbugs you'll need to temporarily change retention to class-level.)
In upcoming CL's I'll use these annotations to clarify the Lint API
and other APIs.
Change-Id: I99096d8b8a7e25ef002624d592da7700195a5872
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This changeset makes the SDK codebase compile with source=1.6 (which
means it also requires JDK 6). This means that methods implementing an
interface requires @Override's. It also means we can start using APIs
like the ArrayDeque class and methods like String#isEmpty().
This changeset looks big but the change is trivial: it's basically
adding @Override in all the places that need it, along with some other
automatic Eclipse cleanup in certain files (such as reordering imports
where they were incorrectly ordered (because older versions of Eclipse
didn't always handle inner classes right)), as well as cleaning up
trailing whitespace and removing some $NON-NLS-1$ markers on lines
where there aren't any string literals anymore.
This changeset also sets the source and target JDK level to 6 in the
Eclipse compiler .settings file, and synchronizes this file to all the
other Eclipse SDK projects.
Change-Id: I6a9585aa44c3dee9a5c00739ab22fbdbcb9f8275
|
|\ |
|
| |
| |
| |
| |
| |
| |
| | |
This changeset fixes enhancement
23288: Style extending itself Lint rule
Change-Id: Id35bcce02b55735becb2260a3276128bfd71f2a6
|
|\ \ |
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This changeset fixes this issue:
http://code.google.com/p/android/issues/detail?id=23214
The icon detector makes sure that if an icon appears in a given -dpi
folder, it appears in all the other -dpi folders as well (except for
-nodpi). However, in the set comparison it would use the full filename
(including file extension), which is not correct since it's okay to
have an .9.png in one folder and a .gif in another (and as reported in
this bug, an .xml file).
This changeset also associates a file location with folder warnings
for a missing density folder (it uses the res folder), which made
various unit tests need updates since the results sort differently.
Change-Id: I7f09772f3a54683a9d0c5c5d93ae2499707f533a
|
|/
|
|
|
|
|
|
|
| |
The check which identifies "useless" views (layouts that do not have
an id, background, or children) also need to consider the style
attribute since custom styles could be setting (for example) a
background.
Change-Id: I5adad11a365082d52609a060f7573ab7e80a0351
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This changeset fixes the handling of resource references inside items,
such as creating a layout alias like this:
<item type="layout" name="foo">@layout/bar</item>
This was not working correctly for code completion (no resource
completion inside the text node area of the item, and it was not
working correctly for the unused resource detector.
Change-Id: I844bf9be4802a0d246accd47b83514ebf0ae6d53
|
|/
|
|
|
|
|
|
|
|
| |
Lint's cli parser would throw an exception if handling a file that has
\r's without correspoding \n's. This changeset fixes that.
This addresses issue 22925: Lint: StringIndexOutOfBoundsException when
reading xml files containing incorrect line endings
Change-Id: I68c134e15d148f6f0bbcd477ec37b0fd2e70f0c0
|
|
|
|
|
|
|
|
|
| |
The Lint CLI driver stashes file contents (used to show code snippets
with the errors). However, for repeated errors in the same file this
could lead to a lot of extra memory usage (and OOM for large code
bases). This adds a file cache for the CLI driver.
Change-Id: Icfbca31457a6cf0b33c89a5ffd04b5079f8fed09
|
|\ |
|
| |
| |
| |
| |
| |
| | |
TabHosts etc should not be eligible as parents for an unused layout.
Change-Id: Ic934046530a5c8a4ff84a873e63230819f4fd4a5
|
| |
| |
| |
| | |
Change-Id: I7cdc3f92fa58f2702288476443bacc4a7b17e0b3
|