Working on supporting pluggable descriptor.proto definitions.

diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/Descriptor_fileOptions_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/Descriptor_fileOptions_Test.java
index 92b0e57..3afe1bb 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/Descriptor_fileOptions_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/Descriptor_fileOptions_Test.java
@@ -20,7 +20,7 @@
 import com.google.eclipse.protobuf.protobuf.Property;
 
 /**
- * Tests for <code>{@link Descriptor#fileOptions()}</code>.
+ * Tests for <code>{@link ProtoDescriptor#fileOptions()}</code>.
  *
  * @author alruiz@google.com (Alex Ruiz)
  */
@@ -28,10 +28,10 @@
 
   @Rule public XtextRule xtext = new XtextRule();
 
-  private Descriptor descriptor;
+  private IProtoDescriptor descriptor;
 
   @Before public void setUp() {
-    descriptor = xtext.getInstanceOf(Descriptor.class);
+    descriptor = xtext.getInstanceOf(ProtoDescriptor.class);
   }
 
   @Test public void should_return_all_file_options() {
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/contentassist/ProtobufProposalProvider.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/contentassist/ProtobufProposalProvider.java
index 62e62a4..0bdd093 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/contentassist/ProtobufProposalProvider.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/contentassist/ProtobufProposalProvider.java
@@ -29,8 +29,7 @@
 import com.google.common.collect.ImmutableList;
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.eclipse.protobuf.protobuf.Enum;
-import com.google.eclipse.protobuf.scoping.Descriptor;
-import com.google.eclipse.protobuf.scoping.DescriptorProvider;
+import com.google.eclipse.protobuf.scoping.*;
 import com.google.eclipse.protobuf.ui.grammar.CommonKeyword;
 import com.google.eclipse.protobuf.ui.grammar.CompoundElement;
 import com.google.eclipse.protobuf.ui.labeling.Images;
@@ -48,7 +47,7 @@
   private static final String SPACE = " ";
 
   @Inject private ProtobufElementFinder finder;
-  @Inject private DescriptorProvider descriptorProvider;
+  @Inject private ProtoDescriptorProvider descriptorProvider;
   @Inject private PluginImageHelper imageHelper;
 
   @Inject private Fields fields;
@@ -126,7 +125,7 @@
   @Override public void completeOption_Value(EObject model, Assignment assignment, ContentAssistContext context,
       ICompletionProposalAcceptor acceptor) {
     Option option = (Option) model;
-    Descriptor descriptor = descriptorProvider.get();
+    IProtoDescriptor descriptor = descriptorProvider.get();
     Enum enumType = descriptor.enumTypeOf(option);
     if (enumType != null) {
       proposeAndAccept(enumType, context, acceptor);
@@ -405,7 +404,7 @@
   @Override public void completeFieldOption_Value(EObject model, Assignment assignment, ContentAssistContext context,
       ICompletionProposalAcceptor acceptor) {
     FieldOption option = (FieldOption) model;
-    Descriptor descriptor = descriptorProvider.get();
+    IProtoDescriptor descriptor = descriptorProvider.get();
     Enum enumType = descriptor.enumTypeOf(option);
     if (enumType != null) {
       proposeAndAccept(enumType, context, acceptor);
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/IProtoDescriptor.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/IProtoDescriptor.java
new file mode 100644
index 0000000..c8c6482
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/IProtoDescriptor.java
@@ -0,0 +1,83 @@
+/*
+ * 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.scoping;
+
+import com.google.eclipse.protobuf.protobuf.*;
+import com.google.eclipse.protobuf.protobuf.Enum;
+
+import java.util.Collection;
+
+/**
+ * Contains the elements from descriptor.proto (provided with protobuf's library.)
+ * 
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public interface IProtoDescriptor {
+
+  /**
+   * Returns all the file-level options available. These are the options defined in
+   * {@code google/protobuf/descriptor.proto} (more details can be found
+   * <a href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
+   * @return all the file-level options available.
+   */
+  public abstract Collection<Property> fileOptions();
+
+  /**
+   * Looks up an option per name, as defined in {@code google/protobuf/descriptor.proto}
+   * (more details can be found <a
+   * href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
+   * @param name the name of the option to look for.
+   * @return the option whose name matches the given one or {@code null} if a matching option is not found.
+   */
+  public abstract Property lookupOption(String name);
+
+  /**
+   * Returns all the message-level options available. These are the options defined in
+   * {@code google/protobuf/descriptor.proto} (more details can be found
+   * <a href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
+   * @return all the message-level options available.
+   */
+  public abstract Collection<Property> messageOptions();
+
+  /**
+   * Returns all the field-level options available. These are the options defined in
+   * {@code google/protobuf/descriptor.proto} (more details can be found
+   * <a href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
+   * @return all the field-level options available.
+   */
+  public abstract Collection<Property> fieldOptions();
+
+  /**
+   * Looks up a field-level option per name. Field-level options are defined in {@code google/protobuf/descriptor.proto}
+   * (more details can be found <a
+   * href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
+   * @param name the name of the option to look for.
+   * @return the option whose name matches the given one or {@code null} if a matching option is not found.
+   */
+  public abstract Property lookupFieldOption(String name);
+
+  /**
+   * Returns the enum type of the given option, only if the given option is defined in 
+   * {@code google/protobuf/descriptor.proto} and its type an enum (more details can be found <a
+   * href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
+   * @param option the given option.
+   * @return the enum type of the given option or {@code null} if the type of the given option is not enum.
+   */
+  public abstract Enum enumTypeOf(Option option);
+
+  /**
+   * Returns the enum type of the given option, only if the given option is defined in 
+   * {@code google/protobuf/descriptor.proto} and its type an enum (more details can be found <a
+   * href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
+   * @param option the given option.
+   * @return the enum type of the given option or {@code null} if the type of the given option is not enum.
+   */
+  public abstract Enum enumTypeOf(FieldOption option);
+
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/Descriptor.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
similarity index 67%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/Descriptor.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
index d0e21c6..6e4b7a8 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/Descriptor.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
@@ -31,7 +31,7 @@
  *
  * @author alruiz@google.com (Alex Ruiz)
  */
-public class Descriptor {
+public class ProtoDescriptor implements IProtoDescriptor {
 
   private static final String DESCRIPTOR_URI = "platform:/plugin/com.google.eclipse.protobuf/descriptor.proto";
 
@@ -41,7 +41,7 @@
   private Enum optimizedMode;
   private Enum cType;
 
-  @Inject public Descriptor(IParser parser) {
+  @Inject public ProtoDescriptor(IParser parser) {
     addOptionTypes();
     InputStreamReader reader = null;
     try {
@@ -151,45 +151,24 @@
     return name.equals(anEnum.getName());
   }
   
-  /**
-   * Returns all the file-level options available. These are the options defined in
-   * {@code google/protobuf/descriptor.proto} (more details can be found
-   * <a href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
-   * @return all the file-level options available.
-   */
+  /** {@inheritDoc} */
   public Collection<Property> fileOptions() {
     return optionsOfType(FILE);
   }
 
-  /**
-   * Looks up an option per name, as defined in {@code google/protobuf/descriptor.proto}
-   * (more details can be found <a
-   * href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
-   * @param name the name of the option to look for.
-   * @return the option whose name matches the given one or {@code null} if a matching option is not found.
-   */
+  /** {@inheritDoc} */
   public Property lookupOption(String name) {
     Property p = lookupOption(FILE, name);
     if (p == null) lookupOption(MESSAGE, name);
     return p;
   }
 
-  /**
-   * Returns all the message-level options available. These are the options defined in
-   * {@code google/protobuf/descriptor.proto} (more details can be found
-   * <a href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
-   * @return all the message-level options available.
-   */
+  /** {@inheritDoc} */
   public Collection<Property> messageOptions() {
     return optionsOfType(MESSAGE);
   }
 
-  /**
-   * Returns all the field-level options available. These are the options defined in
-   * {@code google/protobuf/descriptor.proto} (more details can be found
-   * <a href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
-   * @return all the field-level options available.
-   */
+  /** {@inheritDoc} */
   public Collection<Property> fieldOptions() {
     return optionsOfType(FIELD);
   }
@@ -198,13 +177,7 @@
     return unmodifiableCollection(options.get(type).values());
   }
   
-  /**
-   * Looks up a field-level option per name. Field-level options are defined in {@code google/protobuf/descriptor.proto}
-   * (more details can be found <a
-   * href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
-   * @param name the name of the option to look for.
-   * @return the option whose name matches the given one or {@code null} if a matching option is not found.
-   */
+  /** {@inheritDoc} */
   public Property lookupFieldOption(String name) {
     return lookupOption(FIELD, name);
   }
@@ -213,13 +186,7 @@
     return options.get(type).get(name);
   }
 
-  /**
-   * Returns the enum type of the given option, only if the given option is defined in 
-   * {@code google/protobuf/descriptor.proto} and its type an enum (more details can be found <a
-   * href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
-   * @param option the given option.
-   * @return the enum type of the given option or {@code null} if the type of the given option is not enum.
-   */
+  /** {@inheritDoc} */
   public Enum enumTypeOf(Option option) {
     if (isOptimizeForOption(option)) return optimizedMode;
     return null;
@@ -230,13 +197,7 @@
     return "optimize_for".equals(option.getName());
   }
 
-  /**
-   * Returns the enum type of the given option, only if the given option is defined in 
-   * {@code google/protobuf/descriptor.proto} and its type an enum (more details can be found <a
-   * href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
-   * @param option the given option.
-   * @return the enum type of the given option or {@code null} if the type of the given option is not enum.
-   */
+  /** {@inheritDoc} */
   public Enum enumTypeOf(FieldOption option) {
     if (isCTypeOption(option)) return cType;
     return null;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/DescriptorProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptorProvider.java
similarity index 62%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/DescriptorProvider.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptorProvider.java
index dc481ea..4de2810 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/DescriptorProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptorProvider.java
@@ -13,19 +13,19 @@
 import org.eclipse.xtext.parser.IParser;
 
 /**
- * Provider of a singleton instance of <code>{@link Descriptor}</code>.
+ * Provider of a singleton instance of <code>{@link ProtoDescriptor}</code>.
  *
  * @author Alex Ruiz
  */
 @Singleton
-public class DescriptorProvider implements Provider<Descriptor> {
+public class ProtoDescriptorProvider implements Provider<IProtoDescriptor> {
 
   @Inject private IParser parser;
 
-  private Descriptor descriptor;
+  private IProtoDescriptor descriptor;
 
-  public synchronized Descriptor get() {
-    if (descriptor == null) descriptor = new Descriptor(parser);
+  public synchronized IProtoDescriptor get() {
+    if (descriptor == null) descriptor = new ProtoDescriptor(parser);
     return descriptor;
   }
 }
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider.java
index 963a962..90d9e62 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider.java
@@ -41,7 +41,7 @@
   private static final boolean DO_NOT_IGNORE_CASE = false;
 
   @Inject private ProtobufElementFinder finder;
-  @Inject private DescriptorProvider descriptorProvider;
+  @Inject private ProtoDescriptorProvider descriptorProvider;
   @Inject private IQualifiedNameProvider nameProvider;
   @Inject private ImportUriResolver uriResolver;
   @Inject private LocalNamesProvider localNamesProvider;
@@ -166,7 +166,7 @@
   }
 
   private Enum enumTypeOfOption(EObject mayBeOption) {
-    Descriptor descriptor = descriptorProvider.get();
+    IProtoDescriptor descriptor = descriptorProvider.get();
     if (mayBeOption instanceof Option) return descriptor.enumTypeOf((Option) mayBeOption);
     if (mayBeOption instanceof FieldOption) return descriptor.enumTypeOf((FieldOption) mayBeOption);
     return null;