public class Extractor
extends java.lang.Object
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
Extractor.ClassKind |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ANDROID_ANNOTATIONS_PREFIX |
static java.lang.String |
ANDROID_INT_DEF |
static java.lang.String |
ANDROID_INT_RANGE |
static java.lang.String |
ANDROID_LONG_DEF |
static java.lang.String |
ANDROID_NOTNULL |
static java.lang.String |
ANDROID_NULLABLE |
static java.lang.String |
ANDROID_REQUIRES_PERMISSION |
static java.lang.String |
ANDROID_STRING_DEF |
static java.lang.String |
ATTR_PURE |
static java.lang.String |
ATTR_VAL |
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 boolean |
REMOVE_HIDDEN_TYPEDEFS
If true, remove typedefs (even public ones) if they are marked with
@hide. |
static java.lang.String |
REQUIRES_PERMISSION |
static java.lang.String |
RESOURCE_TYPE_ANNOTATIONS_SUFFIX |
static java.lang.String |
SUPPORT_KEEP |
static java.lang.String |
SUPPORT_NOTNULL |
static java.lang.String |
SUPPORT_NULLABLE |
| Constructor and Description |
|---|
Extractor(ApiDatabase apiFilter,
java.util.Collection<java.io.File> classDir,
boolean displayInfo,
boolean includeClassRetentionAnnotations,
boolean sortAnnotations) |
| Modifier and Type | Method and Description |
|---|---|
static void |
addJavaSources(java.util.List<java.io.File> list,
java.io.File file) |
com.android.tools.lint.annotations.Extractor.AnnotationData |
createData(java.lang.String name,
org.jetbrains.uast.UAnnotation annotation) |
static java.util.List<? extends com.intellij.psi.PsiFile> |
createUnitsForFiles(com.intellij.openapi.project.Project project,
java.util.List<java.io.File> specificSources) |
static java.util.List<? extends com.intellij.psi.PsiFile> |
createUnitsInDirectories(com.intellij.openapi.project.Project project,
java.util.List<java.io.File> sourceDirs) |
void |
export(java.io.File annotationsZip,
java.io.File proguardCfg) |
void |
extractFromProjectSource(java.util.List<? extends com.intellij.psi.PsiFile> units) |
static java.util.List<java.io.File> |
gatherSources(java.util.List<java.io.File> sourcePath) |
static boolean |
isHiddenTypeDef(org.jetbrains.uast.UClass declaration)
Returns true if this type declaration for a typedef is hidden (e.g.
|
boolean |
isListIgnored() |
void |
mergeExisting(java.io.File file) |
void |
removeTypedefClasses() |
static void |
removeTypedefClasses(java.util.Collection<java.io.File> classDirs,
java.io.File typedefFile) |
void |
setListIgnored(boolean listIgnored) |
void |
writeStats() |
void |
writeTypedefFile(java.io.File file) |
public static final boolean REMOVE_HIDDEN_TYPEDEFS
@hide.
This is disabled because for some reason, the ECJ nodes do not provide valid
contents of javadoc entries for classes.public static final java.lang.String ANDROID_ANNOTATIONS_PREFIX
public static final java.lang.String ANDROID_NULLABLE
public static final java.lang.String SUPPORT_NULLABLE
public static final java.lang.String SUPPORT_KEEP
public static final java.lang.String RESOURCE_TYPE_ANNOTATIONS_SUFFIX
public static final java.lang.String ANDROID_NOTNULL
public static final java.lang.String SUPPORT_NOTNULL
public static final java.lang.String ANDROID_INT_DEF
public static final java.lang.String ANDROID_LONG_DEF
public static final java.lang.String ANDROID_INT_RANGE
public static final java.lang.String ANDROID_STRING_DEF
public static final java.lang.String REQUIRES_PERMISSION
public static final java.lang.String ANDROID_REQUIRES_PERMISSION
public static final java.lang.String IDEA_NULLABLE
public static final java.lang.String IDEA_NOTNULL
public static final java.lang.String IDEA_MAGIC
public static final java.lang.String IDEA_CONTRACT
public static final java.lang.String IDEA_NON_NLS
public static final java.lang.String ATTR_VAL
public static final java.lang.String ATTR_PURE
public Extractor(@Nullable
ApiDatabase apiFilter,
@Nullable
java.util.Collection<java.io.File> classDir,
boolean displayInfo,
boolean includeClassRetentionAnnotations,
boolean sortAnnotations)
public static java.util.List<? extends com.intellij.psi.PsiFile> createUnitsForFiles(@NonNull
com.intellij.openapi.project.Project project,
@NonNull
java.util.List<java.io.File> specificSources)
public static java.util.List<? extends com.intellij.psi.PsiFile> createUnitsInDirectories(@NonNull
com.intellij.openapi.project.Project project,
@NonNull
java.util.List<java.io.File> sourceDirs)
public static void addJavaSources(@NonNull
java.util.List<java.io.File> list,
@NonNull
java.io.File file)
public static java.util.List<java.io.File> gatherSources(java.util.List<java.io.File> sourcePath)
public void extractFromProjectSource(java.util.List<? extends com.intellij.psi.PsiFile> units)
public void removeTypedefClasses()
public void writeTypedefFile(@NonNull
java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic static void removeTypedefClasses(@NonNull
java.util.Collection<java.io.File> classDirs,
@NonNull
java.io.File typedefFile)
public void export(@Nullable
java.io.File annotationsZip,
@Nullable
java.io.File proguardCfg)
throws java.io.IOException
java.io.IOExceptionpublic void writeStats()
public void mergeExisting(@NonNull
java.io.File file)
public void setListIgnored(boolean listIgnored)
public boolean isListIgnored()
public com.android.tools.lint.annotations.Extractor.AnnotationData createData(@NonNull
java.lang.String name,
@NonNull
org.jetbrains.uast.UAnnotation annotation)
public static boolean isHiddenTypeDef(@NonNull
org.jetbrains.uast.UClass declaration)
declaration - the type declaration