Adding more tests.
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ContainAllFieldsInMessage.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ContainAllFieldsInMessage.java
index 5b64340..b144280 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ContainAllFieldsInMessage.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ContainAllFieldsInMessage.java
@@ -24,12 +24,12 @@
private final EObject container;
- static ContainAllFieldsInMessage containAllFieldsIn(Group group) {
- return new ContainAllFieldsInMessage(group);
+ static ContainAllFieldsInMessage containAllFieldsIn(Group g) {
+ return new ContainAllFieldsInMessage(g);
}
- static ContainAllFieldsInMessage containAllFieldsIn(Message message) {
- return new ContainAllFieldsInMessage(message);
+ static ContainAllFieldsInMessage containAllFieldsIn(Message m) {
+ return new ContainAllFieldsInMessage(m);
}
private ContainAllFieldsInMessage(EObject container) {
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_ExtensionFieldNotationNameSource_extension_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_ExtensionFieldNotationNameSource_extension_Test.java
new file mode 100644
index 0000000..e8f9a67
--- /dev/null
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_ExtensionFieldNotationNameSource_extension_Test.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2011 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.scoping;
+
+import static com.google.eclipse.protobuf.junit.core.Setups.integrationTestSetup;
+import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
+import static com.google.eclipse.protobuf.scoping.ContainAllNames.containAll;
+import static com.google.eclipse.protobuf.scoping.IEObjectDescriptions.descriptionsIn;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+
+import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.*;
+
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.xtext.scoping.IScope;
+import org.junit.*;
+
+/**
+ * Tests for <code>{@link ProtobufScopeProvider#scope_ExtensionFieldNotationNameSource_extension(ExtensionFieldNotationNameSource, EReference)}</code>.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class ProtobufScopeProvider_scope_ExtensionFieldNotationNameSource_extension_Test {
+
+ private static EReference reference;
+
+ @BeforeClass public static void setUpOnce() {
+ reference = mock(EReference.class);
+ }
+
+ @Rule public XtextRule xtext = createWith(integrationTestSetup());
+
+ private ProtobufScopeProvider provider;
+
+ @Before public void setUp() {
+ provider = xtext.getInstanceOf(ProtobufScopeProvider.class);
+ }
+
+ // syntax = "proto2";
+ //
+ // import "google/protobuf/descriptor.proto";
+ //
+ // package google.proto.test;
+ //
+ // message Aggregate {
+ // optional string s = 1;
+ // optional google.protobuf.FileOptions file = 2;
+ // }
+ //
+ // extend google.protobuf.FileOptions {
+ // optional Aggregate fileopt = 15478479;
+ // }
+ //
+ // option (fileopt) = {
+ // file {
+ // [google.proto.test.fileopt] {
+ // s:'FileExtensionAnnotation'
+ // }
+ // }
+ // };
+ @Test public void should_provide_sources_for_field_notation_in_option() {
+ FieldNotation notation = xtext.find("google.proto.test.fileopt", "]", FieldNotation.class);
+ ExtensionFieldNotationNameSource s = (ExtensionFieldNotationNameSource) notation.getName();
+ IScope scope = provider.scope_ExtensionFieldNotationNameSource_extension(s, reference);
+ assertThat(descriptionsIn(scope), containAll("google.proto.test.fileopt", ".google.proto.test.fileopt"));
+ }
+}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_NormalFieldNotationNameSource_property_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_NormalFieldNotationNameSource_property_Test.java
index bb7e64b..40c211a 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_NormalFieldNotationNameSource_property_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtobufScopeProvider_scope_NormalFieldNotationNameSource_property_Test.java
@@ -58,7 +58,7 @@
// option (type) = {
// code: 68
// };
- @Test public void should_provide_property_if_container_is_CustomOption() {
+ @Test public void should_provide_sources_for_field_notation_in_option() {
FieldNotation notation = xtext.find("code", ":", FieldNotation.class);
NormalFieldNotationNameSource s = (NormalFieldNotationNameSource) notation.getName();
IScope scope = provider.scope_NormalFieldNotationNameSource_property(s, reference);
@@ -86,7 +86,58 @@
// option (type) = {
// name { value: 'Address' }
// };
- @Test public void should_provide_property_if_notation_is_nested() {
+ @Test public void should_provide_sources_for_nested_field_notation_in_option() {
+ FieldNotation notation = xtext.find("value", ":", FieldNotation.class);
+ NormalFieldNotationNameSource s = (NormalFieldNotationNameSource) notation.getName();
+ IScope scope = provider.scope_NormalFieldNotationNameSource_property(s, reference);
+ Message message = xtext.find("Names", " {", Message.class);
+ assertThat(descriptionsIn(scope), containAllFieldsIn(message));
+ }
+
+ // syntax = "proto2";
+ //
+ // import "google/protobuf/descriptor.proto";
+ //
+ // message Type {
+ // optional int32 code = 1;
+ // }
+ //
+ // extend google.protobuf.FieldOptions {
+ // optional Type type = 15478479;
+ // }
+ //
+ // message Address {
+ // optional int target = 1 [(type) = { code: 68 }];
+ // }
+ @Test public void should_provide_sources_for_field_notation_in_field_option() {
+ FieldNotation notation = xtext.find("code", ":", FieldNotation.class);
+ NormalFieldNotationNameSource s = (NormalFieldNotationNameSource) notation.getName();
+ IScope scope = provider.scope_NormalFieldNotationNameSource_property(s, reference);
+ Message message = xtext.find("Type", " {", Message.class);
+ assertThat(descriptionsIn(scope), containAllFieldsIn(message));
+ }
+
+ // syntax = "proto2";
+ //
+ // import "google/protobuf/descriptor.proto";
+ //
+ // message Type {
+ // optional int32 code = 1;
+ // optional Names name = 2;
+ // }
+ //
+ // message Names {
+ // optional string value = 1;
+ // }
+ //
+ // extend google.protobuf.FieldOptions {
+ // optional Type type = 15478479;
+ // }
+ //
+ // message Address {
+ // optional int target = 1 [(type) = { name: { value: 'Address' } }];
+ // }
+ @Test public void should_provide_sources_for_nested_field_notation_in_field_option() {
FieldNotation notation = xtext.find("value", ":", FieldNotation.class);
NormalFieldNotationNameSource s = (NormalFieldNotationNameSource) notation.getName();
IScope scope = provider.scope_NormalFieldNotationNameSource_property(s, reference);
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/Finder.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/Finder.java
index 0eda06c..05e0d91 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/Finder.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/Finder.java
@@ -27,7 +27,7 @@
*/
class Finder {
- private static final String[] FEATURE_NAMES = { "message", "name", "optionField", "property", "source", "type" };
+ private static final String[] FEATURE_NAMES = { "extension", "message", "name", "optionField", "property", "source", "type" };
private final String protoAsText;
private final AbstractNode root;