diff options
author | Tor Norbye <tnorbye@google.com> | 2012-04-05 14:35:31 -0700 |
---|---|---|
committer | android code review <noreply-gerritcodereview@google.com> | 2012-04-05 14:35:31 -0700 |
commit | b6cb615af90cf8363c7e02101e5ba7366709dc53 (patch) | |
tree | bbc08ed25ab5ba0712ba764ca938bbc65ecf8c6c /lint/libs | |
parent | 55ac65d7eb8aec583f624241551b7b0aec2015ff (diff) | |
parent | f4cece27e64ffa7cb98ec3074dbe7e54ed2891ca (diff) | |
download | sdk-b6cb615af90cf8363c7e02101e5ba7366709dc53.zip sdk-b6cb615af90cf8363c7e02101e5ba7366709dc53.tar.gz sdk-b6cb615af90cf8363c7e02101e5ba7366709dc53.tar.bz2 |
Merge "28321: Lint didn't warn about "new Long(long)""
Diffstat (limited to 'lint/libs')
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" + |