|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.android.tools.lint.client.api.LintDriver
@Beta public class LintDriver
Analyzes Android projects and files
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 | |
---|---|
LintDriver(IssueRegistry registry,
LintClient client)
Creates a new LintDriver |
Method Summary | |
---|---|
void |
addLintListener(LintListener listener)
Adds a listener to be notified of lint progress |
void |
analyze(LintRequest request)
Analyze the given files (which can point to Android projects or directories containing Android projects). |
void |
analyze(java.util.List<java.io.File> files,
java.util.EnumSet<Scope> scope)
Deprecated. use instead |
void |
cancel()
Cancels the current lint run as soon as possible |
org.objectweb.asm.tree.ClassNode |
findClass(ClassContext context,
java.lang.String type,
int flags)
Returns the ClassNode corresponding to the given type, if possible, or null |
Project |
findProjectFor(java.io.File file)
Returns the project containing a given file, or null if not found. |
LintClient |
getClient()
Returns the lint client requesting the lint check. |
org.objectweb.asm.tree.ClassNode |
getOuterClassNode(org.objectweb.asm.tree.ClassNode classNode)
Returns the outer class node of the given class node |
int |
getPhase()
Returns the current phase number. |
java.util.List<Project> |
getProjects()
Returns the projects being analyzed |
java.lang.Object |
getProperty(java.lang.Object key)
Returns the property previously stored with the given key, or null |
IssueRegistry |
getRegistry()
Returns the current IssueRegistry . |
LintRequest |
getRequest()
Returns the current request, which points to the original files to be checked, the original scope, the original LintClient , as well as the release mode. |
int |
getResourceFolderVersion(java.io.File resourceFile)
Returns the folder version of the given file. |
java.util.EnumSet<Scope> |
getScope()
Returns the scope for the lint job |
java.lang.String |
getSuperClass(java.lang.String name)
Returns the super class for the given class name, which should be in VM format (e.g. |
boolean |
hasParserErrors()
Returns whether lint has encountered any files with fatal parser errors (e.g. |
boolean |
isAbbreviating()
Returns whether lint should abbreviate output when appropriate. |
boolean |
isCustomIssue(Issue issue)
Returns true if the given issue is an issue that was loaded as a custom rule (e.g. |
boolean |
isSubclassOf(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String superClassName)
Returns true if the given class is a subclass of the given super class. |
boolean |
isSuppressed(Issue issue,
org.objectweb.asm.tree.ClassNode classNode)
Returns whether the given issue is suppressed in the given class. |
boolean |
isSuppressed(Issue issue,
org.objectweb.asm.tree.ClassNode classNode,
org.objectweb.asm.tree.MethodNode method,
org.objectweb.asm.tree.AbstractInsnNode instruction)
Returns whether the given issue is suppressed in the given method. |
boolean |
isSuppressed(Issue issue,
org.objectweb.asm.tree.FieldNode field)
Returns whether the given issue is suppressed for the given field. |
boolean |
isSuppressed(JavaContext context,
Issue issue,
lombok.ast.Node scope)
Returns whether the given issue is suppressed in the given parse tree node. |
boolean |
isSuppressed(XmlContext context,
Issue issue,
org.w3c.dom.Node node)
Returns whether the given issue is suppressed in the given XML DOM node. |
void |
putProperty(java.lang.Object key,
java.lang.Object value)
Records a property for later retrieval by getProperty(Object) |
void |
removeLintListener(LintListener listener)
Removes a listener such that it is no longer notified of progress |
void |
requestRepeat(Detector detector,
java.util.EnumSet<Scope> scope)
Requests another pass through the data for the given detector. |
void |
setAbbreviating(boolean abbreviating)
Sets whether lint should abbreviate output when appropriate. |
void |
setHasParserErrors(boolean hasErrors)
Sets whether lint has encountered files with fatal parser errors. |
void |
setScope(java.util.EnumSet<Scope> scope)
Sets the scope for the lint job |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LintDriver(@NonNull IssueRegistry registry, @NonNull LintClient client)
LintDriver
registry
- The registry containing issues to be checkedclient
- the tool wrapping the analyzer, such as an IDE or a CLIMethod Detail |
---|
public void cancel()
@NonNull public java.util.EnumSet<Scope> getScope()
public void setScope(@NonNull java.util.EnumSet<Scope> scope)
scope
- the scope to use@NonNull public LintClient getClient()
LintClient
is suitable for use by detectors to look
up a client to for example get location handles from, but tool handling code should
never try to cast this client back to their original lint client. For the original
lint client, use LintRequest
instead.
@NonNull public LintRequest getRequest()
LintClient
, as well as the release mode.
public void putProperty(@NonNull java.lang.Object key, @Nullable java.lang.Object value)
getProperty(Object)
key
- the key to associate the value withvalue
- the value, or null to remove a previous binding@Nullable public java.lang.Object getProperty(@NonNull java.lang.Object key)
key
- the key
public int getPhase()
Detector
calls requestRepeat(com.android.tools.lint.detector.api.Detector, java.util.EnumSet)
.
@NonNull public IssueRegistry getRegistry()
IssueRegistry
.
IssueRegistry
@Nullable public Project findProjectFor(@NonNull java.io.File file)
file
- the file to be checked
public void setAbbreviating(boolean abbreviating)
abbreviating
- true to abbreviate output, false to include everythingpublic boolean isAbbreviating()
public boolean hasParserErrors()
This is useful for checks that need to make sure they've seen all data in order to be conclusive (such as an unused resource check).
public void setHasParserErrors(boolean hasErrors)
hasErrors
- whether parser errors have been encounteredhasParserErrors()
@NonNull public java.util.List<Project> getProjects()
@Deprecated public void analyze(@NonNull java.util.List<java.io.File> files, @Nullable java.util.EnumSet<Scope> scope)
instead
LintClient
.
files
- the files and directories to be analyzedscope
- the scope of the analysis; detectors with a wider scope will
not be run. If null, the scope will be inferred from the files.public void analyze(@NonNull LintRequest request)
LintClient
.
Note that the LintDriver
is not multi thread safe or re-entrant;
if you want to run potentially overlapping lint jobs, create a separate driver
for each job.
request
- the files and directories to be analyzedpublic boolean isCustomIssue(@NonNull Issue issue)
issue
- the issue to be looked up
@Nullable public java.lang.String getSuperClass(@NonNull java.lang.String name)
name
- the fully qualified class name
public boolean isSubclassOf(@NonNull org.objectweb.asm.tree.ClassNode classNode, @NonNull java.lang.String superClassName)
classNode
- the class to check whether it is a subclass of the given
super class namesuperClassName
- the fully qualified super class name (in VM format,
e.g. java/lang/Integer, not java.lang.Integer.
public org.objectweb.asm.tree.ClassNode getOuterClassNode(@NonNull org.objectweb.asm.tree.ClassNode classNode)
classNode
- the inner class node
@Nullable public org.objectweb.asm.tree.ClassNode findClass(@NonNull ClassContext context, @NonNull java.lang.String type, int flags)
ClassNode
corresponding to the given type, if possible, or null
type
- the fully qualified type, using JVM signatures (/ and $, not . as path
separators)flags
- the ASM flags to pass to the ClassReader
, normally 0 but can
for example be ClassReader.SKIP_CODE
and/oor
ClassReader.SKIP_DEBUG
public void addLintListener(@NonNull LintListener listener)
listener
- the listener to be addedpublic void removeLintListener(@NonNull LintListener listener)
listener
- the listener to be removedpublic void requestRepeat(@NonNull Detector detector, @Nullable java.util.EnumSet<Scope> scope)
detector
- the detector that should be included in the next pass.
Note that the lint runner may refuse to run more than a couple
of runs.scope
- the scope to be revisited. This must be a subset of the
current scope (getScope()
, and it is just a performance hint;
in particular, the detector should be prepared to be called on other
scopes as well (since they may have been requested by other detectors).
You can pall null to indicate "all".public boolean isSuppressed(@Nullable Issue issue, @NonNull org.objectweb.asm.tree.ClassNode classNode, @NonNull org.objectweb.asm.tree.MethodNode method, @Nullable org.objectweb.asm.tree.AbstractInsnNode instruction)
issue
- the issue to be checked, or null to just check for "all"classNode
- the class containing the issuemethod
- the method containing the issueinstruction
- the instruction within the method, if any
public boolean isSuppressed(@Nullable Issue issue, @NonNull org.objectweb.asm.tree.FieldNode field)
issue
- the issue to be checked, or null to just check for "all"field
- the field potentially annotated with a suppress annotation
public boolean isSuppressed(@Nullable Issue issue, @NonNull org.objectweb.asm.tree.ClassNode classNode)
issue
- the issue to be checked, or null to just check for "all"classNode
- the class containing the issue
public boolean isSuppressed(@Nullable JavaContext context, @NonNull Issue issue, @Nullable lombok.ast.Node scope)
context
- the context for the source being scannedissue
- the issue to be checked, or null to just check for "all"scope
- the AST node containing the issue
public boolean isSuppressed(@Nullable XmlContext context, @NonNull Issue issue, @Nullable org.w3c.dom.Node node)
issue
- the issue to be checked, or null to just check for "all"node
- the DOM node containing the issue
public int getResourceFolderVersion(@NonNull java.io.File resourceFile)
resourceFile
- the file to be checked
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |