Sort & format.

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2565 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/i18n/rebind/AbstractLocalizableImplCreator.java b/user/src/com/google/gwt/i18n/rebind/AbstractLocalizableImplCreator.java
index b4c4d4d..25c0952 100644
--- a/user/src/com/google/gwt/i18n/rebind/AbstractLocalizableImplCreator.java
+++ b/user/src/com/google/gwt/i18n/rebind/AbstractLocalizableImplCreator.java
@@ -47,9 +47,9 @@
 abstract class AbstractLocalizableImplCreator extends
     AbstractGeneratorClassCreator {
 
-  static String generateConstantOrMessageClass(TreeLogger logger, TreeLogger deprecatedLogger,
-      GeneratorContext context, String locale, JClassType targetClass)
-      throws UnableToCompleteException {
+  static String generateConstantOrMessageClass(TreeLogger logger,
+      TreeLogger deprecatedLogger, GeneratorContext context, String locale,
+      JClassType targetClass) throws UnableToCompleteException {
     TypeOracle oracle = context.getTypeOracle();
     JClassType constantsClass;
     JClassType messagesClass;
@@ -88,12 +88,15 @@
 
     AbstractResource resource = null;
     try {
-      resource = ResourceFactory.getBundle(logger, targetClass, locale, assignableToConstants);
+      resource = ResourceFactory.getBundle(logger, targetClass, locale,
+          assignableToConstants);
     } catch (MissingResourceException e) {
       throw error(
           logger,
           "Localization failed; there must be at least one properties file accessible through"
-              + " the classpath in package '" + packageName + "' whose base name is '"
+              + " the classpath in package '"
+              + packageName
+              + "' whose base name is '"
               + ResourceFactory.getResourceName(targetClass) + "'");
     } catch (IllegalArgumentException e) {
       // A bad key can generate an illegal argument exception.
@@ -118,15 +121,18 @@
       // Now that we have all the information set up, process the class
       if (constantsWithLookupClass.isAssignableFrom(targetClass)) {
         ConstantsWithLookupImplCreator c = new ConstantsWithLookupImplCreator(
-            logger, deprecatedLogger, writer, targetClass, resource, context.getTypeOracle());
+            logger, deprecatedLogger, writer, targetClass, resource,
+            context.getTypeOracle());
         c.emitClass(logger, locale);
       } else if (constantsClass.isAssignableFrom(targetClass)) {
-        ConstantsImplCreator c = new ConstantsImplCreator(logger, deprecatedLogger, writer,
-            targetClass, resource, context.getTypeOracle());
+        ConstantsImplCreator c = new ConstantsImplCreator(logger,
+            deprecatedLogger, writer, targetClass, resource,
+            context.getTypeOracle());
         c.emitClass(logger, locale);
       } else {
-        MessagesImplCreator messages = new MessagesImplCreator(logger, deprecatedLogger, writer,
-            targetClass, resource, context.getTypeOracle());
+        MessagesImplCreator messages = new MessagesImplCreator(logger,
+            deprecatedLogger, writer, targetClass, resource,
+            context.getTypeOracle());
         messages.emitClass(logger, locale);
       }
       context.commit(logger, pw);
@@ -137,7 +143,7 @@
       String path = generate.fileName();
       if (Generate.DEFAULT.equals(path)) {
         path = targetClass.getPackage().getName() + "."
-        + targetClass.getName().replace('.', '_');
+            + targetClass.getName().replace('.', '_');
       } else if (path.endsWith(File.pathSeparator)) {
         path = path + targetClass.getName().replace('.', '_');
       }
@@ -163,33 +169,38 @@
                 genClassName).asSubclass(MessageCatalogFormat.class);
             msgWriter = msgFormatClass.newInstance();
           } catch (InstantiationException e) {
-            logger.log(TreeLogger.ERROR, "Error instantiating @Generate class " + genClassName, e);
+            logger.log(TreeLogger.ERROR, "Error instantiating @Generate class "
+                + genClassName, e);
             seenError = true;
             continue;
           } catch (IllegalAccessException e) {
-            logger.log(TreeLogger.ERROR, "@Generate class " + genClassName + " illegal access", e);
+            logger.log(TreeLogger.ERROR, "@Generate class " + genClassName
+                + " illegal access", e);
             seenError = true;
             continue;
           } catch (ClassNotFoundException e) {
-            logger.log(TreeLogger.ERROR, "@Generate class " + genClassName + " not found");
+            logger.log(TreeLogger.ERROR, "@Generate class " + genClassName
+                + " not found");
             seenError = true;
             continue;
           }
           // Make generator-specific changes to a temporary copy of the path.
           String genPath = path;
           if (genLocales.length != 1) {
-            // If the user explicitly specified only one locale, do not add the locale.
+            // If the user explicitly specified only one locale, do not add the
+            // locale.
             genPath += '_' + locale;
           }
           genPath += msgWriter.getExtension();
           OutputStream outStr = context.tryCreateResource(logger, genPath);
           if (outStr != null) {
-            TreeLogger branch = logger.branch(TreeLogger.INFO, "Generating " + genPath
-                + " from " + className + " for locale " + locale, null);
+            TreeLogger branch = logger.branch(TreeLogger.INFO, "Generating "
+                + genPath + " from " + className + " for locale " + locale,
+                null);
             PrintWriter out = null;
             try {
-              out = new PrintWriter(new BufferedWriter(
-                  new OutputStreamWriter(outStr, "UTF-8")), false);
+              out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
+                  outStr, "UTF-8")), false);
             } catch (UnsupportedEncodingException e) {
               throw error(logger, e.getMessage());
             }
