public final class JavaSource extends Object
Modifier and Type | Class and Description |
---|---|
static class |
JavaSource.InsufficientMemoryException
This specialization of
IOException signals that a JavaSource.runUserActionTask(org.netbeans.api.java.source.Task<org.netbeans.api.java.source.CompilationController>, boolean)
or JavaSource.runModificationTask(org.netbeans.api.java.source.Task<org.netbeans.api.java.source.WorkingCopy>) failed due to lack of memory. |
static class |
JavaSource.Phase |
static class |
JavaSource.Priority |
Modifier and Type | Method and Description |
---|---|
static JavaSource |
create(ClasspathInfo cpInfo,
Collection<? extends FileObject> files)
Returns a
JavaSource instance representing given FileObject s
and classpath represented by given ClasspathInfo . |
static JavaSource |
create(ClasspathInfo cpInfo,
FileObject... files)
Returns a
JavaSource instance representing given FileObject s
and classpath represented by given ClasspathInfo . |
static JavaSource |
forDocument(Document doc)
Returns a
JavaSource instance associated to the given Document ,
it returns null if the Document is not
associated with data type providing the JavaSource . |
static JavaSource |
forFileObject(FileObject fileObject)
Returns a
JavaSource instance associated to given FileObject ,
it returns null if the Document is not associated with data type providing the JavaSource . |
ClasspathInfo |
getClasspathInfo()
Returns the classpaths (
ClasspathInfo ) used by this
JavaSource |
Collection<FileObject> |
getFileObjects()
|
ModificationResult |
runModificationTask(Task<WorkingCopy> task)
Runs a task which permits for modifying the sources.
|
void |
runUserActionTask(Task<CompilationController> task,
boolean shared)
Runs a task which permits for controlling phases of the parsing process.
|
Future<Void> |
runWhenScanFinished(Task<CompilationController> task,
boolean shared)
Performs the given task when the scan finished.
|
@NullUnknown public static JavaSource create(@NonNull ClasspathInfo cpInfo, @NonNull FileObject... files) throws IllegalArgumentException
JavaSource
instance representing given FileObject
s
and classpath represented by given ClasspathInfo
.cpInfo
- the classpaths to be used.files
- for which the JavaSource
should be createdJavaSource
IllegalArgumentException
- if fileObject or cpInfo is null@NullUnknown public static JavaSource create(@NonNull ClasspathInfo cpInfo, @NonNull Collection<? extends FileObject> files) throws IllegalArgumentException
JavaSource
instance representing given FileObject
s
and classpath represented by given ClasspathInfo
.cpInfo
- the classpaths to be used.files
- for which the JavaSource
should be createdJavaSource
or null
if the essential infrastructure is missingIllegalArgumentException
- if fileObject or cpInfo is null@CheckForNull public static JavaSource forFileObject(@NonNull FileObject fileObject) throws IllegalArgumentException
JavaSource
instance associated to given FileObject
,
it returns null if the Document
is not associated with data type providing the JavaSource
.fileObject
- for which the JavaSource
should be found/created.JavaSource
or nullIllegalArgumentException
- if fileObject is null@CheckForNull public static JavaSource forDocument(@NonNull Document doc) throws IllegalArgumentException
JavaSource
instance associated to the given Document
,
it returns null if the Document
is not
associated with data type providing the JavaSource
.doc
- Document
for which the JavaSource
should be found/created.JavaSource
or nullIllegalArgumentException
- if doc is nullpublic void runUserActionTask(@NonNull Task<CompilationController> task, boolean shared) throws IOException
JavaSourceTaskFactory
.task
- The task which.shared
- if true the java compiler may be reused by other CancellableTask
s,
the value false may have negative impact on the IDE performance.
It's legal to nest the JavaSource.runUserActionTask(org.netbeans.api.java.source.Task<org.netbeans.api.java.source.CompilationController>, boolean)
into another JavaSource.runUserActionTask(org.netbeans.api.java.source.Task<org.netbeans.api.java.source.CompilationController>, boolean)
.
It's also legal to nest the JavaSource.runModificationTask(org.netbeans.api.java.source.Task<org.netbeans.api.java.source.WorkingCopy>)
into JavaSource.runUserActionTask(org.netbeans.api.java.source.Task<org.netbeans.api.java.source.CompilationController>, boolean)
,
the outer JavaSource.runUserActionTask(org.netbeans.api.java.source.Task<org.netbeans.api.java.source.CompilationController>, boolean)
does not see changes caused by nested JavaSource.runModificationTask(org.netbeans.api.java.source.Task<org.netbeans.api.java.source.WorkingCopy>)
,
but the following nested task see them.
IOException
for information about implementation requirements
@NonNull public Future<Void> runWhenScanFinished(@NonNull Task<CompilationController> task, boolean shared) throws IOException
task
- to be performedshared
- if true the java compiler may be reused by other CancellableTask
s,
the value false may have negative impact on the IDE performance.Future
which can be used to find out the sate of the task Future.isDone()
or Future.isCancelled()
.
The caller may cancel the task using Future.cancel(boolean)
or wait until the task is performed Future.get()
.IOException
- encapsulating the exception thrown by Task.run(P)
@NonNull public ModificationResult runModificationTask(@NonNull Task<WorkingCopy> task) throws IOException
task
- The task which.IOException
for information about implementation requirements
@NonNull public ClasspathInfo getClasspathInfo()
ClasspathInfo
) used by this
JavaSource
ClasspathInfo
, never returns null.@NonNull public Collection<FileObject> getFileObjects()
FileObject
s