Names are now strings again, to enable rename refactoring.
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/junit/matchers/ContainAllFields.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/junit/matchers/ContainAllFields.java
index 8a5214a..b586d29 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/junit/matchers/ContainAllFields.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/junit/matchers/ContainAllFields.java
@@ -36,8 +36,8 @@
IEObjectDescriptions descriptions = (IEObjectDescriptions) arg;
if (descriptions.size() != fields.size()) return false;
for (MessageField field : fields) {
- Name name = field.getName();
- EObject described = descriptions.objectDescribedAs(name.getValue());
+ String name = field.getName();
+ EObject described = descriptions.objectDescribedAs(name);
if (described != field) return false;
}
return true;
@@ -46,7 +46,7 @@
@Override public void describeTo(Description description) {
List<String> names = new ArrayList<String>();
for (MessageField field : fields) {
- names.add(field.getName().getValue());
+ names.add(field.getName());
}
description.appendValue(names);
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/junit/matchers/ContainAllFieldsInMessage.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/junit/matchers/ContainAllFieldsInMessage.java
index f14949e..a4b2d55 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/junit/matchers/ContainAllFieldsInMessage.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/junit/matchers/ContainAllFieldsInMessage.java
@@ -64,7 +64,6 @@
private String nameOf(IndexedElement e) {
if (e == null) return null;
- Name name = (e instanceof Group) ? ((Group) e).getName() : ((MessageField) e).getName();
- return name.getValue();
+ return (e instanceof Group) ? ((Group) e).getName() : ((MessageField) e).getName();
}
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/junit/matchers/ContainAllLiteralsInEnum.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/junit/matchers/ContainAllLiteralsInEnum.java
index cf03f7c..f0ba0a2 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/junit/matchers/ContainAllLiteralsInEnum.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/junit/matchers/ContainAllLiteralsInEnum.java
@@ -40,8 +40,8 @@
List<Literal> literals = allLiterals();
if (descriptions.size() != literals.size()) return false;
for (Literal literal : literals) {
- Name name = literal.getName();
- EObject described = descriptions.objectDescribedAs(name.getValue());
+ String name = literal.getName();
+ EObject described = descriptions.objectDescribedAs(name);
if (described != literal) return false;
}
return true;
@@ -50,8 +50,8 @@
@Override public void describeTo(Description description) {
List<String> names = new ArrayList<String>();
for (Literal literal : allLiterals()) {
- Name name = literal.getName();
- names.add(name.getValue());
+ String name = literal.getName();
+ names.add(name);
}
description.appendValue(names);
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_rootSourceOf_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_rootSourceOf_Test.java
index 3f852dd..b6ec71f 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_rootSourceOf_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_rootSourceOf_Test.java
@@ -41,7 +41,7 @@
@Test public void should_return_field_of_native_field_option() {
FieldOption option = xtext.find("deprecated", FieldOption.class);
MessageField field = (MessageField) fieldOptions.rootSourceOf(option);
- assertThat(field.getName().getValue(), equalTo("deprecated"));
+ assertThat(field.getName(), equalTo("deprecated"));
}
// syntax = "proto2";
@@ -58,6 +58,6 @@
@Test public void should_return_field_of_custom_field_option() {
FieldOption option = xtext.find("encoding", ")", FieldOption.class);
MessageField field = (MessageField) fieldOptions.rootSourceOf(option);
- assertThat(field.getName().getValue(), equalTo("encoding"));
+ assertThat(field.getName(), equalTo("encoding"));
}
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOfLastFieldIn_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOfLastFieldIn_Test.java
index 1008b54..755de75 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOfLastFieldIn_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOfLastFieldIn_Test.java
@@ -51,6 +51,6 @@
@Test public void should_return_option_field() {
CustomFieldOption option = xtext.find("custom", ").", CustomFieldOption.class);
MessageField field = (MessageField) fieldOptions.sourceOfLastFieldIn(option);
- assertThat(field.getName().getValue(), equalTo("count"));
+ assertThat(field.getName(), equalTo("count"));
}
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOf_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOf_Test.java
index 3b01f5b..d97ea3a 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOf_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOf_Test.java
@@ -47,7 +47,7 @@
@Test public void should_return_source_of_field_option() {
CustomFieldOption option = xtext.find("encoding", ")", CustomFieldOption.class);
MessageField field = (MessageField) fieldOptions.sourceOf(option);
- assertThat(field.getName().getValue(), equalTo("encoding"));
+ assertThat(field.getName(), equalTo("encoding"));
}
// syntax = "proto2";
@@ -68,6 +68,6 @@
@Test public void should_return_source_of_field_in_field_option() {
CustomFieldOption option = xtext.find("custom", ").", CustomFieldOption.class);
MessageField field = (MessageField) fieldOptions.sourceOf(option);
- assertThat(field.getName().getValue(), equalTo("count"));
+ assertThat(field.getName(), equalTo("count"));
}
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_lastFieldSourceFrom_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_lastFieldSourceFrom_Test.java
index 2c9b754..f035ebb 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_lastFieldSourceFrom_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_lastFieldSourceFrom_Test.java
@@ -49,6 +49,6 @@
@Test public void should_return_option_field() {
CustomOption option = xtext.find("custom", ")", CustomOption.class);
MessageField field = (MessageField) options.lastFieldSourceFrom(option);
- assertThat(field.getName().getValue(), equalTo("count"));
+ assertThat(field.getName(), equalTo("count"));
}
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_rootSourceOf_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_rootSourceOf_Test.java
index 7901f00..f582b9b 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_rootSourceOf_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_rootSourceOf_Test.java
@@ -39,7 +39,7 @@
@Test public void should_return_source_of_native_option() {
Option option = xtext.find("java_package", Option.class);
MessageField field = (MessageField) options.rootSourceOf(option);
- assertThat(field.getName().getValue(), equalTo("java_package"));
+ assertThat(field.getName(), equalTo("java_package"));
}
// syntax = "proto2";
@@ -54,6 +54,6 @@
@Test public void should_return_source_of_custom_option() {
Option option = xtext.find("encoding", ")", Option.class);
MessageField field = (MessageField) options.rootSourceOf(option);
- assertThat(field.getName().getValue(), equalTo("encoding"));
+ assertThat(field.getName(), equalTo("encoding"));
}
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_Test.java
index 9412acd..bb6e9c0 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_Test.java
@@ -45,7 +45,7 @@
@Test public void should_return_source_of_custom_option() {
CustomOption option = xtext.find("encoding", ")", CustomOption.class);
MessageField p = (MessageField) options.sourceOf(option);
- assertThat(p.getName().getValue(), equalTo("encoding"));
+ assertThat(p.getName(), equalTo("encoding"));
}
// syntax = "proto2";
@@ -64,6 +64,6 @@
@Test public void should_return_source_of_field_in_option() {
CustomOption option = xtext.find("custom", ")", CustomOption.class);
MessageField p = (MessageField) options.sourceOf(option);
- assertThat(p.getName().getValue(), equalTo("count"));
+ assertThat(p.getName(), equalTo("count"));
}
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_availableOptionsFor_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_availableOptionsFor_Test.java
index a51a6f8..e2df747 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_availableOptionsFor_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_availableOptionsFor_Test.java
@@ -82,8 +82,8 @@
void mapByName(Collection<MessageField> options) {
optionsByName.clear();
for (MessageField option : options) {
- Name name = option.getName();
- optionsByName.put(name.getValue(), option);
+ String name = option.getName();
+ optionsByName.put(name, option);
}
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_enumTypeOf_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_enumTypeOf_Test.java
index 6ad2aec..e59b78a 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_enumTypeOf_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor_enumTypeOf_Test.java
@@ -39,7 +39,7 @@
@Test public void should_return_Enum_if_field_type_is_enum() {
MessageField option = descriptor.option("optimize_for", FILE);
Enum anEnum = descriptor.enumTypeOf(option);
- assertThat(anEnum.getName().getValue(), equalTo("OptimizeMode"));
+ assertThat(anEnum.getName(), equalTo("OptimizeMode"));
}
@Test public void should_return_null_if_field_is_null() {
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/NameValueConverter_toValue_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/NameValueConverter_toValue_Test.java
deleted file mode 100644
index 755fb40..0000000
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/NameValueConverter_toValue_Test.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.conversion;
-
-import static com.google.eclipse.protobuf.junit.core.Setups.unitTestSetup;
-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 com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.Name;
-
-import org.eclipse.xtext.nodemodel.INode;
-import org.junit.*;
-
-/**
- * Tests for <code>{@link NameValueConverter#toValue(String, INode)}</code>
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-public class NameValueConverter_toValue_Test {
-
- @Rule public XtextRule xtext = createWith(unitTestSetup());
-
- private INode node;
- private NameValueConverter converter;
-
- @Before public void setUp() {
- node = mock(INode.class);
- converter = xtext.getInstanceOf(NameValueConverter.class);
- }
-
- @Test public void should_return_name_using_given_value_if_given_value_is_not_null() {
- Name name = converter.toValue("hello", node);
- assertThat(name.getValue(), equalTo("hello"));
- }
-
- @Test public void should_return_name_using_text_from_node_if_value_is_null_and_text_in_node_is_keyword() {
- when(node.getText()).thenReturn("message");
- Name name = converter.toValue(null, node);
- assertThat(name.getValue(), equalTo("message"));
- }
-
- @Test public void should_return_null_if_given_value_is_null_and_text_in_node_is_not_keyword() {
- when(node.getText()).thenReturn("hello");
- assertNull(converter.toValue(null, node));
- }
-}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/matchers/EnumHasLiterals.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/matchers/EnumHasLiterals.java
index 847fb0d..65fd42c 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/matchers/EnumHasLiterals.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/matchers/EnumHasLiterals.java
@@ -44,7 +44,7 @@
private List<String> literalNames(Enum anEnum) {
List<String> names = new ArrayList<String>();
for (Literal literal : getAllContentsOfType(anEnum, Literal.class)) {
- names.add(literal.getName().getValue());
+ names.add(literal.getName());
}
return names;
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/matchers/FieldHasType.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/matchers/FieldHasType.java
index ca4cb3c..3b31b28 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/matchers/FieldHasType.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/matchers/FieldHasType.java
@@ -46,7 +46,7 @@
if (link instanceof ScalarTypeLink) return ((ScalarTypeLink) link).getTarget().getName();
if (link instanceof ComplexTypeLink) {
ComplexType type = ((ComplexTypeLink) link).getTarget();
- return type == null ? null : type.getName().getValue();
+ return type == null ? null : type.getName();
}
return link.toString();
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_nameOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_nameOf_Test.java
index c81ebbc..413c94e 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_nameOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/IndexedElements_nameOf_Test.java
@@ -28,26 +28,22 @@
@Rule public XtextRule xtext = createWith(unitTestSetup());
- private Name name;
private IndexedElements indexedElements;
@Before public void setUp() {
- name = mock(Name.class);
indexedElements = xtext.getInstanceOf(IndexedElements.class);
}
@Test public void should_return_name_of_Property() {
MessageField field = mock(MessageField.class);
- when(field.getName()).thenReturn(name);
- when(name.getValue()).thenReturn("foo");
+ when(field.getName()).thenReturn("foo");
assertThat(indexedElements.nameOf(field), equalTo("foo"));
verify(field).getName();
}
@Test public void should_return_name_of_Group() {
Group group = mock(Group.class);
- when(group.getName()).thenReturn(name);
- when(name.getValue()).thenReturn("foo");
+ when(group.getName()).thenReturn("foo");
assertThat(indexedElements.nameOf(group), equalTo("foo"));
verify(group).getName();
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_enumTypeOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_enumTypeOf_Test.java
index cf92013..132cdc0 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_enumTypeOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_enumTypeOf_Test.java
@@ -48,7 +48,7 @@
@Test public void should_return_enum_if_field_type_is_enum() {
MessageField field = xtext.find("type", MessageField.class);
Enum anEnum = finder.enumTypeOf(field);
- assertThat(anEnum.getName().getValue(), equalTo("PhoneType"));
+ assertThat(anEnum.getName(), equalTo("PhoneType"));
}
// syntax = "proto2";
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_messageFrom_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_messageFrom_Test.java
index d1d4bef..f51de92 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_messageFrom_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/model/util/ModelFinder_messageFrom_Test.java
@@ -44,7 +44,7 @@
@Test public void should_return_message_from_extension() {
MessageExtension extension = xtext.find("Person", " {}", MessageExtension.class);
Message message = finder.messageFrom(extension);
- assertThat(message.getName().getValue(), equalTo("Person"));
+ assertThat(message.getName(), equalTo("Person"));
}
@Test public void should_return_null_if_extension_is_not_referring_to_message() {
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 07fc757..093c4b6 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
@@ -27,26 +27,22 @@
@Rule public XtextRule xtext = createWith(unitTestSetup());
- private Name name;
private Options options;
@Before public void setUp() {
- name = mock(Name.class);
options = xtext.getInstanceOf(Options.class);
}
@Test public void should_return_unchanged_name_if_element_is_Field() {
MessageField field = mock(MessageField.class);
- when(field.getName()).thenReturn(name);
- when(name.getValue()).thenReturn("active");
+ when(field.getName()).thenReturn("active");
assertThat(options.nameForOption(field), equalTo("active"));
verify(field).getName();
}
@Test public void should_return_name_in_lower_case_if_element_is_Group() {
Group group = mock(Group.class);
- when(group.getName()).thenReturn(name);
- when(name.getValue()).thenReturn("Person");
+ when(group.getName()).thenReturn("Person");
assertThat(options.nameForOption(group), equalTo("person"));
verify(group).getName();
}
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 6894a39..36f8d22 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
@@ -56,7 +56,6 @@
@Inject private IndexedElements indexedElements;
@Inject private PluginImageHelper imageHelper;
@Inject private Literals literals;
- @Inject private Names names;
@Inject private Options options;
@Inject private Fields properties;
@@ -319,7 +318,7 @@
proposeDefaultKeyword(field, optionNames, context, acceptor);
ProtoDescriptor descriptor = descriptorProvider.primaryDescriptor();
for (MessageField optionSource : descriptor.availableOptionsFor(field)) {
- String optionName = names.valueOf(optionSource.getName());
+ String optionName = optionSource.getName();
if (optionNames.contains(optionName) || ("packed".equals(optionName) && !canBePacked(field))) continue;
proposeOption(optionSource, context, acceptor);
}
@@ -356,7 +355,7 @@
private void proposeOption(MessageField optionSource, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {
- String displayString = names.valueOf(optionSource.getName());
+ String displayString = optionSource.getName();
String proposalText = displayString + space() + EQUAL + space();
Object value = defaultValueOf(optionSource);
if (value != null) proposalText = proposalText + value;
@@ -574,7 +573,7 @@
private void proposeAndAccept(Enum enumType, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
Image image = imageHelper.getImage(images.imageFor(Literal.class));
for (Literal literal : getAllContentsOfType(enumType, Literal.class))
- proposeAndAccept(names.valueOf(literal.getName()), image, context, acceptor);
+ proposeAndAccept(literal.getName(), image, context, acceptor);
}
private void proposeAndAccept(String proposalText, Image image, ContentAssistContext context,
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlineTreeProvider.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlineTreeProvider.java
index 0f2aa81..87fc2ca 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlineTreeProvider.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/outline/ProtobufOutlineTreeProvider.java
@@ -32,7 +32,6 @@
IGNORED_ELEMENT_TYPES.add(BooleanLink.class);
IGNORED_ELEMENT_TYPES.add(FieldOption.class);
IGNORED_ELEMENT_TYPES.add(MessageLink.class);
- IGNORED_ELEMENT_TYPES.add(Name.class);
}
boolean _isLeaf(Extensions extensions) {
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext
index d1b1665..1299e78 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext
@@ -120,7 +120,7 @@
(('{' options+=Option* '}') (';')? | ';');
Name:
- value=IdOrReservedWord;
+ IdOrReservedWord;
IdOrReservedWord:
ID | ReservedWord;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/NameValueConverter.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/NameValueConverter.java
deleted file mode 100644
index 1e78eb9..0000000
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/NameValueConverter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.conversion;
-
-import com.google.eclipse.protobuf.protobuf.*;
-import com.google.inject.Inject;
-
-import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
-import org.eclipse.xtext.nodemodel.INode;
-
-/**
- * Converts names to <code>{@link Name}</code>s.
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-public class NameValueConverter extends AbstractLexerBasedConverter<Name> {
-
- private ProtobufFactory factory = ProtobufFactory.eINSTANCE;
- @Inject private Keywords keywords;
-
- @Override public Name toValue(String string, INode node) {
- String value = value(string, node);
- if (value == null) return null;
- Name name = factory.createName();
- name.setValue(value);
- return name;
- }
-
- private String value(String string, INode node) {
- if (string != null) return string;
- String text = node.getText();
- if (text == null) return text;
- text = text.trim();
- return keywords.isKeyword(text) ? text : null;
- }
-}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/ProtobufTerminalConverters.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/ProtobufTerminalConverters.java
index 50289cb..47f60ec 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/ProtobufTerminalConverters.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/ProtobufTerminalConverters.java
@@ -8,11 +8,10 @@
*/
package com.google.eclipse.protobuf.conversion;
+import com.google.inject.Inject;
+
import org.eclipse.xtext.common.services.DefaultTerminalConverters;
import org.eclipse.xtext.conversion.*;
-import com.google.eclipse.protobuf.protobuf.Name;
-
-import com.google.inject.Inject;
/**
* @author alruiz@google.com (Alex Ruiz)
@@ -22,7 +21,6 @@
@Inject private DOUBLEValueConverter doubleValueConverter;
@Inject private HEXValueConverter hexValueConverter;
@Inject private LONGValueConverter longValueConverter;
- @Inject private NameValueConverter nameValueConverter;
@Inject private STRINGValueConverter stringValueConverter;
@ValueConverter(rule = "DOUBLE")
@@ -44,9 +42,4 @@
@Override public IValueConverter<String> STRING() {
return stringValueConverter;
}
-
- @ValueConverter(rule = "Name")
- public IValueConverter<Name> Name() {
- return nameValueConverter;
- }
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/FieldOptions.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/FieldOptions.java
index 8bf9a34..59641d5 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/FieldOptions.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/FieldOptions.java
@@ -21,7 +21,6 @@
@Singleton
public class FieldOptions {
- private @Inject Names names;
private @Inject OptionFields optionFields;
/**
@@ -41,8 +40,7 @@
public String nameOf(FieldOption option) {
IndexedElement e = rootSourceOf(option);
if (e instanceof MessageField) {
- Name name = ((MessageField) e).getName();
- return names.valueOf(name);
+ return ((MessageField) e).getName();
}
return null;
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Fields.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Fields.java
index ba0159c..8d5875c 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Fields.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Fields.java
@@ -23,8 +23,6 @@
@Singleton
public class Fields {
- private @Inject Names names;
-
/**
* Indicates whether the modifier of the given field is <code>{@link Modifier#OPTIONAL}</code>.
* @param field the given field.
@@ -90,8 +88,7 @@
if (link instanceof ScalarTypeLink) return ((ScalarTypeLink) link).getTarget().getName();
if (link instanceof ComplexTypeLink) {
ComplexType type = ((ComplexTypeLink) link).getTarget();
- if (type == null) return null;
- return names.valueOf(type.getName());
+ return (type == null) ? null : type.getName();
}
return link.toString();
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/IndexedElements.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/IndexedElements.java
index 2af8c4f..a131513 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/IndexedElements.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/IndexedElements.java
@@ -27,8 +27,6 @@
@Singleton
public class IndexedElements {
- private @Inject Names names;
-
/**
* Returns the name of the given <code>{@link IndexedElement}</code>.
* @param e the given {@code IndexedElement}.
@@ -37,12 +35,12 @@
*/
public String nameOf(IndexedElement e) {
if (e instanceof MessageField) {
- Name name = ((MessageField) e).getName();
- return names.valueOf(name);
+ MessageField field = (MessageField) e;
+ return field.getName();
}
if (e instanceof Group) {
- Name name = ((Group) e).getName();
- return names.valueOf(name);
+ Group group = (Group) e;
+ return group.getName();
}
return null;
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Names.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Names.java
deleted file mode 100644
index 87c633b..0000000
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Names.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.model.util;
-
-import com.google.eclipse.protobuf.protobuf.Name;
-import com.google.inject.Singleton;
-
-/**
- * Utility methods related to <code>{@link Name}</code>s.
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-@Singleton
-public class Names {
-
- public String valueOf(Name name) {
- if (name == null) return null;
- return name.getValue();
- }
-
-}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options.java
index 17bfc21..f1b2c5f 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options.java
@@ -23,7 +23,6 @@
@Singleton
public class Options {
- private @Inject Names names;
private @Inject OptionFields optionFields;
/**
@@ -95,13 +94,13 @@
*/
public String nameForOption(IndexedElement e) {
if (e instanceof MessageField) {
- Name name = ((MessageField) e).getName();
- return names.valueOf(name);
+ MessageField field = (MessageField) e;
+ return field.getName();
}
if (e instanceof Group) {
- Name name = ((Group) e).getName();
- String value = names.valueOf(name);
- if (!isEmpty(value)) return value.toLowerCase();
+ String name = ((Group) e).getName();
+ // TODO check where toLowerCase is being used and remove duplication
+ return (isEmpty(name)) ? name : name.toLowerCase();
}
return null;
}
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 478cbd1..45258ed 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
@@ -8,11 +8,12 @@
*/
package com.google.eclipse.protobuf.naming;
-import org.eclipse.emf.ecore.*;
+import static org.eclipse.xtext.util.SimpleAttributeResolver.NAME_RESOLVER;
-import com.google.eclipse.protobuf.protobuf.Name;
import com.google.inject.Singleton;
+import org.eclipse.emf.ecore.*;
+
/**
* @author alruiz@google.com (Alex Ruiz)
*/
@@ -22,12 +23,11 @@
public String nameOf(EObject o) {
Object value = nameFeatureOf(o);
if (value instanceof String) return (String) value;
- if (value instanceof Name) return ((Name) value).getValue();
return null;
}
private Object nameFeatureOf(EObject e) {
- EStructuralFeature f = e.eClass().getEStructuralFeature("name");
+ EStructuralFeature f = NAME_RESOLVER.getAttribute(e);
return (f != null) ? e.eGet(f) : null;
}
}
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 171dff4..d3df720 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
@@ -73,11 +73,7 @@
if (!(o instanceof MessageExtension)) return false;
Message message = modelFinder.messageFrom((MessageExtension) o);
if (message == null) return false;
- Name name = message.getName();
- if (name != null) {
- String nameValue = name.getValue();
- return optionType.messageName().equals(nameValue);
- }
- return false;
+ String name = message.getName();
+ return optionType.messageName().equals(name);
}
}
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 dd22fc3..3e38f54 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
@@ -28,7 +28,6 @@
@Inject private FieldOptions fieldOptions;
@Inject private Options options;
@Inject private ModelFinder modelFinder;
- @Inject private Names names;
@Inject private QualifiedNameDescriptions qualifiedNameDescriptions;
Collection<IEObjectDescription> sourceOf(FieldName name) {
@@ -72,9 +71,8 @@
Message fieldType = modelFinder.messageTypeOf(field);
for (MessageElement element : fieldType.getElements()) {
if (element instanceof MessageField) {
- Name name = ((MessageField) element).getName();
- String nameValue = names.valueOf(name);
- descriptions.add(create(nameValue, element));
+ String name = ((MessageField) element).getName();
+ descriptions.add(create(name, element));
}
}
return descriptions;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/LiteralDescriptions.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/LiteralDescriptions.java
index 2cc54ae..b91dbe8 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/LiteralDescriptions.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/LiteralDescriptions.java
@@ -12,10 +12,8 @@
import static org.eclipse.xtext.EcoreUtil2.getAllContentsOfType;
import static org.eclipse.xtext.resource.EObjectDescription.create;
-import com.google.eclipse.protobuf.model.util.Names;
import com.google.eclipse.protobuf.protobuf.*;
import com.google.eclipse.protobuf.protobuf.Enum;
-import com.google.inject.Inject;
import org.eclipse.xtext.resource.IEObjectDescription;
@@ -26,14 +24,12 @@
*/
class LiteralDescriptions {
- @Inject private Names names;
-
Collection<IEObjectDescription> literalsOf(Enum anEnum) {
if (anEnum == null) return emptyList();
List<IEObjectDescription> descriptions = new ArrayList<IEObjectDescription>();
for (Literal literal : getAllContentsOfType(anEnum, Literal.class)) {
- String nameValue = names.valueOf(literal.getName());
- descriptions.add(create(nameValue, literal));
+ String name = literal.getName();
+ descriptions.add(create(name, literal));
}
return descriptions;
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/NativeOptionDescriptions.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/NativeOptionDescriptions.java
index 72b3079..4af132a 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/NativeOptionDescriptions.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/NativeOptionDescriptions.java
@@ -11,7 +11,6 @@
import static java.util.Collections.emptyList;
import static org.eclipse.xtext.resource.EObjectDescription.create;
-import com.google.eclipse.protobuf.model.util.Names;
import com.google.eclipse.protobuf.protobuf.*;
import com.google.inject.Inject;
@@ -26,7 +25,6 @@
class NativeOptionDescriptions {
@Inject private ProtoDescriptorProvider descriptorProvider;
- @Inject private Names names;
Collection <IEObjectDescription> sources(NativeOption option) {
return allSources(option);
@@ -46,8 +44,8 @@
private Collection<IEObjectDescription> describe(Collection<MessageField> fields) {
List<IEObjectDescription> descriptions = new ArrayList<IEObjectDescription>();
for (MessageField field : fields) {
- String nameValue = names.valueOf(field.getName());
- descriptions.add(create(nameValue, field));
+ String name = field.getName();
+ descriptions.add(create(name, field));
}
return descriptions;
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
index 1127262..0e59191 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptor.java
@@ -102,7 +102,7 @@
for (ComplexType t : allTypes) {
if (!(t instanceof Message)) continue;
Message m = (Message) t;
- OptionType type = OPTION_DEFINITION_BY_NAME.get(m.getName().getValue());
+ OptionType type = OPTION_DEFINITION_BY_NAME.get(m.getName());
if (type == null) continue;
initOptions(m, type);
}
@@ -116,16 +116,16 @@
}
if (e instanceof Enum) {
Enum anEnum = (Enum) e;
- Name name = anEnum.getName();
- enumsByName.put(name.getValue(), anEnum);
+ String name = anEnum.getName();
+ enumsByName.put(name, anEnum);
}
}
}
private void addOption(MessageField optionSource, OptionType type) {
if (shouldIgnore(optionSource)) return;
- Name name = optionSource.getName();
- optionsByType.get(type).put(name.getValue(), optionSource);
+ String name = optionSource.getName();
+ optionsByType.get(type).put(name, optionSource);
}
private boolean shouldIgnore(MessageField field) {