Fixed: [Issue 157] Groups should be considered Types.

Code cleanup.
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider_namesOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/LocalNamesProvider_names_Test.java
similarity index 82%
rename from com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider_namesOf_Test.java
rename to com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/LocalNamesProvider_names_Test.java
index 7638a69..2a55884 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider_namesOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/LocalNamesProvider_names_Test.java
@@ -6,11 +6,10 @@
  *
  * http://www.eclipse.org/legal/epl-v10.html
  */
-package com.google.eclipse.protobuf.scoping;
+package com.google.eclipse.protobuf.naming;
 
 import static com.google.eclipse.protobuf.junit.core.Setups.unitTestSetup;
 import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
-import static com.google.eclipse.protobuf.naming.Naming.NameTarget.TYPE;
 import static org.hamcrest.core.IsEqual.equalTo;
 import static org.junit.Assert.assertThat;
 
@@ -21,15 +20,15 @@
 import org.junit.*;
 
 import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.naming.Naming.NameTarget;
+import com.google.eclipse.protobuf.naming.LocalNamesProvider;
 import com.google.eclipse.protobuf.protobuf.Enum;
 
 /**
- * Tests for <code>{@link LocalNamesProvider#namesOf(EObject, NameTarget)}</code>.
+ * Tests for <code>{@link LocalNamesProvider#names(EObject)}</code>.
  *
  * @author alruiz@google.com (Alex Ruiz)
  */
