public class StubGeneratorContext extends Object implements GeneratorContext
Constructor and Description |
---|
StubGeneratorContext() |
Modifier and Type | Method and Description |
---|---|
boolean |
checkRebindRuleAvailable(String sourceTypeName)
Checks whether a rebind rule is available for a given sourceTypeName, such
as can appear in a replace-with or generate-with rule.
|
void |
commit(TreeLogger logger,
PrintWriter pw)
Commits source generation begun with
GeneratorContext.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,
OutputStream os)
Commits resource generation begun with
GeneratorContext.tryCreateResource(TreeLogger, String) . |
CachedGeneratorResult |
getCachedGeneratorResult()
Get the cached rebind result that has been provided to the context, if
available.
|
PropertyOracle |
getPropertyOracle()
Gets the property oracle for the current generator context.
|
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.
|
boolean |
isGeneratorResultCachingEnabled()
Check whether generator result caching is currently enabled.
|
boolean |
isProdMode()
Returns true if generators are being run to produce code for a production
compile.
|
PrintWriter |
tryCreate(TreeLogger logger,
String packageName,
String simpleName)
Attempts to get a
PrintWriter so that the caller can generate
the source code for the named type. |
OutputStream |
tryCreateResource(TreeLogger logger,
String partialPath)
Attempts to get an
OutputStream so that the caller can write
file contents into the named file underneath the compilation output
directory. |
boolean |
tryReuseTypeFromCache(String typeName)
Mark a type to be reused from the generator result cache, if available.
|
public boolean checkRebindRuleAvailable(String sourceTypeName)
GeneratorContext
checkRebindRuleAvailable
in interface GeneratorContext
sourceTypeName
- the name of a type to check for rebind rule
availability.public void commit(TreeLogger logger, PrintWriter pw)
GeneratorContext
GeneratorContext.tryCreate(TreeLogger, String, String)
.commit
in interface GeneratorContext
public void commitArtifact(TreeLogger logger, Artifact<?> artifact)
GeneratorContext
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.commitArtifact
in interface GeneratorContext
logger
- a logger; normally the logger passed into the currently
invoked generator or a branch thereofartifact
- the Artifact to provide to the Linker chain.public GeneratedResource commitResource(TreeLogger logger, OutputStream os)
GeneratorContext
GeneratorContext.tryCreateResource(TreeLogger, String)
.commitResource
in interface GeneratorContext
public CachedGeneratorResult getCachedGeneratorResult()
GeneratorContext
getCachedGeneratorResult
in interface GeneratorContext
CachedGeneratorResult
object, if one has been provided to
the context. Null is returned if there is no previous result
available.public PropertyOracle getPropertyOracle()
GeneratorContext
getPropertyOracle
in interface GeneratorContext
public ResourceOracle getResourcesOracle()
GeneratorContext
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.getResourcesOracle
in interface GeneratorContext
public TypeOracle getTypeOracle()
GeneratorContext
getTypeOracle
in interface GeneratorContext
public boolean isGeneratorResultCachingEnabled()
GeneratorContext
isGeneratorResultCachingEnabled
in interface GeneratorContext
public boolean isProdMode()
GeneratorContext
isProdMode
in interface GeneratorContext
public PrintWriter tryCreate(TreeLogger logger, String packageName, String simpleName)
GeneratorContext
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 GeneratorContext.commit(TreeLogger, PrintWriter)
is
called.tryCreate
in interface GeneratorContext
logger
- a logger; normally the logger passed into the currently
invoked generator, or a branch thereofpackageName
- the name of the package to which the create type belongssimpleName
- the unqualified source name of the type being generatednull
if the package and class already exists,
otherwise a PrintWriter
is returned.public OutputStream tryCreateResource(TreeLogger logger, String partialPath)
GeneratorContext
OutputStream
so that the caller can write
file contents into the named file underneath the compilation output
directory. The file is not committed until
GeneratorContext.commitResource(TreeLogger, OutputStream)
is called.tryCreateResource
in interface GeneratorContext
logger
- a logger; normally the logger passed into the currently
invoked generator, or a branch thereofpartialPath
- the name of the file whose contents are to be written;
the name can include subdirectories separated by forward slashes
('/')OutputStream
into which file contents can be
written, or null
if a resource by that name is already
pending or already existspublic boolean tryReuseTypeFromCache(String typeName)
GeneratorContext
IncrementalGenerator.generateIncrementally(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)
, with a result
containing RebindMode.USE_PARTIAL_CACHED
.tryReuseTypeFromCache
in interface GeneratorContext
typeName
- the fully qualified source name of a type.Copyright © 2018. All rights reserved.