In progress: [Issue 155] Editor does not support complex custom options.
Done. Need to add tests.
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 f61076f..722a9a7 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
@@ -34,20 +34,38 @@
Collection<IEObjectDescription> findScope(OptionMessageFieldSource fieldSource) {
return findScope(fieldSource, new IEObjectDescriptionsProvider() {
@Override public Collection<IEObjectDescription> fieldsInType(Field f) {
- if (!(f instanceof Property)) return emptyList();
- Message propertyType = modelFinder.messageTypeOf((Property) f);
- if (propertyType == null) return emptyList();
Set<IEObjectDescription> descriptions = new HashSet<IEObjectDescription>();
- for (MessageElement e : propertyType.getElements()) {
- if (!(e instanceof Property)) continue;
- Property current = (Property) e;
- descriptions.add(create(current.getName(), current));
+ if (f instanceof Property) {
+ Message propertyType = modelFinder.messageTypeOf((Property) f);
+ for (MessageElement e : propertyType.getElements()) {
+ IEObjectDescription d = describe(e);
+ if (d != null) descriptions.add(d);
+ }
+ }
+ if (f instanceof Group) {
+ Group group = (Group) f;
+ for (GroupElement e : group.getElements()) {
+ IEObjectDescription d = describe(e);
+ if (d != null) descriptions.add(d);
+ }
}
return descriptions;
}
});
}
+ private IEObjectDescription describe(EObject e) {
+ if (e instanceof Property) {
+ Property p = (Property) e;
+ return create(p.getName(), p);
+ }
+ if (e instanceof Group) {
+ Group g = (Group) e;
+ return create(g.getName(), g);
+ }
+ return null;
+ }
+
Collection<IEObjectDescription> findScope(OptionExtendMessageFieldSource fieldSource) {
return findScope(fieldSource, new IEObjectDescriptionsProvider() {
@Override public Collection<IEObjectDescription> fieldsInType(Field f) {
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 7906fc8..b5dabfd 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
@@ -39,9 +39,7 @@
Set<IEObjectDescription> descriptions = new HashSet<IEObjectDescription>();
ExtendMessage extend = (ExtendMessage) target;
for (MessageElement e : extend.getElements()) {
- if (!(e instanceof Property)) continue;
- Property p = (Property) e;
- descriptions.addAll(qualifiedNamesDescriptions.qualifiedNames(p));
+ descriptions.addAll(qualifiedNamesDescriptions.qualifiedNames(e));
}
return descriptions;
}
@@ -52,14 +50,12 @@
Set<IEObjectDescription> descriptions = new HashSet<IEObjectDescription>();
ExtendMessage extend = (ExtendMessage) target;
for (MessageElement e : extend.getElements()) {
- if (!(e instanceof Property)) continue;
- Property p = (Property) e;
- List<QualifiedName> names = localNamesProvider.namesOf(p);
+ List<QualifiedName> names = localNamesProvider.namesOf(e);
int nameCount = names.size();
for (int i = level; i < nameCount; i++) {
- descriptions.add(create(names.get(i), p));
+ descriptions.add(create(names.get(i), e));
}
- descriptions.addAll(qualifiedNamesDescriptions.qualifiedNames(p));
+ descriptions.addAll(qualifiedNamesDescriptions.qualifiedNames(e));
}
return descriptions;
}