|
||||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.android.build.gradle.tasks.annotations.Extractor
public class Extractor
Annotation extractor which looks for annotations in parsed compilation units and writes the annotations into a format suitable for use by IntelliJ and Android Studio etc; it's basically an XML file, organized by package, which lists the signatures for fields and methods in classes in the given package, and identifiers method parameters by index, and lists the annotations annotated on that element.
This is primarily intended for use in Android libraries such as the support library, where you want to use the resource int (StringRes, DrawableRes, and so on) annotations to indicate what types of id's are expected, or the IntDef or StringDef annotations to record which specific constants are allowed in int and String parameters.
However, the code is also used to extract SDK annotations from the platform, where the package names of the annotations differ slightly (and where the nullness annotations do not have class retention for example). Therefore, this code contains some extra support not needed when extracting annotations in an Android library, such as code to skip annotations for any method/field not mentioned in the API database, and code to rewrite the android.jar file to insert annotations in the generated bytecode.
TODO: - Warn if the @IntDef annotation is used on a non-int, and similarly if @StringDef is used on a non-string - Ignore annotations defined on
Field Summary | |
---|---|
static java.lang.String |
ANDROID_ANNOTATIONS_PREFIX
|
static java.lang.String |
ANDROID_INT_DEF
|
static java.lang.String |
ANDROID_NOTNULL
|
static java.lang.String |
ANDROID_NULLABLE
|
static java.lang.String |
ANDROID_STRING_DEF
|
static java.lang.String |
IDEA_CONTRACT
|
static java.lang.String |
IDEA_MAGIC
|
static java.lang.String |
IDEA_NON_NLS
|
static java.lang.String |
IDEA_NOTNULL
|
static java.lang.String |
IDEA_NULLABLE
|
static java.lang.String |
RESOURCE_TYPE_ANNOTATIONS_SUFFIX
|
static java.lang.String |
SUPPORT_NOTNULL
|
static java.lang.String |
SUPPORT_NULLABLE
|
Constructor Summary | |
Extractor(ApiDatabase apiFilter, java.io.File classDir)
|
Method Summary | |
---|---|
void
|
export(java.io.File output)
|
void
|
extractFromProjectSource(java.util.Collection units)
|
boolean
|
isListIgnored()
|
void
|
mergeExisting(java.io.File file)
|
void
|
removeTypedefClasses()
|
void
|
setListIgnored(boolean listIgnored)
|
void
|
writeStats()
|
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
public static final java.lang.String ANDROID_ANNOTATIONS_PREFIX
public static final java.lang.String ANDROID_INT_DEF
public static final java.lang.String ANDROID_NOTNULL
public static final java.lang.String ANDROID_NULLABLE
public static final java.lang.String ANDROID_STRING_DEF
public static final java.lang.String IDEA_CONTRACT
public static final java.lang.String IDEA_MAGIC
public static final java.lang.String IDEA_NON_NLS
public static final java.lang.String IDEA_NOTNULL
public static final java.lang.String IDEA_NULLABLE
public static final java.lang.String RESOURCE_TYPE_ANNOTATIONS_SUFFIX
public static final java.lang.String SUPPORT_NOTNULL
public static final java.lang.String SUPPORT_NULLABLE
Constructor Detail |
---|
public Extractor(@Nullable ApiDatabase apiFilter, @Nullable java.io.File classDir)
Method Detail |
---|
public void export(@NonNull java.io.File output)
public void extractFromProjectSource(java.util.Collection units)
public boolean isListIgnored()
public void mergeExisting(@NonNull java.io.File file)
public void removeTypedefClasses()
@SuppressWarnings("UnusedDeclaration") public void setListIgnored(boolean listIgnored)
public void writeStats()
Copyright (C) 2012 The Android Open Source Project