Added list of types to ignore when getting the qualified name of an
object.
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 ad148ba..4c8c87b 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
@@ -12,6 +12,7 @@
import static org.eclipse.xtext.util.Tuples.pair;
import com.google.eclipse.protobuf.model.util.*;
+import com.google.eclipse.protobuf.protobuf.*;
import com.google.eclipse.protobuf.protobuf.Package;
import com.google.inject.*;
@@ -30,6 +31,10 @@
IProtobufQualifiedNameProvider {
private static final Pair<NameType, QualifiedName> EMPTY_NAME = pair(NORMAL, null);
+ private static final Class<?>[] IGNORED_TYPES = { Protobuf.class, Import.class, AbstractOption.class,
+ OptionSource.class, ScalarTypeLink.class, NumberLink.class, BooleanLink.class, StringLink.class, ComplexValue.class,
+ ValueField.class, FieldName.class };
+
@Inject private final IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl();
@Inject private final IResourceScopeCache cache = IResourceScopeCache.NullImpl.INSTANCE;
@@ -43,6 +48,9 @@
}
@Override public QualifiedName getFullyQualifiedName(final EObject e, final NamingStrategy namingStrategy) {
+ if (shouldIgnore(e)) {
+ return null;
+ }
Pair<EObject, String> key = pair(e, "fqn");
Pair<NameType, QualifiedName> cached = cache.get(key, e.eResource(), new Provider<Pair<NameType, QualifiedName>>() {
@Override public Pair<NameType, QualifiedName> get() {
@@ -65,6 +73,15 @@
return cached.getSecond();
}
+ private boolean shouldIgnore(EObject e) {
+ for (Class<?> ignoredType : IGNORED_TYPES) {
+ if (ignoredType.isInstance(e)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private QualifiedName addPackage(EObject obj, QualifiedName qualifiedName) {
if (qualifiedName == null || obj instanceof Package) {
return qualifiedName;