com.android.tools.lint.detector.api
Class ResourceXmlDetector

java.lang.Object
  extended by com.android.tools.lint.detector.api.Detector
      extended by com.android.tools.lint.detector.api.ResourceXmlDetector
All Implemented Interfaces:
Detector.XmlScanner
Direct Known Subclasses:
LayoutDetector

@Beta
public abstract class ResourceXmlDetector
extends Detector
implements Detector.XmlScanner

Specialized detector intended for XML resources. Detectors that apply to XML resources should extend this detector instead since it provides special iteration hooks that are more efficient.

NOTE: This is not a public or final API; if you rely on this be prepared to adjust your code for the next tools release.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.android.tools.lint.detector.api.Detector
Detector.BinaryResourceScanner, Detector.ClassScanner, Detector.GradleScanner, Detector.JavaScanner, Detector.OtherFileScanner, Detector.ResourceFolderScanner, Detector.XmlScanner
 
Field Summary
 
Fields inherited from interface com.android.tools.lint.detector.api.Detector.XmlScanner
ALL
 
Constructor Summary
ResourceXmlDetector()
           
 
Method Summary
 boolean appliesTo(Context context, java.io.File file)
          Returns true if this detector applies to the given file
 boolean appliesTo(com.android.resources.ResourceFolderType folderType)
          Returns whether this detector applies to the given folder type.
 void run(Context context)
          Runs the detector.
 
Methods inherited from class com.android.tools.lint.detector.api.Detector
afterCheckFile, afterCheckLibraryProject, afterCheckProject, applicableSuperClasses, appliesToFolder, appliesToResourceRefs, beforeCheckFile, beforeCheckLibraryProject, beforeCheckProject, checkBinaryResource, checkCall, checkClass, checkClass, checkFolder, checkInstruction, createJavaVisitor, getApplicableAsmNodeTypes, getApplicableAttributes, getApplicableCallNames, getApplicableCallOwners, getApplicableConstructorTypes, getApplicableElements, getApplicableFiles, getApplicableMethodNames, getApplicableNodeTypes, getSpeed, getSpeed, visitAttribute, visitBuildScript, visitConstructor, visitDocument, visitElement, visitElementAfter, visitMethod, visitResourceReference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.android.tools.lint.detector.api.Detector.XmlScanner
getApplicableAttributes, getApplicableElements, visitAttribute, visitDocument, visitElement, visitElementAfter
 

Constructor Detail

ResourceXmlDetector

public ResourceXmlDetector()
Method Detail

appliesTo

public boolean appliesTo(@NonNull
                         Context context,
                         @NonNull
                         java.io.File file)
Description copied from class: Detector
Returns true if this detector applies to the given file

Overrides:
appliesTo in class Detector
Parameters:
context - the context to check
file - the file in the context to check
Returns:
true if this detector applies to the given context and file

appliesTo

public boolean appliesTo(@NonNull
                         com.android.resources.ResourceFolderType folderType)
Returns whether this detector applies to the given folder type. This allows the detectors to be pruned from iteration, so for example when we are analyzing a string value file we don't need to look up detectors related to layout.

Overrides:
appliesTo in class Detector
Parameters:
folderType - the folder type to be visited
Returns:
true if this detector can apply to resources in folders of the given type

run

public void run(@NonNull
                Context context)
Description copied from class: Detector
Runs the detector. This method will not be called for certain specialized detectors, such as Detector.XmlScanner and Detector.JavaScanner, where there are specialized analysis methods instead such as Detector.XmlScanner.visitElement(XmlContext, Element).

Overrides:
run in class Detector
Parameters:
context - the context describing the work to be done