In progress [Issue 125] Support for custom options.

Code cleanup.
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/util/FieldOptions_isDefaultValueOption_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/util/FieldOptions_isDefaultValueOption_Test.java
index 8779e7a..c320a8d 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/util/FieldOptions_isDefaultValueOption_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/util/FieldOptions_isDefaultValueOption_Test.java
@@ -35,9 +35,9 @@
   @Before public void setUp() {
     fieldOptions = xtext.getInstanceOf(FieldOptions.class);
     MultiLineTextBuilder proto = new MultiLineTextBuilder();
-    proto.append("message Person {                                                   ");
-    proto.append("  optional boolean active = 1 [default = true, deprecated = false];");
-    proto.append("}                                                                  ");
+    proto.append("message Person {                                                   ")
+         .append("  optional boolean active = 1 [default = true, deprecated = false];")
+         .append("}                                                                  ");
     root = xtext.parseText(proto);
   }
 
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/util/FieldOptions_nameOf_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/util/FieldOptions_nameOf_Test.java
new file mode 100644
index 0000000..c8181e9
--- /dev/null
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/util/FieldOptions_nameOf_Test.java
@@ -0,0 +1,65 @@
+/*
+ * 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.util;
+
+import static com.google.eclipse.protobuf.junit.find.FieldOptionFinder.findFieldOption;
+import static com.google.eclipse.protobuf.junit.find.Name.name;
+import static com.google.eclipse.protobuf.junit.find.Root.in;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+import org.junit.*;
+
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
+import com.google.eclipse.protobuf.protobuf.*;
+
+/**
+ * Tests for <code>{@link FieldOptions#nameOf(FieldOption)}</code>.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class FieldOptions_nameOf_Test {
+
+  @Rule public XtextRule xtext = XtextRule.integrationTestSetup();
+
+  private FieldOptions fieldOptions;
+
+  @Before public void setUp() {
+    fieldOptions = xtext.getInstanceOf(FieldOptions.class);
+  }
+
+  @Test public void should_return_name_of_native_field_option() {
+    MultiLineTextBuilder proto = new MultiLineTextBuilder();
+    proto.append("message Person {                                   ")
+         .append("  optional boolean active = 1 [deprecated = false];")
+         .append("}                                                  ");
+    Protobuf root = xtext.parseText(proto);
+    FieldOption option = findFieldOption(name("deprecated"), in(root));
+    String name = fieldOptions.nameOf(option);
+    assertThat(name, equalTo("deprecated"));
+  }
+
+  @Test public void should_return_name_of_custom_field_option() {
+    MultiLineTextBuilder proto = new MultiLineTextBuilder();
+    proto.append("import \"google/protobuf/descriptor.proto\";         ")
+         .append("                                                     ")
+         .append("extend google.protobuf.FieldOptions {                ")
+         .append("  optional string encoding = 1000;                   ")
+         .append("}                                                    ")
+         .append("                                                     ")
+         .append("message Person {                                     ")
+         .append("  optional boolean active = 1 [(encoding) = 'UTF-8'];")
+         .append("}                                                    ");
+    Protobuf root = xtext.parseText(proto);
+    FieldOption option = findFieldOption(name("encoding"), in(root));
+    String name = fieldOptions.nameOf(option);
+    assertThat(name, equalTo("encoding"));
+  }
+}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/util/FieldOptions_propertyFrom_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/util/FieldOptions_propertyFrom_Test.java
new file mode 100644
index 0000000..8a86499
--- /dev/null
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/util/FieldOptions_propertyFrom_Test.java
@@ -0,0 +1,65 @@
+/*
+ * 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.util;
+
+import static com.google.eclipse.protobuf.junit.find.FieldOptionFinder.findFieldOption;
+import static com.google.eclipse.protobuf.junit.find.Name.name;
+import static com.google.eclipse.protobuf.junit.find.Root.in;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+import org.junit.*;
+
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
+import com.google.eclipse.protobuf.protobuf.*;
+
+/**
+ * Tests for <code>{@link FieldOptions#propertyFrom(FieldOption)}</code>.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class FieldOptions_propertyFrom_Test {
+
+  @Rule public XtextRule xtext = XtextRule.integrationTestSetup();
+
+  private FieldOptions fieldOptions;
+
+  @Before public void setUp() {
+    fieldOptions = xtext.getInstanceOf(FieldOptions.class);
+  }
+
+  @Test public void should_return_property_of_native_field_option() {
+    MultiLineTextBuilder proto = new MultiLineTextBuilder();
+    proto.append("message Person {                                   ")
+         .append("  optional boolean active = 1 [deprecated = false];")
+         .append("}                                                  ");
+    Protobuf root = xtext.parseText(proto);
+    FieldOption option = findFieldOption(name("deprecated"), in(root));
+    Property p = fieldOptions.propertyFrom(option);
+    assertThat(p.getName(), equalTo("deprecated"));
+  }
+
+  @Test public void should_return_property_of_custom_field_option() {
+    MultiLineTextBuilder proto = new MultiLineTextBuilder();
+    proto.append("import \"google/protobuf/descriptor.proto\";         ")
+         .append("                                                     ")
+         .append("extend google.protobuf.FieldOptions {                ")
+         .append("  optional string encoding = 1000;                   ")
+         .append("}                                                    ")
+         .append("                                                     ")
+         .append("message Person {                                     ")
+         .append("  optional boolean active = 1 [(encoding) = 'UTF-8'];")
+         .append("}                                                    ");
+    Protobuf root = xtext.parseText(proto);
+    FieldOption option = findFieldOption(name("encoding"), in(root));
+    Property p = fieldOptions.propertyFrom(option);
+    assertThat(p.getName(), equalTo("encoding"));
+  }
+}