GWT 2.3.0

com.google.gwt.core.ext
Interface GeneratorContext

All Known Subinterfaces:
GeneratorContextExt
All Known Implementing Classes:
GeneratorContextExtWrapper

public interface GeneratorContext

Provides metadata to deferred binding generators.


Method Summary
 void commit(TreeLogger logger, java.io.PrintWriter pw)
          Commits source generation begun with tryCreate(TreeLogger, String, String).
 void commitArtifact(TreeLogger logger, Artifact<?> artifact)
          Add an Artifact to the ArtifactSet that will be presented to the Linker chain at the end of the compilation cycle.
 GeneratedResource commitResource(TreeLogger logger, java.io.OutputStream os)
          Commits resource generation begun with tryCreateResource(TreeLogger, String).
 PropertyOracle getPropertyOracle()
          Gets the property oracle for the current generator context.
 com.google.gwt.dev.resource.ResourceOracle getResourcesOracle()
          Returns a resource oracle containing all resources that are mapped into the module's source (or super-source) paths.
 TypeOracle getTypeOracle()
          Gets the type oracle for the current generator context.
 java.io.PrintWriter tryCreate(TreeLogger logger, java.lang.String packageName, java.lang.String simpleName)
          Attempts to get a PrintWriter so that the caller can generate the source code for the named type.
 java.io.OutputStream tryCreateResource(TreeLogger logger, java.lang.String partialPath)
          Attempts to get an OutputStream so that the caller can write file contents into the named file underneath the compilation output directory.
 

Method Detail

commit

void commit(TreeLogger logger,
            java.io.PrintWriter pw)
Commits source generation begun with tryCreate(TreeLogger, String, String).


commitArtifact

void commitArtifact(TreeLogger logger,
                    Artifact<?> artifact)
                    throws UnableToCompleteException
Add an Artifact to the ArtifactSet that will be presented to the Linker chain at the end of the compilation cycle. Custom sub-classes of Artifact can be used to write cooperating Generator and Linker combinations. This method is semantically equivalent to calling ArtifactSet.replace(Artifact) if an equivalent Artifact had previously been committed.

Parameters:
logger - a logger; normally the logger passed into Generator.generate(TreeLogger, GeneratorContext, String) or a branch thereof
artifact - the Artifact to provide to the Linker chain.
Throws:
UnableToCompleteException

commitResource

GeneratedResource commitResource(TreeLogger logger,
                                 java.io.OutputStream os)
                                 throws UnableToCompleteException
Commits resource generation begun with tryCreateResource(TreeLogger, String).

Returns:
the GeneratedResource that was created as a result of committing the OutputStream.
Throws:
UnableToCompleteException - if the resource cannot be written to disk, if the specified stream is unknown, or if the stream has already been committed

getPropertyOracle

PropertyOracle getPropertyOracle()
Gets the property oracle for the current generator context. Generators can use the property oracle to query deferred binding properties.


getResourcesOracle

com.google.gwt.dev.resource.ResourceOracle getResourcesOracle()
Returns a resource oracle containing all resources that are mapped into the module's source (or super-source) paths. Conceptually, this resource oracle exposes resources which are "siblings" to GWT-compatible Java classes. For example, if the module includes com.google.gwt.core.client as a source package, then a resource at com/google/gwt/core/client/Foo.properties would be exposed by this resource oracle.


getTypeOracle

TypeOracle getTypeOracle()
Gets the type oracle for the current generator context. Generators can use the type oracle to ask questions about the entire translatable code base.

Returns:
a TypeOracle over all the relevant translatable compilation units in the source path

tryCreate

java.io.PrintWriter tryCreate(TreeLogger logger,
                              java.lang.String packageName,
                              java.lang.String simpleName)
Attempts to get a PrintWriter so that the caller can generate the source code for the named type. If the named types already exists, null is returned to indicate that no work needs to be done. The file is not committed until commit(TreeLogger, PrintWriter) is called.

Parameters:
logger - a logger; normally the logger passed into Generator.generate(TreeLogger, GeneratorContext, String) or a branch thereof
packageName - the name of the package to which the create type belongs
simpleName - the unqualified source name of the type being generated
Returns:
null if the package and class already exists, otherwise a PrintWriter is returned.

tryCreateResource

java.io.OutputStream tryCreateResource(TreeLogger logger,
                                       java.lang.String partialPath)
                                       throws UnableToCompleteException
Attempts to get an OutputStream so that the caller can write file contents into the named file underneath the compilation output directory. The file is not committed until commitResource(TreeLogger, OutputStream) is called.

Parameters:
logger - a logger; normally the logger passed into Generator.generate(TreeLogger, GeneratorContext, String) or a branch thereof
partialPath - the name of the file whose contents are to be written; the name can include subdirectories separated by forward slashes ('/')
Returns:
an OutputStream into which file contents can be written, or null if a resource by that name is already pending or already exists
Throws:
UnableToCompleteException - if the resource could not be initialized for some reason, such as if the specified partial path is invalid

GWT 2.3.0