Fixed: [Issue 113] Not all protoc errors are shown as editor markers
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/builder/CodeGenerationErrorParser_parseAndAddMarkerIfNecessary_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/builder/CodeGenerationErrorParser_parseAndAddMarkerIfNecessary_Test.java
new file mode 100644
index 0000000..2338707
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/builder/CodeGenerationErrorParser_parseAndAddMarkerIfNecessary_Test.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.builder;
+
+import static org.mockito.Mockito.*;
+
+import org.eclipse.core.runtime.CoreException;
+import org.junit.*;
+
+/**
+ * Tests for <code>{@link CodeGenerationErrorParser#parseAndAddMarkerIfNecessary(String, ProtocMarkerFactory)}</code>.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class CodeGenerationErrorParser_parseAndAddMarkerIfNecessary_Test {
+
+  private ProtocMarkerFactory markerFactory;
+  private CodeGenerationErrorParser outputParser;
+
+  @Before public void setUp() {
+    markerFactory = mock(ProtocMarkerFactory.class);
+    outputParser = new CodeGenerationErrorParser();
+  }
+
+  @Test public void should_not_create_IMarker_if_line_does_not_match_error_pattern() throws CoreException {
+    String line = "Expected field name.";
+    outputParser.parseAndAddMarkerIfNecessary(line, markerFactory);
+    verifyZeroInteractions(markerFactory);
+  }
+
+  @Test public void should_attempt_to_create_IMarker_if_line_matches_error_pattern() throws CoreException {
+    String line = "person.proto: --java_out: person.proto: Cannot generate Java.";
+    outputParser.parseAndAddMarkerIfNecessary(line, markerFactory);
+    verify(markerFactory).createErrorIfNecessary("person.proto", "--java_out: person.proto: Cannot generate Java.", -1);
+  }
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/CodeGenerationErrorParser.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/CodeGenerationErrorParser.java
new file mode 100644
index 0000000..e9cfbe1
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/CodeGenerationErrorParser.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.builder;
+
+import java.util.regex.*;
+
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+class CodeGenerationErrorParser implements ProtocOutputParser {
+
+  /*
+   * (.*):\\s*(--.*)
+   * --1- -*- --2-
+   *
+   * 1: file name
+   * *: whitespace
+   * 2: description
+   */
+  private static final Pattern ERROR_PATTERN = Pattern.compile("(.*):\\s*(--.*)");
+
+  public boolean parseAndAddMarkerIfNecessary(String line, ProtocMarkerFactory markerFactory) throws CoreException {
+    Matcher errorMatcher = ERROR_PATTERN.matcher(line);
+    if (!errorMatcher.matches()) return false;
+    markerFactory.createErrorIfNecessary(errorMatcher.group(1), errorMatcher.group(2), -1);
+    return true;
+  }
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/CompoundParser.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/CompoundParser.java
new file mode 100644
index 0000000..af6acdf
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/CompoundParser.java
@@ -0,0 +1,23 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+
+package com.google.eclipse.protobuf.ui.builder;
+
+import static java.util.Arrays.asList;
+
+import org.eclipse.core.runtime.CoreException;
+
+import java.util.*;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+class CompoundParser implements ProtocOutputParser {
+
+  private static final List<ProtocOutputParser> PARSERS = asList(new LineSpecificErrorParser(), new CodeGenerationErrorParser()); 
+  
+  public boolean parseAndAddMarkerIfNecessary(String line, ProtocMarkerFactory markerFactory) throws CoreException {
+    for (ProtocOutputParser parser: PARSERS)
+      if (parser.parseAndAddMarkerIfNecessary(line, markerFactory)) return true;
+    return false;
+  }
+}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/LineSpecificErrorParser.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/LineSpecificErrorParser.java
index 6ab3cac..233729f 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/LineSpecificErrorParser.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/LineSpecificErrorParser.java
@@ -15,11 +15,9 @@
 import org.eclipse.core.runtime.CoreException;
 
 /**
- * Parses the output of protoc.
- *
  * @author alruiz@google.com (Alex Ruiz)
  */
-class LineSpecificErrorParser {
+class LineSpecificErrorParser implements ProtocOutputParser {
 
   /*
    * (.*):(\\d+):(\\d+):\\s*(.*)
@@ -33,12 +31,10 @@
    */
   private static final Pattern ERROR_PATTERN = Pattern.compile("(.*):(\\d+):(\\d+):\\s*(.*)");
 
-  public void parseAndAddMarkerIfNecessary(String line, ProtocMarkerFactory markerFactory) throws CoreException {
+  public boolean parseAndAddMarkerIfNecessary(String line, ProtocMarkerFactory markerFactory) throws CoreException {
     Matcher errorMatcher = ERROR_PATTERN.matcher(line);
-    if (!errorMatcher.matches()) return;
-    String fileName = errorMatcher.group(1);
-    int lineNumber = parseInt(errorMatcher.group(2));
-    String message = errorMatcher.group(4);
-    markerFactory.createErrorIfNecessary(fileName, message, lineNumber);
+    if (!errorMatcher.matches()) return false;
+    markerFactory.createErrorIfNecessary(errorMatcher.group(1), errorMatcher.group(4), parseInt(errorMatcher.group(2)));
+    return true;
   }
 }
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/ProtobufBuildParticipant.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/ProtobufBuildParticipant.java
index 32522f4..0ae6304 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/ProtobufBuildParticipant.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/ProtobufBuildParticipant.java
@@ -37,10 +37,10 @@
  */
 public class ProtobufBuildParticipant implements IXtextBuilderParticipant {
 
-  @Inject private LineSpecificErrorParser outputParser;
-  @Inject private ProtocCommandFactory commandFactory;
   @Inject private CompilerPreferencesFactory compilerPreferencesFactory;
   @Inject private PathsPreferencesFactory pathsPreferencesFactory;
+  @Inject private ProtocCommandFactory commandFactory;
+  @Inject private ProtocOutputParser outputParser;
   @Inject private ProtoDescriptorPathFinder protoDescriptorPathFinder;
 
   public void build(IBuildContext context, IProgressMonitor monitor) throws CoreException {
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/ProtocOutputParser.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/ProtocOutputParser.java
new file mode 100644
index 0000000..ee50aca
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/ProtocOutputParser.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2011 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.builder;
+
+import com.google.inject.ImplementedBy;
+
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+@ImplementedBy(CompoundParser.class)
+interface ProtocOutputParser {
+
+  boolean parseAndAddMarkerIfNecessary(String line, ProtocMarkerFactory markerFactory) throws CoreException;
+
+}