diff options
author | Tor Norbye <tnorbye@google.com> | 2012-02-24 07:56:55 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2012-02-24 09:14:33 -0800 |
commit | 0fe590d956435c3c6a2d4c802108f627b173a573 (patch) | |
tree | f99ed167eee6edcfbda48109cbd06c5a7d12dae8 /lint/cli | |
parent | 9e36cb7689bf68ceafff3385e95dc24b756c34d5 (diff) | |
download | sdk-0fe590d956435c3c6a2d4c802108f627b173a573.zip sdk-0fe590d956435c3c6a2d4c802108f627b173a573.tar.gz sdk-0fe590d956435c3c6a2d4c802108f627b173a573.tar.bz2 |
Lint bug fixes
This changeset fixes a couple of Lint bugs:
(1) Handle BOMs (byte order marks) in Java files. We already handle
this for XML files (where it's common) but these can be present in
other file types as well, such as Java.
See http://code.google.com/p/android/issues/detail?id=25952
(2) Fix a bug (false positive) in the FloatMath detector; the visitor
approach can get confused; do simple ASM node iteration instead
(which is how all the other detectors work; this detector was
written before we had the ASM DOM model)
Change-Id: I65b4e6cd8d8e6c7e591433d8eb5aedf273e2caad
Diffstat (limited to 'lint/cli')
-rw-r--r-- | lint/cli/src/com/android/tools/lint/Main.java | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/lint/cli/src/com/android/tools/lint/Main.java b/lint/cli/src/com/android/tools/lint/Main.java index e12e473..ccd713d 100644 --- a/lint/cli/src/com/android/tools/lint/Main.java +++ b/lint/cli/src/com/android/tools/lint/Main.java @@ -33,14 +33,12 @@ import com.android.tools.lint.client.api.LintListener; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Issue; +import com.android.tools.lint.detector.api.LintUtils; import com.android.tools.lint.detector.api.Location; import com.android.tools.lint.detector.api.Position; import com.android.tools.lint.detector.api.Project; import com.android.tools.lint.detector.api.Severity; -import com.android.util.PositionXmlParser; -import com.google.common.base.Charsets; import com.google.common.io.Closeables; -import com.google.common.io.Files; import java.io.File; import java.io.FileInputStream; @@ -959,13 +957,7 @@ public class Main extends LintClient { @Override public String readFile(File file) { try { - // For XML files, apply special logic to pick up encoding information within the file - if (endsWith(file.getName(), DOT_XML)) { - byte[] data = Files.toByteArray(file); - return PositionXmlParser.getXmlString(data); - } - - return Files.toString(file, Charsets.UTF_8); + return LintUtils.getEncodedString(file); } catch (IOException e) { return ""; //$NON-NLS-1$ } |