Reformatting pass with updated gwt-format.xml Eclipse formatter before persistent unit cache patch
review.
Review at http://gwt-code-reviews.appspot.com/1368802
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9812 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/DevMode.java b/dev/core/src/com/google/gwt/dev/DevMode.java
index 7d186b2..baa3362 100644
--- a/dev/core/src/com/google/gwt/dev/DevMode.java
+++ b/dev/core/src/com/google/gwt/dev/DevMode.java
@@ -114,9 +114,10 @@
}
Throwable t;
try {
- Class<?> clazz = Class.forName(sclClassName, true,
- Thread.currentThread().getContextClassLoader());
- Class<? extends ServletContainerLauncher> sclClass = clazz.asSubclass(ServletContainerLauncher.class);
+ Class<?> clazz =
+ Class.forName(sclClassName, true, Thread.currentThread().getContextClassLoader());
+ Class<? extends ServletContainerLauncher> sclClass =
+ clazz.asSubclass(ServletContainerLauncher.class);
options.setServletContainerLauncher(sclClass.newInstance());
options.setServletContainerLauncherArgs(sclArgs);
return true;
@@ -196,8 +197,7 @@
/**
* Options controlling dev mode.
*/
- protected interface HostedModeOptions extends HostedModeBaseOptions,
- CompilerOptions {
+ protected interface HostedModeOptions extends HostedModeBaseOptions, CompilerOptions {
ServletContainerLauncher getServletContainerLauncher();
String getServletContainerLauncherArgs();
@@ -210,8 +210,8 @@
/**
* Concrete class to implement all hosted mode options.
*/
- protected static class HostedModeOptionsImpl extends
- HostedModeBaseOptionsImpl implements HostedModeOptions {
+ protected static class HostedModeOptionsImpl extends HostedModeBaseOptionsImpl implements
+ HostedModeOptions {
private File extraDir;
private int localWorkers;
private ServletContainerLauncher scl;
@@ -223,8 +223,7 @@
* @return the deploy directory.
*/
public File getDeployDir() {
- return (deployDir == null) ? new File(warDir, "WEB-INF/deploy")
- : deployDir;
+ return (deployDir == null) ? new File(warDir, "WEB-INF/deploy") : deployDir;
}
public File getExtraDir() {
@@ -290,8 +289,8 @@
/**
* The pattern for files usable as startup URLs.
*/
- private static final Pattern STARTUP_FILE_PATTERN = Pattern.compile(
- ".*\\.(html|jsp)", Pattern.CASE_INSENSITIVE);
+ private static final Pattern STARTUP_FILE_PATTERN = Pattern.compile(".*\\.(html|jsp)",
+ Pattern.CASE_INSENSITIVE);
/**
* Startup development mode.
@@ -385,13 +384,13 @@
}
}
- TreeLogger branch = getTopLogger().branch(TreeLogger.TRACE,
- "Linking modules");
+ TreeLogger branch = getTopLogger().branch(TreeLogger.TRACE, "Linking modules");
Event slowStartupEvent = SpeedTracerLogger.start(DevModeEventType.SLOW_STARTUP);
try {
for (ModuleDef module : startupModules.values()) {
- TreeLogger loadLogger = branch.branch(TreeLogger.DEBUG,
- "Bootstrap link for command-line module '" + module.getCanonicalName() + "'");
+ TreeLogger loadLogger =
+ branch.branch(TreeLogger.DEBUG, "Bootstrap link for command-line module '"
+ + module.getCanonicalName() + "'");
link(loadLogger, module);
}
} catch (UnableToCompleteException e) {
@@ -430,8 +429,7 @@
}
}
- TreeLogger branch = getTopLogger().branch(TreeLogger.TRACE,
- "Loading modules");
+ TreeLogger branch = getTopLogger().branch(TreeLogger.TRACE, "Loading modules");
try {
for (String moduleName : options.getModuleNames()) {
TreeLogger moduleBranch = branch.branch(TreeLogger.TRACE, moduleName);
@@ -441,30 +439,27 @@
startupModules.put(module.getName(), module);
if (!options.isNoServer()) {
- validateServletTags(moduleBranch, servletValidator, servletWriter,
- module);
+ validateServletTags(moduleBranch, servletValidator, servletWriter, module);
}
}
if (servletWriter != null) {
servletWriter.realize(webXml);
}
} catch (IOException e) {
- getTopLogger().log(TreeLogger.WARN,
- "Unable to generate '" + webXml.getAbsolutePath() + "'");
+ getTopLogger().log(TreeLogger.WARN, "Unable to generate '" + webXml.getAbsolutePath() + "'");
} catch (UnableToCompleteException e) {
// Already logged.
return false;
}
return true;
}
-
+
@Override
protected int doStartUpServer() {
// Create the war directory if it doesn't exist
File warDir = options.getWarDir();
if (!warDir.exists() && !warDir.mkdirs()) {
- getTopLogger().log(TreeLogger.ERROR,
- "Unable to create war directory " + warDir);
+ getTopLogger().log(TreeLogger.ERROR, "Unable to create war directory " + warDir);
return -1;
}
@@ -475,8 +470,7 @@
ServletContainerLauncher scl = options.getServletContainerLauncher();
- TreeLogger serverLogger = ui.getWebServerLogger(getWebServerName(),
- scl.getIconBytes());
+ TreeLogger serverLogger = ui.getWebServerLogger(getWebServerName(), scl.getIconBytes());
String sclArgs = options.getServletContainerLauncherArgs();
if (sclArgs != null) {
@@ -502,17 +496,13 @@
}
scl.setBindAddress(bindAddress);
- serverLogger.log(TreeLogger.TRACE, "Starting HTTP on port " + getPort(),
- null);
+ serverLogger.log(TreeLogger.TRACE, "Starting HTTP on port " + getPort(), null);
server = scl.start(serverLogger, getPort(), options.getWarDir());
assert (server != null);
clearCallback = false;
return server.getPort();
} catch (BindException e) {
- System.err.println("Port "
- + bindAddress
- + ':'
- + getPort()
+ System.err.println("Port " + bindAddress + ':' + getPort()
+ " is already is use; you probably still have another session active");
} catch (Exception e) {
System.err.println("Unable to start embedded HTTP server");
@@ -549,8 +539,8 @@
}
@Override
- protected ModuleDef loadModule(TreeLogger logger, String moduleName,
- boolean refresh) throws UnableToCompleteException {
+ protected ModuleDef loadModule(TreeLogger logger, String moduleName, boolean refresh)
+ throws UnableToCompleteException {
if (startupModules.containsKey(moduleName)) {
// First load of a startup module; remove from list, no need to refresh.
return startupModules.remove(moduleName);
@@ -559,28 +549,23 @@
}
@Override
- protected synchronized void produceOutput(TreeLogger logger,
- StandardLinkerContext linkerStack, ArtifactSet artifacts,
- ModuleDef module, boolean isRelink) throws UnableToCompleteException {
- TreeLogger linkLogger = logger.branch(TreeLogger.DEBUG, "Linking module '"
- + module.getName() + "'");
+ protected synchronized void produceOutput(TreeLogger logger, StandardLinkerContext linkerStack,
+ ArtifactSet artifacts, ModuleDef module, boolean isRelink) throws UnableToCompleteException {
+ TreeLogger linkLogger =
+ logger.branch(TreeLogger.DEBUG, "Linking module '" + module.getName() + "'");
- OutputFileSetOnDirectory outFileSet = new OutputFileSetOnDirectory(
- options.getWarDir(), module.getName() + "/");
- OutputFileSetOnDirectory deployFileSet = new OutputFileSetOnDirectory(
- options.getDeployDir(), module.getName() + "/");
+ OutputFileSetOnDirectory outFileSet =
+ new OutputFileSetOnDirectory(options.getWarDir(), module.getName() + "/");
+ OutputFileSetOnDirectory deployFileSet =
+ new OutputFileSetOnDirectory(options.getDeployDir(), module.getName() + "/");
OutputFileSet extraFileSet = new NullOutputFileSet();
if (options.getExtraDir() != null) {
- extraFileSet = new OutputFileSetOnDirectory(options.getExtraDir(),
- module.getName() + "/");
+ extraFileSet = new OutputFileSetOnDirectory(options.getExtraDir(), module.getName() + "/");
}
- linkerStack.produceOutput(linkLogger, artifacts, Visibility.Public,
- outFileSet);
- linkerStack.produceOutput(linkLogger, artifacts, Visibility.Deploy,
- deployFileSet);
- linkerStack.produceOutput(linkLogger, artifacts, Visibility.Private,
- extraFileSet);
+ linkerStack.produceOutput(linkLogger, artifacts, Visibility.Public, outFileSet);
+ linkerStack.produceOutput(linkLogger, artifacts, Visibility.Deploy, deployFileSet);
+ linkerStack.produceOutput(linkLogger, artifacts, Visibility.Private, extraFileSet);
outFileSet.close();
deployFileSet.close();
@@ -594,23 +579,20 @@
@Override
protected void warnAboutNoStartupUrls() {
- getTopLogger().log(
- TreeLogger.WARN,
- "No startup URLs supplied and no plausible ones found -- use "
- + "-startupUrl");
+ getTopLogger().log(TreeLogger.WARN,
+ "No startup URLs supplied and no plausible ones found -- use " + "-startupUrl");
}
- private void validateServletTags(TreeLogger logger,
- ServletValidator servletValidator, ServletWriter servletWriter,
- ModuleDef module) {
+ private void validateServletTags(TreeLogger logger, ServletValidator servletValidator,
+ ServletWriter servletWriter, ModuleDef module) {
String[] servletPaths = module.getServletPaths();
if (servletPaths.length == 0) {
return;
}
- TreeLogger servletLogger = logger.branch(TreeLogger.DEBUG,
- "Validating <servlet> tags for module '" + module.getName() + "'",
- null, new InstalledHelpInfo("servletMappings.html"));
+ TreeLogger servletLogger =
+ logger.branch(TreeLogger.DEBUG, "Validating <servlet> tags for module '" + module.getName()
+ + "'", null, new InstalledHelpInfo("servletMappings.html"));
for (String servletPath : servletPaths) {
String servletClass = module.findServletForPath(servletPath);
assert (servletClass != null);
diff --git a/dev/core/src/com/google/gwt/dev/DevModeBase.java b/dev/core/src/com/google/gwt/dev/DevModeBase.java
index 1cfd74a..40046e0 100644
--- a/dev/core/src/com/google/gwt/dev/DevModeBase.java
+++ b/dev/core/src/com/google/gwt/dev/DevModeBase.java
@@ -75,9 +75,8 @@
*/
public class UiBrowserWidgetHostImpl implements BrowserWidgetHost {
- public ModuleHandle createModuleLogger(String moduleName, String userAgent,
- String url, String tabKey, String sessionKey,
- BrowserChannelServer serverChannel, byte[] userAgentIcon) {
+ public ModuleHandle createModuleLogger(String moduleName, String userAgent, String url,
+ String tabKey, String sessionKey, BrowserChannelServer serverChannel, byte[] userAgentIcon) {
if (sessionKey == null) {
// if we don't have a unique session key, make one up
sessionKey = randomString();
@@ -85,15 +84,17 @@
TreeLogger.Type maxLevel = options.getLogLevel();
String agentTag = BrowserInfo.getShortName(userAgent);
String remoteSocket = serverChannel.getRemoteEndpoint();
- ModuleHandle module = ui.getModuleLogger(userAgent, remoteSocket, url,
- tabKey, moduleName, sessionKey, agentTag, userAgentIcon, maxLevel);
+ ModuleHandle module =
+ ui.getModuleLogger(userAgent, remoteSocket, url, tabKey, moduleName, sessionKey,
+ agentTag, userAgentIcon, maxLevel);
return module;
}
- public ModuleSpaceHost createModuleSpaceHost(ModuleHandle module,
- String moduleName) throws UnableToCompleteException {
+ public ModuleSpaceHost createModuleSpaceHost(ModuleHandle module, String moduleName)
+ throws UnableToCompleteException {
Event moduleSpaceHostCreateEvent =
- SpeedTracerLogger.start(DevModeEventType.MODULE_SPACE_HOST_CREATE, "Module Name", moduleName);
+ SpeedTracerLogger.start(DevModeEventType.MODULE_SPACE_HOST_CREATE, "Module Name",
+ moduleName);
// TODO(jat): add support for closing an active module
TreeLogger logger = module.getLogger();
try {
@@ -101,8 +102,8 @@
ModuleDef moduleDef = loadModule(logger, moduleName, true);
assert (moduleDef != null);
- ShellModuleSpaceHost host = doCreateShellModuleSpaceHost(logger,
- moduleDef.getCompilationState(logger), moduleDef);
+ ShellModuleSpaceHost host =
+ doCreateShellModuleSpaceHost(logger, moduleDef.getCompilationState(logger), moduleDef);
return host;
} catch (RuntimeException e) {
logger.log(TreeLogger.ERROR, "Exception initializing module", e);
@@ -135,8 +136,8 @@
@Override
public String getPurpose() {
- return "Specifies the bind address for the code server and web server "
- + "(defaults to " + DEFAULT_BIND_ADDRESS + ")";
+ return "Specifies the bind address for the code server and web server " + "(defaults to "
+ + DEFAULT_BIND_ADDRESS + ")";
}
@Override
@@ -219,8 +220,7 @@
@Override
public String getPurpose() {
- return "Specifies the TCP port for the code server (defaults to "
- + DEFAULT_PORT + ")";
+ return "Specifies the TCP port for the code server (defaults to " + DEFAULT_PORT + ")";
}
@Override
@@ -449,18 +449,17 @@
/**
* Base options for dev mode.
*/
- protected interface HostedModeBaseOptions extends JJSOptions, OptionLogDir,
- OptionLogLevel, OptionGenDir, OptionNoServer, OptionPort,
- OptionCodeServerPort, OptionStartupURLs, OptionRemoteUI,
- OptionBindAddress {
+ protected interface HostedModeBaseOptions extends JJSOptions, OptionLogDir, OptionLogLevel,
+ OptionGenDir, OptionNoServer, OptionPort, OptionCodeServerPort, OptionStartupURLs,
+ OptionRemoteUI, OptionBindAddress {
}
/**
* Concrete class to implement all hosted mode base options.
*/
@SuppressWarnings("serial")
- protected static class HostedModeBaseOptionsImpl extends
- PrecompileOptionsImpl implements HostedModeBaseOptions {
+ protected static class HostedModeBaseOptionsImpl extends PrecompileOptionsImpl implements
+ HostedModeBaseOptions {
private String bindAddress;
private int codeServerPort;
@@ -676,8 +675,7 @@
private static final Random RNG = new Random();
- public static String normalizeURL(String unknownUrlText, boolean isHttps,
- int port, String host) {
+ public static String normalizeURL(String unknownUrlText, boolean isHttps, int port, String host) {
if (unknownUrlText.contains("://")) {
// Assume it's a full url.
return unknownUrlText;
@@ -724,7 +722,7 @@
}
return buf.toString();
}
-
+
protected TreeLogger.Type baseLogLevelForUI = null;
protected String bindAddress;
@@ -773,8 +771,7 @@
*/
public TreeLogger.Type getBaseLogLevelForUI() {
if (baseLogLevelForUI == null) {
- throw new IllegalStateException(
- "The ui must be created before calling this method.");
+ throw new IllegalStateException("The ui must be created before calling this method.");
}
return baseLogLevelForUI;
@@ -844,14 +841,11 @@
* @param moduleDef
* @return ShellModuleSpaceHost instance
*/
- protected final ShellModuleSpaceHost doCreateShellModuleSpaceHost(
- TreeLogger logger, CompilationState compilationState, ModuleDef moduleDef)
- throws UnableToCompleteException {
- ArtifactAcceptor artifactAcceptor = createArtifactAcceptor(logger,
- moduleDef);
- return new ShellModuleSpaceHost(logger, compilationState, moduleDef,
- options.getGenDir(), artifactAcceptor,
- getRebindCache(moduleDef.getName()));
+ protected final ShellModuleSpaceHost doCreateShellModuleSpaceHost(TreeLogger logger,
+ CompilationState compilationState, ModuleDef moduleDef) throws UnableToCompleteException {
+ ArtifactAcceptor artifactAcceptor = createArtifactAcceptor(logger, moduleDef);
+ return new ShellModuleSpaceHost(logger, compilationState, moduleDef, options.getGenDir(),
+ artifactAcceptor, getRebindCache(moduleDef.getName()));
}
protected abstract void doShutDownServer();
@@ -896,8 +890,8 @@
Thread checkerThread = new Thread("GWT Update Checker") {
@Override
public void run() {
- CheckForUpdates.logUpdateAvailable(logger,
- updateChecker.check(checkForUpdatesInterval()));
+ CheckForUpdates
+ .logUpdateAvailable(logger, updateChecker.check(checkForUpdatesInterval()));
}
};
checkerThread.setDaemon(true);
@@ -915,8 +909,9 @@
protected void ensureCodeServerListener() {
if (listener == null) {
codeServerPort = options.getCodeServerPort();
- listener = new BrowserListener(getTopLogger(), bindAddress,
- codeServerPort, new OophmSessionHandler(getTopLogger(), browserHost));
+ listener =
+ new BrowserListener(getTopLogger(), bindAddress, codeServerPort, new OophmSessionHandler(
+ getTopLogger(), browserHost));
listener.start();
try {
// save the port we actually used if it was auto
@@ -958,14 +953,12 @@
*/
protected final StandardLinkerContext link(TreeLogger logger, ModuleDef module)
throws UnableToCompleteException {
- TreeLogger linkLogger = logger.branch(TreeLogger.DEBUG, "Linking module '"
- + module.getName() + "'");
+ TreeLogger linkLogger =
+ logger.branch(TreeLogger.DEBUG, "Linking module '" + module.getName() + "'");
// Create a new active linker stack for the fresh link.
- StandardLinkerContext linkerStack = new StandardLinkerContext(linkLogger,
- module, options);
- ArtifactSet artifacts = linkerStack.getArtifactsForPublicResources(logger,
- module);
+ StandardLinkerContext linkerStack = new StandardLinkerContext(linkLogger, module, options);
+ ArtifactSet artifacts = linkerStack.getArtifactsForPublicResources(logger, module);
artifacts = linkerStack.invokeLegacyLinkers(linkLogger, artifacts);
artifacts = linkerStack.invokeFinalLink(linkLogger, artifacts);
produceOutput(linkLogger, linkerStack, artifacts, module, false);
@@ -981,10 +974,9 @@
* @return the loaded module
* @throws UnableToCompleteException
*/
- protected ModuleDef loadModule(TreeLogger logger, String moduleName,
- boolean refresh) throws UnableToCompleteException {
- ModuleDef moduleDef = ModuleDefLoader.loadFromClassPath(logger, moduleName,
- refresh);
+ protected ModuleDef loadModule(TreeLogger logger, String moduleName, boolean refresh)
+ throws UnableToCompleteException {
+ ModuleDef moduleDef = ModuleDefLoader.loadFromClassPath(logger, moduleName, refresh);
assert (moduleDef != null) : "Required module state is absent";
return moduleDef;
}
@@ -1000,8 +992,8 @@
String path = parsedUrl.getPath();
String query = parsedUrl.getQuery();
String hash = parsedUrl.getRef();
- String hostedParam = BrowserListener.getDevModeURLParams(connectAddress,
- listener.getSocketPort());
+ String hostedParam =
+ BrowserListener.getDevModeURLParams(connectAddress, listener.getSocketPort());
if (query == null) {
query = hostedParam;
} else {
@@ -1011,8 +1003,7 @@
if (hash != null) {
path += '#' + hash;
}
- parsedUrl = new URL(parsedUrl.getProtocol(), parsedUrl.getHost(),
- parsedUrl.getPort(), path);
+ parsedUrl = new URL(parsedUrl.getProtocol(), parsedUrl.getHost(), parsedUrl.getPort(), path);
url = parsedUrl.toExternalForm();
} catch (MalformedURLException e) {
getTopLogger().log(TreeLogger.ERROR, "Invalid URL " + url, e);
@@ -1021,9 +1012,8 @@
return parsedUrl;
}
- protected abstract void produceOutput(TreeLogger logger,
- StandardLinkerContext linkerStack, ArtifactSet artifacts,
- ModuleDef module, boolean isRelink) throws UnableToCompleteException;
+ protected abstract void produceOutput(TreeLogger logger, StandardLinkerContext linkerStack,
+ ArtifactSet artifacts, ModuleDef module, boolean isRelink) throws UnableToCompleteException;
protected final void setDone() {
blockUntilDone.release();
@@ -1049,9 +1039,9 @@
try {
// See if there was a UI specified by command-line args
ui = createUI();
-
+
started = true;
-
+
if (!doStartup()) {
/*
* TODO (amitmanjhi): Adding this redundant logging to narrow down a
@@ -1060,7 +1050,7 @@
getTopLogger().log(TreeLogger.ERROR, "shell failed in doStartup method");
return false;
}
-
+
if (!options.isNoServer()) {
int resultPort = doStartUpServer();
if (resultPort < 0) {
@@ -1068,38 +1058,35 @@
* TODO (amitmanjhi): Adding this redundant logging to narrow down a
* failure. Remove soon.
*/
- getTopLogger().log(TreeLogger.ERROR,
- "shell failed in doStartupServer method");
+ getTopLogger().log(TreeLogger.ERROR, "shell failed in doStartupServer method");
return false;
}
options.setPort(resultPort);
- getTopLogger().log(TreeLogger.TRACE,
- "Started web server on port " + resultPort);
+ getTopLogger().log(TreeLogger.TRACE, "Started web server on port " + resultPort);
}
-
+
if (options.getStartupURLs().isEmpty()) {
// if no URLs were supplied, try and find plausible ones
inferStartupUrls();
}
-
+
if (options.getStartupURLs().isEmpty()) {
// TODO(jat): we could walk public resources to find plausible URLs
// after the module(s) are loaded
warnAboutNoStartupUrls();
}
-
+
setStartupUrls(getTopLogger());
-
+
if (!doSlowStartup()) {
/*
* TODO (amitmanjhi): Adding this redundant logging to narrow down a
* failure. Remove soon.
*/
- getTopLogger().log(TreeLogger.ERROR,
- "shell failed in doSlowStartup method");
+ getTopLogger().log(TreeLogger.ERROR, "shell failed in doSlowStartup method");
return false;
}
-
+
return true;
} finally {
startupEvent.end();
@@ -1112,8 +1099,8 @@
*/
protected abstract void warnAboutNoStartupUrls();
- private ArtifactAcceptor createArtifactAcceptor(TreeLogger logger,
- final ModuleDef module) throws UnableToCompleteException {
+ private ArtifactAcceptor createArtifactAcceptor(TreeLogger logger, final ModuleDef module)
+ throws UnableToCompleteException {
final StandardLinkerContext linkerContext = link(logger, module);
return new ArtifactAcceptor() {
public void accept(TreeLogger relinkLogger, ArtifactSet newArtifacts)
@@ -1136,8 +1123,9 @@
} else {
if (options.useRemoteUI()) {
try {
- newUI = new RemoteUI(options.getRemoteUIHost(),
- options.getRemoteUIHostPort(), options.getClientId());
+ newUI =
+ new RemoteUI(options.getRemoteUIHost(), options.getRemoteUIHostPort(), options
+ .getClientId());
baseLogLevelForUI = TreeLogger.Type.TRACE;
} catch (Throwable t) {
System.err.println("Could not connect to remote UI listening at "
@@ -1160,15 +1148,15 @@
}
private RebindCache getRebindCache(String moduleName) {
-
+
if (!options.isGeneratorResultCachingEnabled()) {
return null;
}
-
+
if (rebindCaches == null) {
rebindCaches = new HashMap<String, RebindCache>();
}
-
+
RebindCache cache = rebindCaches.get(moduleName);
if (cache == null) {
cache = new RebindCache();
@@ -1186,17 +1174,15 @@
* @param newlyGeneratedArtifacts the set of new artifacts
* @throws UnableToCompleteException
*/
- private void relink(TreeLogger logger, StandardLinkerContext linkerContext,
- ModuleDef module, ArtifactSet newlyGeneratedArtifacts)
- throws UnableToCompleteException {
- TreeLogger linkLogger = logger.branch(TreeLogger.DEBUG,
- "Relinking module '" + module.getName() + "'");
+ private void relink(TreeLogger logger, StandardLinkerContext linkerContext, ModuleDef module,
+ ArtifactSet newlyGeneratedArtifacts) throws UnableToCompleteException {
+ TreeLogger linkLogger =
+ logger.branch(TreeLogger.DEBUG, "Relinking module '" + module.getName() + "'");
- ArtifactSet artifacts = linkerContext.invokeRelink(linkLogger,
- newlyGeneratedArtifacts);
+ ArtifactSet artifacts = linkerContext.invokeRelink(linkLogger, newlyGeneratedArtifacts);
produceOutput(linkLogger, linkerContext, artifacts, module, true);
}
-
+
/**
* Set the set of startup URLs. This is done before launching to allow the UI
* to better present the options to the user, but note that the UI should not
@@ -1210,16 +1196,13 @@
ensureCodeServerListener();
Map<String, URL> startupUrls = new HashMap<String, URL>();
for (String prenormalized : options.getStartupURLs()) {
- String startupURL = normalizeURL(prenormalized, isHttps, getPort(),
- getHost());
- logger.log(TreeLogger.DEBUG, "URL " + prenormalized + " normalized as "
- + startupURL, null);
+ String startupURL = normalizeURL(prenormalized, isHttps, getPort(), getHost());
+ logger.log(TreeLogger.DEBUG, "URL " + prenormalized + " normalized as " + startupURL, null);
try {
URL url = processUrl(startupURL);
startupUrls.put(prenormalized, url);
} catch (UnableToCompleteException e) {
- logger.log(TreeLogger.ERROR, "Unable to process startup URL "
- + startupURL, null);
+ logger.log(TreeLogger.ERROR, "Unable to process startup URL " + startupURL, null);
}
}
ui.setStartupUrls(startupUrls);
diff --git a/dev/core/src/com/google/gwt/dev/Precompile.java b/dev/core/src/com/google/gwt/dev/Precompile.java
index cb9efac..b93af9e 100644
--- a/dev/core/src/com/google/gwt/dev/Precompile.java
+++ b/dev/core/src/com/google/gwt/dev/Precompile.java
@@ -1,12 +1,12 @@
/*
* Copyright 2008 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -94,10 +94,9 @@
/**
* The set of options for the precompiler.
*/
- public interface PrecompileOptions extends JJSOptions, CompileTaskOptions,
- OptionGenDir, OptionValidateOnly, OptionDisableUpdateCheck,
- OptionEnableGeneratingOnShards, OptionMaxPermsPerPrecompile,
- PrecompilationResult {
+ public interface PrecompileOptions extends JJSOptions, CompileTaskOptions, OptionGenDir,
+ OptionValidateOnly, OptionDisableUpdateCheck, OptionEnableGeneratingOnShards,
+ OptionMaxPermsPerPrecompile, PrecompilationResult {
}
static class ArgProcessor extends CompileArgProcessor {
@@ -130,8 +129,8 @@
}
}
- static class PrecompileOptionsImpl extends CompileTaskOptionsImpl implements
- PrecompileOptions, Serializable {
+ static class PrecompileOptionsImpl extends CompileTaskOptionsImpl implements PrecompileOptions,
+ Serializable {
private boolean disableUpdateCheck;
private boolean enableGeneratingOnShards = true;
private File genDir;
@@ -265,7 +264,7 @@
public void setGenDir(File genDir) {
this.genDir = genDir;
}
-
+
public void setGeneratorResultCachingEnabled(boolean enabled) {
jjsOptions.setGeneratorResultCachingEnabled(enabled);
}
@@ -320,9 +319,9 @@
@Override
public void run() {
- SpeedTracerLogger.Event createGraphicsEvent = SpeedTracerLogger.start(
- CompilerEventType.GRAPHICS_INIT, "java.awt.headless",
- System.getProperty("java.awt.headless"));
+ SpeedTracerLogger.Event createGraphicsEvent =
+ SpeedTracerLogger.start(CompilerEventType.GRAPHICS_INIT, "java.awt.headless", System
+ .getProperty("java.awt.headless"));
GraphicsEnvironment.getLocalGraphicsEnvironment();
createGraphicsEvent.end();
}
@@ -354,8 +353,7 @@
SpeedTracerLogger.init();
Event precompileEvent = SpeedTracerLogger.start(CompilerEventType.PRECOMPILE);
if (System.getProperty("gwt.jjs.dumpAst") != null) {
- System.out.println("Will dump AST to: "
- + System.getProperty("gwt.jjs.dumpAst"));
+ System.out.println("Will dump AST to: " + System.getProperty("gwt.jjs.dumpAst"));
}
/*
@@ -371,8 +369,8 @@
public boolean run(TreeLogger logger) throws UnableToCompleteException {
FutureTask<UpdateResult> updater = null;
if (!options.isUpdateCheckDisabled()) {
- updater = CheckForUpdates.checkForUpdatesInBackgroundThread(logger,
- CheckForUpdates.ONE_DAY);
+ updater =
+ CheckForUpdates.checkForUpdatesInBackgroundThread(logger, CheckForUpdates.ONE_DAY);
}
boolean success = new Precompile(options).run(logger);
if (success) {
@@ -392,7 +390,7 @@
/**
* Precompiles the given module.
- *
+ *
* @param logger a logger to use
* @param jjsOptions a set of compiler options
* @param module the module to compile
@@ -400,24 +398,24 @@
* <code>null</code>
* @return the precompilation
*/
- public static Precompilation precompile(TreeLogger logger,
- JJSOptions jjsOptions, ModuleDef module, File genDir) {
- PropertyPermutations allPermutations = new PropertyPermutations(
- module.getProperties(), module.getActiveLinkerNames());
+ public static Precompilation precompile(TreeLogger logger, JJSOptions jjsOptions,
+ ModuleDef module, File genDir) {
+ PropertyPermutations allPermutations =
+ new PropertyPermutations(module.getProperties(), module.getActiveLinkerNames());
return precompile(logger, jjsOptions, module, 0, allPermutations, genDir);
}
/**
* Validates the given module can be compiled.
- *
+ *
* @param logger a logger to use
* @param jjsOptions a set of compiler options
* @param module the module to compile
* @param genDir optional directory to dump generated source, may be
- * <code>null</code>
+ * <code>null</code>
*/
- public static boolean validate(TreeLogger logger, JJSOptions jjsOptions,
- ModuleDef module, File genDir) {
+ public static boolean validate(TreeLogger logger, JJSOptions jjsOptions, ModuleDef module,
+ File genDir) {
Event validateEvent = SpeedTracerLogger.start(CompilerEventType.VALIDATE);
try {
CompilationState compilationState = module.getCompilationState(logger);
@@ -437,16 +435,16 @@
}
ArtifactSet generatorArtifacts = new ArtifactSet();
- DistillerRebindPermutationOracle rpo = new DistillerRebindPermutationOracle(
- module, compilationState, generatorArtifacts,
- new PropertyPermutations(module.getProperties(),
- module.getActiveLinkerNames()), genDir);
+ DistillerRebindPermutationOracle rpo =
+ new DistillerRebindPermutationOracle(module, compilationState, generatorArtifacts,
+ new PropertyPermutations(module.getProperties(), module.getActiveLinkerNames()),
+ genDir);
// Allow GC later.
compilationState = null;
// Never optimize on a validation run.
jjsOptions.setOptimizePrecompile(false);
- getCompiler(module).precompile(logger, module, rpo, declEntryPts,
- additionalRootTypes, jjsOptions, true, null);
+ getCompiler(module).precompile(logger, module, rpo, declEntryPts, additionalRootTypes,
+ jjsOptions, true, null);
return true;
} catch (UnableToCompleteException e) {
// Already logged.
@@ -461,15 +459,15 @@
* collapsing soft permutations.
*/
static List<PropertyPermutations> getCollapsedPermutations(ModuleDef module) {
- PropertyPermutations allPermutations = new PropertyPermutations(
- module.getProperties(), module.getActiveLinkerNames());
+ PropertyPermutations allPermutations =
+ new PropertyPermutations(module.getProperties(), module.getActiveLinkerNames());
List<PropertyPermutations> collapsedPermutations = allPermutations.collapseProperties();
return collapsedPermutations;
}
static AbstractCompiler getCompiler(ModuleDef module) {
- ConfigurationProperty compilerClassProp = module.getProperties().createConfiguration(
- "x.compiler.class", false);
+ ConfigurationProperty compilerClassProp =
+ module.getProperties().createConfiguration("x.compiler.class", false);
String compilerClassName = compilerClassProp.getValue();
if (compilerClassName == null || compilerClassName.length() == 0) {
return new JavaScriptCompiler();
@@ -485,21 +483,18 @@
} catch (IllegalAccessException e) {
caught = e;
}
- throw new RuntimeException("Unable to instantiate compiler class '"
- + compilerClassName + "'", caught);
+ throw new RuntimeException("Unable to instantiate compiler class '" + compilerClassName + "'",
+ caught);
}
- static Precompilation precompile(TreeLogger logger, JJSOptions jjsOptions,
- ModuleDef module, int permutationBase,
- PropertyPermutations allPermutations, File genDir) {
- return precompile(logger, jjsOptions, module, permutationBase,
- allPermutations, genDir,
+ static Precompilation precompile(TreeLogger logger, JJSOptions jjsOptions, ModuleDef module,
+ int permutationBase, PropertyPermutations allPermutations, File genDir) {
+ return precompile(logger, jjsOptions, module, permutationBase, allPermutations, genDir,
ManagementFactory.getRuntimeMXBean().getStartTime());
}
- static Precompilation precompile(TreeLogger logger, JJSOptions jjsOptions,
- ModuleDef module, int permutationBase,
- PropertyPermutations allPermutations, File genDir,
+ static Precompilation precompile(TreeLogger logger, JJSOptions jjsOptions, ModuleDef module,
+ int permutationBase, PropertyPermutations allPermutations, File genDir,
long startTimeMilliseconds) {
Event precompileEvent = SpeedTracerLogger.start(CompilerEventType.PRECOMPILE);
@@ -532,15 +527,17 @@
}
ArtifactSet generatedArtifacts = new ArtifactSet();
- DistillerRebindPermutationOracle rpo = new DistillerRebindPermutationOracle(
- module, compilationState, generatedArtifacts, allPermutations, genDir);
+ DistillerRebindPermutationOracle rpo =
+ new DistillerRebindPermutationOracle(module, compilationState, generatedArtifacts,
+ allPermutations, genDir);
// Allow GC later.
compilationState = null;
- PrecompilationMetricsArtifact precompilationMetrics = jjsOptions.isCompilerMetricsEnabled()
- ? new PrecompilationMetricsArtifact(permutationBase) : null;
- UnifiedAst unifiedAst = getCompiler(module).precompile(logger, module,
- rpo, declEntryPts, null, jjsOptions, rpo.getPermuationCount() == 1,
- precompilationMetrics);
+ PrecompilationMetricsArtifact precompilationMetrics =
+ jjsOptions.isCompilerMetricsEnabled()
+ ? new PrecompilationMetricsArtifact(permutationBase) : null;
+ UnifiedAst unifiedAst =
+ getCompiler(module).precompile(logger, module, rpo, declEntryPts, null, jjsOptions,
+ rpo.getPermuationCount() == 1, precompilationMetrics);
if (jjsOptions.isCompilerMetricsEnabled()) {
ModuleMetricsArtifact moduleMetrics = new ModuleMetricsArtifact();
@@ -550,24 +547,24 @@
moduleMetrics.setInitialTypes(initialTypeOracleTypes);
// The elapsed time in ModuleMetricsArtifact represents time
// which could be done once for all permutations.
- moduleMetrics.setElapsedMilliseconds(moduleLoadFinished
- - startTimeMilliseconds);
+ moduleMetrics.setElapsedMilliseconds(moduleLoadFinished - startTimeMilliseconds);
unifiedAst.setModuleMetrics(moduleMetrics);
}
// Merge all identical permutations together.
- List<Permutation> permutations = new ArrayList<Permutation>(
- Arrays.asList(rpo.getPermutations()));
+ List<Permutation> permutations =
+ new ArrayList<Permutation>(Arrays.asList(rpo.getPermutations()));
mergeCollapsedPermutations(permutations);
// Sort the permutations by an ordered key to ensure determinism.
- SortedMap<RebindAnswersPermutationKey, Permutation> merged = new TreeMap<RebindAnswersPermutationKey, Permutation>();
+ SortedMap<RebindAnswersPermutationKey, Permutation> merged =
+ new TreeMap<RebindAnswersPermutationKey, Permutation>();
SortedSet<String> liveRebindRequests = unifiedAst.getRebindRequests();
for (Permutation permutation : permutations) {
// Construct a key for the live rebind answers.
- RebindAnswersPermutationKey key = new RebindAnswersPermutationKey(
- permutation, liveRebindRequests);
+ RebindAnswersPermutationKey key =
+ new RebindAnswersPermutationKey(permutation, liveRebindRequests);
if (merged.containsKey(key)) {
Permutation existing = merged.get(key);
existing.mergeFrom(permutation, liveRebindRequests);
@@ -589,8 +586,7 @@
- startTimeMilliseconds);
unifiedAst.setPrecompilationMetrics(precompilationMetrics);
}
- return new Precompilation(unifiedAst, merged.values(), permutationBase,
- generatedArtifacts);
+ return new Precompilation(unifiedAst, merged.values(), permutationBase, generatedArtifacts);
} catch (UnableToCompleteException e) {
// We intentionally don't pass in the exception here since the real
// cause has been logged.
@@ -600,12 +596,11 @@
}
}
- private static void abortDueToStrictMode(TreeLogger logger)
- throws UnableToCompleteException {
- logger.log(TreeLogger.ERROR,
- "Aborting compile due to errors in some input files");
+ private static void abortDueToStrictMode(TreeLogger logger) throws UnableToCompleteException {
+ logger.log(TreeLogger.ERROR, "Aborting compile due to errors in some input files");
throw new UnableToCompleteException();
}
+
/**
* This merges Permutations that can be considered equivalent by considering
* their collapsed properties. The list passed into this method may have
@@ -617,7 +612,8 @@
}
// See the doc for CollapsedPropertyKey
- SortedMap<CollapsedPropertyKey, List<Permutation>> mergedByCollapsedProperties = new TreeMap<CollapsedPropertyKey, List<Permutation>>();
+ SortedMap<CollapsedPropertyKey, List<Permutation>> mergedByCollapsedProperties =
+ new TreeMap<CollapsedPropertyKey, List<Permutation>>();
// This loop creates the equivalence sets
for (Iterator<Permutation> it = permutations.iterator(); it.hasNext();) {
@@ -636,7 +632,8 @@
}
// This loop merges the Permutations together
- for (Map.Entry<CollapsedPropertyKey, List<Permutation>> entry : mergedByCollapsedProperties.entrySet()) {
+ for (Map.Entry<CollapsedPropertyKey, List<Permutation>> entry : mergedByCollapsedProperties
+ .entrySet()) {
Permutation mergeInto = entry.getKey().getPermutation();
/*
@@ -653,6 +650,7 @@
permutations.set(i, new Permutation(i, permutations.get(i)));
}
}
+
private final PrecompileOptionsImpl options;
public Precompile(PrecompileOptions options) {
@@ -675,8 +673,8 @@
ModuleDef module = ModuleDefLoader.loadFromClassPath(logger, moduleName);
- StandardLinkerContext linkerContext = new StandardLinkerContext(
- TreeLogger.NULL, module, options);
+ StandardLinkerContext linkerContext =
+ new StandardLinkerContext(TreeLogger.NULL, module, options);
boolean generateOnShards = true;
@@ -684,11 +682,12 @@
logger.log(TreeLogger.INFO, "Precompiling on the start node");
generateOnShards = false;
} else if (!linkerContext.allLinkersAreShardable()) {
- TreeLogger legacyLinkersLogger = logger.branch(TreeLogger.INFO,
- "Precompiling on the start node, because some linkers are not updated");
+ TreeLogger legacyLinkersLogger =
+ logger.branch(TreeLogger.INFO,
+ "Precompiling on the start node, because some linkers are not updated");
for (Linker linker : linkerContext.findUnshardableLinkers()) {
- legacyLinkersLogger.log(TreeLogger.INFO, "Linker"
- + linker.getClass().getCanonicalName() + " is not updated");
+ legacyLinkersLogger.log(TreeLogger.INFO, "Linker" + linker.getClass().getCanonicalName()
+ + " is not updated");
}
generateOnShards = false;
} else if (options.isValidateOnly()) {
@@ -701,31 +700,30 @@
* Pre-precompile. Count the permutations and plan to do a real
* precompile in the CompilePerms shards.
*/
- TreeLogger branch = logger.branch(TreeLogger.INFO,
- "Precompiling (minimal) module " + module.getName());
+ TreeLogger branch =
+ logger.branch(TreeLogger.INFO, "Precompiling (minimal) module " + module.getName());
Util.writeObjectAsFile(logger, precompilationFile, options);
- int numPermutations = new PropertyPermutations(module.getProperties(),
- module.getActiveLinkerNames()).collapseProperties().size();
- Util.writeStringAsFile(logger, new File(compilerWorkDir,
- PERM_COUNT_FILENAME), String.valueOf(numPermutations));
- branch.log(TreeLogger.INFO,
- "Precompilation (minimal) succeeded, number of permutations: "
- + numPermutations);
+ int numPermutations =
+ new PropertyPermutations(module.getProperties(), module.getActiveLinkerNames())
+ .collapseProperties().size();
+ Util.writeStringAsFile(logger, new File(compilerWorkDir, PERM_COUNT_FILENAME), String
+ .valueOf(numPermutations));
+ branch.log(TreeLogger.INFO, "Precompilation (minimal) succeeded, number of permutations: "
+ + numPermutations);
} else {
if (options.isValidateOnly()) {
- TreeLogger branch = logger.branch(TreeLogger.INFO,
- "Validating compilation " + module.getName());
+ TreeLogger branch =
+ logger.branch(TreeLogger.INFO, "Validating compilation " + module.getName());
if (!validate(branch, options, module, options.getGenDir())) {
branch.log(TreeLogger.ERROR, "Validation failed");
return false;
}
branch.log(TreeLogger.INFO, "Validation succeeded");
} else {
- TreeLogger branch = logger.branch(TreeLogger.INFO,
- "Precompiling module " + module.getName());
+ TreeLogger branch =
+ logger.branch(TreeLogger.INFO, "Precompiling module " + module.getName());
- Precompilation precompilation = precompile(branch, options, module,
- options.getGenDir());
+ Precompilation precompilation = precompile(branch, options, module, options.getGenDir());
if (precompilation == null) {
branch.log(TreeLogger.ERROR, "Precompilation failed");
return false;
@@ -733,11 +731,10 @@
Util.writeObjectAsFile(logger, precompilationFile, precompilation);
int permsPrecompiled = precompilation.getPermutations().length;
- Util.writeStringAsFile(logger, new File(compilerWorkDir,
- PERM_COUNT_FILENAME), String.valueOf(permsPrecompiled));
- branch.log(TreeLogger.INFO,
- "Precompilation succeeded, number of permutations: "
- + permsPrecompiled);
+ Util.writeStringAsFile(logger, new File(compilerWorkDir, PERM_COUNT_FILENAME), String
+ .valueOf(permsPrecompiled));
+ branch.log(TreeLogger.INFO, "Precompilation succeeded, number of permutations: "
+ + permsPrecompiled);
}
}
}
diff --git a/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java b/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
index f7ba73c..b7991d7 100644
--- a/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
+++ b/dev/core/src/com/google/gwt/dev/javac/CompilationStateBuilder.java
@@ -48,8 +48,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
+import java.util.Map.Entry;
/**
* Manages a centralized cache for compiled units.
@@ -63,29 +63,28 @@
private final class UnitProcessorImpl implements UnitProcessor {
- public void process(CompilationUnitBuilder builder,
- CompilationUnitDeclaration cud, List<CompiledClass> compiledClasses) {
+ public void process(CompilationUnitBuilder builder, CompilationUnitDeclaration cud,
+ List<CompiledClass> compiledClasses) {
Event event = SpeedTracerLogger.start(DevModeEventType.CSB_PROCESS);
try {
- Map<MethodDeclaration, JsniMethod> jsniMethods = JsniCollector.collectJsniMethods(
- cud, builder.getSource(), JsRootScope.INSTANCE,
- DummyCorrelationFactory.INSTANCE);
+ Map<MethodDeclaration, JsniMethod> jsniMethods =
+ JsniCollector.collectJsniMethods(cud, builder.getSource(), JsRootScope.INSTANCE,
+ DummyCorrelationFactory.INSTANCE);
JSORestrictionsChecker.check(jsoState, cud);
// JSNI check + collect dependencies.
final Set<String> jsniDeps = new HashSet<String>();
Map<String, Binding> jsniRefs = new HashMap<String, Binding>();
- JsniChecker.check(cud, jsoState, jsniMethods, jsniRefs,
- new JsniChecker.TypeResolver() {
- public ReferenceBinding resolveType(String typeName) {
- ReferenceBinding resolveType = compiler.resolveType(typeName);
- if (resolveType != null) {
- jsniDeps.add(String.valueOf(resolveType.qualifiedSourceName()));
- }
- return resolveType;
- }
- });
+ JsniChecker.check(cud, jsoState, jsniMethods, jsniRefs, new JsniChecker.TypeResolver() {
+ public ReferenceBinding resolveType(String typeName) {
+ ReferenceBinding resolveType = compiler.resolveType(typeName);
+ if (resolveType != null) {
+ jsniDeps.add(String.valueOf(resolveType.qualifiedSourceName()));
+ }
+ return resolveType;
+ }
+ });
ArtificialRescueChecker.check(cud, builder.isGenerated());
BinaryTypeReferenceRestrictionsChecker.check(cud);
@@ -109,20 +108,19 @@
for (int i = 0; i < apiRefs.size(); ++i) {
apiRefs.set(i, interner.intern(apiRefs.get(i)));
}
- Dependencies dependencies = new Dependencies(packageName,
- unresolvedQualified, unresolvedSimple, apiRefs);
+ Dependencies dependencies =
+ new Dependencies(packageName, unresolvedQualified, unresolvedSimple, apiRefs);
- CompilationUnit unit = builder.build(compiledClasses, dependencies,
- jsniMethods.values(), methodArgs,
- cud.compilationResult().getProblems());
+ CompilationUnit unit =
+ builder.build(compiledClasses, dependencies, jsniMethods.values(), methodArgs, cud
+ .compilationResult().getProblems());
addValidUnit(unit);
// Cache the valid unit for future compiles.
ContentId contentId = builder.getContentId();
unitCache.put(contentId, unit);
if (builder instanceof ResourceCompilationUnitBuilder) {
ResourceCompilationUnitBuilder rcub = (ResourceCompilationUnitBuilder) builder;
- ResourceTag resourceTag = new ResourceTag(rcub.getLastModifed(),
- contentId);
+ ResourceTag resourceTag = new ResourceTag(rcub.getLastModifed(), contentId);
resourceContentCache.put(builder.getLocation(), resourceTag);
keepAliveLatestVersion.put(resourceTag, unit);
} else if (builder instanceof GeneratedCompilationUnitBuilder) {
@@ -145,13 +143,13 @@
/**
* The JDT compiler.
*/
- private final JdtCompiler compiler = new JdtCompiler(
- new UnitProcessorImpl());
+ private final JdtCompiler compiler = new JdtCompiler(new UnitProcessorImpl());
/**
* Continuation state for JSNI checking.
*/
- private final JSORestrictionsChecker.CheckerState jsoState = new JSORestrictionsChecker.CheckerState();
+ private final JSORestrictionsChecker.CheckerState jsoState =
+ new JSORestrictionsChecker.CheckerState();
private transient Collection<CompilationUnit> newlyBuiltUnits;
@@ -161,8 +159,7 @@
public Collection<CompilationUnit> addGeneratedTypes(TreeLogger logger,
Collection<GeneratedUnit> generatedUnits) {
- Event event =
- SpeedTracerLogger.start(DevModeEventType.CSB_ADD_GENERATED_TYPES);
+ Event event = SpeedTracerLogger.start(DevModeEventType.CSB_ADD_GENERATED_TYPES);
try {
return doBuildGeneratedTypes(logger, generatedUnits, this);
} finally {
@@ -184,8 +181,7 @@
Collection<CompilationUnit> compile(TreeLogger logger,
Collection<CompilationUnitBuilder> builders,
- Map<CompilationUnitBuilder, CompilationUnit> cachedUnits,
- EventType eventType) {
+ Map<CompilationUnitBuilder, CompilationUnit> cachedUnits, EventType eventType) {
// Initialize the set of valid classes to the initially cached units.
for (CompilationUnit unit : cachedUnits.values()) {
for (CompiledClass cc : unit.getCompiledClasses()) {
@@ -194,20 +190,21 @@
allValidClasses.put(sourceName, cc);
}
}
- Map<CompiledClass, CompiledClass> cachedStructurallySame = new IdentityHashMap<CompiledClass, CompiledClass>();
+ Map<CompiledClass, CompiledClass> cachedStructurallySame =
+ new IdentityHashMap<CompiledClass, CompiledClass>();
ArrayList<CompilationUnit> resultUnits = new ArrayList<CompilationUnit>();
do {
// Compile anything that needs to be compiled.
this.newlyBuiltUnits = new ArrayList<CompilationUnit>();
-
+
Event jdtCompilerEvent = SpeedTracerLogger.start(eventType);
try {
compiler.doCompile(builders);
} finally {
jdtCompilerEvent.end();
}
-
+
resultUnits.addAll(this.newlyBuiltUnits);
builders.clear();
@@ -220,11 +217,12 @@
* Invalidate any cached units with invalid refs.
*/
Collection<CompilationUnit> invalidatedUnits = new ArrayList<CompilationUnit>();
- for (Iterator<Entry<CompilationUnitBuilder, CompilationUnit>> it = cachedUnits.entrySet().iterator(); it.hasNext();) {
+ for (Iterator<Entry<CompilationUnitBuilder, CompilationUnit>> it =
+ cachedUnits.entrySet().iterator(); it.hasNext();) {
Entry<CompilationUnitBuilder, CompilationUnit> entry = it.next();
CompilationUnit unit = entry.getValue();
- boolean isValid = unit.getDependencies().validate(allValidClasses,
- cachedStructurallySame);
+ boolean isValid =
+ unit.getDependencies().validate(allValidClasses, cachedStructurallySame);
if (!isValid) {
invalidatedUnits.add(unit);
builders.add(entry.getKey());
@@ -245,8 +243,7 @@
// Sort, then report all errors (re-report for cached units).
Collections.sort(resultUnits, CompilationUnit.COMPARATOR);
- logger = logger.branch(TreeLogger.DEBUG,
- "Validating newly compiled units");
+ logger = logger.branch(TreeLogger.DEBUG, "Validating newly compiled units");
for (CompilationUnit unit : resultUnits) {
CompilationUnitInvalidator.reportErrors(logger, unit);
}
@@ -284,8 +281,7 @@
private static final CompilationStateBuilder instance = new CompilationStateBuilder();
- public static CompilationState buildFrom(TreeLogger logger,
- Set<Resource> resources) {
+ public static CompilationState buildFrom(TreeLogger logger, Set<Resource> resources) {
Event event = SpeedTracerLogger.start(DevModeEventType.CSB_BUILD_FROM_ORACLE);
try {
return instance.doBuildFrom(logger, resources, null);
@@ -294,8 +290,8 @@
}
}
- public static CompilationState buildFrom(TreeLogger logger,
- Set<Resource> resources, AdditionalTypeProviderDelegate delegate) {
+ public static CompilationState buildFrom(TreeLogger logger, Set<Resource> resources,
+ AdditionalTypeProviderDelegate delegate) {
Event event = SpeedTracerLogger.start(DevModeEventType.CSB_BUILD_FROM_ORACLE);
try {
return instance.doBuildFrom(logger, resources, delegate);
@@ -319,8 +315,9 @@
* WRITE-ONLY
*/
@SuppressWarnings("unchecked")
- private final Map<ResourceTag, CompilationUnit> keepAliveLatestVersion = Collections.synchronizedMap(new ReferenceIdentityMap(
- AbstractReferenceMap.WEAK, AbstractReferenceMap.HARD));
+ private final Map<ResourceTag, CompilationUnit> keepAliveLatestVersion = Collections
+ .synchronizedMap(new ReferenceIdentityMap(AbstractReferenceMap.WEAK,
+ AbstractReferenceMap.HARD));
/**
* This map of hard keys to soft values exists solely to keep the most
@@ -329,15 +326,16 @@
* WRITE-ONLY
*/
@SuppressWarnings("unchecked")
- private final Map<String, CompilationUnit> keepAliveRecentlyGenerated = Collections.synchronizedMap(new ReferenceMap(
- AbstractReferenceMap.HARD, AbstractReferenceMap.SOFT));
+ private final Map<String, CompilationUnit> keepAliveRecentlyGenerated = Collections
+ .synchronizedMap(new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.SOFT));
/**
* Holds a tag for the last seen content for a each resource location. Should
* be bounded by the total number of accessible Java source files on the
* system that we try to compile.
*/
- private final Map<String, ResourceTag> resourceContentCache = Collections.synchronizedMap(new HashMap<String, ResourceTag>());
+ private final Map<String, ResourceTag> resourceContentCache = Collections
+ .synchronizedMap(new HashMap<String, ResourceTag>());
/**
* A map of all previously compiled units by contentId.
@@ -346,8 +344,8 @@
* compiled multiple ways based on its dependencies.
*/
@SuppressWarnings("unchecked")
- private final Map<ContentId, CompilationUnit> unitCache = Collections.synchronizedMap(new ReferenceMap(
- AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK));
+ private final Map<ContentId, CompilationUnit> unitCache = Collections
+ .synchronizedMap(new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK));
/**
* Build a new compilation state from a source oracle.
@@ -362,13 +360,14 @@
*
* TODO: maybe use a finer brush than to synchronize the whole thing.
*/
- public synchronized CompilationState doBuildFrom(TreeLogger logger,
- Set<Resource> resources, AdditionalTypeProviderDelegate compilerDelegate) {
+ public synchronized CompilationState doBuildFrom(TreeLogger logger, Set<Resource> resources,
+ AdditionalTypeProviderDelegate compilerDelegate) {
// Units we definitely want to build.
List<CompilationUnitBuilder> builders = new ArrayList<CompilationUnitBuilder>();
// Units we don't want to rebuild unless we have to.
- Map<CompilationUnitBuilder, CompilationUnit> cachedUnits = new IdentityHashMap<CompilationUnitBuilder, CompilationUnit>();
+ Map<CompilationUnitBuilder, CompilationUnit> cachedUnits =
+ new IdentityHashMap<CompilationUnitBuilder, CompilationUnit>();
CompileMoreLater compileMoreLater = new CompileMoreLater(compilerDelegate);
@@ -376,8 +375,8 @@
for (Resource resource : resources) {
String typeName = Shared.toTypeName(resource.getPath());
// Create a builder for all incoming units.
- ResourceCompilationUnitBuilder builder = new ResourceCompilationUnitBuilder(
- typeName, resource);
+ ResourceCompilationUnitBuilder builder =
+ new ResourceCompilationUnitBuilder(typeName, resource);
// Try to get an existing unit from the cache.
String location = resource.getLocation();
ResourceTag tag = resourceContentCache.get(location);
@@ -392,8 +391,9 @@
}
builders.add(builder);
}
- Collection<CompilationUnit> resultUnits = compileMoreLater.compile(logger,
- builders, cachedUnits, CompilerEventType.JDT_COMPILER_CSB_FROM_ORACLE);
+ Collection<CompilationUnit> resultUnits =
+ compileMoreLater.compile(logger, builders, cachedUnits,
+ CompilerEventType.JDT_COMPILER_CSB_FROM_ORACLE);
return new CompilationState(logger, resultUnits, compileMoreLater);
}
@@ -402,24 +402,23 @@
*
* TODO: maybe use a finer brush than to synchronize the whole thing.
*/
- synchronized Collection<CompilationUnit> doBuildGeneratedTypes(
- TreeLogger logger, Collection<GeneratedUnit> generatedUnits,
- CompileMoreLater compileMoreLater) {
+ synchronized Collection<CompilationUnit> doBuildGeneratedTypes(TreeLogger logger,
+ Collection<GeneratedUnit> generatedUnits, CompileMoreLater compileMoreLater) {
// Units we definitely want to build.
List<CompilationUnitBuilder> builders = new ArrayList<CompilationUnitBuilder>();
// Units we don't want to rebuild unless we have to.
- Map<CompilationUnitBuilder, CompilationUnit> cachedUnits = new IdentityHashMap<CompilationUnitBuilder, CompilationUnit>();
+ Map<CompilationUnitBuilder, CompilationUnit> cachedUnits =
+ new IdentityHashMap<CompilationUnitBuilder, CompilationUnit>();
// For each incoming generated Java source file...
for (GeneratedUnit generatedUnit : generatedUnits) {
// Create a builder for all incoming units.
- GeneratedCompilationUnitBuilder builder = new GeneratedCompilationUnitBuilder(
- generatedUnit);
+ GeneratedCompilationUnitBuilder builder = new GeneratedCompilationUnitBuilder(generatedUnit);
// Try to get an existing unit from the cache.
- ContentId contentId = new ContentId(generatedUnit.getTypeName(),
- generatedUnit.getStrongHash());
+ ContentId contentId =
+ new ContentId(generatedUnit.getTypeName(), generatedUnit.getStrongHash());
CompilationUnit existingUnit = unitCache.get(contentId);
if (existingUnit != null) {
cachedUnits.put(builder, existingUnit);
@@ -429,6 +428,6 @@
}
}
return compileMoreLater.compile(logger, builders, cachedUnits,
- CompilerEventType.JDT_COMPILER_CSB_GENERATED);
+ CompilerEventType.JDT_COMPILER_CSB_GENERATED);
}
}