@Beta
public abstract class UastParser
extends java.lang.Object
NOTE: This is not public or final API; if you rely on this be prepared to adjust your code for the next tools release.
Constructor and Description |
---|
UastParser() |
Modifier and Type | Method and Description |
---|---|
abstract Location |
createLocation(com.intellij.psi.PsiElement element) |
abstract Location |
createLocation(org.jetbrains.uast.UElement element) |
void |
dispose()
Dispose any remaining data structures held for all contexts.
|
void |
dispose(JavaContext context,
org.jetbrains.uast.UFile compilationUnit)
Dispose any data structures held for the given context.
|
abstract Location |
getCallLocation(JavaContext context,
org.jetbrains.uast.UCallExpression call,
boolean includeReceiver,
boolean includeArguments) |
abstract JavaEvaluator |
getEvaluator()
Returns an evaluator which can perform various resolution tasks,
evaluate inheritance lookup etc.
|
abstract java.io.File |
getFile(com.intellij.psi.PsiFile file) |
abstract java.lang.CharSequence |
getFileContents(com.intellij.psi.PsiFile file) |
abstract Location |
getLocation(JavaContext context,
com.intellij.psi.PsiElement element)
Returns a
Location for the given element |
abstract Location |
getLocation(JavaContext context,
org.jetbrains.uast.UElement element) |
abstract Location |
getNameLocation(JavaContext context,
com.intellij.psi.PsiElement element)
Returns a
Location for the given node. |
abstract Location |
getNameLocation(JavaContext context,
org.jetbrains.uast.UElement element) |
abstract Location |
getRangeLocation(JavaContext context,
com.intellij.psi.PsiElement from,
int fromDelta,
int toDelta)
Like
getRangeLocation(JavaContext, PsiElement, int, PsiElement, int)
but both offsets are relative to the starting offset of the given node. |
abstract Location |
getRangeLocation(JavaContext context,
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). |
abstract Location |
getRangeLocation(JavaContext context,
org.jetbrains.uast.UElement from,
int fromDelta,
int toDelta) |
abstract Location |
getRangeLocation(JavaContext context,
org.jetbrains.uast.UElement from,
int fromDelta,
org.jetbrains.uast.UElement to,
int toDelta) |
abstract org.jetbrains.uast.UastContext |
getUastContext()
Returns a UastContext which can provide UAST representations for source files
|
abstract org.jetbrains.uast.UFile |
parse(JavaContext context)
Parse the file pointed to by the given context.
|
boolean |
prepare(java.util.List<JavaContext> contexts)
Prepare to parse the given contexts.
|
public boolean prepare(@NonNull java.util.List<JavaContext> contexts)
parse(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
filecontexts
- a list of contexts to be parsed@NonNull public abstract JavaEvaluator getEvaluator()
@Nullable public abstract org.jetbrains.uast.UFile parse(@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)@Nullable public abstract org.jetbrains.uast.UastContext getUastContext()
@NonNull public abstract Location getLocation(@NonNull JavaContext context, @NonNull com.intellij.psi.PsiElement element)
Location
for the given elementcontext
- information about the file being parsedelement
- the element to create a location for@NonNull public abstract Location getLocation(@NonNull JavaContext context, @NonNull org.jetbrains.uast.UElement element)
@NonNull public abstract Location getCallLocation(@NonNull JavaContext context, @NonNull org.jetbrains.uast.UCallExpression call, boolean includeReceiver, boolean includeArguments)
@Nullable public abstract java.io.File getFile(@NonNull com.intellij.psi.PsiFile file)
@NonNull public abstract java.lang.CharSequence getFileContents(@NonNull com.intellij.psi.PsiFile file)
@NonNull public abstract Location createLocation(@NonNull com.intellij.psi.PsiElement element)
@NonNull public abstract Location createLocation(@NonNull org.jetbrains.uast.UElement element)
@NonNull public abstract Location getRangeLocation(@NonNull JavaContext context, @NonNull com.intellij.psi.PsiElement from, int fromDelta, @NonNull com.intellij.psi.PsiElement 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).context
- information about the file being parsedfrom
- 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 abstract Location getRangeLocation(@NonNull JavaContext context, @NonNull org.jetbrains.uast.UElement from, int fromDelta, @NonNull org.jetbrains.uast.UElement to, int toDelta)
@NonNull public abstract Location getRangeLocation(@NonNull JavaContext context, @NonNull com.intellij.psi.PsiElement from, int fromDelta, int toDelta)
getRangeLocation(JavaContext, PsiElement, int, PsiElement, int)
but both offsets are relative to the starting offset of the given node. This is
sometimes more convenient than operating relative to the ending offset when you
have a fixed range in mind.context
- information about the file being parsedfrom
- the AST node to get a starting location fromfromDelta
- Offset delta to apply to the starting offsettoDelta
- Offset delta to apply to the starting offset@NonNull public abstract Location getRangeLocation(@NonNull JavaContext context, @NonNull org.jetbrains.uast.UElement from, int fromDelta, int toDelta)
@NonNull public abstract Location getNameLocation(@NonNull JavaContext context, @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.context
- information about the file being parsedelement
- the node to create a location for@NonNull public abstract Location getNameLocation(@NonNull JavaContext context, @NonNull org.jetbrains.uast.UElement element)
public void dispose(@NonNull JavaContext context, @NonNull org.jetbrains.uast.UFile compilationUnit)
context
- information about the file previously parsedcompilationUnit
- the compilation unit being disposedpublic void dispose()
prepare(List)