public class CompilationInfo extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CompilationInfo.CacheClearPolicy
Constants to specify when a valued cached by
CompilationInfo.putCachedValue(java.lang.Object, java.lang.Object, org.netbeans.api.java.source.CompilationInfo.CacheClearPolicy)
should be evicted from the cache. |
Modifier and Type | Method and Description |
---|---|
protected void |
doInvalidate() |
static CompilationInfo |
get(Parser.Result result)
Returns an instance of the
CompilationInfo for
given Parser.Result if it is a result
of a java parser. |
Object |
getCachedValue(Object key)
Retrieve a value cached under the given key using the
CompilationInfo.putCachedValue(java.lang.Object, java.lang.Object, org.netbeans.api.java.source.CompilationInfo.CacheClearPolicy) method. |
TreePath |
getChangedTree()
Returns tree which was reparsed by an incremental reparse.
|
ClasspathInfo |
getClasspathInfo()
Returns
ClasspathInfo for which this CompilationInfo was created. |
CompilationUnitTree |
getCompilationUnit()
Returns the javac tree representing the source file.
|
List<Diagnostic> |
getDiagnostics()
Returns the errors in the file represented by the
JavaSource . |
DocTrees |
getDocTrees()
Return the
DocTrees service of the javac represented by this CompilationInfo . |
Document |
getDocument()
Returns
Document of this CompilationInfoImpl |
Elements |
getElements()
Return the
Elements service of the javac represented by this CompilationInfo . |
ElementUtilities |
getElementUtilities()
Returns
ElementUtilities . |
FileObject |
getFileObject()
Returns the
FileObject represented by this CompilationInfo . |
JavaSource |
getJavaSource()
Deprecated.
Works only when the CompilationInfo was created by JavaSource using
the compatibility bridge, when the CompilationInfo was created by the parsing api
it returns null. Use
CompilationInfo.getSnapshot() instead. |
JavaSource.Phase |
getPhase()
Returns the current phase of the
JavaSource . |
PositionConverter |
getPositionConverter()
Deprecated.
as of 0.42, this is superseded by Parsing API.
|
Snapshot |
getSnapshot()
Returns the snapshot used by java parser
|
SourceVersion |
getSourceVersion()
Returns the
SourceVersion used by the javac represented by this CompilationInfo . |
String |
getText()
Returns the content of the file represented by the
JavaSource . |
TokenHierarchy<?> |
getTokenHierarchy()
Returns the
TokenHierarchy for the file represented by the JavaSource . |
List<? extends TypeElement> |
getTopLevelElements()
Returns all top level elements defined in file for which the
CompilationInfo
was created. |
Trees |
getTrees()
Return the
Trees service of the javac represented by this CompilationInfo . |
TreeUtilities |
getTreeUtilities()
Returns
TreeUtilities . |
Types |
getTypes()
Return the
Types service of the javac represented by this CompilationInfo . |
TypeUtilities |
getTypeUtilities()
Get the TypeUtilities.
|
void |
putCachedValue(Object key,
Object value,
CompilationInfo.CacheClearPolicy clearPolicy)
Put a value into a cache under the given key.
|
@NullUnknown public static CompilationInfo get(@NonNull Parser.Result result)
CompilationInfo
for
given Parser.Result
if it is a result
of a java parser.result
- for which the CompilationInfo
should be
returned.CompilationInfo
or null when the given result
is not a result of java parsing.@NonNull public JavaSource.Phase getPhase()
JavaSource
.JavaSource.Phase
the state which was reached by the JavaSource
.@CheckForNull @CheckReturnValue public TreePath getChangedTree()
Currently the leaf tree is a MethodTree but this may change in the future. Client of this method is responsible to check the corresponding TreeKind to find out if it may perform on the changed subtree or it needs to reprocess the whole tree.
TreePath
or nullpublic CompilationUnitTree getCompilationUnit()
CompilationUnitTree
the compilation unit containing the top level classes contained in the,
java source file.IllegalStateException
- when the phase is less than JavaSource.Phase.PARSED
@NonNull public String getText()
JavaSource
.@NonNull public Snapshot getSnapshot()
@NonNull public TokenHierarchy<?> getTokenHierarchy()
TokenHierarchy
for the file represented by the JavaSource
.@NonNull public List<Diagnostic> getDiagnostics()
JavaSource
.Diagnostic
@NullUnknown public List<? extends TypeElement> getTopLevelElements() throws IllegalStateException
CompilationInfo
was created. The CompilationInfo
has to be in phase JavaSource#Phase#ELEMENTS_RESOLVED
.CompilationInfo
is not
in phase JavaSource#Phase#ELEMENTS_RESOLVED
or higher.IllegalStateException
- is thrown when the JavaSource
was created with no files@NonNull public Trees getTrees()
Trees
service of the javac represented by this CompilationInfo
.@NonNull public DocTrees getDocTrees()
DocTrees
service of the javac represented by this CompilationInfo
.@NonNull public Types getTypes()
Types
service of the javac represented by this CompilationInfo
.@NonNull public Elements getElements()
Elements
service of the javac represented by this CompilationInfo
.@NullUnknown public JavaSource getJavaSource()
CompilationInfo.getSnapshot()
instead.JavaSource
for which this CompilationInfo
was created.@NonNull public ClasspathInfo getClasspathInfo()
ClasspathInfo
for which this CompilationInfo
was created.@NullUnknown public FileObject getFileObject()
FileObject
represented by this CompilationInfo
.@Deprecated public PositionConverter getPositionConverter()
PositionConverter
binding virtual Java source and the real source.
Please note that this method is needed only for clients that need to work
in non-Java files (e.g. JSP files) or in dialogs, like code completion.
Most clients do not need to use PositionConverter
.@CheckForNull public Document getDocument() throws IOException
Document
of this CompilationInfoImpl
DataObject
doesn't
exist or has no EditorCookie
.IOException
@NonNull public TreeUtilities getTreeUtilities()
TreeUtilities
.@NonNull public ElementUtilities getElementUtilities()
ElementUtilities
.@NonNull public TypeUtilities getTypeUtilities()
@NonNull public SourceVersion getSourceVersion()
SourceVersion
used by the javac represented by this CompilationInfo
.@CheckForNull public Object getCachedValue(@NonNull Object key)
CompilationInfo.putCachedValue(java.lang.Object, java.lang.Object, org.netbeans.api.java.source.CompilationInfo.CacheClearPolicy)
method.key
- for which the cached value should be retrievedCompilationInfo.putCachedValue(java.lang.Object, java.lang.Object, org.netbeans.api.java.source.CompilationInfo.CacheClearPolicy)
, or null if nonepublic void putCachedValue(@NonNull Object key, @NullAllowed Object value, @NonNull CompilationInfo.CacheClearPolicy clearPolicy)
#clearPolicy
parameter specifies the latest time the
references to the key and value should be cleared. The infrastructure is free to clear the references at any earlier time.
The clients should not depend on this cache for correctness, only to improve performance.key
- a unique key under which the value should be storedvalue
- the value to store - any value previously set under the same key will be erased from the cacheclearPolicy
- the latest time when the mapping should be cleared from the cacheprotected void doInvalidate()