Package com.google.gwt.core.ext
Class StubGeneratorContext
java.lang.Object
com.google.gwt.core.ext.StubGeneratorContext
- All Implemented Interfaces:
GeneratorContext
An abstract generator context class which by default throws
UnsupportedOperationException for all methods. Implementing classes can
selectively override individual methods. Useful for mocking and/or selective
reuse of generator functionality.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckRebindRuleAvailable(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.voidcommit(TreeLogger logger, PrintWriter pw) Commits source generation begun withGeneratorContext.tryCreate(TreeLogger, String, String).voidcommitArtifact(TreeLogger logger, Artifact<?> artifact) Add an Artifact to theArtifactSetthat will be presented to theLinkerchain at the end of the compilation cycle.commitResource(TreeLogger logger, OutputStream os) Commits resource generation begun withGeneratorContext.tryCreateResource(TreeLogger, String).Get the cached rebind result that has been provided to the context, if available.Gets the property oracle for the current generator context.com.google.gwt.dev.resource.ResourceOracleReturns a resource oracle containing all resources that are mapped into the module's source (or super-source) paths.Gets the type oracle for the current generator context.booleanCheck whether generator result caching is currently enabled.booleanReturns true if generators are being run to produce code for a production compile.tryCreate(TreeLogger logger, String packageName, String simpleName) Attempts to get aPrintWriterso that the caller can generate the source code for the named type.tryCreateResource(TreeLogger logger, String partialPath) Attempts to get anOutputStreamso that the caller can write file contents into the named file underneath the compilation output directory.booleantryReuseTypeFromCache(String typeName) Mark a type to be reused from the generator result cache, if available.
-
Constructor Details
-
StubGeneratorContext
public StubGeneratorContext()
-
-
Method Details
-
checkRebindRuleAvailable
Description copied from interface:GeneratorContextChecks whether a rebind rule is available for a given sourceTypeName, such as can appear in a replace-with or generate-with rule.- Specified by:
checkRebindRuleAvailablein interfaceGeneratorContext- Parameters:
sourceTypeName- the name of a type to check for rebind rule availability.- Returns:
- true if a rebind rule is available
-
commit
Description copied from interface:GeneratorContextCommits source generation begun withGeneratorContext.tryCreate(TreeLogger, String, String).- Specified by:
commitin interfaceGeneratorContext
-
commitArtifact
Description copied from interface:GeneratorContextAdd an Artifact to theArtifactSetthat will be presented to theLinkerchain 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 callingArtifactSet.replace(Artifact)if an equivalent Artifact had previously been committed.- Specified by:
commitArtifactin interfaceGeneratorContext- Parameters:
logger- a logger; normally the logger passed into the currently invoked generator or a branch thereofartifact- the Artifact to provide to the Linker chain.
-
commitResource
Description copied from interface:GeneratorContextCommits resource generation begun withGeneratorContext.tryCreateResource(TreeLogger, String).- Specified by:
commitResourcein interfaceGeneratorContext- Returns:
- the GeneratedResource that was created as a result of committing the OutputStream.
-
getCachedGeneratorResult
Description copied from interface:GeneratorContextGet the cached rebind result that has been provided to the context, if available. The provided result will be the most recent previously generated result for the currently active rebind rule and requested type name.- Specified by:
getCachedGeneratorResultin interfaceGeneratorContext- Returns:
- A
CachedGeneratorResultobject, if one has been provided to the context. Null is returned if there is no previous result available.
-
getPropertyOracle
Description copied from interface:GeneratorContextGets the property oracle for the current generator context. Generators can use the property oracle to query deferred binding properties.- Specified by:
getPropertyOraclein interfaceGeneratorContext
-
getResourcesOracle
public com.google.gwt.dev.resource.ResourceOracle getResourcesOracle()Description copied from interface:GeneratorContextReturns 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 includescom.google.gwt.core.clientas a source package, then a resource atcom/google/gwt/core/client/Foo.propertieswould be exposed by this resource oracle.- Specified by:
getResourcesOraclein interfaceGeneratorContext
-
getTypeOracle
Description copied from interface:GeneratorContextGets the type oracle for the current generator context. Generators can use the type oracle to ask questions about the entire translatable code base.- Specified by:
getTypeOraclein interfaceGeneratorContext- Returns:
- a TypeOracle over all the relevant translatable compilation units in the source path
-
isGeneratorResultCachingEnabled
public boolean isGeneratorResultCachingEnabled()Description copied from interface:GeneratorContextCheck whether generator result caching is currently enabled.- Specified by:
isGeneratorResultCachingEnabledin interfaceGeneratorContext
-
isProdMode
public boolean isProdMode()Description copied from interface:GeneratorContextReturns true if generators are being run to produce code for a production compile. Returns false for dev mode. Generators can use this information to produce code optimized for the target.- Specified by:
isProdModein interfaceGeneratorContext
-
tryCreate
Description copied from interface:GeneratorContextAttempts to get aPrintWriterso that the caller can generate the source code for the named type. If the named types already exists,nullis returned to indicate that no work needs to be done. The file is not committed untilGeneratorContext.commit(TreeLogger, PrintWriter)is called.- Specified by:
tryCreatein interfaceGeneratorContext- Parameters:
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 generated- Returns:
nullif the package and class already exists, otherwise aPrintWriteris returned.
-
tryCreateResource
Description copied from interface:GeneratorContextAttempts to get anOutputStreamso that the caller can write file contents into the named file underneath the compilation output directory. The file is not committed untilGeneratorContext.commitResource(TreeLogger, OutputStream)is called.- Specified by:
tryCreateResourcein interfaceGeneratorContext- Parameters:
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 ('/')- Returns:
- an
OutputStreaminto which file contents can be written, ornullif a resource by that name is already pending or already exists
-
tryReuseTypeFromCache
Description copied from interface:GeneratorContextMark a type to be reused from the generator result cache, if available. Calling this method with a successful response indicates that the calling generator will not re-generate this type. A cached version of this type will be added to the context once the calling generator returns fromIncrementalGenerator.generateIncrementally(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String), with a result containingRebindMode.USE_PARTIAL_CACHED.- Specified by:
tryReuseTypeFromCachein interfaceGeneratorContext- Parameters:
typeName- the fully qualified source name of a type.- Returns:
- true if the requested type is available from the generator result cache, false otherwise.
-