-public class LocalNamesProvider_namesOf_Test {
+public class LocalNamesProvider_names_Test {
 
   @Rule public XtextRule xtext = createWith(unitTestSetup());
 
@@ -53,7 +52,7 @@
   // }
   @Test public void should_return_all_possible_local_names() {
     Enum phoneType = xtext.find("PhoneType", " {", Enum.class);
-    List<QualifiedName> names = namesProvider.namesOf(phoneType, TYPE);
+    List<QualifiedName> names = namesProvider.names(phoneType);
     assertThat(names.get(0).toString(), equalTo("PhoneType"));
     assertThat(names.get(1).toString(), equalTo("PhoneNumber.PhoneType"));
     assertThat(names.get(2).toString(), equalTo("Person.PhoneNumber.PhoneType"));
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider_getFullyQualifiedName_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider_getFullyQualifiedName_Test.java
index c189190..f77b9eb 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider_getFullyQualifiedName_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider_getFullyQualifiedName_Test.java
@@ -28,10 +28,10 @@
 
   @Rule public XtextRule xtext = createWith(unitTestSetup());
 
-  private ProtobufQualifiedNameProvider provider;
+  private IProtobufQualifiedNameProvider provider;
 
   @Before public void setUp() {
-    provider = (ProtobufQualifiedNameProvider) xtext.getInstanceOf(IQualifiedNameProvider.class);
+    provider = (IProtobufQualifiedNameProvider) xtext.getInstanceOf(IQualifiedNameProvider.class);
   }
 
   // syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/QualifiedNames_addLeadingDot_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/QualifiedNames_addLeadingDot_Test.java
similarity index 93%
rename from com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/QualifiedNames_addLeadingDot_Test.java
rename to com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/QualifiedNames_addLeadingDot_Test.java
index 77a41b7..c175535 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/QualifiedNames_addLeadingDot_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/QualifiedNames_addLeadingDot_Test.java
@@ -6,7 +6,7 @@
  *
  * http://www.eclipse.org/legal/epl-v10.html
  */
-package com.google.eclipse.protobuf.scoping;
+package com.google.eclipse.protobuf.naming;
 
 import static com.google.eclipse.protobuf.junit.core.Setups.unitTestSetup;
 import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
@@ -17,6 +17,7 @@
 import org.junit.*;
 
 import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.naming.QualifiedNames;
 
 /**
  * Tests for <code>{@link QualifiedNames#addLeadingDot(QualifiedName)}</code>.
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 8dc744c..f2fef10 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
@@ -73,6 +73,11 @@
     proposeAndAccept(proposal, imageHelper.getImage(images.imageFor(Syntax.class)), context, acceptor);
   }
 
+  @Override public void complete_TypeRef(EObject model, RuleCall ruleCall, ContentAssistContext context,
+      ICompletionProposalAcceptor acceptor) {
+    System.out.println("Hello");
+  }
+
   @Override public void completeNativeOption_Source(EObject model, Assignment assignment,
       ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
     ProtoDescriptor descriptor = descriptorProvider.primaryDescriptor();
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/IProtobufQualifiedNameProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/IProtobufQualifiedNameProvider.java
new file mode 100644
index 0000000..b4c34aa
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/IProtobufQualifiedNameProvider.java
@@ -0,0 +1,24 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+
+package com.google.eclipse.protobuf.naming;
+
+import com.google.eclipse.protobuf.protobuf.Group;
+import com.google.inject.ImplementedBy;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.naming.*;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+@ImplementedBy(ProtobufQualifiedNameProvider.class)
+public interface IProtobufQualifiedNameProvider extends IQualifiedNameProvider {
+
+  /**
+   * Returns the qualified name of the given object, to be used in an option. If the given object is a 
+   * <code>{@link Group}</code>, this methods returns the name in lower case.
+   * @param e the given object.
+   * @return the qualified name of the given object, to be used in an option.
+   */
+  QualifiedName getFullyQualifiedNameForOption(EObject e);
+}
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/naming/LocalNamesProvider.java
similarity index 82%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/LocalNamesProvider.java
index ef56271..55983b5 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/LocalNamesProvider.java
@@ -6,23 +6,24 @@
  *
  * http://www.eclipse.org/legal/epl-v10.html
  */
-package com.google.eclipse.protobuf.scoping;
+package com.google.eclipse.protobuf.naming;
 
+import static com.google.eclipse.protobuf.naming.Naming.NamingUsage.*;
 import static java.util.Collections.*;
 import static org.eclipse.xtext.util.SimpleAttributeResolver.newResolver;
 import static org.eclipse.xtext.util.Strings.isEmpty;
 import static org.eclipse.xtext.util.Tuples.pair;
 
-import java.util.*;
+import com.google.common.base.Function;
+import com.google.eclipse.protobuf.model.util.ModelFinder;
+import com.google.eclipse.protobuf.naming.Naming.NamingUsage;
+import com.google.inject.*;
 
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.xtext.naming.*;
 import org.eclipse.xtext.util.*;
 
-import com.google.common.base.Function;
-import com.google.eclipse.protobuf.model.util.*;
-import com.google.eclipse.protobuf.naming.Naming;
-import com.google.inject.*;
+import java.util.*;
 
 /**
  * Provides alternative qualified names for protobuf elements.
@@ -55,7 +56,7 @@
  *
  * @author alruiz@google.com (Alex Ruiz)
  */
-class LocalNamesProvider {
+public class LocalNamesProvider {
 
   @Inject private final IResourceScopeCache cache = IResourceScopeCache.NullImpl.INSTANCE;
   @Inject private final IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl();
@@ -65,16 +66,23 @@
   @Inject private QualifiedNames qualifiedNames;
 
   private final Function<EObject, String> resolver = newResolver(String.class, "name");
-
-  List<QualifiedName> namesOf(final EObject e, final Naming.NameTarget target) {
+  
+  public List<QualifiedName> names(EObject e) {
+    return allNames(e, DEFAULT);
+  }
+  
+  public List<QualifiedName> namesForOption(EObject e) {
+    return allNames(e, OPTION);
+  }
+  
+  private List<QualifiedName> allNames(final EObject e, final NamingUsage usage) {
     Pair<EObject, String> key = pair(e, "localFqns");
     return cache.get(key, e.eResource(), new Provider<List<QualifiedName>>() {
       @Override public List<QualifiedName> get() {
         List<QualifiedName> allNames = new ArrayList<QualifiedName>();
         EObject current = e;
-        String name = naming.nameOf(e, target);
+        String name = naming.nameOf(e, usage);
         if (isEmpty(name)) return emptyList();
-        
         QualifiedName qualifiedName = converter.toQualifiedName(name);
         allNames.add(qualifiedName);
         while (current.eContainer() != null) {
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/Naming.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/Naming.java
index 0752820..91a7985 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/Naming.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/Naming.java
@@ -30,23 +30,23 @@
   private final Function<EObject, String> resolver = newResolver(String.class, "name");
 
   /**
-   * Returns the name of the given object. If the name target is an option and the given object is a 
+   * Returns the name of the given object. If the name will be used for an option and if the given object is a 
    * <code>{@link Group}</code>, this method will return the name of the group in lower case.
    * @param e the given object.
-   * @param target the name target.
+   * @param usage indicates how the returned name will be used.
    * @return the name of the given object.
    */
-  public String nameOf(EObject e, NameTarget target) {
-    if (NameTarget.TYPE.equals(target)) return resolver.apply(e);
+  String nameOf(EObject e, NamingUsage usage) {
+    if (NamingUsage.DEFAULT.equals(usage)) return resolver.apply(e);
     return (e instanceof IndexedElement) ? options.nameForOption((IndexedElement) e) : resolver.apply(e);
   }
 
   /**
-   * Indicates if the name to obtain will be used by a type or an option.
+   * Indicates if the name to obtain will be used by a type (default) or an option.
    * 
    * @author alruiz@google.com (Alex Ruiz)
    */
-  public static enum NameTarget {
-    TYPE, OPTION;
+  static enum NamingUsage {
+    DEFAULT, OPTION;
   }
 }
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 a6dfc8f..e4df283 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
@@ -8,6 +8,7 @@
  */
 package com.google.eclipse.protobuf.naming;
 
+import static com.google.eclipse.protobuf.naming.Naming.NamingUsage.*;
 import static org.eclipse.xtext.util.Strings.isEmpty;
 import static org.eclipse.xtext.util.Tuples.pair;
 
@@ -16,7 +17,7 @@
 import org.eclipse.xtext.util.*;
 
 import com.google.eclipse.protobuf.model.util.*;
-import com.google.eclipse.protobuf.naming.Naming.NameTarget;
+import com.google.eclipse.protobuf.naming.Naming.NamingUsage;
 import com.google.eclipse.protobuf.protobuf.Package;
 import com.google.inject.*;
 
@@ -25,7 +26,8 @@
  *
  * @author alruiz@google.com (Alex Ruiz)
  */
-public class ProtobufQualifiedNameProvider extends IQualifiedNameProvider.AbstractImpl {
+public class ProtobufQualifiedNameProvider extends IQualifiedNameProvider.AbstractImpl 
+    implements IProtobufQualifiedNameProvider {
 
   @Inject private final IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl();
   @Inject private final IResourceScopeCache cache = IResourceScopeCache.NullImpl.INSTANCE;
@@ -34,22 +36,27 @@
   @Inject private Naming naming;
 
   @Override public QualifiedName getFullyQualifiedName(EObject e) {
-    return getFullyQualifiedName(e, NameTarget.TYPE);
+    return getFullyQualifiedName(e, DEFAULT);
   }
 
-  public QualifiedName getFullyQualifiedName(final EObject e, final NameTarget target) {
+  @Override public QualifiedName getFullyQualifiedNameForOption(EObject e) {
+    return getFullyQualifiedName(e, OPTION);
+  }
+  
+  private QualifiedName getFullyQualifiedName(final EObject e, final NamingUsage usage) {
     Pair<EObject, String> key = pair(e, "fqn");
     return cache.get(key, e.eResource(), new Provider<QualifiedName>() {
       @Override public QualifiedName get() {
         EObject current = e;
-        String name = naming.nameOf(e, target);
+        String name = naming.nameOf(e, usage);
         if (isEmpty(name)) return null;
         QualifiedName qualifiedName = converter.toQualifiedName(name);
         while (current.eContainer() != null) {
           current = current.eContainer();
-          QualifiedName parentsQualifiedName = getFullyQualifiedName(current);
-          if (parentsQualifiedName != null)
+          QualifiedName parentsQualifiedName = getFullyQualifiedName(current, usage);
+          if (parentsQualifiedName != null) {
             return parentsQualifiedName.append(qualifiedName);
+          }
         }
         return addPackage(e, qualifiedName);
       }
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/QualifiedNames.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/QualifiedNames.java
similarity index 87%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/QualifiedNames.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/QualifiedNames.java
index a073fe8..086214f 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/QualifiedNames.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/QualifiedNames.java
@@ -6,7 +6,7 @@
  *
  * http://www.eclipse.org/legal/epl-v10.html
  */
-package com.google.eclipse.protobuf.scoping;
+package com.google.eclipse.protobuf.naming;
 
 import static java.util.Collections.*;
 import static org.eclipse.xtext.util.Strings.isEmpty;
@@ -21,11 +21,11 @@
 /**
  * @author alruiz@google.com (Alex Ruiz)
  */
-class QualifiedNames {
+public class QualifiedNames {
 
   @Inject private final IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl();
 
-  QualifiedName addLeadingDot(QualifiedName name) {
+  public QualifiedName addLeadingDot(QualifiedName name) {
     if (name.getFirstSegment().equals("")) return name;
     List<String> segments = new ArrayList<String>();
     segments.addAll(name.getSegments());
@@ -33,7 +33,7 @@
     return QualifiedName.create(segments.toArray(new String[segments.size()]));
   }
 
-  Collection<QualifiedName> addPackageNameSegments(QualifiedName name, Package p) {
+  public Collection<QualifiedName> addPackageNameSegments(QualifiedName name, Package p) {
     QualifiedName current = name;
     List<String> segments = fqnSegments(p);
     int segmentCount = segments.size();
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/CustomOptionFieldScopeFinder.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/CustomOptionFieldScopeFinder.java
index 2b1de3b..473e8e7 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/CustomOptionFieldScopeFinder.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/CustomOptionFieldScopeFinder.java
@@ -8,19 +8,18 @@
  */
 package com.google.eclipse.protobuf.scoping;
 
-import static com.google.eclipse.protobuf.naming.Naming.NameTarget.OPTION;
 import static java.util.Collections.*;
 import static org.eclipse.xtext.resource.EObjectDescription.create;
 
-import java.util.*;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtext.resource.IEObjectDescription;
-
 import com.google.eclipse.protobuf.model.util.*;
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.inject.*;
 
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.resource.IEObjectDescription;
+
+import java.util.*;
+
 /**
  * @author alruiz@google.com (Alex Ruiz)
  */
@@ -124,7 +123,7 @@
         for (MessageElement element : extend.getElements()) {
           if (!(element instanceof Property)) continue;
           Property current = (Property) element;
-          descriptions.addAll(qualifiedNamesDescriptions.qualifiedNames(current, OPTION));
+          descriptions.addAll(qualifiedNamesDescriptions.qualifiedNamesForOption(current));
           descriptions.add(create(current.getName(), current));
         }
       }
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/CustomOptionScopeFinder.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/CustomOptionScopeFinder.java
index eaf0c0b..33523c6 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/CustomOptionScopeFinder.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/CustomOptionScopeFinder.java
@@ -8,27 +8,24 @@
  */
 package com.google.eclipse.protobuf.scoping;
 
-import static com.google.eclipse.protobuf.naming.Naming.NameTarget.OPTION;
 import static java.util.Collections.emptySet;
 import static org.eclipse.xtext.resource.EObjectDescription.create;
 
-import java.util.*;
+import com.google.eclipse.protobuf.model.util.ModelFinder;
+import com.google.eclipse.protobuf.naming.LocalNamesProvider;
+import com.google.eclipse.protobuf.protobuf.*;
+import com.google.inject.Inject;
 
 import org.eclipse.xtext.naming.QualifiedName;
 import org.eclipse.xtext.resource.IEObjectDescription;
 
-import com.google.eclipse.protobuf.model.util.ModelFinder;
-import com.google.eclipse.protobuf.naming.Naming.NameTarget;
-import com.google.eclipse.protobuf.protobuf.*;
-import com.google.inject.Inject;
+import java.util.*;
 
 /**
  * @author alruiz@google.com (Alex Ruiz)
  */
 class CustomOptionScopeFinder implements ScopeFinder {
 
-  private static final NameTarget NAME_TARGET = OPTION;
-
   @Inject private LocalNamesProvider localNamesProvider;
   @Inject private ModelFinder modelFinder;
   @Inject private QualifiedNameDescriptions qualifiedNamesDescriptions;
@@ -43,7 +40,7 @@
     Set<IEObjectDescription> descriptions = new HashSet<IEObjectDescription>();
     ExtendMessage extend = (ExtendMessage) target;
     for (MessageElement e : extend.getElements()) {
-      descriptions.addAll(qualifiedNamesDescriptions.qualifiedNames(e, NAME_TARGET));
+      descriptions.addAll(qualifiedNamesDescriptions.qualifiedNamesForOption(e));
     }
     return descriptions;
   }
@@ -54,12 +51,12 @@
     Set<IEObjectDescription> descriptions = new HashSet<IEObjectDescription>();
     ExtendMessage extend = (ExtendMessage) target;
     for (MessageElement e : extend.getElements()) {
-      List<QualifiedName> names = localNamesProvider.namesOf(e, NAME_TARGET);
+      List<QualifiedName> names = localNamesProvider.namesForOption(e);
       int nameCount = names.size();
       for (int i = level; i < nameCount; i++) {
         descriptions.add(create(names.get(i), e));
       }
-      descriptions.addAll(qualifiedNamesDescriptions.qualifiedNames(e, NAME_TARGET));
+      descriptions.addAll(qualifiedNamesDescriptions.qualifiedNamesForOption(e));
     }
     return descriptions;
   }
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 5559084..3f744fa 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
@@ -50,8 +50,7 @@
     EObject c = typeRef.eContainer();
     if (c instanceof Property) {
       Property property = (Property) c;
-      Class<?>[] types = { Type.class, Group.class };
-      return createScope(astWalker.traverseAst(property, typeScopeFinder, types));
+      return createScope(astWalker.traverseAst(property, typeScopeFinder, Type.class));
     }
     Set<IEObjectDescription> descriptions = emptySet();
     return createScope(descriptions);
@@ -60,8 +59,7 @@
   @SuppressWarnings("unused")
   public IScope scope_MessageRef_type(MessageRef messageRef, EReference reference) {
     Protobuf root = modelFinder.rootOf(messageRef);
-    Class<?>[] types = { Message.class };
-    return createScope(astWalker.traverseAst(root, typeScopeFinder, types));
+    return createScope(astWalker.traverseAst(root, typeScopeFinder, Message.class));
   }
 
   @SuppressWarnings("unused")
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/QualifiedNameDescriptions.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/QualifiedNameDescriptions.java
index accaffc..af90372 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/QualifiedNameDescriptions.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/QualifiedNameDescriptions.java
@@ -10,27 +10,35 @@
 
 import static org.eclipse.xtext.resource.EObjectDescription.create;
 
-import java.util.*;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtext.naming.*;
-import org.eclipse.xtext.resource.IEObjectDescription;
-
-import com.google.eclipse.protobuf.naming.Naming.NameTarget;
 import com.google.eclipse.protobuf.naming.*;
 import com.google.inject.Inject;
 
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.naming.QualifiedName;
+import org.eclipse.xtext.resource.IEObjectDescription;
+
+import java.util.*;
+
 /**
  * @author alruiz@google.com (Alex Ruiz)
  */
 class QualifiedNameDescriptions {
 
-  @Inject private ProtobufQualifiedNameProvider nameProvider;
+  @Inject private IProtobufQualifiedNameProvider nameProvider;
   @Inject private QualifiedNames qualifiedNames;
 
-  Collection<IEObjectDescription> qualifiedNames(EObject e, NameTarget target) {
+  Collection<IEObjectDescription> qualifiedNames(EObject e) {
+    QualifiedName fqn = nameProvider.getFullyQualifiedName(e);
+    return allQualifiedNames(e, fqn);
+  }
+
+  Collection<IEObjectDescription> qualifiedNamesForOption(EObject e) {
+    QualifiedName fqn = nameProvider.getFullyQualifiedNameForOption(e);
+    return allQualifiedNames(e, fqn);
+  }
+
+  private Collection<IEObjectDescription> allQualifiedNames(EObject e, QualifiedName fqn) {
     List<IEObjectDescription> descriptions = new ArrayList<IEObjectDescription>();
-    QualifiedName fqn = nameProvider.getFullyQualifiedName(e, target);
     descriptions.add(create(fqn, e));
     descriptions.add(create(qualifiedNames.addLeadingDot(fqn), e));
     return descriptions;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/TypeScopeFinder.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/TypeScopeFinder.java
index df6573d..8a5c447 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/TypeScopeFinder.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/TypeScopeFinder.java
@@ -8,11 +8,10 @@
  */
 package com.google.eclipse.protobuf.scoping;
 
-import static com.google.eclipse.protobuf.naming.Naming.NameTarget.TYPE;
 import static java.util.Collections.emptySet;
 import static org.eclipse.xtext.resource.EObjectDescription.create;
 
-import com.google.eclipse.protobuf.naming.Naming.NameTarget;
+import com.google.eclipse.protobuf.naming.LocalNamesProvider;
 import com.google.eclipse.protobuf.protobuf.*;
 import com.google.inject.Inject;
 
@@ -27,8 +26,6 @@
  */
 class TypeScopeFinder implements ScopeFinder {
 
-  private static final NameTarget NAME_TARGET = TYPE;
-  
   @Inject private ProtoDescriptorProvider descriptorProvider;
   @Inject private LocalNamesProvider localNamesProvider;
   @Inject private QualifiedNameDescriptions qualifiedNamesDescriptions;
@@ -38,7 +35,7 @@
     ProtoDescriptor descriptor = descriptorProvider.descriptor(anImport.getImportURI());
     for (Type type : descriptor.allTypes()) {
       if (!isInstance(type, criteria)) continue;
-      descriptions.addAll(qualifiedNamesDescriptions.qualifiedNames(type, NAME_TARGET));
+      descriptions.addAll(qualifiedNamesDescriptions.qualifiedNames(type));
     }
     return descriptions;
   }
@@ -46,32 +43,29 @@
   @Override public Collection<IEObjectDescription> descriptions(Object target, Object criteria) {
     if (!isInstance(target, criteria)) return emptySet();
     EObject e = (EObject) target;
-    return qualifiedNamesDescriptions.qualifiedNames(e, NAME_TARGET);
+    return qualifiedNamesDescriptions.qualifiedNames(e);
   }
 
   @Override public Collection<IEObjectDescription> descriptions(Object target, Object criteria, int level) {
     if (!isInstance(target, criteria)) return emptySet();
     EObject e = (EObject) target;
     Set<IEObjectDescription> descriptions = new HashSet<IEObjectDescription>();
-    List<QualifiedName> names = localNamesProvider.namesOf(e, NAME_TARGET);
+    List<QualifiedName> names = localNamesProvider.names(e);
     int nameCount = names.size();
     for (int i = level; i < nameCount; i++) {
       descriptions.add(create(names.get(i), e));
     }
-    descriptions.addAll(qualifiedNamesDescriptions.qualifiedNames(e, NAME_TARGET));
+    descriptions.addAll(qualifiedNamesDescriptions.qualifiedNames(e));
     return descriptions;
   }
   
   private boolean isInstance(Object target, Object criteria) {
-    Class<?>[] targetTypes = targetTypesFrom(criteria);
-    for (Class<?> type : targetTypes) {
-      if (type.isInstance(target)) return true;
-    }
-    return false;
+    Class<?> targetType = targetTypeFrom(criteria);
+    return targetType.isInstance(target);
   }
   
-  private Class<?>[] targetTypesFrom(Object criteria) {
-    if (criteria instanceof Class<?>[]) return (Class<?>[]) criteria;
-    throw new IllegalArgumentException("Search criteria should be an array of Class<? extends EObject>");
+  private Class<?> targetTypeFrom(Object criteria) {
+    if (criteria instanceof Class<?>) return (Class<?>) criteria;
+    throw new IllegalArgumentException("Search criteria should be Class<?>");
   }
 }