@@ -241,9 +252,9 @@
    * @param targetClass current target
    * @param messageBindings backing resource
    */
-  public AbstractLocalizableImplCreator(TreeLogger logger, TreeLogger deprecatedLogger,
-      SourceWriter writer, JClassType targetClass, AbstractResource messageBindings,
-      boolean isConstants) {
+  public AbstractLocalizableImplCreator(TreeLogger logger,
+      TreeLogger deprecatedLogger, SourceWriter writer, JClassType targetClass,
+      AbstractResource messageBindings, boolean isConstants) {
     super(writer, targetClass);
     this.deprecatedLogger = deprecatedLogger;
     this.messageBindings = messageBindings;
@@ -279,13 +290,13 @@
    * @param locale locale to generate
    * @throws UnableToCompleteException
    */
-  protected void delegateToCreator(TreeLogger logger, JMethod method, String locale)
-      throws UnableToCompleteException {
+  protected void delegateToCreator(TreeLogger logger, JMethod method,
+      String locale) throws UnableToCompleteException {
     AbstractMethodCreator methodCreator = getMethodCreator(logger, method);
     String key = getKey(logger, method);
     if (key == null) {
-      logger.log(TreeLogger.ERROR, "Unable to get or compute key for method " + method.getName(),
-          null);
+      logger.log(TreeLogger.ERROR, "Unable to get or compute key for method "
+          + method.getName(), null);
       throw new UnableToCompleteException();
     }
     methodCreator.createMethodFor(logger, method, key, messageBindings, locale);
@@ -296,8 +307,8 @@
    * 
    * @param logger TreeLogger instance for logging
    * @param method method to get key for
-   * @return the key to use for resource lookups or null if unable to get
-   *     or compute the key
+   * @return the key to use for resource lookups or null if unable to get or
+   *         compute the key
    */
   protected String getKey(TreeLogger logger, JMethod method) {
     Key key = method.getAnnotation(Key.class);
@@ -317,7 +328,7 @@
     }
     return AnnotationsResource.getKey(logger, keyGenerator, method, isConstants);
   }
-  
+
   /**
    * Issue a warning about deprecated metadata.
    * 
diff --git a/user/src/com/google/gwt/user/rebind/ui/ImageBundleGenerator.java b/user/src/com/google/gwt/user/rebind/ui/ImageBundleGenerator.java
index ea35ff8..1513790 100644
--- a/user/src/com/google/gwt/user/rebind/ui/ImageBundleGenerator.java
+++ b/user/src/com/google/gwt/user/rebind/ui/ImageBundleGenerator.java
@@ -61,7 +61,7 @@
 
     String getPackageName();
   }
-  
+
   /**
    * Indirection around the act of looking up a resource that allows for unit
    * test mocking.
@@ -70,7 +70,7 @@
     /**
      * 
      * @param resName the resource name in a format that could be passed to
-     *            <code>ClassLoader.getResource()</code>
+     *          <code>ClassLoader.getResource()</code>
      * @return <code>true</code> if the resource is present
      */
     boolean isResourcePresent(String resName);
@@ -100,12 +100,12 @@
     }
   }
 
-  /* private */static final String MSG_NO_FILE_BASED_ON_METHOD_NAME = "No matching image resource was found; any of the following filenames would have matched had they been present:";
-
   /* private */static final String MSG_JAVADOC_FORM_DEPRECATED = "Use of @gwt.resource in javadoc is deprecated; use the annotation ImageBundle.@Resource instead";
 
   /* private */static final String MSG_MULTIPLE_ANNOTATIONS = "You are using both the @Resource annotation and the deprecated @gwt.resource in javadoc; @Resource will be used, and @gwt.resource will be ignored";
 
+  /* private */static final String MSG_NO_FILE_BASED_ON_METHOD_NAME = "No matching image resource was found; any of the following filenames would have matched had they been present:";
+
   private static final String ABSTRACTIMAGEPROTOTYPE_QNAME = "com.google.gwt.user.client.ui.AbstractImagePrototype";
 
   private static final String CLIPPEDIMAGEPROTOTYPE_QNAME = "com.google.gwt.user.client.ui.impl.ClippedImagePrototype";
@@ -146,8 +146,8 @@
   }
 
   @Override
