public class ResourceEvaluator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ANIM_RES_ANNOTATION |
static java.lang.String |
ANIMATOR_RES_ANNOTATION |
static java.lang.String |
ANY_RES_ANNOTATION |
static java.lang.String |
ARRAY_RES_ANNOTATION |
static java.lang.String |
ATTR_RES_ANNOTATION |
static java.lang.String |
BOOL_RES_ANNOTATION |
static java.lang.String |
COLOR_INT_ANNOTATION |
static com.android.resources.ResourceType |
COLOR_INT_MARKER_TYPE
Marker ResourceType used to signify that an expression is of type
@ColorInt ,
which isn't actually a ResourceType but one we want to specifically compare with. |
static java.lang.String |
COLOR_RES_ANNOTATION |
static java.lang.String |
DIMEN_RES_ANNOTATION |
static java.lang.String |
DIMENSION_ANNOTATION |
static com.android.resources.ResourceType |
DIMENSION_MARKER_TYPE
Marker ResourceType used to signify that an expression is of type
@Px ,
which isn't actually a ResourceType but one we want to specifically compare with. |
static java.lang.String |
DRAWABLE_RES_ANNOTATION |
static java.lang.String |
FRACTION_RES_ANNOTATION |
static java.lang.String |
ID_RES_ANNOTATION |
static java.lang.String |
INTEGER_RES_ANNOTATION |
static java.lang.String |
INTERPOLATOR_RES_ANNOTATION |
static java.lang.String |
LAYOUT_RES_ANNOTATION |
static java.lang.String |
MENU_RES_ANNOTATION |
static java.lang.String |
PLURALS_RES_ANNOTATION |
static java.lang.String |
PX_ANNOTATION |
static java.lang.String |
RAW_RES_ANNOTATION |
static java.lang.String |
RES_SUFFIX |
static java.lang.String |
STRING_RES_ANNOTATION |
static java.lang.String |
STYLE_RES_ANNOTATION |
static java.lang.String |
STYLEABLE_RES_ANNOTATION |
static java.lang.String |
TRANSITION_RES_ANNOTATION |
static java.lang.String |
XML_RES_ANNOTATION |
Constructor and Description |
---|
ResourceEvaluator(JavaEvaluator evaluator)
Creates a new resource evaluator
|
Modifier and Type | Method and Description |
---|---|
ResourceEvaluator |
allowDereference(boolean allow)
Whether we allow dereferencing resources when computing constants;
e.g.
|
static com.android.ide.common.resources.ResourceUrl |
getResource(JavaEvaluator evaluator,
com.intellij.psi.PsiElement element)
Evaluates the given node and returns the resource reference (type and name) it
points to, if any
|
static com.android.ide.common.resources.ResourceUrl |
getResource(JavaEvaluator evaluator,
org.jetbrains.uast.UElement element)
Evaluates the given node and returns the resource reference (type and name) it
points to, if any
|
com.android.ide.common.resources.ResourceUrl |
getResource(com.intellij.psi.PsiElement element)
Evaluates the given node and returns the resource reference (type and name) it
points to, if any
|
com.android.ide.common.resources.ResourceUrl |
getResource(org.jetbrains.uast.UElement element)
Evaluates the given node and returns the resource reference (type and name) it
points to, if any
|
static com.android.ide.common.resources.ResourceUrl |
getResourceConstant(com.intellij.psi.PsiElement node)
Returns a resource URL based on the field reference in the code
|
static com.android.ide.common.resources.ResourceUrl |
getResourceConstant(org.jetbrains.uast.UElement node)
Returns a resource URL based on the field reference in the code
|
static java.util.EnumSet<com.android.resources.ResourceType> |
getResourceTypes(JavaEvaluator evaluator,
com.intellij.psi.PsiElement element)
Evaluates the given node and returns the resource types implied by the given element,
if any.
|
static java.util.EnumSet<com.android.resources.ResourceType> |
getResourceTypes(JavaEvaluator evaluator,
org.jetbrains.uast.UElement element)
Evaluates the given node and returns the resource types implied by the given element,
if any.
|
java.util.EnumSet<com.android.resources.ResourceType> |
getResourceTypes(com.intellij.psi.PsiElement element)
Evaluates the given node and returns the resource types applicable to the
node, if any.
|
java.util.EnumSet<com.android.resources.ResourceType> |
getResourceTypes(org.jetbrains.uast.UElement element)
Evaluates the given node and returns the resource types applicable to the
node, if any.
|
static com.android.resources.ResourceType |
getTypeFromAnnotationSignature(java.lang.String signature) |
static java.util.EnumSet<com.android.resources.ResourceType> |
getTypesFromAnnotations(java.util.List<org.jetbrains.uast.UAnnotation> annotations) |
static java.util.EnumSet<com.android.resources.ResourceType> |
getTypesFromAnnotations(com.intellij.psi.PsiAnnotation[] annotations) |
public static final com.android.resources.ResourceType COLOR_INT_MARKER_TYPE
@ColorInt
,
which isn't actually a ResourceType but one we want to specifically compare with.
We're using ResourceType.PUBLIC
because that one won't appear in the R
class (and ResourceType is an enum we can't just create new constants for.)public static final com.android.resources.ResourceType DIMENSION_MARKER_TYPE
@Px
,
which isn't actually a ResourceType but one we want to specifically compare with.
We're using ResourceType.DECLARE_STYLEABLE
because that one doesn't
have a corresponding *Res
constant (and ResourceType is an enum we can't
just create new constants for.)public static final java.lang.String COLOR_INT_ANNOTATION
public static final java.lang.String PX_ANNOTATION
public static final java.lang.String DIMENSION_ANNOTATION
public static final java.lang.String RES_SUFFIX
public static final java.lang.String INTEGER_RES_ANNOTATION
public static final java.lang.String MENU_RES_ANNOTATION
public static final java.lang.String INTERPOLATOR_RES_ANNOTATION
public static final java.lang.String ID_RES_ANNOTATION
public static final java.lang.String TRANSITION_RES_ANNOTATION
public static final java.lang.String STYLE_RES_ANNOTATION
public static final java.lang.String STRING_RES_ANNOTATION
public static final java.lang.String XML_RES_ANNOTATION
public static final java.lang.String BOOL_RES_ANNOTATION
public static final java.lang.String FRACTION_RES_ANNOTATION
public static final java.lang.String COLOR_RES_ANNOTATION
public static final java.lang.String DRAWABLE_RES_ANNOTATION
public static final java.lang.String DIMEN_RES_ANNOTATION
public static final java.lang.String RAW_RES_ANNOTATION
public static final java.lang.String ATTR_RES_ANNOTATION
public static final java.lang.String ARRAY_RES_ANNOTATION
public static final java.lang.String STYLEABLE_RES_ANNOTATION
public static final java.lang.String ANIMATOR_RES_ANNOTATION
public static final java.lang.String LAYOUT_RES_ANNOTATION
public static final java.lang.String PLURALS_RES_ANNOTATION
public static final java.lang.String ANIM_RES_ANNOTATION
public static final java.lang.String ANY_RES_ANNOTATION
public ResourceEvaluator(@Nullable JavaEvaluator evaluator)
evaluator
- the evaluator to use to resolve annotations references, if anypublic ResourceEvaluator allowDereference(boolean allow)
x
when the code is
x = getString(R.string.name)
, if allowDereference
is
true we'll return R.string.name, otherwise we'll return null.@Nullable public static com.android.ide.common.resources.ResourceUrl getResource(@Nullable JavaEvaluator evaluator, @NonNull com.intellij.psi.PsiElement element)
evaluator
- the evaluator to use to look up annotationselement
- the node to compute the constant value for@Nullable public static com.android.ide.common.resources.ResourceUrl getResource(@NonNull JavaEvaluator evaluator, @NonNull org.jetbrains.uast.UElement element)
evaluator
- the evaluator to use to look up annotationselement
- the node to compute the constant value for@Nullable public static java.util.EnumSet<com.android.resources.ResourceType> getResourceTypes(@Nullable JavaEvaluator evaluator, @NonNull com.intellij.psi.PsiElement element)
evaluator
- the evaluator to use to look up annotationselement
- the node to compute the constant value for@Nullable public static java.util.EnumSet<com.android.resources.ResourceType> getResourceTypes(@Nullable JavaEvaluator evaluator, @NonNull org.jetbrains.uast.UElement element)
evaluator
- the evaluator to use to look up annotationselement
- the node to compute the constant value for@Nullable public com.android.ide.common.resources.ResourceUrl getResource(@Nullable org.jetbrains.uast.UElement element)
element
- the node to compute the constant value for@Nullable public com.android.ide.common.resources.ResourceUrl getResource(@Nullable com.intellij.psi.PsiElement element)
element
- the node to compute the constant value for@Nullable public java.util.EnumSet<com.android.resources.ResourceType> getResourceTypes(@Nullable org.jetbrains.uast.UElement element)
element
- the element to compute the types for@Nullable public java.util.EnumSet<com.android.resources.ResourceType> getResourceTypes(@Nullable com.intellij.psi.PsiElement element)
element
- the element to compute the types for@Nullable public static java.util.EnumSet<com.android.resources.ResourceType> getTypesFromAnnotations(@NonNull com.intellij.psi.PsiAnnotation[] annotations)
@Nullable public static java.util.EnumSet<com.android.resources.ResourceType> getTypesFromAnnotations(@NonNull java.util.List<org.jetbrains.uast.UAnnotation> annotations)
@Nullable public static com.android.resources.ResourceType getTypeFromAnnotationSignature(@NonNull java.lang.String signature)
@Nullable public static com.android.ide.common.resources.ResourceUrl getResourceConstant(@NonNull com.intellij.psi.PsiElement node)
@Nullable public static com.android.ide.common.resources.ResourceUrl getResourceConstant(@NonNull org.jetbrains.uast.UElement node)