Moved settings for parser checks from extension point to preferences.
diff --git a/com.google.eclipse.protobuf.ui.functional.test/.classpath b/com.google.eclipse.protobuf.ui.functional.test/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.functional.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/com.google.eclipse.protobuf.ui.functional.test/.gitignore b/com.google.eclipse.protobuf.ui.functional.test/.gitignore
new file mode 100644
index 0000000..5e56e04
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.functional.test/.gitignore
@@ -0,0 +1 @@
+/bin
diff --git a/com.google.eclipse.protobuf.ui.functional.test/.project b/com.google.eclipse.protobuf.ui.functional.test/.project
new file mode 100644
index 0000000..b0c832e
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.functional.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>com.google.eclipse.protobuf.ui.functional.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/com.google.eclipse.protobuf.ui.functional.test/.settings/org.eclipse.jdt.core.prefs b/com.google.eclipse.protobuf.ui.functional.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..dd7d0d5
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.functional.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,8 @@
+#Thu Dec 29 17:04:14 EST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/com.google.eclipse.protobuf.ui.functional.test/META-INF/MANIFEST.MF b/com.google.eclipse.protobuf.ui.functional.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..cc5ba7d
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.functional.test/META-INF/MANIFEST.MF
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Test
+Bundle-SymbolicName: com.google.eclipse.protobuf.ui.functional.test
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Google Inc.
+Fragment-Host: com.google.eclipse.protobuf.ui;bundle-version="1.1.1"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.eclipse.swtbot.go;bundle-version="2.0.5",
+ org.mockito;bundle-version="1.8.5"
diff --git a/com.google.eclipse.protobuf.ui.functional.test/build.properties b/com.google.eclipse.protobuf.ui.functional.test/build.properties
new file mode 100644
index 0000000..34d2e4d
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.functional.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/junit/core/OverrideUiModuleSetup.java b/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/junit/core/OverrideUiModuleSetup.java
new file mode 100644
index 0000000..8552cef
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/junit/core/OverrideUiModuleSetup.java
@@ -0,0 +1,44 @@
+/*
+ * 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.junit.core;
+
+import static org.eclipse.xtext.util.Modules2.mixin;
+
+import org.eclipse.xtext.ISetup;
+import org.eclipse.xtext.ui.shared.SharedStateModule;
+
+import com.google.eclipse.protobuf.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.ui.ProtobufUiModule;
+import com.google.eclipse.protobuf.ui.internal.ProtobufActivator;
+import com.google.inject.*;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class OverrideUiModuleSetup extends ProtobufStandaloneSetup {
+ private final Module module;
+
+ public static XtextRule overrideUiModuleWith(Module module) {
+ ISetup setup = new OverrideUiModuleSetup(module);
+ return XtextRule.createWith(setup);
+ }
+
+ OverrideUiModuleSetup(Module module) {
+ this.module = module;
+ }
+
+ @Override public Injector createInjector() {
+ Module mixin = mixin(new ProtobufRuntimeModule(),
+ new SharedStateModule(),
+ new ProtobufUiModule(ProtobufActivator.getInstance()),
+ module);
+ return Guice.createInjector(mixin);
+ }
+}
diff --git a/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/parser/PreferenceDrivenProtobufParser_doParse_Test.java b/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/parser/PreferenceDrivenProtobufParser_doParse_Test.java
new file mode 100644
index 0000000..c01d672
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui.functional.test/src/com/google/eclipse/protobuf/ui/parser/PreferenceDrivenProtobufParser_doParse_Test.java
@@ -0,0 +1,64 @@
+/*
+ * 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.parser;
+
+import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
+import static com.google.eclipse.protobuf.ui.Internals.injector;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.junit.Assert.*;
+
+import org.antlr.runtime.CharStream;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.xtext.nodemodel.impl.NodeModelBuilder;
+import org.eclipse.xtext.ui.editor.preferences.IPreferenceStoreAccess;
+import org.junit.*;
+
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
+import com.google.eclipse.protobuf.parser.NonProto2Protobuf;
+import com.google.eclipse.protobuf.protobuf.Protobuf;
+
+/**
+ * Tests for <code>{@link PreferenceDrivenProtobufParser#doParse(String, CharStream, NodeModelBuilder, int)}</code>.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class PreferenceDrivenProtobufParser_doParse_Test {
+ private static String proto1;
+
+ @BeforeClass public static void setUpOnce() {
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
+ proto.append("// ignore errors")
+ .append("c++header #include 'test/common/proto_class.h'");
+ proto1 = proto.toString();
+ }
+
+ @Rule public XtextRule xtext = createWith(injector());
+
+ private IPreferenceStore store;
+
+ @Before public void setUp() {
+ IPreferenceStoreAccess storeAccess = xtext.getInstanceOf(IPreferenceStoreAccess.class);
+ store = storeAccess.getWritablePreferenceStore();
+ }
+
+ @Test public void should_recognize_proto1_syntax() {
+ store.setValue("parser.checkProto2Only", true);
+ xtext.parseText(proto1);
+ Protobuf root = xtext.root();
+ assertThat(root, instanceOf(NonProto2Protobuf.class));
+ }
+
+ @Test public void should_not_recognize_proto1_syntax() {
+ store.setValue("parser.checkProto2Only", false);
+ xtext.parseText(proto1);
+ Protobuf root = xtext.root();
+ assertNull(root);
+ }
+}