diff options
author | Tor Norbye <tnorbye@google.com> | 2011-12-08 18:38:27 -0800 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2011-12-09 12:15:54 -0800 |
commit | b45957a134d6fd6184348387fd0f0b14ffa7021c (patch) | |
tree | 0d6f49a7e70b91d69171652bdddc1e8fbb46bcda | |
parent | 542d119b6c8353283199e493402c3b2fd720c57c (diff) | |
download | sdk-b45957a134d6fd6184348387fd0f0b14ffa7021c.zip sdk-b45957a134d6fd6184348387fd0f0b14ffa7021c.tar.gz sdk-b45957a134d6fd6184348387fd0f0b14ffa7021c.tar.bz2 |
A few misc lint fixes
Change-Id: Idc81f7a2d033675a03209eeabda0216babc35ebe
22 files changed, 188 insertions, 84 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java index 8f87a99..ff0effa 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java @@ -94,6 +94,7 @@ import org.eclipse.ui.console.MessageConsoleStream; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.ui.texteditor.AbstractTextEditor; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; @@ -1809,6 +1810,12 @@ public class AdtPlugin extends AbstractUIPlugin implements ILogger { } else if (showEditorTab) { editor.setActivePage(AndroidXmlEditor.TEXT_EDITOR_ID); } + } else if (targetEditor instanceof AbstractTextEditor) { + AbstractTextEditor editor = (AbstractTextEditor) targetEditor; + if (region != null) { + editor.setHighlightRange(region.getOffset(), region.getLength(), + true /* moveCursor*/); + } } return targetEditor; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java index 7270824..ef42f44 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java @@ -53,6 +53,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PartInitException; import org.eclipse.ui.editors.text.TextFileDocumentProvider; +import org.eclipse.ui.ide.IDE; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.wst.sse.core.StructuredModelManager; import org.eclipse.wst.sse.core.internal.provisional.IModelManager; @@ -388,7 +389,12 @@ public class EclipseLintClient extends LintClient implements IDomParser { */ public static String describe(IMarker marker) { IssueRegistry registry = getRegistry(); - Issue issue = registry.getIssue(getId(marker)); + String markerId = getId(marker); + Issue issue = registry.getIssue(markerId); + if (issue == null) { + return ""; + } + String summary = issue.getDescription(); String explanation = issue.getExplanation(); @@ -441,7 +447,11 @@ public class EclipseLintClient extends LintClient implements IDomParser { IResource resource = marker.getResource(); if (resource instanceof IFile) { - AdtPlugin.openFile((IFile) resource, region, true /* showEditorTab */); + IEditorPart editor = + AdtPlugin.openFile((IFile) resource, region, true /* showEditorTab */); + if (editor != null) { + IDE.gotoMarker(editor, marker); + } } } catch (PartInitException ex) { AdtPlugin.log(ex, null); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintViewPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintViewPart.java index 6f42bf2..b4a4a0c 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintViewPart.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintViewPart.java @@ -63,7 +63,6 @@ import java.util.List; /** * Eclipse View which shows lint warnings for the current project */ -@SuppressWarnings("restriction") // DOM model public class LintViewPart extends ViewPart implements SelectionListener, IJobChangeListener { /** The view id for this view part */ public static final String ID = "com.android.ide.eclipse.adt.internal.lint.LintViewPart"; //$NON-NLS-1$ diff --git a/lint/libs/lint_api/src/com/android/tools/lint/client/api/IssueRegistry.java b/lint/libs/lint_api/src/com/android/tools/lint/client/api/IssueRegistry.java index 3616b5e..67efe36 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/client/api/IssueRegistry.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/client/api/IssueRegistry.java @@ -47,9 +47,10 @@ public abstract class IssueRegistry { * parse an XML file prior to analysis */ public static final Issue PARSER_ERROR = Issue.create( - "XmlParserError", //$NON-NLS-1$ - "Finds XML files that contain fatal parser errors", - "XML files must be parsable.", + "ParserError", //$NON-NLS-1$ + "Finds files that contain fatal parser errors", + "Lint will ignore any files that contain fatal parsing errors. These may contain " + + "other errors, or contain code which affects issues in other files.", Category.CORRECTNESS, 10, Severity.ERROR, @@ -203,6 +204,8 @@ public abstract class IssueRegistry { for (Issue issue : issues) { sIdToIssue.put(issue.getId(), issue); } + + sIdToIssue.put(PARSER_ERROR.getId(), PARSER_ERROR); } return sIdToIssue.get(id); } diff --git a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/ClassContext.java b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/ClassContext.java index 0fbb96c..a06ed1b 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/ClassContext.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/ClassContext.java @@ -22,7 +22,6 @@ import static com.android.tools.lint.detector.api.LintConstants.DOT_JAVA; import com.android.tools.lint.client.api.LintClient; import com.google.common.annotations.Beta; -import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.tree.ClassNode; import java.io.File; @@ -38,8 +37,16 @@ import java.util.List; @Beta public class ClassContext extends Context { private final File mBinDir; + /** The class file DOM root node */ private ClassNode mClassNode; + /** The class file byte data */ private byte[] mBytes; + /** The source file, if known/found */ + private File mSourceFile; + /** The contents of the source file, if source file is known/found */ + private String mSourceContents; + /** Whether we've searched for the source file (used to avoid repeated failed searches) */ + private boolean mSearchedForSource; /** * Construct a new {@link ClassContext} @@ -72,49 +79,93 @@ public class ClassContext extends Context { /** * Returns the bytecode object model * - * @return the bytecode object model + * @return the bytecode object model, never null */ public ClassNode getClassNode() { return mClassNode; } /** - * Finds the corresponding source file for the current class file. + * Returns the source file for this class file, if possible. * - * @param source the name of the source file, if known (which is often - * stored in the bytecode and provided by the - * {@link ClassVisitor#visitSource(String, String)} method). If - * not known, this method will guess by stripping out inner-class - * suffixes like $1. - * @return the source file corresponding to the {@link #file} field. + * @return the source file, or null */ - public File findSourceFile(String source) { - if (source == null) { - source = file.getName(); - if (source.endsWith(DOT_CLASS)) { - source = source.substring(0, source.length() - DOT_CLASS.length()) + DOT_JAVA; - } - int index = source.indexOf('$'); - if (index != -1) { - source = source.substring(0, index) + DOT_JAVA; + public File getSourceFile() { + if (mSourceFile == null && !mSearchedForSource) { + mSearchedForSource = true; + + String source = mClassNode.sourceFile; + if (source == null) { + source = file.getName(); + if (source.endsWith(DOT_CLASS)) { + source = source.substring(0, source.length() - DOT_CLASS.length()) + DOT_JAVA; + } + int index = source.indexOf('$'); + if (index != -1) { + source = source.substring(0, index) + DOT_JAVA; + } } - } - if (source != null) { - // Determine package - String topPath = mBinDir.getPath(); - String parentPath = file.getParentFile().getPath(); - if (parentPath.startsWith(topPath)) { - String relative = parentPath.substring(topPath.length() + 1); - List<File> sources = getProject().getJavaSourceFolders(); - for (File dir : sources) { - File sourceFile = new File(dir, relative + File.separator + source); - if (sourceFile.exists()) { - return sourceFile; + if (source != null) { + // Determine package + String topPath = mBinDir.getPath(); + String parentPath = file.getParentFile().getPath(); + if (parentPath.startsWith(topPath)) { + String relative = parentPath.substring(topPath.length() + 1); + List<File> sources = getProject().getJavaSourceFolders(); + for (File dir : sources) { + File sourceFile = new File(dir, relative + File.separator + source); + if (sourceFile.exists()) { + mSourceFile = sourceFile; + break; + } } } } } - return null; + return mSourceFile; + } + + /** + * Returns the contents of the source file for this class file, if found. + * + * @return the source contents, or "" + */ + public String getSourceContents() { + if (mSourceContents == null) { + File sourceFile = getSourceFile(); + if (sourceFile != null) { + mSourceContents = getClient().readFile(mSourceFile); + } + + if (mSourceContents == null) { + mSourceContents = ""; + } + } + + return mSourceContents; + } + + + + /** + * Returns a location for the given source line number in this class file's + * source file, if available. + * + * @param line the line number (1-based, which is what ASM uses) + * @param patternStart optional pattern to search for in the source for + * range start + * @param patternEnd optional pattern to search for in the source for range + * end + * @return a location, never null + */ + public Location getLocationForLine(int line, String patternStart, String patternEnd) { + File sourceFile = getSourceFile(); + if (sourceFile != null) { + return Location.create(sourceFile, getSourceContents(), line - 1, + patternStart, patternEnd); + } + + return Location.create(file); } } diff --git a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Location.java b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Location.java index c49e2ac..10f1d6b 100644 --- a/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Location.java +++ b/lint/libs/lint_api/src/com/android/tools/lint/detector/api/Location.java @@ -213,6 +213,26 @@ public class Location { * @return a new location */ public static Location create(File file, String contents, int line) { + return create(file, contents, line, null, null); + } + + /** + * Creates a new location for the given file, with the given contents, for + * the given line number. + * + * @param file the file containing the location + * @param contents the current contents of the file + * @param line the line number (0-based) for the position + * @param patternStart an optional pattern to search for from the line + * match; if found, adjust the column and offsets to begin at the + * pattern start + * @param patternEnd an optional pattern to search for behind the start + * pattern; if found, adjust the end offset to match the end of + * the pattern + * @return a new location + */ + public static Location create(File file, String contents, int line, + String patternStart, String patternEnd) { int currentLine = 0; int offset = 0; while (currentLine < line) { @@ -225,6 +245,26 @@ public class Location { } if (line == currentLine) { + if (patternStart != null) { + int index = contents.indexOf(patternStart, offset); + if (index != -1) { + int lineStart = contents.lastIndexOf('\n', index); + if (lineStart == -1) { + lineStart = 0; + } + int column = index - lineStart; + if (patternEnd != null) { + int end = contents.indexOf(patternEnd, offset + patternStart.length()); + if (end != -1) { + return new Location(file, new DefaultPosition(line, column, index), + new DefaultPosition(line, -1, end + patternEnd.length())); + } + } + return new Location(file, new DefaultPosition(line, column, index), + new DefaultPosition(line, column, index + patternStart.length())); + } + } + Position position = new DefaultPosition(line, -1, offset); return new Location(file, position, position); } diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/AccessibilityDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/AccessibilityDetector.java index c61dbcd..a3cfc7c 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/AccessibilityDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/AccessibilityDetector.java @@ -68,10 +68,10 @@ public class AccessibilityDetector extends LayoutDetector { @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { + return Arrays.asList( IMAGE_BUTTON, IMAGE_VIEW - }); + ); } @Override diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ArraySizeDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ArraySizeDetector.java index 01faa2f..b11fdc3 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ArraySizeDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ArraySizeDetector.java @@ -94,11 +94,11 @@ public class ArraySizeDetector extends ResourceXmlDetector { @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { + return Arrays.asList( TAG_ARRAY, TAG_STRING_ARRAY, TAG_INTEGER_ARRAY - }); + ); } @Override diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ChildCountDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ChildCountDetector.java index cd0585e..2bd6a77 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ChildCountDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ChildCountDetector.java @@ -80,13 +80,13 @@ public class ChildCountDetector extends LayoutDetector { @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { + return Arrays.asList( SCROLL_VIEW, HORIZONTAL_SCROLL_VIEW, LIST_VIEW, GRID_VIEW // TODO: Shouldn't Spinner be in this list too? (Was not there in layoutopt) - }); + ); } @Override diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/DeprecationDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/DeprecationDetector.java index 8fdc1cd..c6cf4e8 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/DeprecationDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/DeprecationDetector.java @@ -28,8 +28,8 @@ import com.android.tools.lint.detector.api.XmlContext; import org.w3c.dom.Element; -import java.util.Arrays; import java.util.Collection; +import java.util.Collections; /** * Check which looks for usage of deprecated tags, attributes, etc. @@ -58,9 +58,9 @@ public class DeprecationDetector extends LayoutDetector { @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { + return Collections.singletonList( ABSOLUTE_LAYOUT - }); + ); } @Override diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/FieldGetterDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/FieldGetterDetector.java index a9085f7..ad48355 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/FieldGetterDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/FieldGetterDetector.java @@ -116,11 +116,8 @@ public class FieldGetterDetector extends Detector implements Detector.ClassScann List<String> getters = checkMethods(mContext.getClassNode(), names); if (getters.size() > 0) { - File source = mContext.findSourceFile(null); - String contents = null; - if (source != null) { - contents = mContext.getClient().readFile(source); - } + File source = mContext.getSourceFile(); + String contents = mContext.getSourceContents(); for (String getter : getters) { for (Pair<String, Integer> pair : mPendingCalls) { String name = pair.getFirst(); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/GridLayoutDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/GridLayoutDetector.java index b26c88b..b19d537 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/GridLayoutDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/GridLayoutDetector.java @@ -34,8 +34,8 @@ import com.android.tools.lint.detector.api.XmlContext; import org.w3c.dom.Attr; import org.w3c.dom.Element; -import java.util.Arrays; import java.util.Collection; +import java.util.Collections; /** * Check which looks for potential errors in declarations of GridLayouts, such as specifying @@ -66,9 +66,9 @@ public class GridLayoutDetector extends LayoutDetector { @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { - "GridLayout", //$NON-NLS-1$ - }); + return Collections.singletonList( + "GridLayout" //$NON-NLS-1$ + ); } private static int getInt(Element element, String attribute, int defaultValue) { diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedValuesDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedValuesDetector.java index e629a7c..816ecab 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedValuesDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/HardcodedValuesDetector.java @@ -72,13 +72,13 @@ public class HardcodedValuesDetector extends LayoutDetector { @Override public Collection<String> getApplicableAttributes() { - return Arrays.asList(new String[] { + return Arrays.asList( ATTR_TEXT, ATTR_CONTENT_DESCRIPTION, ATTR_HINT, ATTR_LABEL, ATTR_PROMPT - }); + ); } @Override diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ManifestOrderDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ManifestOrderDetector.java index bc0e401..5eecfb2 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ManifestOrderDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ManifestOrderDetector.java @@ -84,7 +84,7 @@ public class ManifestOrderDetector extends Detector implements Detector.XmlScann @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { + return Arrays.asList( TAG_APPLICATION, TAG_USES_PERMISSION, "permission", //$NON-NLS-1$ @@ -95,8 +95,8 @@ public class ManifestOrderDetector extends Detector implements Detector.XmlScann "uses-feature", //$NON-NLS-1$ "supports-screens", //$NON-NLS-1$ "compatible-screens", //$NON-NLS-1$ - "supports-gl-texture", //$NON-NLS-1$ - }); + "supports-gl-texture" //$NON-NLS-1$ + ); } @Override diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/MathDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/MathDetector.java index 9eccaef..79ad282 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/MathDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/MathDetector.java @@ -117,14 +117,12 @@ public class MathDetector extends Detector implements Detector.ClassScanner { private static class MyMethodVisitor extends MethodVisitor { private final ClassContext mContext; private int mCurrentLine; - private String mCurrentSource; private int mLastInsn; private String mPendingMethod; public MyMethodVisitor(ClassContext context, String currentSource) { super(Opcodes.ASM4); mContext = context; - mCurrentSource = currentSource; } private Location getCurrentLocation() { @@ -133,13 +131,13 @@ public class MathDetector extends Detector implements Detector.ClassScanner { int line = 0; // Determine package - File source = mContext.findSourceFile(mCurrentSource); + File source = mContext.getSourceFile(); if (source != null) { file = source; line = mCurrentLine; if (line > 0) { - String contents = mContext.getClient().readFile(file); + String contents = mContext.getSourceContents(); if (contents != null) { // bytecode line numbers are 1-based return Location.create(file, contents, line - 1); diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/NestedScrollingWidgetDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/NestedScrollingWidgetDetector.java index 099efeb..af240e2 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/NestedScrollingWidgetDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/NestedScrollingWidgetDetector.java @@ -74,14 +74,14 @@ public class NestedScrollingWidgetDetector extends LayoutDetector { @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { + return Arrays.asList( SCROLL_VIEW, LIST_VIEW, GRID_VIEW, // Horizontal GALLERY, HORIZONTAL_SCROLL_VIEW - }); + ); } private Element findOuterScrollingWidget(Node node, boolean vertical) { diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/OverdrawDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/OverdrawDetector.java index eb79ee7..6683a22 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/OverdrawDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/OverdrawDetector.java @@ -37,7 +37,6 @@ import static com.android.tools.lint.detector.api.LintConstants.VALUE_DISABLED; import static com.android.tools.lint.detector.api.LintUtils.endsWith; import com.android.resources.ResourceFolderType; -import com.android.tools.lint.client.api.IDomParser; import com.android.tools.lint.detector.api.Category; import com.android.tools.lint.detector.api.Context; import com.android.tools.lint.detector.api.Detector; @@ -45,7 +44,6 @@ import com.android.tools.lint.detector.api.Issue; import com.android.tools.lint.detector.api.LayoutDetector; 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.Scope; import com.android.tools.lint.detector.api.Severity; @@ -62,6 +60,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; @@ -282,15 +281,15 @@ public class OverdrawDetector extends LayoutDetector implements Detector.JavaSca @Override public Collection<String> getApplicableAttributes() { - return Arrays.asList(new String[] { + return Collections.singletonList( // Layouts: Look for background attributes on root elements for possible overdraw - ATTR_BACKGROUND, - }); + ATTR_BACKGROUND + ); } @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { + return Arrays.asList( // Manifest: Look at theme registrations TAG_ACTIVITY, TAG_APPLICATION, @@ -300,7 +299,7 @@ public class OverdrawDetector extends LayoutDetector implements Detector.JavaSca // Bitmaps TAG_BITMAP - }); + ); } @Override diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ScrollViewChildDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ScrollViewChildDetector.java index dcdd0f8..2d5e0e9 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/ScrollViewChildDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/ScrollViewChildDetector.java @@ -70,10 +70,10 @@ public class ScrollViewChildDetector extends LayoutDetector { @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { + return Arrays.asList( SCROLL_VIEW, HORIZONTAL_SCROLL_VIEW - }); + ); } @Override diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/SecurityDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/SecurityDetector.java index 54b5f62..5c24455 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/SecurityDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/SecurityDetector.java @@ -96,10 +96,10 @@ public class SecurityDetector extends Detector implements Detector.XmlScanner { @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { + return Arrays.asList( TAG_SERVICE, TAG_GRANT_PERMISSION - }); + ); } @Override diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TranslationDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TranslationDetector.java index b07039f..6e8624d 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TranslationDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TranslationDetector.java @@ -119,10 +119,10 @@ public class TranslationDetector extends ResourceXmlDetector { @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { + return Arrays.asList( TAG_STRING, TAG_STRING_ARRAY - }); + ); } @Override diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TypographyDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TypographyDetector.java index f747996..8f52e4c 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/TypographyDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/TypographyDetector.java @@ -200,10 +200,10 @@ public class TypographyDetector extends ResourceXmlDetector { @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { + return Arrays.asList( TAG_STRING, TAG_STRING_ARRAY - }); + ); } @Override diff --git a/lint/libs/lint_checks/src/com/android/tools/lint/checks/UseCompoundDrawableDetector.java b/lint/libs/lint_checks/src/com/android/tools/lint/checks/UseCompoundDrawableDetector.java index 7636869..a578e19 100644 --- a/lint/libs/lint_checks/src/com/android/tools/lint/checks/UseCompoundDrawableDetector.java +++ b/lint/libs/lint_checks/src/com/android/tools/lint/checks/UseCompoundDrawableDetector.java @@ -33,8 +33,8 @@ import com.android.tools.lint.detector.api.XmlContext; import org.w3c.dom.Element; -import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; /** @@ -66,9 +66,9 @@ public class UseCompoundDrawableDetector extends LayoutDetector { @Override public Collection<String> getApplicableElements() { - return Arrays.asList(new String[] { + return Collections.singletonList( LINEAR_LAYOUT - }); + ); } @Override |