aboutsummaryrefslogtreecommitdiffstats
path: root/lint/cli
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2011-10-17 18:32:51 -0700
committerTor Norbye <tnorbye@google.com>2011-10-20 16:35:49 -0700
commit8027fad9680e1622d7c70be330422d6b11fc6c88 (patch)
tree21c78e65820234b8dc3638d3624450997fa7cd91 /lint/cli
parenta85107f7d763276a5a040cf68e2046ac54202015 (diff)
downloadsdk-8027fad9680e1622d7c70be330422d6b11fc6c88.zip
sdk-8027fad9680e1622d7c70be330422d6b11fc6c88.tar.gz
sdk-8027fad9680e1622d7c70be330422d6b11fc6c88.tar.bz2
More lint checks: translation, i18n, proguard, gridlayout, "px"
This changeset adds more lint checks: (1) Translation. It looks at all the string values in the application, and if there are discrepancies (where a translatable string is not defined in all provided languages and regions) then these are listed. (2) Internationalization. It looks for text: and contentDescription: attributes and ensures that these refer to @string resources, not hardcoded string values. This lint warning also has an associated quickfix when shown in Eclipse which invokes the Extract String refactoring wizard on the right selection context. (3) Proguard. It looks for the old (broken) patterns we had in older proguard.cfg files (-keepclasseswithmembernames instead of -keepclasseswithmembers which implies shrinking.) (4) GridLayout. It looks at the layout constraints provided on views in a GridLayout and ensures that they fall within the overall dimensions of the grid. (5) "px" usage. It looks for dimensions using "px" as a unit and recommends switching to dp instead. This lint warning also has a quickfix in Eclipse which pops up a dialog asking for the screen density and then converts the px value to the right dp value and changes the unit. (6) TextFields. It looks at EditTexts and makes sure they either set inputType, hint or inputMethod. There's a quickfix in Eclipse for setting the inputType, which adds the property and automatically invokes content assist for showing the possible values. This changeset also adds some quick fixes for a few existing lint warnings: (7) Accessibility: Insert a content description attribute, front the editor and select the placeholder value. (8) Useless leaf layout: Remove the leaf layout (9) Useless middle layout: Invoke the Remove Container visual refactoring 10) Inefficient Linear Layout Weights: Change the attribute to 0dp Plus unit tests. Change-Id: Iebd7b23224a898bd1851abd578460019aee44df5
Diffstat (limited to 'lint/cli')
-rw-r--r--lint/cli/src/com/android/tools/lint/Main.java57
1 files changed, 30 insertions, 27 deletions
diff --git a/lint/cli/src/com/android/tools/lint/Main.java b/lint/cli/src/com/android/tools/lint/Main.java
index 9e8dc28..119dbc3 100644
--- a/lint/cli/src/com/android/tools/lint/Main.java
+++ b/lint/cli/src/com/android/tools/lint/Main.java
@@ -214,40 +214,43 @@ public class Main implements ToolContext {
int startLength = mOutput.length();
- File file = location.getFile();
- if (file != null) {
- String path = file.getPath();
- if (path.startsWith(mCommonPrefix)) {
- int chop = mCommonPrefix.length();
- if (path.length() > chop && path.charAt(chop) == File.separatorChar) {
- chop++;
+ if (location != null) {
+ File file = location.getFile();
+ if (file != null) {
+ String path = file.getPath();
+ if (path.startsWith(mCommonPrefix)) {
+ int chop = mCommonPrefix.length();
+ if (path.length() > chop && path.charAt(chop) == File.separatorChar) {
+ chop++;
+ }
+ path = path.substring(chop);
}
- path = path.substring(chop);
+ mOutput.append(path);
+ mOutput.append(':');
}
- mOutput.append(path);
- mOutput.append(':');
- }
- Position startPosition = location.getStart();
- if (startPosition != null) {
- int line = startPosition.getLine();
- if (line >= 0) {
- // line is 0-based, should display 1-based
- mOutput.append(Integer.toString(line + 1));
- mOutput.append(':');
+ Position startPosition = location.getStart();
+ if (startPosition != null) {
+ int line = startPosition.getLine();
+ if (line >= 0) {
+ // line is 0-based, should display 1-based
+ mOutput.append(Integer.toString(line + 1));
+ mOutput.append(':');
+ }
}
- }
- // Column is not particularly useful here
- //int column = location.getColumn();
- //if (column > 0) {
- // mOutput.append(Integer.toString(column));
- // mOutput.append(':');
- //}
+ // Column is not particularly useful here
+ //int column = location.getColumn();
+ //if (column > 0) {
+ // mOutput.append(Integer.toString(column));
+ // mOutput.append(':');
+ //}
- if (startLength < mOutput.length()) {
- mOutput.append(' ');
+ if (startLength < mOutput.length()) {
+ mOutput.append(' ');
+ }
}
+
mOutput.append(severity.getDescription());
mOutput.append(':');
mOutput.append(' ');