Code cleanup. Updated plug-in version. Added tests.
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/CommentProcessor.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/CommentProcessor.java
index 51bf47d..0ebc1c8 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/CommentProcessor.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/CommentProcessor.java
@@ -26,7 +26,7 @@
     Scanner scanner = new Scanner(comment);
     String fileName = null;
     while (scanner.hasNextLine()) {
-      String line = scanner.nextLine().trim();
+      String line = scanner.nextLine();
       Matcher matcher = CREATE_FILE_PATTERN.matcher(line);
       if (!matcher.matches()) return comment;
       fileName = matcher.group(1);
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/TestSourceReader.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/TestSourceReader.java
index 8a48387..5add2bd 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/TestSourceReader.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/TestSourceReader.java
@@ -65,7 +65,7 @@
       while (scanner.hasNextLine()) {
         line = scanner.nextLine().replaceFirst("^\\s*", "");
         if (line.startsWith(COMMENT_START)) {
-          comment.append(line.substring(COMMENT_START.length()));
+          comment.append(line.substring(COMMENT_START.length()).trim());
           continue;
         }
         if (comment.isEmpty()) continue;
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/XtextRule.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/XtextRule.java
index 4ab24d0..0b445be 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/XtextRule.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/XtextRule.java
@@ -70,10 +70,14 @@
   }
 
   private void parseText(String text) {
+    boolean ignoreSyntaxErrors = shouldIgnoreSyntaxErrorsIn(text);
     resource = resourceFrom(new StringInputStream(text));
     IParseResult parseResult = resource.getParseResult();
-    if (!parseResult.hasSyntaxErrors()) {
+    if (ignoreSyntaxErrors) {
       root = (Protobuf) parseResult.getRootASTElement();
+      return;
+    }
+    if (!parseResult.hasSyntaxErrors()) {
       if (root.getSyntax() == null) {
         throw new IllegalStateException("Please specify 'proto2' syntax");
       }
@@ -86,6 +90,10 @@
     throw new IllegalStateException(builder.toString());
   }
 
+  private boolean shouldIgnoreSyntaxErrorsIn(String text) {
+    return text.startsWith("// ignore errors");
+  }
+
   private XtextResource resourceFrom(InputStream input) {
     return resourceFrom(input, createURI("mytestmodel.proto")); //$NON-NLS-1$
   }
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser_doParse_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser_doParse_Test.java
new file mode 100644
index 0000000..6d1d335
--- /dev/null
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser_doParse_Test.java
@@ -0,0 +1,38 @@
+/*
+ * 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.parser;
+
+import static com.google.eclipse.protobuf.junit.core.Setups.unitTestSetup;
+import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.junit.Assert.assertThat;
+
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.Protobuf;
+
+import org.antlr.runtime.CharStream;
+import org.eclipse.xtext.nodemodel.impl.NodeModelBuilder;
+import org.junit.*;
+
+/**
+ * Tests for <code>{@link Proto2OnlyParser#doParse(String, CharStream, NodeModelBuilder, int)}</code>.
+ * 
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class Proto2OnlyParser_doParse_Test {
+
+  @Rule public XtextRule xtext = createWith(unitTestSetup());
+
+  // // ignore errors
+  // c++header #include "test/common/proto_class.h"
+  @Test public void should_recognize_proto1_syntax() {
+    Protobuf root = xtext.root();
+    assertThat(root, instanceOf(NonProto2Protobuf.class));
+  }
+}
diff --git a/com.google.eclipse.protobuf.ui/META-INF/MANIFEST.MF b/com.google.eclipse.protobuf.ui/META-INF/MANIFEST.MF
index 6727157..e462e9b 100644
--- a/com.google.eclipse.protobuf.ui/META-INF/MANIFEST.MF
+++ b/com.google.eclipse.protobuf.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2

 Bundle-Name: %Bundle-Name

 Bundle-Vendor: %Bundle-Vendor

-Bundle-Version: 1.0.11.qualifier

+Bundle-Version: 1.1.0.qualifier

 Bundle-SymbolicName: com.google.eclipse.protobuf.ui; singleton:=true

 Bundle-ActivationPolicy: lazy

 Require-Bundle: com.google.eclipse.protobuf;visibility:=reexport,

diff --git a/com.google.eclipse.protobuf/META-INF/MANIFEST.MF b/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
index 2ed523b..790ec7e 100644
--- a/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
+++ b/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
 Eclipse-ExtensibleAPI: true

 Bundle-Name: %Bundle-Name

 Bundle-Vendor: %Bundle-Vendor

-Bundle-Version: 1.0.11.qualifier

+Bundle-Version: 1.1.0.qualifier

 Bundle-SymbolicName: com.google.eclipse.protobuf; singleton:=true

 Bundle-ActivationPolicy: lazy

 Require-Bundle: org.eclipse.xtext;bundle-version="2.1.1",

diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser.java
index 8697ea9..82bc189 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser.java
@@ -39,10 +39,10 @@
 
   private boolean isNonProto2(IParseResult result) {
     if (!result.hasSyntaxErrors()) return false;
-    Protobuf root = (Protobuf) result.getRootASTElement();
     for (INode node : result.getSyntaxErrors()) {
       if (isNonProto2(node.getSyntaxErrorMessage())) return true;
     }
+    Protobuf root = (Protobuf) result.getRootASTElement();
     if (root != null) {
       if (root.getSyntax() == null) return true;
     }
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/resource/ResourceServiceProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/resource/ResourceServiceProvider.java
index d640484..0a70a85 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/resource/ResourceServiceProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/resource/ResourceServiceProvider.java
@@ -12,6 +12,7 @@
 import com.google.inject.Inject;
 
 import org.eclipse.emf.ecore.*;
+import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.xtext.resource.*;
 import org.eclipse.xtext.resource.IGlobalServiceProvider.ResourceServiceProviderImpl;
 
@@ -28,7 +29,8 @@
     if (e.eIsProxy()) {
       return findService(((InternalEObject) e).eProxyURI(), serviceType);
     }
-    if (e.eResource() == null) return null;
-    return findService(e.eResource().getURI(), serviceType);
+    Resource resource = e.eResource();
+    if (resource == null) return null;
+    return findService(resource.getURI(), serviceType);
   }
 }