@Beta
public class Implementation
extends java.lang.Object
Issue maps to the Detector class responsible
for analyzing the issue, as well as the Scope required by the detector to perform its
analysis.
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 and Description |
|---|
Implementation(java.lang.Class<? extends com.android.tools.lint.detector.api.Detector> detectorClass,
java.util.EnumSet<com.android.tools.lint.detector.api.Scope> scope)
Creates a new implementation for analyzing one or more issues
|
Implementation(java.lang.Class<? extends com.android.tools.lint.detector.api.Detector> detectorClass,
java.util.EnumSet<com.android.tools.lint.detector.api.Scope> scope,
java.util.EnumSet<com.android.tools.lint.detector.api.Scope>... analysisScopes)
Creates a new implementation for analyzing one or more issues
|
| Modifier and Type | Method and Description |
|---|---|
java.util.EnumSet<com.android.tools.lint.detector.api.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 com.android.tools.lint.detector.api.Detector> |
getDetectorClass()
Returns the class of the detector to use to find this issue
|
java.util.EnumSet<com.android.tools.lint.detector.api.Scope> |
getScope()
Returns the scope required to analyze the code to detect this issue.
|
boolean |
isAdequate(java.util.EnumSet<com.android.tools.lint.detector.api.Scope> scope)
Returns true if the given scope is adequate for analyzing this issue.
|
java.lang.String |
toString() |
public Implementation(@NonNull
java.lang.Class<? extends com.android.tools.lint.detector.api.Detector> detectorClass,
@NonNull
java.util.EnumSet<com.android.tools.lint.detector.api.Scope> scope)
detectorClass - the class of the detector to find this issuescope - the scope of files required to analyze this issue@SafeVarargs
public Implementation(@NonNull
java.lang.Class<? extends com.android.tools.lint.detector.api.Detector> detectorClass,
@NonNull
java.util.EnumSet<com.android.tools.lint.detector.api.Scope> scope,
@NonNull
java.util.EnumSet<com.android.tools.lint.detector.api.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 in@NonNull public java.lang.Class<? extends com.android.tools.lint.detector.api.Detector> getDetectorClass()
public java.lang.String toString()
toString in class java.lang.Object@NonNull public java.util.EnumSet<com.android.tools.lint.detector.api.Scope> getScope()
@NonNull public java.util.EnumSet<com.android.tools.lint.detector.api.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<com.android.tools.lint.detector.api.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