Permalink
Browse files

Run google-java-format on all Guice code.

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=132692207
  • Loading branch information...
lukesandberg authored and sameb committed Sep 9, 2016
1 parent 24be2ea commit 751b555176032e7cd2d49000b8acbb1292574781
Showing with 1,129 additions and 904 deletions.
  1. +22 −17 core/test/com/google/inject/internal/util/LineNumbersTest.java
  2. +10 −15 core/test/com/google/inject/matcher/MatcherTest.java
  3. +274 −173 core/test/com/google/inject/multibindings/ProvidesIntoTest.java
  4. +175 −122 core/test/com/googlecode/guice/bundle/OSGiTestActivator.java
  5. +28 −25 extensions/dagger-adapter/src/com/google/inject/daggeradapter/DaggerAdapter.java
  6. +9 −9 extensions/dagger-adapter/src/com/google/inject/daggeradapter/DaggerMethodScanner.java
  7. +27 −21 extensions/dagger-adapter/test/com/google/inject/daggeradapter/DaggerAdapterTest.java
  8. +8 −12 extensions/jmx/test/com/google/inject/tools/jmx/JmxTest.java
  9. +4 −8 extensions/jndi/src/com/google/inject/jndi/JndiIntegration.java
  10. +1 −3 extensions/jndi/src/com/google/inject/jndi/package-info.java
  11. +44 −36 extensions/mini/src/com/google/inject/mini/MiniGuice.java
  12. +133 −71 extensions/mini/test/com/google/inject/mini/MiniGuiceTest.java
  13. +3 −6 extensions/persist/test/com/google/inject/persist/AllTests.java
  14. +10 −10 extensions/persist/test/com/google/inject/persist/EdslTest.java
  15. +29 −27 extensions/service/test/com/google/inject/service/SingleServiceIntegrationTest.java
  16. +13 −20 extensions/spring/src/com/google/inject/spring/SpringIntegration.java
  17. +1 −3 extensions/spring/src/com/google/inject/spring/package-info.java
  18. +15 −30 extensions/spring/test/com/google/inject/spring/SpringIntegrationTest.java
  19. +14 −18 extensions/struts2/test/com/google/inject/struts2/Struts2FactoryTest.java
  20. +8 −8 extensions/testlib/src/com/google/inject/testing/fieldbinder/Bind.java
  21. +39 −60 extensions/testlib/src/com/google/inject/testing/fieldbinder/BoundFieldModule.java
  22. +258 −204 extensions/testlib/test/com/google/inject/testing/fieldbinder/BoundFieldModuleTest.java
  23. +4 −6 lib/build/jdiff/Null.java
@@ -1,4 +1,4 @@
/**
/*
* Copyright (C) 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,16 +24,11 @@
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.matcher.Matchers;
import junit.framework.TestCase;
import java.lang.reflect.Modifier;
import javax.inject.Inject;
import junit.framework.TestCase;
/**
* @author jessewilson@google.com (Jesse Wilson)
*/
/** @author jessewilson@google.com (Jesse Wilson) */
public class LineNumbersTest extends TestCase {
public void testLineNumbers() {
@@ -57,8 +52,10 @@ protected void configure() {
}
static class A {
@Inject A(B b) {}
@Inject
A(B b) {}
}
public interface B {}
/*if[AOP]*/
@@ -103,19 +100,27 @@ public Object invoke(
Class<?> generate() {
org.objectweb.asm.ClassWriter cw =
new org.objectweb.asm.ClassWriter(org.objectweb.asm.ClassWriter.COMPUTE_MAXS);
cw.visit(org.objectweb.asm.Opcodes.V1_5,
Modifier.PUBLIC, name, null,
org.objectweb.asm.Type.getInternalName(Object.class), null);
cw.visit(
org.objectweb.asm.Opcodes.V1_5,
Modifier.PUBLIC,
name,
null,
org.objectweb.asm.Type.getInternalName(Object.class),
null);
String sig = "("+org.objectweb.asm.Type.getDescriptor(B.class)+")V";
String sig = "(" + org.objectweb.asm.Type.getDescriptor(B.class) + ")V";
org.objectweb.asm.MethodVisitor mv = cw.visitMethod(Modifier.PUBLIC, "<init>", sig, null, null);
org.objectweb.asm.MethodVisitor mv =
cw.visitMethod(Modifier.PUBLIC, "<init>", sig, null, null);
mv.visitAnnotation(org.objectweb.asm.Type.getDescriptor(Inject.class), true);
mv.visitCode();
mv.visitVarInsn(org.objectweb.asm.Opcodes.ALOAD, 0);
mv.visitMethodInsn(org.objectweb.asm.Opcodes.INVOKESPECIAL,
org.objectweb.asm.Type.getInternalName(Object.class), "<init>", "()V" );
mv.visitMethodInsn(
org.objectweb.asm.Opcodes.INVOKESPECIAL,
org.objectweb.asm.Type.getInternalName(Object.class),
"<init>",
"()V");
mv.visitInsn(org.objectweb.asm.Opcodes.RETURN);
mv.visitMaxs(0, 0);
mv.visitEnd();
@@ -146,7 +151,7 @@ protected void configure() {
getDeclaringSourcePart(getClass()));
}
}
public void testGeneratedClassesCanSucceed() {
final Class<?> generated = new GeneratingClassLoader().generate();
Injector injector =
@@ -1,4 +1,4 @@
/**
/*
* Copyright (C) 2006 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,18 +30,14 @@
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import junit.framework.TestCase;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;
import java.util.AbstractList;
import junit.framework.TestCase;
/**
* @author crazybob@google.com (Bob Lee)
*/
/** @author crazybob@google.com (Bob Lee) */
public class MatcherTest extends TestCase {
@@ -77,8 +73,7 @@ public void testOr() {
public void testAnnotatedWith() {
assertTrue(annotatedWith(Foo.class).matches(Bar.class));
assertFalse(annotatedWith(Foo.class).matches(
MatcherTest.class.getMethods()[0]));
assertFalse(annotatedWith(Foo.class).matches(MatcherTest.class.getMethods()[0]));
assertEquals("annotatedWith(Foo.class)", annotatedWith(Foo.class).toString());
assertEqualsBothWays(annotatedWith(Foo.class), annotatedWith(Foo.class));
assertFalse(annotatedWith(Foo.class).equals(annotatedWith(Named.class)));
@@ -134,15 +129,15 @@ public void testInSubpackage() {
assertFalse(inSubpackage(stringPackageName).matches(Matchers.class));
assertFalse(inSubpackage("jav").matches(Object.class));
assertEqualsBothWays(inSubpackage(stringPackageName), inSubpackage(stringPackageName));
assertFalse(inSubpackage(stringPackageName).equals(inSubpackage(Matchers.class.getPackage().getName())));
assertFalse(
inSubpackage(stringPackageName)
.equals(inSubpackage(Matchers.class.getPackage().getName())));
}
public void testReturns() throws NoSuchMethodException {
Matcher<Method> predicate = returns(only(String.class));
assertTrue(predicate.matches(
Object.class.getMethod("toString")));
assertFalse(predicate.matches(
Object.class.getMethod("hashCode")));
assertTrue(predicate.matches(Object.class.getMethod("toString")));
assertFalse(predicate.matches(Object.class.getMethod("hashCode")));
assertEquals("returns(only(class java.lang.String))", returns(only(String.class)).toString());
assertEqualsBothWays(predicate, returns(only(String.class)));
assertFalse(predicate.equals(returns(only(Integer.class))));
@@ -163,7 +158,7 @@ public void testSerialization() throws IOException {
assertEqualWhenReserialized(only("a").and(only("b")));
}
static abstract class MyRunnable implements Runnable {}
abstract static class MyRunnable implements Runnable {}
@Retention(RetentionPolicy.RUNTIME)
@interface Foo {}
Oops, something went wrong.

0 comments on commit 751b555

Please sign in to comment.