public class ConstantEvaluator
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ConstantEvaluator.LastAssignmentFinder |
| Constructor and Description |
|---|
ConstantEvaluator(com.android.tools.lint.detector.api.JavaContext context)
Creates a new constant evaluator
|
| Modifier and Type | Method and Description |
|---|---|
ConstantEvaluator |
allowFieldInitializers() |
ConstantEvaluator |
allowUnknowns()
Whether we allow computing values where some terms are unknown.
|
static java.lang.Object |
evaluate(com.android.tools.lint.detector.api.JavaContext context,
lombok.ast.Node node)
Deprecated.
Use
evaluate(JavaContext, PsiElement) instead |
static java.lang.Object |
evaluate(com.android.tools.lint.detector.api.JavaContext context,
com.intellij.psi.PsiElement node)
Evaluates the given node and returns the constant value it resolves to, if any.
|
static java.lang.Object |
evaluate(com.android.tools.lint.detector.api.JavaContext context,
org.jetbrains.uast.UElement element)
Evaluates the given node and returns the constant value it resolves to, if any.
|
java.lang.Object |
evaluate(lombok.ast.Node node)
Deprecated.
Use
evaluate(PsiElement) instead |
java.lang.Object |
evaluate(com.intellij.psi.PsiElement node)
Evaluates the given node and returns the constant value it resolves to, if any
|
java.lang.Object |
evaluate(org.jetbrains.uast.UElement node)
Evaluates the given node and returns the constant value it resolves to, if any
|
static java.lang.String |
evaluateString(com.android.tools.lint.detector.api.JavaContext context,
lombok.ast.Node node,
boolean allowUnknown)
Deprecated.
Use
evaluateString(JavaContext, PsiElement, boolean) instead |
static java.lang.String |
evaluateString(com.android.tools.lint.detector.api.JavaContext context,
com.intellij.psi.PsiElement node,
boolean allowUnknown)
Evaluates the given node and returns the constant string it resolves to, if any.
|
static java.lang.String |
evaluateString(com.android.tools.lint.detector.api.JavaContext context,
org.jetbrains.uast.UElement element,
boolean allowUnknown)
Evaluates the given node and returns the constant string it resolves to, if any.
|
static com.intellij.psi.PsiExpression |
findLastAssignment(com.intellij.psi.PsiElement usage,
com.intellij.psi.PsiVariable variable)
Computes the last assignment to a given variable counting backwards from
the given context element
|
static boolean |
isArrayLiteral(com.intellij.psi.PsiElement node)
Returns true if the node is pointing to a an array literal
|
static boolean |
isArrayLiteral(org.jetbrains.uast.UElement node)
Returns true if the node is pointing to a an array literal
|
public ConstantEvaluator(@Nullable
com.android.tools.lint.detector.api.JavaContext context)
context - the context to use to resolve field references, if anypublic ConstantEvaluator allowUnknowns()
"foo" + x + "bar" would return null without and "foobar" with.public ConstantEvaluator allowFieldInitializers()
@Deprecated
@Nullable
public java.lang.Object evaluate(@NonNull
lombok.ast.Node node)
evaluate(PsiElement) insteadnode - the node to compute the constant value for@Nullable
public java.lang.Object evaluate(@Nullable
org.jetbrains.uast.UElement node)
node - the node to compute the constant value for@Nullable
public java.lang.Object evaluate(@Nullable
com.intellij.psi.PsiElement node)
node - the node to compute the constant value forpublic static boolean isArrayLiteral(@Nullable
com.intellij.psi.PsiElement node)
public static boolean isArrayLiteral(@Nullable
org.jetbrains.uast.UElement node)
@Deprecated
@Nullable
public static java.lang.Object evaluate(@NonNull
com.android.tools.lint.detector.api.JavaContext context,
@NonNull
lombok.ast.Node node)
evaluate(JavaContext, PsiElement) insteadcontext - the context to use to resolve field references, if anynode - the node to compute the constant value for@Deprecated
@Nullable
public static java.lang.String evaluateString(@NonNull
com.android.tools.lint.detector.api.JavaContext context,
@NonNull
lombok.ast.Node node,
boolean allowUnknown)
evaluateString(JavaContext, PsiElement, boolean) insteadcontext - the context to use to resolve field references, if anynode - the node to compute the constant value forallowUnknown - whether we should construct the string even if some parts of it are
unknown@Nullable
public static java.lang.Object evaluate(@Nullable
com.android.tools.lint.detector.api.JavaContext context,
@NonNull
com.intellij.psi.PsiElement node)
context - the context to use to resolve field references, if anynode - the node to compute the constant value for@Nullable
public static java.lang.Object evaluate(@Nullable
com.android.tools.lint.detector.api.JavaContext context,
@NonNull
org.jetbrains.uast.UElement element)
context - the context to use to resolve field references, if anyelement - the node to compute the constant value for@Nullable
public static java.lang.String evaluateString(@Nullable
com.android.tools.lint.detector.api.JavaContext context,
@NonNull
com.intellij.psi.PsiElement node,
boolean allowUnknown)
context - the context to use to resolve field references, if anynode - the node to compute the constant value forallowUnknown - whether we should construct the string even if some parts of it are
unknown@Nullable
public static com.intellij.psi.PsiExpression findLastAssignment(@NonNull
com.intellij.psi.PsiElement usage,
@NonNull
com.intellij.psi.PsiVariable variable)
usage - the usage site to search backwards fromvariable - the variable@Nullable
public static java.lang.String evaluateString(@Nullable
com.android.tools.lint.detector.api.JavaContext context,
@NonNull
org.jetbrains.uast.UElement element,
boolean allowUnknown)
context - the context to use to resolve field references, if anyelement - the node to compute the constant value forallowUnknown - whether we should construct the string even if some parts of it are
unknown