Class IncrementalGenerator
Generator
class which supports incremental
generation. It adds a generateIncrementally(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)
method.-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.gwt.core.ext.Generator
Generator.RunsLocal
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal String
generate
(TreeLogger logger, GeneratorContext context, String typeName) This method overridesGenerator.generate(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)
, and is included only for backwards compatibility.abstract RebindResult
generateIncrementally
(TreeLogger logger, GeneratorContext context, String typeName) Incrementally generate a default constructible subclass of the requested type.static RebindResult
generateNonIncrementally
(TreeLogger logger, Generator generator, GeneratorContext context, String typeName) A static helper method to wrap a non-incremental generator's result.abstract long
Returns a version id for an IncrementalGenerator.Methods inherited from class com.google.gwt.core.ext.Generator
escape, escapeClassName
-
Constructor Details
-
IncrementalGenerator
public IncrementalGenerator()
-
-
Method Details
-
generateNonIncrementally
public static RebindResult generateNonIncrementally(TreeLogger logger, Generator generator, GeneratorContext context, String typeName) throws UnableToCompleteException A static helper method to wrap a non-incremental generator's result. It calls the generator'sGenerator.generate(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)
method, and synthesizes aRebindResult
instance to be returned.- Parameters:
logger
- A TreeLoggergenerator
- A non-incremental generatorcontext
- The generator contexttypeName
- The type for which a subclass will be generated- Returns:
- a RebindResult
- Throws:
UnableToCompleteException
-
generate
public final String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException This method overridesGenerator.generate(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)
, and is included only for backwards compatibility. It wraps a call togenerateIncrementally(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.GeneratorContext, java.lang.String)
. This method won't normally be called by the gwt rebind process, and it is declared final and can't be overridden. It is provided in support of existing applications and other generators which call this method directly, outside of the gwt framework.The passed in context is wrapped with an instance of
NonIncrementalGeneratorContext
, to ensure that no generator result caching is attempted, since the cached result will be ignored by callers of this method anyway.- Specified by:
generate
in classGenerator
- Parameters:
logger
- A TreeLoggercontext
- The generator contexttypeName
- The type for which a subclass will be generated- Returns:
- the name of a subclass to substitute for the requested class, or
return
null
to cause the requested type itself to be used - Throws:
UnableToCompleteException
- See Also:
-
generateIncrementally
public abstract RebindResult generateIncrementally(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException Incrementally generate a default constructible subclass of the requested type. The generator can use information from the context to make decisions on whether to incrementally reuse cached output from previous invocations.It returns a
RebindResult
, which contains aRebindMode
field, which indicates whether to use previously cached output, newly generated output, or a partial mixture of both cached and newly generated output.The result also includes a field for the name of the subclass to substitute for the requested class. It may also contain extra client data added by specific generator implementations.
This method throws an
UnableToCompleteException
if for any reason it cannot complete successfully.- Parameters:
logger
- A TreeLoggercontext
- The generator contexttypeName
- The type for which a subclass will be generated- Returns:
- a RebindResult
- Throws:
UnableToCompleteException
- See Also:
-
getVersionId
public abstract long getVersionId()Returns a version id for an IncrementalGenerator. It is used by the system to invalidateCachedGeneratorResult
's that were generated by a different version of this generator. This is useful when new versions of a generator are developed, which might alter the structure of generated output, or alter semantics for cache reusability checking.It is the responsibility of the developer to maintain this version id consistently.
- Returns:
- a version id
-