Fixed a bug in scoping of options. ExtensionOptionField was being scoped insufficiently causing test Labels_labelFor_Test.should_return_label_for_custom_option() to fail. Change-Id: I64344d6a611361deb4986c68fb9b2c87edd3bf8d
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 d541014..2071827 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
@@ -257,18 +257,19 @@ * Recursively scope {@code OptionField} starting with an {@code OptionSource}. */ private IScope getScopeOfOptionField( - OptionSource optionSource, EReference reference, int fieldIndex, EList<OptionField> fields) { + IScope scope, OptionSource optionSource, EReference reference, int fieldIndex, EList<OptionField> fields) { if (fieldIndex < 0 || fields.size() <= fieldIndex) { throw new IllegalArgumentException(); } - IScope parentScope, retval = IScope.NULLSCOPE; + IScope retval = scope; + IScope parentScope = IScope.NULLSCOPE; QualifiedName name = QualifiedName.EMPTY; if (fieldIndex == 0) { parentScope = super.getScope(optionSource, OPTION_SOURCE__TARGET); name = getEObjectName(optionSource); } else { OptionField parentOptionField = fields.get(fieldIndex - 1); - parentScope = getScopeOfOptionField(optionSource, reference, fieldIndex - 1, fields); + parentScope = getScopeOfOptionField(retval, optionSource, reference, fieldIndex - 1, fields); name = getEObjectName(parentOptionField); } IEObjectDescription indexedElementDescription = parentScope.getSingleElement(name); @@ -532,7 +533,8 @@ * * The {@code OptionField} {@code number} contains a cross-reference to {@code Code.number}. */ - public @Nullable IScope scope_OptionField_target(OptionField optionField, EReference reference) { + public IScope scope_OptionField_target(OptionField optionField, EReference reference) { + IScope scope = getLocalScopeProvider().getResourceScope(optionField.eResource(), reference); EObject customOption = optionField.eContainer(); if (customOption != null) { OptionSource optionSource = null; @@ -547,10 +549,10 @@ } if (optionSource != null && fields != null) { int index = fields.indexOf(optionField); - return getScopeOfOptionField(optionSource, reference, index, fields); + return getScopeOfOptionField(scope, optionSource, reference, index, fields); } } - return null; + return scope; } /**