In progress [Issue 125] Support for custom options.

Code cleanup.
diff --git a/com.google.eclipse.protobuf/META-INF/MANIFEST.MF b/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
index 21189b7..b1316ee 100644
--- a/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
+++ b/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
@@ -23,6 +23,8 @@
 Export-Package: com.google.eclipse.protobuf,

  com.google.eclipse.protobuf.conversion,

  com.google.eclipse.protobuf.grammar,

+ com.google.eclipse.protobuf.model,

+ com.google.eclipse.protobuf.model.util,

  com.google.eclipse.protobuf.parseTreeConstruction,

  com.google.eclipse.protobuf.parser.antlr,

  com.google.eclipse.protobuf.parser.antlr.internal,

diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/OptionType.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/OptionType.java
similarity index 97%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/OptionType.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/OptionType.java
index a58b31f..7ead38b 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/OptionType.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/OptionType.java
@@ -6,7 +6,7 @@
  *
  * http://www.eclipse.org/legal/epl-v10.html
  */
-package com.google.eclipse.protobuf.util;
+package com.google.eclipse.protobuf.model;
 
 import java.util.*;
 import java.util.Map.Entry;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/FieldOptions.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/FieldOptions.java
similarity index 98%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/FieldOptions.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/FieldOptions.java
index 5291ee4..41d1365 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/FieldOptions.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/FieldOptions.java
@@ -6,7 +6,7 @@
  *
  * http://www.eclipse.org/legal/epl-v10.html
  */
-package com.google.eclipse.protobuf.util;
+package com.google.eclipse.protobuf.model.util;
 
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.inject.Singleton;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/ModelNodes.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/INodes.java
similarity index 97%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/ModelNodes.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/INodes.java
index 6c8fb35..a200c52 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/ModelNodes.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/INodes.java
@@ -6,7 +6,7 @@
  *
  * http://www.eclipse.org/legal/epl-v10.html
  */
-package com.google.eclipse.protobuf.util;
+package com.google.eclipse.protobuf.model.util;
 
 import static org.eclipse.xtext.nodemodel.util.NodeModelUtils.findNodesForFeature;
 
@@ -24,7 +24,7 @@
  * @author alruiz@google.com (Alex Ruiz)
  */
 @Singleton