-  public String generate(TreeLogger logger, GeneratorContext context, String typeName)
-      throws UnableToCompleteException {
+  public String generate(TreeLogger logger, GeneratorContext context,
+      String typeName) throws UnableToCompleteException {
 
     TypeOracle typeOracle = context.getTypeOracle();
 
@@ -173,10 +173,10 @@
    *         <code>ClassLoader.getResource()</code>; never returns
    *         <code>null</code>
    * @throws UnableToCompleteException thrown if a resource was specified but
-   *             could not be found on the classpath
+   *           could not be found on the classpath
    */
-  /* private */String getImageResourceName(TreeLogger logger, JMethodOracle method)
-      throws UnableToCompleteException {
+  /* private */String getImageResourceName(TreeLogger logger,
+      JMethodOracle method) throws UnableToCompleteException {
     String imgName = tryGetImageNameFromMetaData(logger, method);
     if (imgName != null) {
       return imgName;
@@ -200,8 +200,8 @@
     return lineNum;
   }
 
-  private void generateImageMethod(TreeLogger logger, ImageBundleBuilder compositeImage,
-      SourceWriter sw, JMethod method, String imgResName) throws UnableToCompleteException {
+  private void generateImageMethod(ImageBundleBuilder compositeImage,
+      SourceWriter sw, JMethod method, String imgResName) {
 
     String decl = method.getReadableDeclaration(false, true, true, true, true);
 
@@ -248,13 +248,15 @@
    * validity as it is encountered.
    */
   private String generateImplClass(TreeLogger logger, GeneratorContext context,
-      JClassType userType, JMethod[] imageMethods) throws UnableToCompleteException {
+      JClassType userType, JMethod[] imageMethods)
+      throws UnableToCompleteException {
     // Lookup the type info for AbstractImagePrototype so that we can check for
     // the proper return type
     // on image bundle methods.
     final JClassType abstractImagePrototype;
     try {
-      abstractImagePrototype = userType.getOracle().getType(ABSTRACTIMAGEPROTOTYPE_QNAME);
+      abstractImagePrototype = userType.getOracle().getType(
+          ABSTRACTIMAGEPROTOTYPE_QNAME);
     } catch (NotFoundException e) {
       logger.log(TreeLogger.ERROR, "GWT " + ABSTRACTIMAGEPROTOTYPE_QNAME
           + " class is not available", e);
@@ -266,7 +268,8 @@
     String subName = computeSubclassName(userType);
 
     // Begin writing the generated source.
-    ClassSourceFileComposerFactory f = new ClassSourceFileComposerFactory(pkgName, subName);
+    ClassSourceFileComposerFactory f = new ClassSourceFileComposerFactory(
+        pkgName, subName);
     f.addImport(ABSTRACTIMAGEPROTOTYPE_QNAME);
     f.addImport(CLIPPEDIMAGEPROTOTYPE_QNAME);
     f.addImport(GWT_QNAME);
@@ -287,13 +290,14 @@
         CompilationUnitProvider unit = method.getEnclosingType().getCompilationUnit();
         String sourceFile = unit.getLocation();
         int lineNum = countLines(unit.getSource(), method.getDeclStart());
-        String branchMsg = "Analyzing method '" + method.getName() + "' beginning on line "
-            + lineNum + " of " + sourceFile;
+        String branchMsg = "Analyzing method '" + method.getName()
+            + "' beginning on line " + lineNum + " of " + sourceFile;
         TreeLogger branch = logger.branch(TreeLogger.DEBUG, branchMsg, null);
 
         // Verify that this method is valid on an image bundle.
         if (method.getReturnType() != abstractImagePrototype) {
-          branch.log(TreeLogger.ERROR, "Return type must be " + ABSTRACTIMAGEPROTOTYPE_QNAME, null);
+          branch.log(TreeLogger.ERROR, "Return type must be "
+              + ABSTRACTIMAGEPROTOTYPE_QNAME, null);
           throw new UnableToCompleteException();
         }
 
@@ -303,7 +307,8 @@
         }
 
         // Find the associated imaged resource.
-        String imageResName = getImageResourceName(branch, new JMethodOracleImpl(method));
+        String imageResName = getImageResourceName(branch,
+            new JMethodOracleImpl(method));
         assert (imageResName != null);
         imageResNames.add(imageResName);
         bulder.assimilate(logger, imageResName);
@@ -322,7 +327,8 @@
       // Generate an implementation of each method.
       int imageResNameIndex = 0;
       for (JMethod method : imageMethods) {
-        generateImageMethod(logger, bulder, sw, method, imageResNames.get(imageResNameIndex++));
+        generateImageMethod(bulder, sw, method,
+            imageResNames.get(imageResNameIndex++));
       }
 
       // Finish.
@@ -338,17 +344,17 @@
    * order. The first image found, if any, is used.
    * 
    * @param logger if no matching image resource is found, an explanatory
-   *            message will be logged
+   *          message will be logged
    * @param method the method whose name is being examined for matching image
-   *            resources
+   *          resources
    * @return a resource name that is suitable to be passed into
    *         <code>ClassLoader.getResource()</code>; never returns
    *         <code>null</code>
    * @throws UnableToCompleteException thrown when no image can be found based
-   *             on the method name
+   *           on the method name
    */
-  private String getImageNameFromMethodName(TreeLogger logger, JMethodOracle method)
-      throws UnableToCompleteException {
+  private String getImageNameFromMethodName(TreeLogger logger,
+      JMethodOracle method) throws UnableToCompleteException {
     String pkgName = method.getPackageName();
     String pkgPrefix = pkgName.replace('.', '/');
     if (pkgPrefix.length() > 0) {
@@ -365,7 +371,8 @@
       testImgNames.add(testImgName);
     }
 
-    TreeLogger branch = logger.branch(TreeLogger.ERROR, MSG_NO_FILE_BASED_ON_METHOD_NAME, null);
+    TreeLogger branch = logger.branch(TreeLogger.ERROR,
+        MSG_NO_FILE_BASED_ON_METHOD_NAME, null);
     for (String testImgName : testImgNames) {
       branch.log(TreeLogger.ERROR, testImgName, null);
     }
@@ -373,8 +380,8 @@
     throw new UnableToCompleteException();
   }
 
-  private JClassType getValidUserType(TreeLogger logger, String typeName, TypeOracle typeOracle)
-      throws UnableToCompleteException {
+  private JClassType getValidUserType(TreeLogger logger, String typeName,
+      TypeOracle typeOracle) throws UnableToCompleteException {
     try {
       // Get the type that the user is introducing.
       JClassType userType = typeOracle.getType(typeName);
@@ -384,15 +391,16 @@
 
       // Ensure it's an interface.
       if (userType.isInterface() == null) {
-        logger.log(TreeLogger.ERROR, userType.getQualifiedSourceName() + " must be an interface",
-            null);
+        logger.log(TreeLogger.ERROR, userType.getQualifiedSourceName()
+            + " must be an interface", null);
         throw new UnableToCompleteException();
       }
 
       // Ensure proper derivation.
       if (!userType.isAssignableTo(magicType)) {
-        logger.log(TreeLogger.ERROR, userType.getQualifiedSourceName() + " must be assignable to "
-            + magicType.getQualifiedSourceName(), null);
+        logger.log(TreeLogger.ERROR, userType.getQualifiedSourceName()
+            + " must be assignable to " + magicType.getQualifiedSourceName(),
+            null);
         throw new UnableToCompleteException();
       }
 
@@ -443,17 +451,17 @@
    * forms of metadata are present).
    * 
    * @param logger if metadata is found but the specified resource isn't
-   *            available, a warning is logged
+   *          available, a warning is logged
    * @param method the image bundle method whose associated image resource is
-   *            being sought
+   *          being sought
    * @return a resource name that is suitable to be passed into
    *         <code>ClassLoader.getResource()</code>, or <code>null</code>
    *         if metadata wasn't provided
    * @throws UnableToCompleteException thrown when metadata is provided but the
-   *             resource cannot be found
+   *           resource cannot be found
    */
-  private String tryGetImageNameFromMetaData(TreeLogger logger, JMethodOracle method)
-      throws UnableToCompleteException {
+  private String tryGetImageNameFromMetaData(TreeLogger logger,
+      JMethodOracle method) throws UnableToCompleteException {
     String imgFileName = null;
     String imgNameAnn = tryGetImageNameFromAnnotation(method);
     String imgNameJavaDoc = tryGetImageNameFromJavaDoc(method);
@@ -490,7 +498,8 @@
 
     if (!resLocator.isResourcePresent(imgFileName)) {
       // Not found.
-      logger.log(TreeLogger.ERROR, msgCannotFindImageFromMetaData(imgFileName), null);
+      logger.log(TreeLogger.ERROR, msgCannotFindImageFromMetaData(imgFileName),
+          null);
       throw new UnableToCompleteException();
     }