public class ApiDetector
extends com.android.tools.lint.detector.api.ResourceXmlDetector
implements com.android.tools.lint.detector.api.Detector.UastScanner, com.android.tools.lint.detector.api.Detector.ResourceFolderScanner
com.android.tools.lint.detector.api.Detector.BinaryResourceScanner, com.android.tools.lint.detector.api.Detector.ClassScanner, com.android.tools.lint.detector.api.Detector.GradleScanner, com.android.tools.lint.detector.api.Detector.JavaPsiScanner, com.android.tools.lint.detector.api.Detector.JavaScanner, com.android.tools.lint.detector.api.Detector.OtherFileScanner, com.android.tools.lint.detector.api.Detector.ResourceFolderScanner, com.android.tools.lint.detector.api.Detector.UastScanner, com.android.tools.lint.detector.api.Detector.XmlScanner
Modifier and Type | Field and Description |
---|---|
static com.android.tools.lint.detector.api.Issue |
INLINED
Accessing an inlined API on older platforms
|
protected ApiLookup |
mApiDatabase |
static com.android.tools.lint.detector.api.Issue |
OBSOLETE_SDK
Obsolete SDK_INT version check
|
static com.android.tools.lint.detector.api.Issue |
OVERRIDE
Method conflicts with new inherited method
|
static java.lang.String |
REQUIRES_API_ANNOTATION |
static java.lang.String |
SDK_SUPPRESS_ANNOTATION |
static com.android.tools.lint.detector.api.Issue |
UNSUPPORTED
Accessing an unsupported API
|
static com.android.tools.lint.detector.api.Issue |
UNUSED
Attribute unused on older versions
|
Constructor and Description |
---|
ApiDetector()
Constructs a new API check
|
Modifier and Type | Method and Description |
---|---|
boolean |
appliesTo(com.android.resources.ResourceFolderType folderType) |
void |
beforeCheckProject(com.android.tools.lint.detector.api.Context context) |
void |
checkFolder(com.android.tools.lint.detector.api.ResourceContext context,
java.lang.String folderName) |
protected void |
checkObsoleteSdkVersion(com.android.tools.lint.detector.api.JavaContext context,
org.jetbrains.uast.UElement node) |
com.android.tools.lint.client.api.UElementHandler |
createUastHandler(com.android.tools.lint.detector.api.JavaContext context) |
java.util.Collection<java.lang.String> |
getApplicableAttributes() |
java.util.Collection<java.lang.String> |
getApplicableElements() |
java.util.List<java.lang.Class<? extends org.jetbrains.uast.UElement>> |
getApplicableUastTypes() |
static com.android.tools.lint.detector.api.Location |
getCatchParametersLocation(com.android.tools.lint.detector.api.JavaContext context,
org.jetbrains.uast.UCatchClause catchClause) |
protected int |
getMinSdk(com.android.tools.lint.detector.api.Context context) |
static int |
getRequiredVersion(com.android.tools.lint.detector.api.Issue issue,
java.lang.String errorMessage,
com.android.tools.lint.detector.api.TextFormat format) |
static int |
getTargetApi(com.intellij.psi.PsiModifierList modifierList)
Returns the API level for the given AST node if specified with
an
@TargetApi annotation. |
static int |
getTargetApi(org.jetbrains.uast.UElement scope) |
static boolean |
isBenignConstantUsage(org.jetbrains.uast.UElement node,
java.lang.String name,
java.lang.String owner)
Checks whether the given instruction is a benign usage of a constant defined in
a later version of Android than the application's
minSdkVersion . |
static boolean |
isBenignUnusedAttribute(java.lang.String name)
Is the given attribute a "benign" unused attribute, one we probably don't need to
flag to the user as not applicable on all versions? These are typically attributes
which add some nice platform behavior when available, but that are not critical
and developers would not typically need to be aware of to try to implement workarounds
on older platforms.
|
static boolean |
isMultiCatchReflectiveOperationException(org.jetbrains.uast.UCatchClause catchClause) |
void |
visitAttribute(com.android.tools.lint.detector.api.XmlContext context,
org.w3c.dom.Attr attribute) |
void |
visitElement(com.android.tools.lint.detector.api.XmlContext context,
org.w3c.dom.Element element) |
afterCheckFile, afterCheckLibraryProject, afterCheckProject, applicableSuperClasses, appliesTo, appliesToResourceRefs, beforeCheckFile, beforeCheckLibraryProject, checkBinaryResource, checkCall, checkClass, checkClass, checkClass, checkInstruction, createJavaVisitor, createPsiVisitor, getApplicableAsmNodeTypes, getApplicableCallNames, getApplicableCallOwners, getApplicableConstructorTypes, getApplicableFiles, getApplicableMethodNames, getApplicableNodeTypes, getApplicablePsiTypes, getApplicableReferenceNames, getSpeed, getSpeed, visitBuildScript, visitClass, visitClass, visitConstructor, visitConstructor, visitConstructor, visitDocument, visitElementAfter, visitMethod, visitMethod, visitMethod, visitReference, visitReference, visitResourceReference, visitResourceReference, visitResourceReference
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applicableSuperClasses, appliesToResourceRefs, getApplicableConstructorTypes, getApplicableMethodNames, getApplicablePsiTypes, getApplicableReferenceNames, visitClass, visitClass, visitConstructor, visitMethod, visitReference, visitResourceReference
public static final java.lang.String REQUIRES_API_ANNOTATION
public static final java.lang.String SDK_SUPPRESS_ANNOTATION
public static final com.android.tools.lint.detector.api.Issue UNSUPPORTED
public static final com.android.tools.lint.detector.api.Issue INLINED
public static final com.android.tools.lint.detector.api.Issue OVERRIDE
public static final com.android.tools.lint.detector.api.Issue UNUSED
public static final com.android.tools.lint.detector.api.Issue OBSOLETE_SDK
protected ApiLookup mApiDatabase
public void beforeCheckProject(@NonNull com.android.tools.lint.detector.api.Context context)
beforeCheckProject
in class com.android.tools.lint.detector.api.Detector
public boolean appliesTo(@NonNull com.android.resources.ResourceFolderType folderType)
appliesTo
in interface com.android.tools.lint.detector.api.Detector.ResourceFolderScanner
appliesTo
in class com.android.tools.lint.detector.api.ResourceXmlDetector
public java.util.Collection<java.lang.String> getApplicableElements()
getApplicableElements
in interface com.android.tools.lint.detector.api.Detector.XmlScanner
getApplicableElements
in class com.android.tools.lint.detector.api.Detector
public java.util.Collection<java.lang.String> getApplicableAttributes()
getApplicableAttributes
in interface com.android.tools.lint.detector.api.Detector.XmlScanner
getApplicableAttributes
in class com.android.tools.lint.detector.api.Detector
public void visitAttribute(@NonNull com.android.tools.lint.detector.api.XmlContext context, @NonNull org.w3c.dom.Attr attribute)
visitAttribute
in interface com.android.tools.lint.detector.api.Detector.XmlScanner
visitAttribute
in class com.android.tools.lint.detector.api.Detector
public static boolean isBenignUnusedAttribute(@NonNull java.lang.String name)
public void visitElement(@NonNull com.android.tools.lint.detector.api.XmlContext context, @NonNull org.w3c.dom.Element element)
visitElement
in interface com.android.tools.lint.detector.api.Detector.XmlScanner
visitElement
in class com.android.tools.lint.detector.api.Detector
protected int getMinSdk(com.android.tools.lint.detector.api.Context context)
@Nullable public com.android.tools.lint.client.api.UElementHandler createUastHandler(@NonNull com.android.tools.lint.detector.api.JavaContext context)
createUastHandler
in interface com.android.tools.lint.detector.api.Detector.UastScanner
createUastHandler
in class com.android.tools.lint.detector.api.Detector
public java.util.List<java.lang.Class<? extends org.jetbrains.uast.UElement>> getApplicableUastTypes()
getApplicableUastTypes
in interface com.android.tools.lint.detector.api.Detector.UastScanner
getApplicableUastTypes
in class com.android.tools.lint.detector.api.Detector
public static boolean isBenignConstantUsage(@Nullable org.jetbrains.uast.UElement node, @NonNull java.lang.String name, @NonNull java.lang.String owner)
minSdkVersion
.node
- the instruction to checkname
- the name of the constantowner
- the field ownerpublic static int getTargetApi(@Nullable org.jetbrains.uast.UElement scope)
public static int getTargetApi(@Nullable com.intellij.psi.PsiModifierList modifierList)
@TargetApi
annotation.modifierList
- the modifier list to checkpublic static int getRequiredVersion(@NonNull com.android.tools.lint.detector.api.Issue issue, @NonNull java.lang.String errorMessage, @NonNull com.android.tools.lint.detector.api.TextFormat format)
protected void checkObsoleteSdkVersion(@NonNull com.android.tools.lint.detector.api.JavaContext context, @NonNull org.jetbrains.uast.UElement node)
public void checkFolder(@NonNull com.android.tools.lint.detector.api.ResourceContext context, @NonNull java.lang.String folderName)
checkFolder
in interface com.android.tools.lint.detector.api.Detector.ResourceFolderScanner
checkFolder
in class com.android.tools.lint.detector.api.Detector
public static com.android.tools.lint.detector.api.Location getCatchParametersLocation(com.android.tools.lint.detector.api.JavaContext context, org.jetbrains.uast.UCatchClause catchClause)
public static boolean isMultiCatchReflectiveOperationException(org.jetbrains.uast.UCatchClause catchClause)