|
|||||||||
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.Implementation
@Beta public class Implementation
An Implementation of an Issue
maps to the Detector
class responsible for analyzing the issue, as well as the Scope
required
by the detector to perform its analysis.
Constructor Summary | |
---|---|
Implementation(java.lang.Class<? extends Detector> detectorClass,
java.util.EnumSet<Scope> scope)
Creates a new implementation for analyzing one or more issues |
|
Implementation(java.lang.Class<? extends Detector> detectorClass,
java.util.EnumSet<Scope> scope,
java.util.EnumSet<Scope>... analysisScopes)
Creates a new implementation for analyzing one or more issues |
Method Summary | |
---|---|
java.util.EnumSet<Scope>[] |
getAnalysisScopes()
Returns the sets of scopes required to analyze this issue, or null if all scopes named by getScope() are necessary. |
java.lang.Class<? extends Detector> |
getDetectorClass()
Returns the class of the detector to use to find this issue |
java.util.EnumSet<Scope> |
getScope()
Returns the scope required to analyze the code to detect this issue. |
boolean |
isAdequate(java.util.EnumSet<Scope> scope)
Returns true if the given scope is adequate for analyzing this issue. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Implementation(@NonNull java.lang.Class<? extends Detector> detectorClass, @NonNull java.util.EnumSet<Scope> scope)
detectorClass
- the class of the detector to find this issuescope
- the scope of files required to analyze this issuepublic Implementation(@NonNull java.lang.Class<? extends Detector> detectorClass, @NonNull java.util.EnumSet<Scope> scope, @NonNull java.util.EnumSet<Scope>... analysisScopes)
detectorClass
- the class of the detector to find this issuescope
- the scope of files required to analyze this issueanalysisScopes
- optional set of extra scopes the detector is capable of working inMethod Detail |
---|
@NonNull public java.lang.Class<? extends Detector> getDetectorClass()
public java.lang.String toString()
toString
in class java.lang.Object
@NonNull public java.util.EnumSet<Scope> getScope()
@NonNull public java.util.EnumSet<Scope>[] getAnalysisScopes()
getScope()
are necessary. Note that only
one match out of this collection is required, not all, and that
the scope set returned by getScope()
does not have to be returned
by this method, but is always implied to be included.
The scopes returned by getScope()
list all the various
scopes that are affected by this issue, meaning the detector
should consider it. Frequently, the detector must analyze all these
scopes in order to properly decide whether an issue is found. For
example, the unused resource detector needs to consider both the XML
resource files and the Java source files in order to decide if a resource
is unused. If it analyzes just the Java files for example, it might
incorrectly conclude that a resource is unused because it did not
discover a resource reference in an XML file.
However, there are other issues where the issue can occur in a variety of files, but the detector can consider each in isolation. For example, the API checker is affected by both XML files and Java class files (detecting both layout constructor references in XML layout files as well as code references in .class files). It doesn't have to analyze both; it is capable of incrementally analyzing just an XML file, or just a class file, without considering the other.
The required scope list provides a list of scope sets that can be used to analyze this issue. For each scope set, all the scopes must be matched by the incremental analysis, but any one of the scope sets can be analyzed in isolation.
The required scope list is not required to include the full scope set
returned by getScope()
; that set is always assumed to be
included.
NOTE: You would normally call isAdequate(EnumSet)
rather
than calling this method directly.
public boolean isAdequate(@NonNull java.util.EnumSet<Scope> scope)
getAnalysisScopes()
) and if the scope passed in fully
covers at least one of them, or if it covers the scope of the issue
itself (see getScope()
, which should be a superset of all the
analysis scopes) returns true.
The scope set returned by getScope()
lists all the various
scopes that are affected by this issue, meaning the detector
should consider it. Frequently, the detector must analyze all these
scopes in order to properly decide whether an issue is found. For
example, the unused resource detector needs to consider both the XML
resource files and the Java source files in order to decide if a resource
is unused. If it analyzes just the Java files for example, it might
incorrectly conclude that a resource is unused because it did not
discover a resource reference in an XML file.
However, there are other issues where the issue can occur in a variety of files, but the detector can consider each in isolation. For example, the API checker is affected by both XML files and Java class files (detecting both layout constructor references in XML layout files as well as code references in .class files). It doesn't have to analyze both; it is capable of incrementally analyzing just an XML file, or just a class file, without considering the other.
An issue can register additional scope sets that can are adequate
for analyzing the issue, by supplying it to
Implementation(Class, java.util.EnumSet, java.util.EnumSet[])
.
This method returns true if the given scope matches one or more analysis
scope, or the overall scope.
scope
- the scope available for analysis
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |