Constructor and Description |
---|
JavaContext(LintDriver driver,
Project project,
Project main,
java.io.File file,
JavaParser parser)
Constructs a
JavaContext for running lint on the given file, with
the given scope, in the given project reporting errors to the given
client. |
Modifier and Type | Method and Description |
---|---|
Location.Handle |
createLocationHandle(lombok.ast.Node node)
Deprecated.
Location handles aren't needed for AST nodes anymore; just use the
PsiElement from the AST |
JavaParser.ResolvedClass |
findClass(java.lang.String fullyQualifiedName)
Deprecated.
Use
JavaEvaluator.findClass(String) instead |
static com.intellij.psi.PsiElement |
findNameElement(com.intellij.psi.PsiElement element)
Searches for a name node corresponding to the given node
|
static lombok.ast.Node |
findNameNode(lombok.ast.Node node)
Deprecated.
Use
findNameElement(PsiElement) instead |
static lombok.ast.ClassDeclaration |
findSurroundingClass(lombok.ast.Node scope)
Deprecated.
Use
PsiTreeUtil.getParentOfType(PsiElement, Class[])
with PsiMethod.class instead |
static lombok.ast.Node |
findSurroundingMethod(lombok.ast.Node scope)
Deprecated.
Use
PsiTreeUtil.getParentOfType(PsiElement, Class[])
with PsiMethod.class instead |
static lombok.ast.Node |
getArgumentNode(lombok.ast.MethodInvocation call,
int index)
Deprecated.
|
lombok.ast.Node |
getCompilationUnit() |
JavaEvaluator |
getEvaluator() |
com.intellij.psi.PsiJavaFile |
getJavaFile()
Returns the
PsiJavaFile . |
Location |
getLocation(lombok.ast.Node node)
Returns a location for the given node
|
Location |
getLocation(com.intellij.psi.PsiElement node) |
static java.lang.String |
getMethodName(lombok.ast.Node call)
Deprecated.
Use
getMethodName(PsiElement) instead |
static java.lang.String |
getMethodName(com.intellij.psi.PsiElement call) |
Location |
getNameLocation(lombok.ast.Node node)
Returns a
Location for the given node. |
Location |
getNameLocation(com.intellij.psi.PsiElement element)
Returns a
Location for the given node. |
static <T extends lombok.ast.Node> |
getNextSiblingOfType(lombok.ast.Node sibling,
java.lang.Class<T> clz)
Deprecated.
Use
PsiTreeUtil.getNextSiblingOfType(PsiElement, Class) instead |
static lombok.ast.Node |
getParameter(lombok.ast.Node call,
int parameter)
Deprecated.
|
static java.util.Iterator<lombok.ast.Expression> |
getParameters(lombok.ast.Node call)
Deprecated.
|
static <T extends lombok.ast.Node> |
getParentOfType(lombok.ast.Node element,
java.lang.Class<T> clz)
Deprecated.
Use
PsiTreeUtil.getParentOfType(com.intellij.psi.PsiElement, java.lang.Class<T>) instead |
static <T extends lombok.ast.Node> |
getParentOfType(lombok.ast.Node element,
java.lang.Class<T> clz,
boolean strict)
Deprecated.
Use
PsiTreeUtil.getParentOfType(com.intellij.psi.PsiElement, java.lang.Class<T>) instead |
static <T extends lombok.ast.Node> |
getParentOfType(lombok.ast.Node element,
java.lang.Class<T> clz,
boolean strict,
java.lang.Class<? extends lombok.ast.Node>... terminators)
Deprecated.
Use
PsiTreeUtil.getParentOfType(com.intellij.psi.PsiElement, java.lang.Class<T>) instead |
JavaParser |
getParser() |
Location |
getRangeLocation(lombok.ast.Node from,
int fromDelta,
lombok.ast.Node to,
int toDelta)
Returns a location for the given node range (from the starting offset of the first node to
the ending offset of the second node).
|
Location |
getRangeLocation(com.intellij.psi.PsiElement from,
int fromDelta,
int length)
Returns a location for the given node range (from the starting offset of the first node to
the ending offset of the second node).
|
Location |
getRangeLocation(com.intellij.psi.PsiElement from,
int fromDelta,
com.intellij.psi.PsiElement to,
int toDelta)
Returns a location for the given node range (from the starting offset of the first node to
the ending offset of the second node).
|
protected java.lang.String |
getSuppressCommentPrefix()
Returns the comment marker used in Studio to suppress statements for language, if any
|
JavaParser.TypeDescriptor |
getType(lombok.ast.Node node)
Deprecated.
Use
PsiExpression.getType() )} instead |
boolean |
isContextMethod(lombok.ast.MethodInvocation node)
Deprecated.
|
boolean |
isSuppressedWithComment(lombok.ast.Node scope,
Issue issue)
Deprecated.
Use
isSuppressedWithComment(PsiElement, Issue) instead |
boolean |
isSuppressedWithComment(com.intellij.psi.PsiElement scope,
Issue issue) |
boolean |
isTestSource()
Whether this compilation unit is in a test folder
|
void |
report(Issue issue,
Location location,
java.lang.String message)
Reports an issue.
|
void |
report(Issue issue,
lombok.ast.Node scope,
Location location,
java.lang.String message)
Reports an issue applicable to a given AST node.
|
void |
report(Issue issue,
lombok.ast.Node scope,
Location location,
java.lang.String message,
java.lang.Object data)
Deprecated.
Use
report(Issue, Node, Location, String) instead;
this method is here for custom rule compatibility |
void |
report(Issue issue,
com.intellij.psi.PsiElement scope,
Location location,
java.lang.String message) |
JavaParser.ResolvedNode |
resolve(lombok.ast.Node node)
Deprecated.
Use PsiElement resolve methods (varies by AST node type, e.g.
PsiCall.resolveMethod() |
void |
setCompilationUnit(lombok.ast.Node compilationUnit)
Sets the compilation result.
|
void |
setJavaFile(com.intellij.psi.PsiJavaFile javaFile)
Sets the compilation result.
|
void |
setTestSource(boolean testSource)
Sets whether this compilation unit is in a test folder
|
containsCommentSuppress, getClient, getConfiguration, getContents, getDriver, getMainProject, getPhase, getProject, getProperty, getScope, getSdkInfo, isEnabled, isSuppressedWithComment, log, report, requestRepeat, setProperty
public JavaContext(@NonNull LintDriver driver, @NonNull Project project, @Nullable Project main, @NonNull java.io.File file, @NonNull JavaParser parser)
JavaContext
for running lint on the given file, with
the given scope, in the given project reporting errors to the given
client.driver
- the driver running through the checksproject
- the project to run lint on which contains the given filemain
- the main project if this project is a library project, or
null if this is not a library project. The main project is
the root project of all library projects, not necessarily the
directly including project.file
- the file to be analyzedparser
- the parser to use@NonNull public Location getLocation(@NonNull lombok.ast.Node node)
node
- the AST node to get a location for@NonNull public Location getRangeLocation(@NonNull lombok.ast.Node from, int fromDelta, @NonNull lombok.ast.Node to, int toDelta)
from
- the AST node to get a starting location fromfromDelta
- Offset delta to apply to the starting offsetto
- the AST node to get a ending location fromtoDelta
- Offset delta to apply to the ending offset@NonNull public Location getRangeLocation(@NonNull com.intellij.psi.PsiElement from, int fromDelta, @NonNull com.intellij.psi.PsiElement to, int toDelta)
from
- the AST node to get a starting location fromfromDelta
- Offset delta to apply to the starting offsetto
- the AST node to get a ending location fromtoDelta
- Offset delta to apply to the ending offset@NonNull public Location getRangeLocation(@NonNull com.intellij.psi.PsiElement from, int fromDelta, int length)
from
- the AST node to get a starting location fromfromDelta
- Offset delta to apply to the starting offsetlength
- The number of characters to add from the delta@NonNull public Location getNameLocation(@NonNull lombok.ast.Node node)
Location
for the given node. This attempts to pick a shorter
location range than the entire node; for a class or method for example, it picks
the name node (if found). For statement constructs such as a switch
statement
it will highlight the keyword, etc.node
- the AST node to create a location for@NonNull public Location getNameLocation(@NonNull com.intellij.psi.PsiElement element)
Location
for the given node. This attempts to pick a shorter
location range than the entire node; for a class or method for example, it picks
the name node (if found). For statement constructs such as a switch
statement
it will highlight the keyword, etc.element
- the AST node to create a location for@NonNull public Location getLocation(@NonNull com.intellij.psi.PsiElement node)
@NonNull public JavaParser getParser()
@NonNull public JavaEvaluator getEvaluator()
@Nullable public lombok.ast.Node getCompilationUnit()
public void setCompilationUnit(@Nullable lombok.ast.Node compilationUnit)
compilationUnit
- the parse tree@Nullable public com.intellij.psi.PsiJavaFile getJavaFile()
PsiJavaFile
.public void setJavaFile(@Nullable com.intellij.psi.PsiJavaFile javaFile)
javaFile
- the parse treepublic void report(@NonNull Issue issue, @NonNull Location location, @NonNull java.lang.String message)
Context
LintClient.report(com.android.tools.lint.detector.api.Context, com.android.tools.lint.detector.api.Issue, com.android.tools.lint.detector.api.Severity, com.android.tools.lint.detector.api.Location, java.lang.String, com.android.tools.lint.detector.api.TextFormat)
public void report(@NonNull Issue issue, @Nullable lombok.ast.Node scope, @NonNull Location location, @NonNull java.lang.String message)
issue
- the issue to reportscope
- the AST node scope the error applies to. The lint infrastructure
will check whether there are suppress annotations on this node (or its enclosing
nodes) and if so suppress the warning without involving the client.location
- the location of the issue, or null if not knownmessage
- the message for this warningpublic void report(@NonNull Issue issue, @Nullable com.intellij.psi.PsiElement scope, @NonNull Location location, @NonNull java.lang.String message)
@Deprecated public void report(@NonNull Issue issue, @Nullable lombok.ast.Node scope, @NonNull Location location, @NonNull java.lang.String message, @Nullable java.lang.Object data)
report(Issue, Node, Location, String)
instead;
this method is here for custom rule compatibilityreport(Issue, Node, Location, String)
but with
a now-unused data parameter at the end.@Deprecated @Nullable public static lombok.ast.Node findSurroundingMethod(lombok.ast.Node scope)
PsiTreeUtil.getParentOfType(PsiElement, Class[])
with PsiMethod.class instead@Deprecated @Nullable public static lombok.ast.ClassDeclaration findSurroundingClass(@Nullable lombok.ast.Node scope)
PsiTreeUtil.getParentOfType(PsiElement, Class[])
with PsiMethod.class instead@Nullable protected java.lang.String getSuppressCommentPrefix()
Context
getSuppressCommentPrefix
in class Context
@Deprecated public boolean isSuppressedWithComment(@NonNull lombok.ast.Node scope, @NonNull Issue issue)
isSuppressedWithComment(PsiElement, Issue)
insteadpublic boolean isSuppressedWithComment(@NonNull com.intellij.psi.PsiElement scope, @NonNull Issue issue)
@Deprecated @NonNull public Location.Handle createLocationHandle(@NonNull lombok.ast.Node node)
PsiElement
from the AST@Deprecated @Nullable public JavaParser.ResolvedNode resolve(@NonNull lombok.ast.Node node)
PsiCall.resolveMethod()
@Deprecated @Nullable public JavaParser.ResolvedClass findClass(@NonNull java.lang.String fullyQualifiedName)
JavaEvaluator.findClass(String)
instead@Deprecated @Nullable public JavaParser.TypeDescriptor getType(@NonNull lombok.ast.Node node)
PsiExpression.getType()
)} instead@Deprecated @Nullable public static java.lang.String getMethodName(@NonNull lombok.ast.Node call)
getMethodName(PsiElement)
instead@Nullable public static java.lang.String getMethodName(@NonNull com.intellij.psi.PsiElement call)
@Deprecated @Nullable public static lombok.ast.Node findNameNode(@NonNull lombok.ast.Node node)
findNameElement(PsiElement)
instead@Nullable public static com.intellij.psi.PsiElement findNameElement(@NonNull com.intellij.psi.PsiElement element)
@Deprecated @NonNull public static java.util.Iterator<lombok.ast.Expression> getParameters(@NonNull lombok.ast.Node call)
@Deprecated @Nullable public static lombok.ast.Node getParameter(@NonNull lombok.ast.Node call, int parameter)
@Deprecated public boolean isContextMethod(@NonNull lombok.ast.MethodInvocation node)
JavaEvaluator.isMemberInSubClassOf(PsiMember, String, boolean)
insteadandroid.content.Context
node
- the method call node@Deprecated @Nullable public static <T extends lombok.ast.Node> T getParentOfType(@Nullable lombok.ast.Node element, @NonNull java.lang.Class<T> clz)
PsiTreeUtil.getParentOfType(com.intellij.psi.PsiElement, java.lang.Class<T>)
insteadT
- the target node typeelement
- the element to search fromclz
- the target node type@Deprecated @Nullable public static <T extends lombok.ast.Node> T getParentOfType(@Nullable lombok.ast.Node element, @NonNull java.lang.Class<T> clz, boolean strict)
PsiTreeUtil.getParentOfType(com.intellij.psi.PsiElement, java.lang.Class<T>)
insteadT
- the target node typeelement
- the element to search fromclz
- the target node typestrict
- if true, do not consider the element itself, only its parents@Deprecated @Nullable public static <T extends lombok.ast.Node> T getParentOfType(@Nullable lombok.ast.Node element, @NonNull java.lang.Class<T> clz, boolean strict, @NonNull java.lang.Class<? extends lombok.ast.Node>... terminators)
PsiTreeUtil.getParentOfType(com.intellij.psi.PsiElement, java.lang.Class<T>)
insteadT
- the target node typeelement
- the element to search fromclz
- the target node typestrict
- if true, do not consider the element itself, only its parentsterminators
- optional node types to terminate the search at@Deprecated @Nullable public static <T extends lombok.ast.Node> T getNextSiblingOfType(@Nullable lombok.ast.Node sibling, @NonNull java.lang.Class<T> clz)
PsiTreeUtil.getNextSiblingOfType(PsiElement, Class)
insteadT
- the typesibling
- the sibling to search fromclz
- the type to look for@Deprecated @NonNull public static lombok.ast.Node getArgumentNode(@NonNull lombok.ast.MethodInvocation call, int index)
call
- the call containing argumentsindex
- the index of the target argumentjava.lang.IllegalArgumentException
- if index is outside the valid rangepublic boolean isTestSource()
public void setTestSource(boolean testSource)