|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.android.tools.lint.detector.api.Detector
@Beta public abstract class Detector
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.
Detectors will be called in a predefined order:
LintDriver.requestRepeat(com.android.tools.lint.detector.api.Detector, java.util.EnumSet)
.
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 file parse trees |
static interface |
Detector.OtherFileScanner
Specialized interface for detectors that scan other files |
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 |
afterCheckLibraryProject(Context context)
Analysis has just been finished for the given library project, perform any cleanup or report issues that require library-project-wide analysis. |
void |
afterCheckProject(Context context)
Analysis has just been finished for the whole project, perform any cleanup or report issues that require project-wide analysis. |
boolean |
appliesTo(Context context,
java.io.File file)
Returns true if this detector applies to the given file |
boolean |
appliesToFolder(Scope scope,
com.android.resources.ResourceFolderType folderType)
|
boolean |
appliesToResourceRefs()
|
void |
beforeCheckFile(Context context)
Analysis is about to be performed on a specific file, perform any setup steps. |
void |
beforeCheckLibraryProject(Context context)
Analysis is about to begin for the given library project, perform any setup steps. |
void |
beforeCheckProject(Context context)
Analysis is about to begin, perform any setup steps. |
void |
checkCall(ClassContext context,
org.objectweb.asm.tree.ClassNode classNode,
org.objectweb.asm.tree.MethodNode method,
org.objectweb.asm.tree.MethodInsnNode call)
|
void |
checkClass(ClassContext context,
org.objectweb.asm.tree.ClassNode classNode)
|
void |
checkInstruction(ClassContext context,
org.objectweb.asm.tree.ClassNode classNode,
org.objectweb.asm.tree.MethodNode method,
org.objectweb.asm.tree.AbstractInsnNode instruction)
|
lombok.ast.AstVisitor |
createJavaVisitor(JavaContext context)
|
int[] |
getApplicableAsmNodeTypes()
|
java.util.Collection<java.lang.String> |
getApplicableAttributes()
|
java.util.List<java.lang.String> |
getApplicableCallNames()
|
java.util.List<java.lang.String> |
getApplicableCallOwners()
|
java.util.Collection<java.lang.String> |
getApplicableElements()
|
java.util.EnumSet<Scope> |
getApplicableFiles()
|
java.util.List<java.lang.String> |
getApplicableMethodNames()
|
java.util.List<java.lang.Class<? extends lombok.ast.Node>> |
getApplicableNodeTypes()
|
Speed |
getSpeed()
Returns the expected speed of this detector |
void |
run(Context context)
Runs the detector. |
void |
visitAttribute(XmlContext context,
org.w3c.dom.Attr attribute)
|
void |
visitDocument(XmlContext context,
org.w3c.dom.Document document)
|
void |
visitElement(XmlContext context,
org.w3c.dom.Element element)
|
void |
visitElementAfter(XmlContext context,
org.w3c.dom.Element element)
|
void |
visitMethod(JavaContext context,
lombok.ast.AstVisitor visitor,
lombok.ast.MethodInvocation node)
|
void |
visitResourceReference(JavaContext context,
lombok.ast.AstVisitor visitor,
lombok.ast.Node node,
java.lang.String type,
java.lang.String name,
boolean isFramework)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Detector()
Method Detail |
---|
public void run(@NonNull Context context)
Detector.XmlScanner
and Detector.JavaScanner
, where
there are specialized analysis methods instead such as
Detector.XmlScanner.visitElement(XmlContext, Element)
.
context
- the context describing the work to be donepublic boolean appliesTo(@NonNull Context context, @NonNull java.io.File file)
context
- the context to checkfile
- the file in the context to check
public void beforeCheckProject(@NonNull Context context)
context
- the context for the check referencing the project, lint
client, etcpublic void afterCheckProject(@NonNull Context context)
context
- the context for the check referencing the project, lint
client, etcpublic void beforeCheckLibraryProject(@NonNull Context context)
context
- the context for the check referencing the project, lint
client, etcpublic void afterCheckLibraryProject(@NonNull Context context)
context
- the context for the check referencing the project, lint
client, etcpublic void beforeCheckFile(@NonNull Context context)
Note: When this method is called at the beginning of checking an XML
file, the context is guaranteed to be an instance of XmlContext
,
and similarly for a Java source file, the context will be a
JavaContext
and so on.
context
- the context for the check referencing the file to be
checked, the project, etc.public void afterCheckFile(@NonNull Context context)
Note: When this method is called at the end of checking an XML
file, the context is guaranteed to be an instance of XmlContext
,
and similarly for a Java source file, the context will be a
JavaContext
and so on.
context
- the context for the check referencing the file to be
checked, the project, etc.@NonNull public Speed getSpeed()
public void visitDocument(@NonNull XmlContext context, @NonNull org.w3c.dom.Document document)
public void visitElement(@NonNull XmlContext context, @NonNull org.w3c.dom.Element element)
public void visitElementAfter(@NonNull XmlContext context, @NonNull org.w3c.dom.Element element)
public void visitAttribute(@NonNull XmlContext context, @NonNull org.w3c.dom.Attr attribute)
@Nullable public java.util.Collection<java.lang.String> getApplicableElements()
@Nullable public java.util.Collection<java.lang.String> getApplicableAttributes()
@Nullable public java.util.List<java.lang.String> getApplicableMethodNames()
@Nullable public lombok.ast.AstVisitor createJavaVisitor(@NonNull JavaContext context)
@Nullable public java.util.List<java.lang.Class<? extends lombok.ast.Node>> getApplicableNodeTypes()
public void visitMethod(@NonNull JavaContext context, @Nullable lombok.ast.AstVisitor visitor, @NonNull lombok.ast.MethodInvocation node)
public boolean appliesToResourceRefs()
public void visitResourceReference(@NonNull JavaContext context, @Nullable lombok.ast.AstVisitor visitor, @NonNull lombok.ast.Node node, @NonNull java.lang.String type, @NonNull java.lang.String name, boolean isFramework)
public void checkClass(@NonNull ClassContext context, @NonNull org.objectweb.asm.tree.ClassNode classNode)
@Nullable public java.util.List<java.lang.String> getApplicableCallNames()
@Nullable public java.util.List<java.lang.String> getApplicableCallOwners()
public void checkCall(@NonNull ClassContext context, @NonNull org.objectweb.asm.tree.ClassNode classNode, @NonNull org.objectweb.asm.tree.MethodNode method, @NonNull org.objectweb.asm.tree.MethodInsnNode call)
@Nullable public int[] getApplicableAsmNodeTypes()
public void checkInstruction(@NonNull ClassContext context, @NonNull org.objectweb.asm.tree.ClassNode classNode, @NonNull org.objectweb.asm.tree.MethodNode method, @NonNull org.objectweb.asm.tree.AbstractInsnNode instruction)
public boolean appliesToFolder(@NonNull Scope scope, @Nullable com.android.resources.ResourceFolderType folderType)
@NonNull public java.util.EnumSet<Scope> getApplicableFiles()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |