Allow the CommentReader to handle above-line @Test annotation.

* Now the reader can handle the annotation regardless of whether its
placed above or in-line with the method declaration.

* Cleanup to only use in-line notation.

Change-Id: I9b71ba08519ce7d5dfb287e473ea6896a518e5d7
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/CommentReader.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/CommentReader.java
index 24e61a5..e8eca5e 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/CommentReader.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/CommentReader.java
@@ -31,6 +31,8 @@
  * @author alruiz@google.com (Alex Ruiz)
  */
 public class CommentReader {
+
+  private static final String AT_TEST = "@Test";
   private static final String COMMENT_START = "//";
 
   private final Map<String, List<String>> commentsByMethod = newHashMap();
@@ -67,8 +69,9 @@
     MultiLineTextBuilder comment = new MultiLineTextBuilder();
     try {
       scanner = new Scanner(new FileInputStream(file));
-      String line;
+      String line = "";
       while (scanner.hasNextLine()) {
+        String prevLine = line;
         line = scanner.nextLine().replaceFirst("^\\s*", "");
         if (line.startsWith(COMMENT_START)) {
           String text = line.substring(COMMENT_START.length());
@@ -82,7 +85,7 @@
           continue;
         }
         line = line.trim();
-        String testName = testName(line);
+        String testName = testName(line, prevLine);
         if (line.length() == 0 || testName != null) {
           if (!comments.contains(comment)) {
             comments.add(comment.toString());
@@ -101,11 +104,12 @@
     }
   }
 
-  private static String testName(String line) {
-    if (!line.startsWith("@Test")) {
-      return null;
+  private static String testName(String line, String prevLine) {
+    String testName = null;
+    if (line.startsWith(AT_TEST) || prevLine.startsWith(AT_TEST)) {
+      int indexOfShould = line.indexOf("should");
+      testName = (indexOfShould == -1) ? null : line.substring(indexOfShould, line.indexOf("("));
     }
-    int indexOfShould = line.indexOf("should");
-    return (indexOfShould == -1) ? null : line.substring(indexOfShould, line.indexOf("("));
+    return testName;
   }
 }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_LiteralLink_target_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_LiteralLink_target_Test.java
index 33123c9..a2decb5 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_LiteralLink_target_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_LiteralLink_target_Test.java
@@ -281,8 +281,7 @@
   //     kind: CREATE
   //   };
   // }
-  @Test
-  public void should_provide_Literals_for_source_of_simple_value_field() {
+  @Test public void should_provide_Literals_for_source_of_simple_value_field() {
     Message message = xtext.find("Example", " {", Message.class);
     CustomOption customFieldOption = (CustomOption) message.getElements().get(0);
     ComplexValueCurlyBracket complexValueCurlyBracket =