com.android.tools.lint.client.api
Class LintClient

java.lang.Object
  extended by com.android.tools.lint.client.api.LintClient

public abstract class LintClient
extends Object

Information about the tool embedding the lint analyzer. IDEs and other tools implementing lint support will extend this to integrate logging, displaying errors, etc.

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.


Constructor Summary
LintClient()
           
 
Method Summary
 Configuration getConfiguration(Project project)
          Returns a configuration for use by the given project.
 List<File> getJavaClassFolders(Project project)
          Returns the list of output folders for class files
 List<File> getJavaSourceFolders(Project project)
          Returns the list of source folders for Java source files
abstract  IDomParser getParser()
          Returns a IDomParser to use to parse XML
abstract  void log(Throwable exception, String format, Object... args)
          Send an exception to the log
abstract  String readFile(File file)
          Reads the given text file and returns the content as a string
 Class<? extends Detector> replaceDetector(Class<? extends Detector> detectorClass)
          Returns an optimal detector, if applicable.
abstract  void report(Context context, Issue issue, Location location, String message, Object data)
          Report the given issue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LintClient

public LintClient()
Method Detail

getConfiguration

public Configuration getConfiguration(Project project)
Returns a configuration for use by the given project. The configuration provides information about which issues are enabled, any customizations to the severity of an issue, etc.

By default this method returns a DefaultConfiguration.

Parameters:
project - the project to obtain a configuration for
Returns:
a configuration, never null.

report

public abstract void report(Context context,
                            Issue issue,
                            Location location,
                            String message,
                            Object data)
Report the given issue. This method will only be called if the configuration provided by getConfiguration(Project) has reported the corresponding issue as enabled and has not filtered out the issue with its Configuration.ignore(Context, Issue, Location, String, Object) method.

Parameters:
context - the context used by the detector when the issue was found
issue - the issue that was found
location - the location of the issue
message - the associated user message
data - optional extra data for a discovered issue, or null. The content depends on the specific issue. Detectors can pass extra info here which automatic fix tools etc can use to extract relevant information instead of relying on parsing the error message text. See each detector for details on which data if any is supplied for a given issue.

log

public abstract void log(Throwable exception,
                         String format,
                         Object... args)
Send an exception to the log

Parameters:
exception - the exception, possibly null
format - the error message using String.format(java.lang.String, java.lang.Object...) syntax
args - any arguments for the format string

replaceDetector

public Class<? extends Detector> replaceDetector(Class<? extends Detector> detectorClass)
Returns an optimal detector, if applicable. By default, just returns the original detector, but tools can replace detectors using this hook with a version that takes advantage of native capabilities of the tool.

Parameters:
detectorClass - the class of the detector to be replaced
Returns:
the new detector class, or just the original detector (not null)

getParser

public abstract IDomParser getParser()
Returns a IDomParser to use to parse XML

Returns:
a new IDomParser

readFile

public abstract String readFile(File file)
Reads the given text file and returns the content as a string

Parameters:
file - the file to read
Returns:
the string to return, never null (will be empty if there is an I/O error)

getJavaSourceFolders

public List<File> getJavaSourceFolders(Project project)
Returns the list of source folders for Java source files

Parameters:
project - the project to look up Java source file locations for
Returns:
a list of source folders to search for .java files

getJavaClassFolders

public List<File> getJavaClassFolders(Project project)
Returns the list of output folders for class files

Parameters:
project - the project to look up class file locations for
Returns:
a list of output folders to search for .class files


Copyright © 2008-2012. All Rights Reserved.