aboutsummaryrefslogtreecommitdiffstats
path: root/lint/libs
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2012-04-05 12:42:59 -0700
committerTor Norbye <tnorbye@google.com>2012-04-05 12:42:59 -0700
commitf4cece27e64ffa7cb98ec3074dbe7e54ed2891ca (patch)
treecd00c6b91d2e298580a709a12b1b9980db96e7ff /lint/libs
parentc2d5ffe0b9baa1c24a62459b82bb21df08f4250b (diff)
downloadsdk-f4cece27e64ffa7cb98ec3074dbe7e54ed2891ca.zip
sdk-f4cece27e64ffa7cb98ec3074dbe7e54ed2891ca.tar.gz
sdk-f4cece27e64ffa7cb98ec3074dbe7e54ed2891ca.tar.bz2
28321: Lint didn't warn about "new Long(long)"
Change-Id: I69d053e4242e0af2080fdd9ed233fd10c8963d1b
Diffstat (limited to 'lint/libs')
-rw-r--r--lint/libs/lint_checks/src/com/android/tools/lint/checks/JavaPerformanceDetector.java14
-rw-r--r--lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/JavaPerformanceDetectorTest.java1
2 files changed, 10 insertions, 5 deletions
diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/JavaPerformanceDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/JavaPerformanceDetector.java
index 95fc107..e99005c 100644
--- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/JavaPerformanceDetector.java
+++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/JavaPerformanceDetector.java
@@ -124,6 +124,9 @@ public class JavaPerformanceDetector extends Detector implements Detector.JavaSc
private static final String BOOL = "boolean"; //$NON-NLS-1$
private static final String BOOLEAN = "Boolean"; //$NON-NLS-1$
private static final String LONG = "Long"; //$NON-NLS-1$
+ private static final String CHARACTER = "Character"; //$NON-NLS-1$
+ private static final String DOUBLE = "Double"; //$NON-NLS-1$
+ private static final String FLOAT = "Float"; //$NON-NLS-1$
private static final String HASH_MAP = "HashMap"; //$NON-NLS-1$
private static final String CANVAS = "Canvas"; //$NON-NLS-1$
private static final String ON_DRAW = "onDraw"; //$NON-NLS-1$
@@ -204,11 +207,12 @@ public class JavaPerformanceDetector extends Detector implements Detector.JavaSc
TypeReference reference = node.astTypeReference();
typeName = reference.astParts().last().astIdentifier().astValue();
}
- if ((typeName.equals("Integer") //$NON-NLS-1$
- || typeName.equals("Boolean") //$NON-NLS-1$
- || typeName.equals("Float") //$NON-NLS-1$
- || typeName.equals("Character") //$NON-NLS-1$
- || typeName.equals("Double")) //$NON-NLS-1$
+ if ((typeName.equals(INTEGER)
+ || typeName.equals(BOOLEAN)
+ || typeName.equals(FLOAT)
+ || typeName.equals(CHARACTER)
+ || typeName.equals(LONG)
+ || typeName.equals(DOUBLE))
&& node.astTypeReference().astParts().size() == 1
&& node.astArguments().size() == 1) {
String argument = node.astArguments().first().toString();
diff --git a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/JavaPerformanceDetectorTest.java b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/JavaPerformanceDetectorTest.java
index cfcda6a..100c3f7 100644
--- a/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/JavaPerformanceDetectorTest.java
+++ b/lint/libs/lint_checks/tests/src/com/android/tools/lint/checks/JavaPerformanceDetectorTest.java
@@ -34,6 +34,7 @@ public class JavaPerformanceDetectorTest extends AbstractCheckTest {
"JavaPerformanceTest.java:116: Warning: Avoid object allocations during draw operations: Use Canvas.getClipBounds(Rect) instead of Canvas.getClipBounds() which allocates a temporary Rect\n" +
"JavaPerformanceTest.java:140: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead)\n" +
"JavaPerformanceTest.java:145: Warning: Use Integer.valueOf(42) instead\n" +
+ "JavaPerformanceTest.java:146: Warning: Use Long.valueOf(42L) instead\n" +
"JavaPerformanceTest.java:147: Warning: Use Boolean.valueOf(true) instead\n" +
"JavaPerformanceTest.java:148: Warning: Use Character.valueOf('c') instead\n" +
"JavaPerformanceTest.java:149: Warning: Use Float.valueOf(1.0f) instead\n" +