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

java.lang.Object
  extended by com.android.tools.lint.detector.api.Detector
Direct Known Subclasses:
Detector.XmlDetectorAdapter

public abstract class Detector
extends Object

A detector is able to find a particular problem. It might also be thought of as enforcing a rule, but "rule" is a bit overloaded in ADT terminology since ViewRules are used in the Rules API to allow views to specify designtime behavior in the graphical layout editor.

Each detector provides information about the issues it can find, such as an explanation of how to fix the issue, the priority, the category, etc. It also has an id which is used to persistently identify a particular type of error.

NOTE: Detectors might be constructed just once and shared between lint runs, so any per-detector state should be initialized and reset via the before/after methods.

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
static interface Detector.ClassScanner
          Specialized interface for detectors that scan Java class files
static interface Detector.JavaScanner
          Specialized interface for detectors that scan Java source files
static class Detector.XmlDetectorAdapter
          Concrete implementation of a detector that is a Detector.XmlScanner
static interface Detector.XmlScanner
          Specialized interface for detectors that scan XML files
 
Constructor Summary
Detector()
           
 
Method Summary
 void afterCheckFile(Context context)
          Analysis has just been finished for a specific file, perform any cleanup or report issues found
 void afterCheckProject(Context context)
          Analysis has just been finished for the whole project, perform any cleanup or report issues found
abstract  boolean appliesTo(Context context, File file)
          Returns true if this detector applies to the given file
 void beforeCheckFile(Context context)
          Analysis is about to be performed on a specific file, perform any setup steps.
 void beforeCheckProject(Context context)
          Analysis is about to begin, perform any setup steps.
abstract  Speed getSpeed()
          Returns the expected speed of this detector
abstract  void run(Context context)
          Runs the detector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Detector

public Detector()
Method Detail

run

public abstract void run(Context context)
Runs the detector

Parameters:
context - the context describing the work to be done

appliesTo

public abstract boolean appliesTo(Context context,
                                  File file)
Returns true if this detector applies to the given file


beforeCheckProject

public void beforeCheckProject(Context context)
Analysis is about to begin, perform any setup steps.

TODO: Rename "check" to "scan" here? beforeScanProject, beforeScanFile etc?


afterCheckProject

public void afterCheckProject(Context context)
Analysis has just been finished for the whole project, perform any cleanup or report issues found


beforeCheckFile

public void beforeCheckFile(Context context)
Analysis is about to be performed on a specific file, perform any setup steps.


afterCheckFile

public void afterCheckFile(Context context)
Analysis has just been finished for a specific file, perform any cleanup or report issues found


getSpeed

public abstract Speed getSpeed()
Returns the expected speed of this detector

Returns:
the expected speed of this detector


Copyright © 2008-2012. All Rights Reserved.