public abstract class SelectionScriptLinker extends AbstractLinker
Modifier and Type | Field and Description |
---|---|
protected static String |
COMPUTE_SCRIPT_BASE_JS
File name for computeScriptBase.js.
|
protected static String |
FRAGMENT_EXTENSION
The extension added to demand-loaded fragment files.
|
protected static String |
FRAGMENT_SUBDIR
A subdirectory to hold all the generated fragments.
|
protected static PermutationsUtil |
permutationsUtil
Utility class to handle insertion of permutations code.
|
protected static String |
PROCESS_METAS_JS
File name for processMetas.js.
|
static String |
USE_SOURCE_MAPS_PROPERTY |
Constructor and Description |
---|
SelectionScriptLinker() |
Modifier and Type | Method and Description |
---|---|
protected int |
charsPerChunk(LinkerContext context,
TreeLogger logger)
Extract via
CHUNK_SIZE_PROPERTY the number of characters to be included in each
chunk. |
protected Collection<Artifact<?>> |
doEmitCompilation(TreeLogger logger,
LinkerContext context,
CompilationResult result,
ArtifactSet artifacts) |
protected List<Artifact<?>> |
emitSelectionInformation(String strongName,
CompilationResult result) |
protected EmittedArtifact |
emitSelectionScript(TreeLogger logger,
LinkerContext context,
ArtifactSet artifacts) |
protected String |
fillSelectionScriptTemplate(StringBuffer selectionScript,
TreeLogger logger,
LinkerContext context,
ArtifactSet artifacts,
CompilationResult result)
Generate a selection script.
|
protected String |
generateDeferredFragment(TreeLogger logger,
LinkerContext context,
int fragment,
String js,
ArtifactSet artifacts,
CompilationResult result) |
protected byte[] |
generatePrimaryFragment(TreeLogger logger,
LinkerContext context,
CompilationResult result,
String[] js,
ArtifactSet artifacts)
Generate the primary fragment.
|
protected String |
generatePrimaryFragmentString(TreeLogger logger,
LinkerContext context,
CompilationResult result,
String js,
int length,
ArtifactSet artifacts) |
protected String |
generateSelectionScript(TreeLogger logger,
LinkerContext context,
ArtifactSet artifacts) |
protected String |
generateSelectionScript(TreeLogger logger,
LinkerContext context,
ArtifactSet artifacts,
CompilationResult result) |
protected abstract String |
getCompilationExtension(TreeLogger logger,
LinkerContext context) |
protected String |
getDeferredFragmentPrefix(TreeLogger logger,
LinkerContext context,
int fragment) |
protected String |
getDeferredFragmentSuffix(TreeLogger logger,
LinkerContext context,
int fragment)
Deprecated.
|
protected String |
getDeferredFragmentSuffix2(TreeLogger logger,
LinkerContext context,
int fragment,
String strongName)
Returns the suffix at the end of a JavaScript fragment other than the initial fragment
(new version).
|
protected String |
getFragmentSubdir(TreeLogger logger,
LinkerContext context)
Returns the subdirectory name to be used by getModulPrefix when requesting a runAsync module.
|
protected String |
getHostedFilename() |
protected abstract String |
getModulePrefix(TreeLogger logger,
LinkerContext context,
String strongName)
Compute the beginning of a JavaScript file that will hold the main module implementation.
|
protected String |
getModulePrefix(TreeLogger logger,
LinkerContext context,
String strongName,
int numFragments)
Compute the beginning of a JavaScript file that will hold the main module implementation.
|
protected String |
getModuleSuffix(TreeLogger logger,
LinkerContext context)
Deprecated.
|
protected String |
getModuleSuffix2(TreeLogger logger,
LinkerContext context,
String strongName)
Returns the suffix for the initial JavaScript fragment (new version).
|
protected String |
getScriptChunkSeparator(TreeLogger logger,
LinkerContext context)
Some subclasses support "chunking" of the primary fragment.
|
protected abstract String |
getSelectionScriptTemplate(TreeLogger logger,
LinkerContext context) |
ArtifactSet |
link(TreeLogger logger,
LinkerContext context,
ArtifactSet artifacts)
This method is left in place for existing subclasses of SelectionScriptLinker that have not
been upgraded for the sharding API.
|
ArtifactSet |
link(TreeLogger logger,
LinkerContext context,
ArtifactSet artifacts,
boolean onePermutation)
This method is invoked for linkers annotated with
Shardable . |
protected void |
maybeAddHostedModeFile(TreeLogger logger,
LinkerContext context,
ArtifactSet artifacts,
CompilationResult result)
Add the Development Mode file to the artifact set.
|
protected void |
maybeOutputPropertyMap(TreeLogger logger,
LinkerContext context,
ArtifactSet toReturn) |
protected StringBuffer |
readFileToStringBuffer(String filename,
TreeLogger logger) |
protected static void |
replaceAll(StringBuffer buf,
String search,
String replace) |
static String |
splitPrimaryJavaScript(StatementRanges ranges,
String js,
int charsPerChunk,
String scriptChunkSeparator,
LinkerContext context)
Split a JavaScript string into multiple chunks, at statement boundaries.
|
boolean |
supportsDevModeInJunit(LinkerContext context)
Returns
true if this linker supports DevMode. |
protected String |
wrapDeferredFragment(TreeLogger logger,
LinkerContext context,
int fragment,
String script,
ArtifactSet artifacts) |
protected String |
wrapPrimaryFragment(TreeLogger logger,
LinkerContext context,
String script,
ArtifactSet artifacts,
CompilationResult result) |
emitBytes, emitBytes, emitInputStream, emitInputStream, emitString, emitString, emitWithStrongName, emitWithStrongName
getDescription, isShardable, relink
public static final String USE_SOURCE_MAPS_PROPERTY
protected static final String COMPUTE_SCRIPT_BASE_JS
protected static final String FRAGMENT_EXTENSION
protected static final String FRAGMENT_SUBDIR
protected static PermutationsUtil permutationsUtil
protected static final String PROCESS_METAS_JS
public static String splitPrimaryJavaScript(StatementRanges ranges, String js, int charsPerChunk, String scriptChunkSeparator, LinkerContext context)
ranges
- Describes where the statements are located within the JavaScript
code. If null
, then return js
unchanged.js
- The JavaScript code to be split up.charsPerChunk
- The number of characters to be put in each script tag.scriptChunkSeparator
- The string to insert between chunks.context
- protected static void replaceAll(StringBuffer buf, String search, String replace)
public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts) throws UnableToCompleteException
link
in class Linker
logger
- the TreeLogger to record tocontext
- provides access to the Linker's environmentartifacts
- an unmodifiable view of the artifacts to linkUnableToCompleteException
- if compilation violates assumptions made
by the Linker or for errors encountered by the Linkerpublic ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, boolean onePermutation) throws UnableToCompleteException
Linker
This method is invoked for linkers annotated with Shardable
. It is
called at two points during compilation: after the compile of each
permutation, and after all compilation has finished. The
onePermutation
is true
for a per-permutation call
and false
for a global final-link call.
For one-permutation calls, this method is passed all artifacts generated for just the one permutation. For the global call at the end of compilation, this method sees artifacts for the whole compilation, but with two modifications intended to support builds on computer clusters:
Transferable
have been discarded.
link
in class Linker
logger
- the TreeLogger to record tocontext
- provides access to the Linker's environmentartifacts
- an unmodifiable view of the artifacts to linkonePermutation
- true for a one-permutation callUnableToCompleteException
- if compilation violates assumptions made
by the Linker or for errors encountered by the Linkerpublic boolean supportsDevModeInJunit(LinkerContext context)
Linker
true
if this linker supports DevMode.supportsDevModeInJunit
in class Linker
context
- a LinkerContextprotected int charsPerChunk(LinkerContext context, TreeLogger logger)
CHUNK_SIZE_PROPERTY
the number of characters to be included in each
chunk.protected Collection<Artifact<?>> doEmitCompilation(TreeLogger logger, LinkerContext context, CompilationResult result, ArtifactSet artifacts) throws UnableToCompleteException
UnableToCompleteException
protected List<Artifact<?>> emitSelectionInformation(String strongName, CompilationResult result)
protected EmittedArtifact emitSelectionScript(TreeLogger logger, LinkerContext context, ArtifactSet artifacts) throws UnableToCompleteException
UnableToCompleteException
protected String fillSelectionScriptTemplate(StringBuffer selectionScript, TreeLogger logger, LinkerContext context, ArtifactSet artifacts, CompilationResult result) throws UnableToCompleteException
PermutationsUtil.setupPermutationsMap(ArtifactSet)
.UnableToCompleteException
protected String generateDeferredFragment(TreeLogger logger, LinkerContext context, int fragment, String js, ArtifactSet artifacts, CompilationResult result) throws UnableToCompleteException
logger
- a TreeLoggercontext
- a LinkerContextfragment
- the fragment numberUnableToCompleteException
protected byte[] generatePrimaryFragment(TreeLogger logger, LinkerContext context, CompilationResult result, String[] js, ArtifactSet artifacts) throws UnableToCompleteException
getModulePrefix(TreeLogger, LinkerContext, String, int)
and getModuleSuffix(TreeLogger, LinkerContext)
.UnableToCompleteException
protected String generatePrimaryFragmentString(TreeLogger logger, LinkerContext context, CompilationResult result, String js, int length, ArtifactSet artifacts) throws UnableToCompleteException
UnableToCompleteException
protected String generateSelectionScript(TreeLogger logger, LinkerContext context, ArtifactSet artifacts) throws UnableToCompleteException
UnableToCompleteException
protected String generateSelectionScript(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, CompilationResult result) throws UnableToCompleteException
UnableToCompleteException
protected abstract String getCompilationExtension(TreeLogger logger, LinkerContext context) throws UnableToCompleteException
UnableToCompleteException
protected String getDeferredFragmentPrefix(TreeLogger logger, LinkerContext context, int fragment)
@Deprecated protected String getDeferredFragmentSuffix(TreeLogger logger, LinkerContext context, int fragment)
getDeferredFragmentSuffix2(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.LinkerContext, int, java.lang.String)
to be called instead. Subclasses should switch to
extending getDeferredFragmentSuffix2.protected String getDeferredFragmentSuffix2(TreeLogger logger, LinkerContext context, int fragment, String strongName)
getDeferredFragmentSuffix(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.LinkerContext, int)
is overridden
to return non-null. Subclasses should stop implementing getDeferredFramgnentSuffix and
implement getDeferredFragmentSuffix2 instead.protected final String getFragmentSubdir(TreeLogger logger, LinkerContext context) throws UnableToCompleteException
PROP_FRAGMENT_SUBDIR_OVERRIDE
and, aside from test cases, is always
FRAGMENT_SUBDIR
.UnableToCompleteException
protected String getHostedFilename()
protected abstract String getModulePrefix(TreeLogger logger, LinkerContext context, String strongName) throws UnableToCompleteException
UnableToCompleteException
protected String getModulePrefix(TreeLogger logger, LinkerContext context, String strongName, int numFragments) throws UnableToCompleteException
getModulePrefix(TreeLogger, LinkerContext, String)
.strongName
- strong name of the module being emittednumFragments
- the number of fragments for this module, including the main fragment
(fragment 0)UnableToCompleteException
@Deprecated protected String getModuleSuffix(TreeLogger logger, LinkerContext context) throws UnableToCompleteException
getModuleSuffix2(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.LinkerContext, java.lang.String)
to be called instead.
Subclasses should switch to extending getModuleSuffix2.UnableToCompleteException
protected String getModuleSuffix2(TreeLogger logger, LinkerContext context, String strongName) throws UnableToCompleteException
getModuleSuffix(com.google.gwt.core.ext.TreeLogger, com.google.gwt.core.ext.LinkerContext)
is overridden so that it doesn't return null.
Subclasses should stop implementing getModuleSuffix and implmenet getModuleSuffix2 instead.UnableToCompleteException
protected String getScriptChunkSeparator(TreeLogger logger, LinkerContext context)
protected abstract String getSelectionScriptTemplate(TreeLogger logger, LinkerContext context) throws UnableToCompleteException
UnableToCompleteException
protected void maybeAddHostedModeFile(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, CompilationResult result) throws UnableToCompleteException
UnableToCompleteException
protected void maybeOutputPropertyMap(TreeLogger logger, LinkerContext context, ArtifactSet toReturn)
protected StringBuffer readFileToStringBuffer(String filename, TreeLogger logger) throws UnableToCompleteException
UnableToCompleteException
protected String wrapDeferredFragment(TreeLogger logger, LinkerContext context, int fragment, String script, ArtifactSet artifacts) throws UnableToCompleteException
UnableToCompleteException
protected String wrapPrimaryFragment(TreeLogger logger, LinkerContext context, String script, ArtifactSet artifacts, CompilationResult result) throws UnableToCompleteException
UnableToCompleteException
Copyright © 2016. All rights reserved.