Skip to content

Commit

Permalink
Run google-java-format on all Guice code.
Browse files Browse the repository at this point in the history
configure a presubmit to ensure that it stays formatted.

Highlights include:
* simplified import order
* method annotations are now consistently defined on the preceding line
* javadoc reformatted to 100 chars column width

One test that contained line numbers in error messages had to be modified and
the formatter didn't like some of the more complicated preprocessor directives
(MOE and AOP).

To avoid formatting the copyright notices as javadoc i did a preprocessing step to rewrite the initial '/**' to '/*' using perl

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=132694034
  • Loading branch information
lukesandberg authored and sameb committed Sep 13, 2016
1 parent 39eadf4 commit 27c5d38
Show file tree
Hide file tree
Showing 21 changed files with 745 additions and 587 deletions.
5 changes: 2 additions & 3 deletions core/src/com/google/inject/name/Named.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright (C) 2006 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,7 +19,6 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import com.google.inject.BindingAnnotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
Expand All @@ -30,7 +29,7 @@
* @author [email protected] (Bob Lee)
*/
@Retention(RUNTIME)
@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
@BindingAnnotation
public @interface Named {
String value();
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/google/inject/name/NamedImpl.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright (C) 2006 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
17 changes: 5 additions & 12 deletions core/src/com/google/inject/name/Names.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright (C) 2006 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,7 +18,6 @@

import com.google.inject.Binder;
import com.google.inject.Key;

import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
Expand All @@ -32,17 +31,12 @@ public class Names {

private Names() {}

/**
* Creates a {@link Named} annotation with {@code name} as the value.
*/
/** Creates a {@link Named} annotation with {@code name} as the value. */
public static Named named(String name) {
return new NamedImpl(name);
}

/**
* Creates a constant binding to {@code @Named(key)} for each entry in
* {@code properties}.
*/
/** Creates a constant binding to {@code @Named(key)} for each entry in {@code properties}. */
public static void bindProperties(Binder binder, Map<String, String> properties) {
binder = binder.skipSources(Names.class);
for (Map.Entry<String, String> entry : properties.entrySet()) {
Expand All @@ -53,9 +47,8 @@ public static void bindProperties(Binder binder, Map<String, String> properties)
}

/**
* Creates a constant binding to {@code @Named(key)} for each property. This
* method binds all properties including those inherited from
* {@link Properties#defaults defaults}.
* Creates a constant binding to {@code @Named(key)} for each property. This method binds all
* properties including those inherited from {@link Properties#defaults defaults}.
*/
public static void bindProperties(Binder binder, Properties properties) {
binder = binder.skipSources(Names.class);
Expand Down
6 changes: 2 additions & 4 deletions core/src/com/google/inject/name/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
* limitations under the License.
*/

/**
* Support for binding to string-based names.
*/
package com.google.inject.name;
/** Support for binding to string-based names. */
package com.google.inject.name;
8 changes: 3 additions & 5 deletions core/test/com/google/inject/util/NoopOverrideTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright (C) 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,14 +20,12 @@
import com.google.inject.spi.ElementVisitor;
import com.google.inject.spi.ElementsTest;

/**
* @author [email protected] (Jesse Wilson)
*/
/** @author [email protected] (Jesse Wilson) */
public class NoopOverrideTest extends ElementsTest {

@Override
protected void checkModule(Module module, ElementVisitor<?>... visitors) {
Module overridden = Modules.override(module).with(Modules.EMPTY_MODULE);
super.checkModule(overridden, visitors);
}
}
}
Loading

0 comments on commit 27c5d38

Please sign in to comment.