Code cleanup. Fixed broken tests.
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_isDefaultValueOption_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_isDefaultValueOption_Test.java
similarity index 87%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_isDefaultValueOption_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_isDefaultValueOption_Test.java
index 54b8ce6..27461e5 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_isDefaultValueOption_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_isDefaultValueOption_Test.java
@@ -18,18 +18,18 @@
import com.google.eclipse.protobuf.protobuf.FieldOption;
/**
- * Tests for <code>{@link Options2#isDefaultValueOption(FieldOption)}</code>.
+ * Tests for <code>{@link Options#isDefaultValueOption(FieldOption)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class Options2_isDefaultValueOption_Test {
+public class Options_isDefaultValueOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private Options2 options;
+ private Options options;
@Before public void setUp() {
- options = xtext.getInstanceOf(Options2.class);
+ options = xtext.getInstanceOf(Options.class);
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_nameOf_FieldOption_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_nameOf_FieldOption_Test.java
similarity index 93%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_nameOf_FieldOption_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_nameOf_FieldOption_Test.java
index c673ed4..afed8a3 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_nameOf_FieldOption_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_nameOf_FieldOption_Test.java
@@ -23,14 +23,14 @@
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class Options2_nameOf_FieldOption_Test {
+public class Options_nameOf_FieldOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private Options2 options;
+ private Options options;
@Before public void setUp() {
- options = xtext.getInstanceOf(Options2.class);
+ options = xtext.getInstanceOf(Options.class);
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_rootSourceOf_FieldOption_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_rootSourceOf_FieldOption_Test.java
similarity index 89%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_rootSourceOf_FieldOption_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_rootSourceOf_FieldOption_Test.java
index 9c94f19..55630b2 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_rootSourceOf_FieldOption_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_rootSourceOf_FieldOption_Test.java
@@ -19,18 +19,18 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link Options2#rootSourceOf(FieldOption)}</code>.
+ * Tests for <code>{@link Options#rootSourceOf(FieldOption)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class Options2_rootSourceOf_FieldOption_Test {
+public class Options_rootSourceOf_FieldOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private Options2 options;
+ private Options options;
@Before public void setUp() {
- options = xtext.getInstanceOf(Options2.class);
+ options = xtext.getInstanceOf(Options.class);
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_rootSourceOf_Option_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_rootSourceOf_Option_Test.java
similarity index 89%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_rootSourceOf_Option_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_rootSourceOf_Option_Test.java
index ddfe033..5511cda 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_rootSourceOf_Option_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_rootSourceOf_Option_Test.java
@@ -19,18 +19,18 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link Options2#rootSourceOf(Option)}</code>.
+ * Tests for <code>{@link Options#rootSourceOf(Option)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class Options2_rootSourceOf_Option_Test {
+public class Options_rootSourceOf_Option_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private Options2 options;
+ private Options options;
@Before public void setUp() {
- options = xtext.getInstanceOf(Options2.class);
+ options = xtext.getInstanceOf(Options.class);
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOfLastFieldIn_CustomFieldOption_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOfLastFieldIn_CustomFieldOption_Test.java
similarity index 86%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOfLastFieldIn_CustomFieldOption_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOfLastFieldIn_CustomFieldOption_Test.java
index 73bbaa8..3f5734c 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOfLastFieldIn_CustomFieldOption_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOfLastFieldIn_CustomFieldOption_Test.java
@@ -19,18 +19,18 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link Options2#sourceOfLastFieldIn(CustomFieldOption)}</code>.
+ * Tests for <code>{@link Options#sourceOfLastFieldIn(CustomFieldOption)}</code>.
*
* alruiz@google.com (Alex Ruiz)
*/
-public class Options2_sourceOfLastFieldIn_CustomFieldOption_Test {
+public class Options_sourceOfLastFieldIn_CustomFieldOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private Options2 fieldOptions;
+ private Options fieldOptions;
@Before public void setUp() {
- fieldOptions = xtext.getInstanceOf(Options2.class);
+ fieldOptions = xtext.getInstanceOf(Options.class);
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOfLastFieldIn_CustomOption_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOfLastFieldIn_CustomOption_Test.java
similarity index 86%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOfLastFieldIn_CustomOption_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOfLastFieldIn_CustomOption_Test.java
index 79afea9..6f59648 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOfLastFieldIn_CustomOption_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOfLastFieldIn_CustomOption_Test.java
@@ -19,18 +19,18 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link Options2#sourceOfLastFieldIn(CustomOption)}</code>.
+ * Tests for <code>{@link Options#sourceOfLastFieldIn(CustomOption)}</code>.
*
* alruiz@google.com (Alex Ruiz)
*/
-public class Options2_sourceOfLastFieldIn_CustomOption_Test {
+public class Options_sourceOfLastFieldIn_CustomOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private Options2 options;
+ private Options options;
@Before public void setUp() {
- options = xtext.getInstanceOf(Options2.class);
+ options = xtext.getInstanceOf(Options.class);
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOf_CustomFieldOption_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_CustomFieldOption_Test.java
similarity index 90%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOf_CustomFieldOption_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_CustomFieldOption_Test.java
index d9bf061..e7e98db 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOf_CustomFieldOption_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_CustomFieldOption_Test.java
@@ -19,18 +19,18 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link Options2#sourceOf(CustomFieldOption)}</code>.
+ * Tests for <code>{@link Options#sourceOf(CustomFieldOption)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class Options2_sourceOf_CustomFieldOption_Test {
+public class Options_sourceOf_CustomFieldOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private Options2 options;
+ private Options options;
@Before public void setUp() {
- options = xtext.getInstanceOf(Options2.class);
+ options = xtext.getInstanceOf(Options.class);
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOf_CustomOption_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_CustomOption_Test.java
similarity index 90%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOf_CustomOption_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_CustomOption_Test.java
index 0185441..d6c9ba2 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOf_CustomOption_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_CustomOption_Test.java
@@ -19,18 +19,18 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link Options2#sourceOf(CustomOption)}</code>
+ * Tests for <code>{@link Options#sourceOf(CustomOption)}</code>
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class Options2_sourceOf_CustomOption_Test {
+public class Options_sourceOf_CustomOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private Options2 options;
+ private Options options;
@Before public void setUp() {
- options = xtext.getInstanceOf(Options2.class);
+ options = xtext.getInstanceOf(Options.class);
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_fieldOptionsOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_fieldOptionsOf_Test.java
index 7be4bc9..d1b49c1 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_fieldOptionsOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_fieldOptionsOf_Test.java
@@ -32,7 +32,7 @@
private IndexedElements indexedElements;
@Before public void setUp() {
- indexedElements = new IndexedElements();
+ indexedElements = xtext.getInstanceOf(IndexedElements.class);
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_indexFeatureOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_indexFeatureOf_Test.java
index 66ff31f..6a5ece0 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_indexFeatureOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_indexFeatureOf_Test.java
@@ -8,14 +8,16 @@
*/
package com.google.eclipse.protobuf.model.util;
+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.protobuf.ProtobufPackage.Literals.*;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.*;
-import static org.mockito.Mockito.mock;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.junit.*;
+import com.google.eclipse.protobuf.junit.core.XtextRule;
import com.google.eclipse.protobuf.protobuf.*;
/**
@@ -25,20 +27,32 @@
*/
public class IndexedElements_indexFeatureOf_Test {
+ @Rule public XtextRule xtext = createWith(unitTestSetup());
+
private static IndexedElements indexedElements;
@BeforeClass public static void setUpOnce() {
indexedElements = new IndexedElements();
}
- @Test public void should_return_name_of_Property() {
- MessageField field = mock(MessageField.class);
+ // syntax = "proto2";
+ //
+ // message Person {
+ // optional String firstName = 6;
+ // }
+ @Test public void should_return_index_feature_of_MessageField() {
+ MessageField field = xtext.find("firstName", MessageField.class);
EStructuralFeature expected = MESSAGE_FIELD__INDEX;
assertThat(indexedElements.indexFeatureOf(field), equalTo(expected));
}
+ // syntax = "proto2";
+ //
+ // message Person {
+ // optional group Names = 8 {}
+ // }
@Test public void should_return_name_of_Group() {
- Group group = mock(Group.class);
+ Group group = xtext.find("Names", Group.class);
EStructuralFeature expected = GROUP__INDEX;
assertThat(indexedElements.indexFeatureOf(group), equalTo(expected));
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_indexOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_indexOf_Test.java
index 2973823..d15201d 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_indexOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_indexOf_Test.java
@@ -30,7 +30,7 @@
private IndexedElements indexedElements;
@Before public void setUp() {
- indexedElements = new IndexedElements();
+ indexedElements = xtext.getInstanceOf(IndexedElements.class);
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Options_nameForOption_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Options_nameForOption_Test.java
index 81b052a..3304ac8 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Options_nameForOption_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/Options_nameForOption_Test.java
@@ -12,7 +12,6 @@
import static com.google.eclipse.protobuf.junit.core.XtextRule.createWith;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
import org.junit.*;
@@ -20,31 +19,37 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link Options2#nameForOption(IndexedElement)}</code>
+ * Tests for <code>{@link Options#nameForOption(IndexedElement)}</code>
* @author alruiz@google.com (Alex Ruiz)
*/
public class Options_nameForOption_Test {
@Rule public XtextRule xtext = createWith(unitTestSetup());
- private Options2 options;
+ private Options options;
@Before public void setUp() {
- options = xtext.getInstanceOf(Options2.class);
+ options = xtext.getInstanceOf(Options.class);
}
+ // syntax = "proto2";
+ //
+ // message Person {
+ // optional String firstName = 6;
+ // }
@Test public void should_return_unchanged_name_if_element_is_Field() {
- MessageField field = mock(MessageField.class);
- when(field.getName()).thenReturn("active");
- assertThat(options.nameForOption(field), equalTo("active"));
- verify(field).getName();
+ MessageField field = xtext.find("firstName", MessageField.class);
+ assertThat(options.nameForOption(field), equalTo("firstName"));
}
+ // syntax = "proto2";
+ //
+ // message Person {
+ // optional group Names = 8 {}
+ // }
@Test public void should_return_name_in_lower_case_if_element_is_Group() {
- Group group = mock(Group.class);
- when(group.getName()).thenReturn("Person");
- assertThat(options.nameForOption(group), equalTo("person"));
- verify(group).getName();
+ Group group = xtext.find("Names", Group.class);
+ assertThat(options.nameForOption(group), equalTo("names"));
}
@Test public void should_return_null_if_element_is_null() {
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 57866d7..f840954 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
@@ -55,7 +55,7 @@
@Inject private PluginImageHelper imageHelper;
@Inject private Literals literals;
@Inject private MessageFields messageFields;
- @Inject private Options2 options;
+ @Inject private Options options;
@Override public void completeProtobuf_Syntax(EObject model, Assignment assignment, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/documentation/SLCommentDocumentationProvider.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/documentation/SLCommentDocumentationProvider.java
index c090a8f..c77083b 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/documentation/SLCommentDocumentationProvider.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/documentation/SLCommentDocumentationProvider.java
@@ -35,7 +35,7 @@
private static final Patterns NEW_LINE = compileAll("\\r\\n", "\\n");
@Inject private INodes nodes;
- @Inject private Options2 options;
+ @Inject private Options options;
@Override public String getDocumentation(EObject o) {
String comment = findComment(o);
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/syntaxcoloring/ProtobufSemanticHighlightingCalculator.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/syntaxcoloring/ProtobufSemanticHighlightingCalculator.java
index 38a5aeb..329a76b 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/syntaxcoloring/ProtobufSemanticHighlightingCalculator.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/editor/syntaxcoloring/ProtobufSemanticHighlightingCalculator.java
@@ -31,7 +31,7 @@
@Inject private IndexedElements indexedElements;
@Inject private INodes nodes;
- @Inject private Options2 options;
+ @Inject private Options options;
@Override public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor) {
if (resource == null) {
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Labels.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Labels.java
index 6f2c67b..1fb28a4 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Labels.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/labeling/Labels.java
@@ -34,7 +34,7 @@
@Inject private NameResolver nameResolver;
@Inject private MessageFields messageFields;
@Inject private INodes nodes;
- @Inject private Options2 options;
+ @Inject private Options options;
public Object labelFor(Object o) {
if (o instanceof Extensions) {
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options2.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options.java
similarity index 99%
rename from com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options2.java
rename to com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options.java
index ae23826..407970c 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options2.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options.java
@@ -22,7 +22,7 @@
* @author alruiz@google.com (Alex Ruiz)
*
*/
-@Singleton public class Options2 {
+@Singleton public class Options {
@Inject private ModelObjects modelObjects;
@Inject private NameResolver nameResolver;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/NameResolver.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/NameResolver.java
index 4d9f97d..0e7840e 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/NameResolver.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/NameResolver.java
@@ -29,14 +29,14 @@
* @return the name of the given element, or {@code null} if the given element does not have support for naming.
*/
public String nameOf(EObject o) {
+ if (o == null) {
+ return null;
+ }
if (o instanceof DefaultValueFieldOption) {
return DEFAULT.toString();
}
Object value = nameFeatureOf(o);
- if (value instanceof String) {
- return (String) value;
- }
- return null;
+ return (String) value;
}
private Object nameFeatureOf(EObject e) {
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 02c5974..69e7771 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
@@ -10,7 +10,7 @@
import org.eclipse.emf.ecore.EObject;
-import com.google.eclipse.protobuf.model.util.Options2;
+import com.google.eclipse.protobuf.model.util.Options;
import com.google.eclipse.protobuf.protobuf.*;
import com.google.inject.*;
@@ -22,7 +22,7 @@
@Singleton public class Naming {
@Inject private NameResolver nameResolver;
- @Inject private Options2 options;
+ @Inject private Options options;
/**
* Returns the name of the given object. If the name will be used for an option and if the given object is a
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 1cb7576..5f95dfc 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
@@ -27,7 +27,7 @@
@Inject private ModelFinder modelFinder;
@Inject private OptionFields optionFields;
- @Inject private Options2 options;
+ @Inject private Options options;
@Inject private QualifiedNameDescriptions qualifiedNameDescriptions;
Collection<IEObjectDescription> findScope(CustomOption option, MessageOptionField field) {
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/FieldNotationScopeFinder.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/FieldNotationScopeFinder.java
index d9742cd..329ebce 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/FieldNotationScopeFinder.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/FieldNotationScopeFinder.java
@@ -25,7 +25,7 @@
*/
class FieldNotationScopeFinder {
- @Inject private Options2 options;
+ @Inject private Options options;
@Inject private ModelFinder modelFinder;
@Inject private QualifiedNameDescriptions qualifiedNameDescriptions;
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 668900c..a49d287 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
@@ -42,7 +42,7 @@
@Inject private ModelFinder modelFinder;
@Inject private LiteralDescriptions literalDescriptions;
@Inject private NativeOptionDescriptions nativeOptionDescriptions;
- @Inject private Options2 options;
+ @Inject private Options options;
@Inject private TypeScopeFinder typeScopeFinder;
@SuppressWarnings("unused") public IScope scope_ComplexTypeLink_target(ComplexTypeLink link, EReference r) {
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/DataTypeValidator.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/DataTypeValidator.java
index 45645d4..f6eab43 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/DataTypeValidator.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/DataTypeValidator.java
@@ -34,7 +34,7 @@
@Inject private MessageFields messageFields;
@Inject private ModelFinder modelFinder;
@Inject private INodes nodes;
- @Inject private Options2 options;
+ @Inject private Options options;
@Check public void checkValueOfDefaultTypeMatchesFieldType(FieldOption option) {
if (options.isDefaultValueOption(option)) {