|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.android.tools.lint.client.api.JavaParser
@Beta public abstract class JavaParser
A wrapper for a Java parser. This allows tools integrating lint to map directly to builtin services, such as already-parsed data structures in Java editors.
NOTE: This is not public or final API; if you rely on this be prepared to adjust your code for the next tools release.
Nested Class Summary | |
---|---|
static class |
JavaParser.DefaultTypeDescriptor
Convenience implementation of JavaParser.TypeDescriptor |
static class |
JavaParser.ResolvedAnnotation
An annotation reference. |
static class |
JavaParser.ResolvedClass
A resolved class declaration (class, interface, enumeration or annotation) |
static class |
JavaParser.ResolvedField
A field declaration |
static class |
JavaParser.ResolvedMethod
A method or constructor declaration |
static class |
JavaParser.ResolvedNode
A resolved declaration from an AST Node reference |
static class |
JavaParser.ResolvedPackage
A package declaration |
static class |
JavaParser.ResolvedVariable
A local variable or parameter declaration |
static class |
JavaParser.TypeDescriptor
A description of a type, such as a primitive int or the android.app.Activity class |
Field Summary | |
---|---|
static java.lang.String |
TYPE_BOOLEAN
|
static java.lang.String |
TYPE_BYTE
|
static java.lang.String |
TYPE_CHAR
|
static java.lang.String |
TYPE_DOUBLE
|
static java.lang.String |
TYPE_FLOAT
|
static java.lang.String |
TYPE_INT
|
static java.lang.String |
TYPE_LONG
|
static java.lang.String |
TYPE_NULL
|
static java.lang.String |
TYPE_OBJECT
|
static java.lang.String |
TYPE_SHORT
|
static java.lang.String |
TYPE_STRING
|
Constructor Summary | |
---|---|
JavaParser()
|
Method Summary | |
---|---|
abstract Location.Handle |
createLocationHandle(JavaContext context,
lombok.ast.Node node)
Creates a light-weight handle to a location for the given node. |
void |
dispose()
Dispose any remaining data structures held for all contexts. |
void |
dispose(JavaContext context,
lombok.ast.Node compilationUnit)
Dispose any data structures held for the given context. |
JavaParser.ResolvedClass |
findClass(JavaContext context,
java.lang.String fullyQualifiedName)
Finds the given type, if possible (which should be reachable from the compilation patch of the given node. |
java.util.List<JavaParser.TypeDescriptor> |
getCatchTypes(JavaContext context,
lombok.ast.Catch catchBlock)
Returns the set of exception types handled by the given catch block. |
abstract Location |
getLocation(JavaContext context,
lombok.ast.Node node)
Returns a Location for the given node |
Location |
getNameLocation(JavaContext context,
lombok.ast.Node node)
Returns a Location for the given node. |
abstract Location |
getRangeLocation(JavaContext context,
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). |
abstract JavaParser.TypeDescriptor |
getType(JavaContext context,
lombok.ast.Node node)
Gets the type of the given node |
abstract lombok.ast.Node |
parseJava(JavaContext context)
Parse the file pointed to by the given context. |
abstract void |
prepareJavaParse(java.util.List<JavaContext> contexts)
Prepare to parse the given contexts. |
abstract JavaParser.ResolvedNode |
resolve(JavaContext context,
lombok.ast.Node node)
Resolves the given expression node: computes the declaration for the given symbol |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String TYPE_OBJECT
public static final java.lang.String TYPE_STRING
public static final java.lang.String TYPE_INT
public static final java.lang.String TYPE_LONG
public static final java.lang.String TYPE_CHAR
public static final java.lang.String TYPE_FLOAT
public static final java.lang.String TYPE_DOUBLE
public static final java.lang.String TYPE_BOOLEAN
public static final java.lang.String TYPE_SHORT
public static final java.lang.String TYPE_BYTE
public static final java.lang.String TYPE_NULL
Constructor Detail |
---|
public JavaParser()
Method Detail |
---|
public abstract void prepareJavaParse(@NonNull java.util.List<JavaContext> contexts)
parseJava(JavaContext)
calls, which allows some
parsers to do up front global computation in case they want to more
efficiently process multiple files at the same time. This allows a single
type-attribution pass for example, which is a lot more efficient than
performing global type analysis over and over again for each individual
file
contexts
- a list of contexts to be parsed@Nullable public abstract lombok.ast.Node parseJava(@NonNull JavaContext context)
context
- the context pointing to the file to be parsed, typically
via Context.getContents()
but the file handle (
Context.file
can also be used to map to an existing
editor buffer in the surrounding tool, etc)
@NonNull public abstract Location getLocation(@NonNull JavaContext context, @NonNull lombok.ast.Node node)
Location
for the given node
context
- information about the file being parsednode
- the node to create a location for
@NonNull public abstract Location getRangeLocation(@NonNull JavaContext context, @NonNull lombok.ast.Node from, int fromDelta, @NonNull lombok.ast.Node to, int toDelta)
Location
for the given node range (from the starting offset of the first
node to the ending offset of the second node).
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 getNameLocation(@NonNull JavaContext context, @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.
context
- information about the file being parsednode
- the node to create a location for
@NonNull public abstract Location.Handle createLocationHandle(@NonNull JavaContext context, @NonNull lombok.ast.Node node)
Location.Handle.resolve()
.
context
- the context providing the nodenode
- the node (element or attribute) to create a location handle
for
public void dispose(@NonNull JavaContext context, @NonNull lombok.ast.Node compilationUnit)
context
- information about the file previously parsedcompilationUnit
- the compilation unit being disposedpublic void dispose()
prepareJavaParse(List)
@Nullable public abstract JavaParser.ResolvedNode resolve(@NonNull JavaContext context, @NonNull lombok.ast.Node node)
context
- information about the file being parsednode
- the node to resolve
@Nullable public JavaParser.ResolvedClass findClass(@NonNull JavaContext context, @NonNull java.lang.String fullyQualifiedName)
context
- information about the file being parsedfullyQualifiedName
- the fully qualified name of the class to look up
public java.util.List<JavaParser.TypeDescriptor> getCatchTypes(@NonNull JavaContext context, @NonNull lombok.ast.Catch catchBlock)
This is a workaround for the fact that the Lombok AST API (and implementation) doesn't support multi-catch statements.
@Nullable public abstract JavaParser.TypeDescriptor getType(@NonNull JavaContext context, @NonNull lombok.ast.Node node)
context
- information about the file being parsednode
- the node to look up the type for
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |