org.netbeans.modules.java.source 0.80.1 17

org.netbeans.api.java.source
Class CompilationInfo

java.lang.Object
  extended by org.netbeans.api.java.source.CompilationInfo
Direct Known Subclasses:
CompilationController

public class CompilationInfo
extends Object

Assorted information about the JavaSource.


Method Summary
protected  void doInvalidate()
           
static CompilationInfo get(org.netbeans.modules.parsing.spi.Parser.Result result)
          Returns an instance of the CompilationInfo for given Parser.Result if it is a result of a java parser.
 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.
 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 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.
 org.netbeans.modules.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

@NullUnknown
public static CompilationInfo get(@NonNull
                                              org.netbeans.modules.parsing.spi.Parser.Result result)
Returns an instance of the CompilationInfo for given Parser.Result if it is a result of a java parser.

Parameters:
result - for which the CompilationInfo should be returned.
Returns:
a CompilationInfo or null when the given result is not a result of java parsing.
Since:
0.42

getPhase

@NonNull
public JavaSource.Phase getPhase()
Returns the current phase of the JavaSource.

Returns:
JavaSource.Phase the state which was reached by the JavaSource.

getChangedTree

@CheckForNull
@CheckReturnValue
public TreePath getChangedTree()
Returns tree which was reparsed by an incremental reparse. When the source file wasn't parsed yet or the parse was a full parse this method returns null.

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.

Returns:
TreePath or null
Since:
0.31

getCompilationUnit

public CompilationUnitTree getCompilationUnit()
Returns the javac tree representing the source file.

Returns:
CompilationUnitTree the compilation unit containing the top level classes contained in the, java source file.
Throws:
IllegalStateException - when the phase is less than JavaSource.Phase.PARSED

getText

@NonNull
public String getText()
Returns the content of the file represented by the JavaSource.

Returns:
String the java source

getSnapshot

@NonNull
public org.netbeans.modules.parsing.api.Snapshot getSnapshot()
Returns the snapshot used by java parser

Returns:
the snapshot
Since:
0.42

getTokenHierarchy

@NonNull
public TokenHierarchy<?> getTokenHierarchy()
Returns the TokenHierarchy for the file represented by the JavaSource.

Returns:
lexer TokenHierarchy

getDiagnostics

@NonNull
public List<Diagnostic> getDiagnostics()
Returns the errors in the file represented by the JavaSource.

Returns:
an list of Diagnostic

getTopLevelElements

@NullUnknown
public List<? extends TypeElement> getTopLevelElements()
                                                throws IllegalStateException
Returns all top level elements defined in file for which the CompilationInfo was created. The CompilationInfo has to be in phase JavaSource#Phase#ELEMENTS_RESOLVED.

Returns:
list of top level elements, it may return null when this CompilationInfo is not in phase JavaSource#Phase#ELEMENTS_RESOLVED or higher.
Throws:
IllegalStateException - is thrown when the JavaSource was created with no files
Since:
0.14

getTrees

@NonNull
public Trees getTrees()
Return the Trees service of the javac represented by this CompilationInfo.

Returns:
javac Trees service

getTypes

@NonNull
public Types getTypes()
Return the Types service of the javac represented by this CompilationInfo.

Returns:
javac Types service

getElements

@NonNull
public Elements getElements()
Return the Elements service of the javac represented by this CompilationInfo.

Returns:
javac Elements service

getJavaSource

@NullUnknown
public 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 getSnapshot() instead.

Returns JavaSource for which this CompilationInfo was created.

Returns:
JavaSource or null

getClasspathInfo

@NonNull
public ClasspathInfo getClasspathInfo()
Returns ClasspathInfo for which this CompilationInfo was created.

Returns:
ClasspathInfo

getFileObject

@NullUnknown
public FileObject getFileObject()
Returns the FileObject represented by this CompilationInfo.

Returns:
FileObject

getPositionConverter

@Deprecated
public PositionConverter getPositionConverter()
Deprecated. as of 0.42, this is superseded by Parsing API.

Return 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.

Returns:
PositionConverter binding the virtual Java source and the real source.
Since:
0.21

getDocument

@CheckForNull
public Document getDocument()
                     throws IOException
Returns Document of this CompilationInfoImpl

Returns:
Document or null when the DataObject doesn't exist or has no EditorCookie.
Throws:
IOException

getTreeUtilities

@NonNull
public TreeUtilities getTreeUtilities()
Returns TreeUtilities.

Returns:
TreeUtilities

getElementUtilities

@NonNull
public ElementUtilities getElementUtilities()
Returns ElementUtilities.

Returns:
ElementUtilities

getTypeUtilities

@NonNull
public TypeUtilities getTypeUtilities()
Get the TypeUtilities.

Returns:
an instance of TypeUtilities

getSourceVersion

@NonNull
public SourceVersion getSourceVersion()
Returns the SourceVersion used by the javac represented by this CompilationInfo.

Returns:
SourceVersion
Since:
0.47

doInvalidate

protected void doInvalidate()

org.netbeans.modules.java.source 0.80.1 17

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.