-public class ModelNodes {
+public class INodes {
 
   private static final String SINGLE_LINE_COMMENT_RULE_NAME = "SL_COMMENT";
 
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Imports.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Imports.java
similarity index 97%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Imports.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Imports.java
index 3b0b4b9..4fbe746 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Imports.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Imports.java
@@ -6,7 +6,7 @@
  *
  * http://www.eclipse.org/legal/epl-v10.html
  */
-package com.google.eclipse.protobuf.util;
+package com.google.eclipse.protobuf.model.util;
 
 import com.google.eclipse.protobuf.protobuf.Import;
 import com.google.eclipse.protobuf.scoping.ProtoDescriptorProvider;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/ProtobufElementFinder.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelFinder.java
similarity index 97%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/ProtobufElementFinder.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelFinder.java
index 6a0bfeb..3529d39 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/ProtobufElementFinder.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelFinder.java
@@ -6,7 +6,7 @@
  *
  * http://www.eclipse.org/legal/epl-v10.html
  */
-package com.google.eclipse.protobuf.util;
+package com.google.eclipse.protobuf.model.util;
 
 import static java.util.Collections.unmodifiableList;
 import static org.eclipse.emf.ecore.util.EcoreUtil.getAllContents;
@@ -29,7 +29,7 @@
  * @author alruiz@google.com (Alex Ruiz)
  */
 @Singleton
-public class ProtobufElementFinder {
+public class ModelFinder {
 
   /**
    * Returns the message type of the given property, only if the type of the given property is a message.
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Options.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options.java
similarity index 96%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Options.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options.java
index f92ae92..4eb677f 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Options.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options.java
@@ -6,10 +6,11 @@
  *
  * http://www.eclipse.org/legal/epl-v10.html
  */
-package com.google.eclipse.protobuf.util;
+package com.google.eclipse.protobuf.model.util;
 
 import org.eclipse.emf.ecore.EObject;
 
+import com.google.eclipse.protobuf.model.OptionType;
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.inject.Singleton;
 
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Packages.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Packages.java
similarity index 97%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Packages.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Packages.java
index 2219dca..ae37a41 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Packages.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Packages.java
@@ -6,7 +6,7 @@
  *
  * http://www.eclipse.org/legal/epl-v10.html
  */
-package com.google.eclipse.protobuf.util;
+package com.google.eclipse.protobuf.model.util;
 
 import static org.eclipse.xtext.util.Strings.isEmpty;
 
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Properties.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Properties.java
similarity index 98%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Properties.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Properties.java
index df6ed1c..e31414c 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Properties.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Properties.java
@@ -6,7 +6,7 @@
  *
  * http://www.eclipse.org/legal/epl-v10.html
  */
-package com.google.eclipse.protobuf.util;
+package com.google.eclipse.protobuf.model.util;
 
 import static com.google.eclipse.protobuf.grammar.CommonKeyword.*;
 import static com.google.eclipse.protobuf.protobuf.Modifier.OPTIONAL;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider.java
index 4b4ee83..d21a62c 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider.java
@@ -20,8 +20,8 @@
 import org.eclipse.xtext.util.Pair;
 
 import com.google.common.base.Function;
+import com.google.eclipse.protobuf.model.util.ModelFinder;
 import com.google.eclipse.protobuf.protobuf.Package;
-import com.google.eclipse.protobuf.util.ProtobufElementFinder;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 
@@ -35,7 +35,7 @@
   @Inject private IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl();
   @Inject private IResourceScopeCache cache = IResourceScopeCache.NullImpl.INSTANCE;
 
-  @Inject private ProtobufElementFinder finder;
+  @Inject private ModelFinder finder;
   
   private Function<EObject, String> resolver = newResolver(String.class, "name");
 
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/CustomOptionDescriptions.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/CustomOptionDescriptions.java
index e037e83..3dc4220 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/CustomOptionDescriptions.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/CustomOptionDescriptions.java
@@ -8,7 +8,7 @@
  */
 package com.google.eclipse.protobuf.scoping;
 
-import static com.google.eclipse.protobuf.util.OptionType.typeOf;
+import static com.google.eclipse.protobuf.model.OptionType.typeOf;
 import static java.util.Collections.emptyList;
 import static org.eclipse.emf.ecore.util.EcoreUtil.getAllContents;
 import static org.eclipse.xtext.resource.EObjectDescription.create;
@@ -21,6 +21,8 @@
 import org.eclipse.xtext.naming.QualifiedName;
 import org.eclipse.xtext.resource.IEObjectDescription;
 
+import com.google.eclipse.protobuf.model.OptionType;
+import com.google.eclipse.protobuf.model.util.*;
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.eclipse.protobuf.protobuf.Package;
 import com.google.eclipse.protobuf.util.*;
@@ -31,7 +33,7 @@
  */
 class CustomOptionDescriptions {
 
-  @Inject private ProtobufElementFinder finder;
+  @Inject private ModelFinder finder;
   @Inject private ImportedNamesProvider importedNamesProvider;
   @Inject private Imports imports;
   @Inject private LocalNamesProvider localNamesProvider;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ImportedNamesProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ImportedNamesProvider.java
index d0eea21..4240c6e 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ImportedNamesProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ImportedNamesProvider.java
@@ -20,7 +20,7 @@
 import org.eclipse.xtext.util.*;
 
 import com.google.common.base.Function;
-import com.google.eclipse.protobuf.util.ProtobufElementFinder;
+import com.google.eclipse.protobuf.model.util.ModelFinder;
 import com.google.inject.*;
 
 /**
@@ -33,7 +33,7 @@
   @Inject private final IResourceScopeCache cache = IResourceScopeCache.NullImpl.INSTANCE;
   @Inject private final IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl();
 
-  @Inject private ProtobufElementFinder finder;
+  @Inject private ModelFinder finder;
   @Inject private QualifiedNames qualifiedNames;
 
   private final Function<EObject, String> resolver = newResolver(String.class, "name");
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider.java
index 8c19341..108d98b 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider.java
@@ -20,7 +20,7 @@
 import org.eclipse.xtext.util.*;
 
 import com.google.common.base.Function;
-import com.google.eclipse.protobuf.util.ProtobufElementFinder;
+import com.google.eclipse.protobuf.model.util.ModelFinder;
 import com.google.inject.*;
 
 /**
@@ -59,7 +59,7 @@
   @Inject private final IResourceScopeCache cache = IResourceScopeCache.NullImpl.INSTANCE;
   @Inject private final IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl();
 
-  @Inject private ProtobufElementFinder finder;
+  @Inject private ModelFinder finder;
   @Inject private QualifiedNames qualifiedNames;
 
   private final Function<EObject, String> resolver = newResolver(String.class, "name");
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
index d3cd34a..9460829 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
@@ -8,10 +8,10 @@
  */
 package com.google.eclipse.protobuf.scoping;
 
+import static com.google.eclipse.protobuf.model.OptionType.*;
 import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.PROPERTY__TYPE;
 import static com.google.eclipse.protobuf.util.Closeables.closeQuietly;
 import static com.google.eclipse.protobuf.util.Encodings.UTF_8;
-import static com.google.eclipse.protobuf.util.OptionType.*;
 import static java.util.Collections.*;
 import static org.eclipse.xtext.EcoreUtil2.*;
 import static org.eclipse.xtext.util.CancelIndicator.NullImpl;
@@ -28,9 +28,10 @@
 import org.eclipse.xtext.resource.XtextResource;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.eclipse.protobuf.model.OptionType;
+import com.google.eclipse.protobuf.model.util.INodes;
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.eclipse.protobuf.protobuf.Enum;
-import com.google.eclipse.protobuf.util.*;
 
 /**
  * Contains the elements from descriptor.proto (provided with protobuf's library.)
@@ -58,10 +59,10 @@
   private Protobuf root;
 
   private final String importUri;
-  private final ModelNodes nodes;
+  private final INodes nodes;
   private final XtextResource resource;
 
-  ProtoDescriptor(String importUri, URI location, IParser parser, ModelNodes nodes) {
+  ProtoDescriptor(String importUri, URI location, IParser parser, INodes nodes) {
     this.importUri = importUri;
     this.nodes = nodes;
     addOptionTypes();
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptorProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptorProvider.java
index 7c91a25..0069deb 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptorProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptorProvider.java
@@ -18,7 +18,7 @@
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.xtext.parser.IParser;
 
-import com.google.eclipse.protobuf.util.ModelNodes;
+import com.google.eclipse.protobuf.model.util.INodes;
 import com.google.inject.*;
 
 /**
@@ -32,7 +32,7 @@
   private static final String EXTENSION_ID = "com.google.eclipse.protobuf.descriptorSource";
 
   @Inject private IParser parser;
-  @Inject private ModelNodes nodes;
+  @Inject private INodes nodes;
   @Inject private IExtensionRegistry registry;
 
   private Map<String, URI> descriptorInfos;
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 4b2a06c..b029280 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
@@ -17,9 +17,9 @@
 import org.eclipse.xtext.scoping.IScope;
 import org.eclipse.xtext.scoping.impl.*;
 
+import com.google.eclipse.protobuf.model.util.*;
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.eclipse.protobuf.protobuf.Enum;
-import com.google.eclipse.protobuf.util.*;
 import com.google.inject.Inject;
 
 /**
@@ -36,7 +36,7 @@
   @Inject private CustomOptionDescriptions customOptionDescriptions;
   @Inject private ProtoDescriptorProvider descriptorProvider;
   @Inject private FieldOptions fieldOptions;
-  @Inject private ProtobufElementFinder finder;
+  @Inject private ModelFinder finder;
   @Inject private LiteralDescriptions literalDescriptions;
   @Inject private NativeOptionDescriptions nativeOptionDescriptions;
   @Inject private Options options;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/TypeDescriptions.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/TypeDescriptions.java
index 9b0af62..555ed7f 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/TypeDescriptions.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/TypeDescriptions.java
@@ -20,6 +20,7 @@
 import org.eclipse.xtext.naming.QualifiedName;
 import org.eclipse.xtext.resource.IEObjectDescription;
 
+import com.google.eclipse.protobuf.model.util.*;
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.eclipse.protobuf.protobuf.Package;
 import com.google.eclipse.protobuf.util.*;
@@ -31,7 +32,7 @@
 class TypeDescriptions {
 
   @Inject private ProtoDescriptorProvider descriptorProvider;
-  @Inject private ProtobufElementFinder finder;
+  @Inject private ModelFinder finder;
   @Inject private ImportedNamesProvider importedNamesProvider;
   @Inject private Imports imports;
   @Inject private LocalNamesProvider localNamesProvider;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
index 8e47ed3..0b38cc9 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
@@ -19,6 +19,7 @@
 import org.eclipse.xtext.scoping.impl.ImportUriResolver;
 import org.eclipse.xtext.validation.Check;
 
+import com.google.eclipse.protobuf.model.util.*;
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.eclipse.protobuf.protobuf.Package;
 import com.google.eclipse.protobuf.util.*;