Code cleanup.
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_isDefaultValueOption_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_isDefaultValueOption_Test.java
similarity index 79%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_isDefaultValueOption_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_isDefaultValueOption_Test.java
index 71aa9c5..54b8ce6 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_isDefaultValueOption_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_isDefaultValueOption_Test.java
@@ -18,18 +18,18 @@
import com.google.eclipse.protobuf.protobuf.FieldOption;
/**
- * Tests for <code>{@link FieldOptions#isDefaultValueOption(FieldOption)}</code>.
+ * Tests for <code>{@link Options2#isDefaultValueOption(FieldOption)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class FieldOptions_isDefaultValueOption_Test {
+public class Options2_isDefaultValueOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private FieldOptions fieldOptions;
+ private Options2 options;
@Before public void setUp() {
- fieldOptions = xtext.getInstanceOf(FieldOptions.class);
+ options = xtext.getInstanceOf(Options2.class);
}
// syntax = "proto2";
@@ -39,7 +39,7 @@
// }
@Test public void should_return_true_if_FieldOption_is_default_value_one() {
FieldOption option = xtext.find("default", FieldOption.class);
- assertTrue(fieldOptions.isDefaultValueOption(option));
+ assertTrue(options.isDefaultValueOption(option));
}
// syntax = "proto2";
@@ -49,6 +49,6 @@
// }
@Test public void should_return_false_if_FieldOption_is_not_default_value_one() {
FieldOption option = xtext.find("deprecated", FieldOption.class);
- assertFalse(fieldOptions.isDefaultValueOption(option));
+ assertFalse(options.isDefaultValueOption(option));
}
}
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_nameOf_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_nameOf_FieldOption_Test.java
similarity index 87%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_nameOf_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_nameOf_FieldOption_Test.java
index de42f49..c673ed4 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_nameOf_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_nameOf_FieldOption_Test.java
@@ -23,14 +23,14 @@
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class FieldOptions_nameOf_Test {
+public class Options2_nameOf_FieldOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private FieldOptions fieldOptions;
+ private Options2 options;
@Before public void setUp() {
- fieldOptions = xtext.getInstanceOf(FieldOptions.class);
+ options = xtext.getInstanceOf(Options2.class);
}
// syntax = "proto2";
@@ -40,7 +40,7 @@
// }
@Test public void should_return_name_of_native_field_option() {
FieldOption option = xtext.find("deprecated", FieldOption.class);
- String name = fieldOptions.nameOf(option);
+ String name = options.nameOf(option);
assertThat(name, equalTo("deprecated"));
}
@@ -57,7 +57,7 @@
// }
@Test public void should_return_name_of_custom_field_option() {
FieldOption option = xtext.find("encoding", ")", FieldOption.class);
- String name = fieldOptions.nameOf(option);
+ String name = options.nameOf(option);
assertThat(name, equalTo("encoding"));
}
}
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/Options2_rootSourceOf_FieldOption_Test.java
similarity index 81%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_rootSourceOf_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_rootSourceOf_FieldOption_Test.java
index b6ec71f..9c94f19 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/Options2_rootSourceOf_FieldOption_Test.java
@@ -19,18 +19,18 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link FieldOptions#rootSourceOf(FieldOption)}</code>.
+ * Tests for <code>{@link Options2#rootSourceOf(FieldOption)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class FieldOptions_rootSourceOf_Test {
+public class Options2_rootSourceOf_FieldOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private FieldOptions fieldOptions;
+ private Options2 options;
@Before public void setUp() {
- fieldOptions = xtext.getInstanceOf(FieldOptions.class);
+ options = xtext.getInstanceOf(Options2.class);
}
// syntax = "proto2";
@@ -40,7 +40,7 @@
// }
@Test public void should_return_field_of_native_field_option() {
FieldOption option = xtext.find("deprecated", FieldOption.class);
- MessageField field = (MessageField) fieldOptions.rootSourceOf(option);
+ MessageField field = (MessageField) options.rootSourceOf(option);
assertThat(field.getName(), equalTo("deprecated"));
}
@@ -57,7 +57,7 @@
// }
@Test public void should_return_field_of_custom_field_option() {
FieldOption option = xtext.find("encoding", ")", FieldOption.class);
- MessageField field = (MessageField) fieldOptions.rootSourceOf(option);
+ MessageField field = (MessageField) options.rootSourceOf(option);
assertThat(field.getName(), equalTo("encoding"));
}
}
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/Options2_rootSourceOf_Option_Test.java
similarity index 89%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_rootSourceOf_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_rootSourceOf_Option_Test.java
index f582b9b..ddfe033 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/Options2_rootSourceOf_Option_Test.java
@@ -19,18 +19,18 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link Options#rootSourceOf(Option)}</code>.
+ * Tests for <code>{@link Options2#rootSourceOf(Option)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class Options_rootSourceOf_Test {
+public class Options2_rootSourceOf_Option_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private Options options;
+ private Options2 options;
@Before public void setUp() {
- options = xtext.getInstanceOf(Options.class);
+ options = xtext.getInstanceOf(Options2.class);
}
// syntax = "proto2";
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/Options2_sourceOfLastFieldIn_CustomFieldOption_Test.java
similarity index 85%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOfLastFieldIn_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOfLastFieldIn_CustomFieldOption_Test.java
index 755de75..73bbaa8 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/Options2_sourceOfLastFieldIn_CustomFieldOption_Test.java
@@ -19,18 +19,18 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link FieldOptions#sourceOfLastFieldIn(CustomFieldOption)}</code>.
+ * Tests for <code>{@link Options2#sourceOfLastFieldIn(CustomFieldOption)}</code>.
*
* alruiz@google.com (Alex Ruiz)
*/
-public class FieldOptions_sourceOfLastFieldIn_Test {
+public class Options2_sourceOfLastFieldIn_CustomFieldOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private FieldOptions fieldOptions;
+ private Options2 fieldOptions;
@Before public void setUp() {
- fieldOptions = xtext.getInstanceOf(FieldOptions.class);
+ fieldOptions = xtext.getInstanceOf(Options2.class);
}
// syntax = "proto2";
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/Options2_sourceOfLastFieldIn_CustomOption_Test.java
similarity index 81%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_lastFieldSourceFrom_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOfLastFieldIn_CustomOption_Test.java
index f035ebb..79afea9 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/Options2_sourceOfLastFieldIn_CustomOption_Test.java
@@ -19,18 +19,18 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link Options#lastFieldSourceFrom(CustomOption)}</code>.
+ * Tests for <code>{@link Options2#sourceOfLastFieldIn(CustomOption)}</code>.
*
* alruiz@google.com (Alex Ruiz)
*/
-public class Options_lastFieldSourceFrom_Test {
+public class Options2_sourceOfLastFieldIn_CustomOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private Options options;
+ private Options2 options;
@Before public void setUp() {
- options = xtext.getInstanceOf(Options.class);
+ options = xtext.getInstanceOf(Options2.class);
}
// syntax = "proto2";
@@ -48,7 +48,7 @@
// option (custom).count = 6;
@Test public void should_return_option_field() {
CustomOption option = xtext.find("custom", ")", CustomOption.class);
- MessageField field = (MessageField) options.lastFieldSourceFrom(option);
+ MessageField field = (MessageField) options.sourceOfLastFieldIn(option);
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/Options2_sourceOf_CustomFieldOption_Test.java
similarity index 83%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/FieldOptions_sourceOf_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOf_CustomFieldOption_Test.java
index d97ea3a..d9bf061 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/Options2_sourceOf_CustomFieldOption_Test.java
@@ -19,18 +19,18 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link FieldOptions#sourceOf(CustomFieldOption)}</code>.
+ * Tests for <code>{@link Options2#sourceOf(CustomFieldOption)}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class FieldOptions_sourceOf_Test {
+public class Options2_sourceOf_CustomFieldOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private FieldOptions fieldOptions;
+ private Options2 options;
@Before public void setUp() {
- fieldOptions = xtext.getInstanceOf(FieldOptions.class);
+ options = xtext.getInstanceOf(Options2.class);
}
// syntax = "proto2";
@@ -46,7 +46,7 @@
// }
@Test public void should_return_source_of_field_option() {
CustomFieldOption option = xtext.find("encoding", ")", CustomFieldOption.class);
- MessageField field = (MessageField) fieldOptions.sourceOf(option);
+ MessageField field = (MessageField) options.sourceOf(option);
assertThat(field.getName(), equalTo("encoding"));
}
@@ -67,7 +67,7 @@
// }
@Test public void should_return_source_of_field_in_field_option() {
CustomFieldOption option = xtext.find("custom", ").", CustomFieldOption.class);
- MessageField field = (MessageField) fieldOptions.sourceOf(option);
+ MessageField field = (MessageField) options.sourceOf(option);
assertThat(field.getName(), equalTo("count"));
}
}
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/Options2_sourceOf_CustomOption_Test.java
similarity index 90%
rename from com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options_sourceOf_Test.java
rename to com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/model/util/Options2_sourceOf_CustomOption_Test.java
index 84a5083..0185441 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/Options2_sourceOf_CustomOption_Test.java
@@ -19,18 +19,18 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link Options#sourceOf(CustomOption)}</code>
+ * Tests for <code>{@link Options2#sourceOf(CustomOption)}</code>
*
* @author alruiz@google.com (Alex Ruiz)
*/
-public class Options_sourceOf_Test {
+public class Options2_sourceOf_CustomOption_Test {
@Rule public XtextRule xtext = createWith(integrationTestSetup());
- private Options options;
+ private Options2 options;
@Before public void setUp() {
- options = xtext.getInstanceOf(Options.class);
+ options = xtext.getInstanceOf(Options2.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 7a99481..81b052a 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
@@ -20,17 +20,17 @@
import com.google.eclipse.protobuf.protobuf.*;
/**
- * Tests for <code>{@link Options#nameForOption(IndexedElement)}</code>
+ * Tests for <code>{@link Options2#nameForOption(IndexedElement)}</code>
* @author alruiz@google.com (Alex Ruiz)
*/
public class Options_nameForOption_Test {
@Rule public XtextRule xtext = createWith(unitTestSetup());
- private Options options;
+ private Options2 options;
@Before public void setUp() {
- options = xtext.getInstanceOf(Options.class);
+ options = xtext.getInstanceOf(Options2.class);
}
@Test public void should_return_unchanged_name_if_element_is_Field() {
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 99e9b0d..57866d7 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
@@ -49,14 +49,13 @@
@Inject private IEObjectDescriptionChooser descriptionChooser;
@Inject private ProtoDescriptorProvider descriptorProvider;
- @Inject private FieldOptions fieldOptions;
@Inject private ModelFinder finder;
@Inject private Images images;
@Inject private IndexedElements indexedElements;
@Inject private PluginImageHelper imageHelper;
@Inject private Literals literals;
@Inject private MessageFields messageFields;
- @Inject private Options options;
+ @Inject private Options2 options;
@Override public void completeProtobuf_Syntax(EObject model, Assignment assignment, ContentAssistContext context,
ICompletionProposalAcceptor acceptor) {}
@@ -243,7 +242,7 @@
}
if (model instanceof FieldOption) {
FieldOption option = (FieldOption) model;
- IndexedElement source = fieldOptions.rootSourceOf(option);
+ IndexedElement source = options.rootSourceOf(option);
if (source instanceof MessageField) {
return (MessageField) source;
}
@@ -383,7 +382,7 @@
}
List<String> optionNames = new ArrayList<String>();
for (FieldOption option : allFieldOptions) {
- optionNames.add(fieldOptions.nameOf(option));
+ optionNames.add(options.nameOf(option));
}
return optionNames;
}
@@ -466,7 +465,7 @@
}
NativeFieldOption option = (NativeFieldOption) model;
ProtoDescriptor descriptor = descriptorProvider.primaryDescriptor();
- MessageField field = (MessageField) fieldOptions.rootSourceOf(option);
+ MessageField field = (MessageField) options.rootSourceOf(option);
Enum enumType = descriptor.enumTypeOf(field);
if (enumType != null) {
proposeAndAccept(enumType, context, acceptor);
@@ -605,7 +604,7 @@
return;
}
CustomOption option = (CustomOption) model;
- IndexedElement e = options.lastFieldSourceFrom(option);
+ IndexedElement e = options.sourceOfLastFieldIn(option);
if (e == null) {
e = options.rootSourceOf(option);
}
@@ -620,10 +619,11 @@
if (!(model instanceof CustomFieldOption)) {
return;
}
+ // TODO check if this is the same as sourceOf
CustomFieldOption option = (CustomFieldOption) model;
- IndexedElement e = fieldOptions.sourceOfLastFieldIn(option);
+ IndexedElement e = options.sourceOfLastFieldIn(option);
if (e == null) {
- e = fieldOptions.rootSourceOf(option);
+ e = options.rootSourceOf(option);
}
if (e instanceof MessageField) {
proposeFieldValue((MessageField) e, context, 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 243746d..c090a8f 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
@@ -34,9 +34,8 @@
private static final Pattern COMMENT_START = compile("//\\s*"); // "//" plus whitespace
private static final Patterns NEW_LINE = compileAll("\\r\\n", "\\n");
- @Inject private FieldOptions fieldOptions;
@Inject private INodes nodes;
- @Inject private Options options;
+ @Inject private Options2 options;
@Override public String getDocumentation(EObject o) {
String comment = findComment(o);
@@ -69,7 +68,7 @@
return e != null ? e : o;
}
if (o instanceof FieldOption) {
- IndexedElement e = fieldOptions.rootSourceOf((FieldOption) o);
+ IndexedElement e = options.rootSourceOf((FieldOption) o);
return e != null ? e : o;
}
return 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 917bfb8..38a5aeb 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
@@ -11,7 +11,6 @@
import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.*;
import static com.google.eclipse.protobuf.ui.editor.syntaxcoloring.HighlightingConfiguration.*;
-import static org.eclipse.xtext.ui.editor.syntaxcoloring.DefaultHighlightingConfiguration.*;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.*;
@@ -32,7 +31,7 @@
@Inject private IndexedElements indexedElements;
@Inject private INodes nodes;
- @Inject private Options options;
+ @Inject private Options2 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 1fb28a4..6f2c67b 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 Options options;
+ @Inject private Options2 options;
public Object labelFor(Object o) {
if (o instanceof Extensions) {
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
deleted file mode 100644
index 0676f91..0000000
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/FieldOptions.java
+++ /dev/null
@@ -1,127 +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 java.util.List;
-
-import com.google.eclipse.protobuf.protobuf.*;
-import com.google.inject.*;
-
-/**
- * Utility methods related to field options.
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-@Singleton public class FieldOptions {
-
- private @Inject OptionFields optionFields;
-
- /**
- * Indicates whether the given option is the "default value" one.
- * @param option the given option to check.
- * @return {@code true} if the given option is the "default value" one, {@code false} otherwise.
- */
- public boolean isDefaultValueOption(FieldOption option) {
- return option instanceof DefaultValueFieldOption && option.eContainer() instanceof MessageField;
- }
-
- /**
- * Returns the name of the given option.
- * @param option the given option.
- * @return the name of the given option.
- */
- public String nameOf(FieldOption option) {
- IndexedElement e = rootSourceOf(option);
- if (e instanceof MessageField) {
- return ((MessageField) e).getName();
- }
- return null;
- }
-
- /**
- * Returns the <code>{@link IndexedElement}</code> the given <code>{@link CustomFieldOption}</code> is referring to.
- * This method will check first the source of the last field of the given option (if any.) If the option does not have
- * any fields, this method will return the root source of the option.
- * <p>
- * Example #1
- *
- * <pre>
- * [(myFieldOption) = true];
- * </pre>
- *
- * this method will return the <code>{@link IndexedElement}</code> "myFieldOption" is pointing to.
- * </p>
- * <p>
- * Example #2
- *
- * <pre>
- * [(myOption).foo = true];
- * </pre>
- *
- * this method will return the <code>{@link IndexedElement}</code> "foo" is pointing to.
- * </p>
- * @param option the given {@code CustomFieldOption}.
- * @return the {@code IndexedElement} the given {@code CustomFieldOption} is referring to, or {@code null} if it
- * cannot be found.
- */
- public IndexedElement sourceOf(CustomFieldOption option) {
- IndexedElement e = sourceOfLastFieldIn(option);
- if (e == null) {
- e = rootSourceOf(option);
- }
- return e;
- }
-
- /**
- * Returns the <code>{@link IndexedElement}</code> the given <code>{@link FieldOption}</code> is referring to. In the
- * following example
- *
- * <pre>
- * [(myFieldOption) = true]
- * </pre>
- *
- * this method will return the <code>{@link IndexedElement}</code> "myFieldOption" is pointing to.
- * @param option the given {@code FieldOption}.
- * @return the {@code Property} the given {@code FieldOption} is referring to, or {@code null} if it cannot be found.
- */
- public IndexedElement rootSourceOf(FieldOption option) {
- OptionSource source = null;
- if (option instanceof NativeFieldOption) {
- NativeFieldOption nativeOption = (NativeFieldOption) option;
- source = nativeOption.getSource();
- }
- if (option instanceof CustomFieldOption) {
- CustomFieldOption customOption = (CustomFieldOption) option;
- source = customOption.getSource();
- }
- return (source == null) ? null : source.getTarget();
- }
-
- /**
- * Returns the last field of the given <code>{@link CustomFieldOption}</code>. In the following example
- *
- * <pre>
- * [(myOption).foo = true];
- * </pre>
- *
- * this method will return the field that "foo" is pointing to.
- * @param option the given {@code CustomFieldOption}.
- * @return the last field of the given {@code CustomFieldOption} is referring to, or {@code null} if one cannot be
- * found.
- */
- public IndexedElement sourceOfLastFieldIn(CustomFieldOption option) {
- List<OptionField> fields = option.getFields();
- int fieldCount = fields.size();
- if (fieldCount == 0) {
- return null;
- }
- OptionField last = fields.get(fieldCount - 1);
- return optionFields.sourceOf(last);
- }
-}
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 b3b314e..e291d5d 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
@@ -18,7 +18,7 @@
import org.eclipse.xtext.util.SimpleAttributeResolver;
import com.google.eclipse.protobuf.protobuf.*;
-import com.google.inject.Singleton;
+import com.google.inject.*;
/**
* Utility methods related to <code>{@link IndexedElement}</code>s.
@@ -28,6 +28,8 @@
@Singleton public class IndexedElements {
private final static SimpleAttributeResolver<EObject, Long> INDEX_RESOLVER = newResolver(long.class, "index");
+ @Inject private ModelObjects modelObjects;
+
/**
* Calculates the index value for the given element. The calculated index value is the maximum of all the
* index values of the given element's siblings, plus one. The minimum index value is 1.
@@ -81,13 +83,11 @@
*/
@SuppressWarnings("unchecked")
public List<FieldOption> fieldOptionsOf(IndexedElement e) {
- if (e != null) {
- EStructuralFeature feature = e.eClass().getEStructuralFeature("fieldOptions");
- if (feature != null) {
- return (List<FieldOption>) e.eGet(feature);
- }
+ List<FieldOption> options = modelObjects.valueOfFeature(e, "fieldOptions", List.class);
+ if (options == null) {
+ options = emptyList();
}
- return emptyList();
+ return options;
}
/**
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelFinder.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelFinder.java
index d9877d1..495e15c 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelFinder.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelFinder.java
@@ -33,9 +33,10 @@
@Singleton public class ModelFinder {
/**
- * Returns all the <strong>local</strong> extensions of the given message.
+ * Returns all the extensions of the given message declared in the same file as the message.
* @param message the given message.
- * @return all the <strong>local</strong> extensions of the given message, or an empty collection if none is found.
+ * @return all the extensions of the given message declared in the same file as the message, or an empty collection if
+ * none are found.
*/
public Collection<TypeExtension> localExtensionsOf(Message message) {
return extensionsOf(message, rootOf(message));
@@ -84,10 +85,10 @@
return fieldType(field, Enum.class);
}
- private <T extends ComplexType> T fieldType(MessageField field, Class<T> typeClazz) {
+ private <T extends ComplexType> T fieldType(MessageField field, Class<T> targetType) {
ComplexType type = typeOf(field);
- if (typeClazz.isInstance(type)) {
- return typeClazz.cast(type);
+ if (targetType.isInstance(type)) {
+ return targetType.cast(type);
}
return null;
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelObjects.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelObjects.java
new file mode 100644
index 0000000..2b792d4
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/ModelObjects.java
@@ -0,0 +1,40 @@
+/*
+ * 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 org.eclipse.emf.ecore.*;
+
+import com.google.inject.Singleton;
+
+/**
+ * Utility methods related to model objects.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+@Singleton public class ModelObjects {
+
+ /**
+ * Returns the value of the structural feature with a matching name in the given model object.
+ * @param e the given model object.
+ * @param featureName the name of the structural feature to read the value from.
+ * @param valueType the expected type of the value to return.
+ * @return the value of the structural feature with a matching name in the given model object, or {@code null} if the
+ * given model object is {@code null} or if the model object does not have a structural feature with a matching name.
+ * @throws ClassCastException if the value of the structural value is not the same as the expected one.
+ */
+ public <T> T valueOfFeature(EObject e, String featureName, Class<T> valueType) {
+ if (e != null) {
+ EStructuralFeature feature = e.eClass().getEStructuralFeature(featureName);
+ if (feature != null) {
+ return valueType.cast(e.eGet(feature));
+ }
+ }
+ return null;
+ }
+}
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
deleted file mode 100644
index c838c2b..0000000
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options.java
+++ /dev/null
@@ -1,116 +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 static org.eclipse.xtext.util.Strings.isEmpty;
-
-import java.util.List;
-
-import com.google.eclipse.protobuf.protobuf.*;
-import com.google.inject.*;
-
-/**
- * Utility methods related to <code>{@link Option}</code>.
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-@Singleton public class Options {
-
- private @Inject OptionFields optionFields;
-
- /**
- * Returns the <code>{@link IndexedElement}</code> the given <code>{@link CustomOption}</code> is referring to. This
- * method will check first the source of the last field of the given option (if any.) If the option does not have any
- * fields, this method will return the root source of the option.
- * <p>
- * Example #1
- *
- * <pre>
- * option(myOption) = true;
- * </pre>
- *
- * this method will return the <code>{@link IndexedElement}</code> "myOption" is pointing to.
- * </p>
- * <p>
- * Example #2
- *
- * <pre>
- * option(myOption).foo = true;
- * </pre>
- *
- * this method will return the <code>{@link IndexedElement}</code> "foo" is pointing to.
- * </p>
- * @param option the given {@code CustomOption}.
- * @return the {@code IndexedElement} the given {@code CustomOption} is referring to, or {@code null} if it cannot be
- * found.
- */
- public IndexedElement sourceOf(CustomOption option) {
- IndexedElement e = lastFieldSourceFrom(option);
- if (e == null) {
- e = rootSourceOf(option);
- }
- return e;
- }
-
- /**
- * Returns the <code>{@link IndexedElement}</code> the given <code>{@link Option}</code> is referring to. In the
- * following example
- *
- * <pre>
- * option(myOption).foo = true;
- * </pre>
- *
- * this method will return the <code>{@link IndexedElement}</code> "myOption" is pointing to.
- * @param option the given {@code Option}.
- * @return the {@code IndexedElement} the given {@code Option} is referring to, or {@code null} if it cannot be found.
- */
- public IndexedElement rootSourceOf(Option option) {
- OptionSource source = option.getSource();
- return (source == null) ? null : source.getTarget();
- }
-
- /**
- * Returns the last field of the given <code>{@link CustomOption}</code>. In the following example
- *
- * <pre>
- * option(myOption).foo = true;
- * </pre>
- *
- * this method will return the field that "foo" is pointing to.
- * @param option the given {@code CustomOption}.
- * @return the last field of the given {@code CustomOption} is referring to, or {@code null} if one cannot be found.
- */
- public IndexedElement lastFieldSourceFrom(CustomOption option) {
- List<OptionField> fields = option.getFields();
- if (fields.isEmpty()) {
- return null;
- }
- OptionField last = fields.get(fields.size() - 1);
- return optionFields.sourceOf(last);
- }
-
- /**
- * Returns the name of the given <code>{@link IndexedElement}</code> used as a source of an option. If the given
- * element is a <code>{@link Group}</code>, this method will return its name in lower case.
- * @param e the given {@code IndexedElement}.
- * @return the name of the given <code>{@link IndexedElement}</code>.
- */
- public String nameForOption(IndexedElement e) {
- if (e instanceof MessageField) {
- MessageField field = (MessageField) e;
- return field.getName();
- }
- if (e instanceof Group) {
- 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/model/util/Options2.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options2.java
new file mode 100644
index 0000000..ae23826
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Options2.java
@@ -0,0 +1,212 @@
+/*
+ * 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 static org.eclipse.xtext.util.Strings.isEmpty;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+
+import com.google.eclipse.protobuf.naming.NameResolver;
+import com.google.eclipse.protobuf.protobuf.*;
+import com.google.inject.*;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ *
+ */
+@Singleton public class Options2 {
+
+ @Inject private ModelObjects modelObjects;
+ @Inject private NameResolver nameResolver;
+ @Inject private OptionFields optionFields;
+
+ /**
+ * Indicates whether the given option is the "default value" one.
+ * @param option the given option to check.
+ * @return {@code true} if the given option is the "default value" one, {@code false} otherwise.
+ */
+ public boolean isDefaultValueOption(FieldOption option) {
+ return option instanceof DefaultValueFieldOption && option.eContainer() instanceof MessageField;
+ }
+
+ /**
+ * Returns the <code>{@link IndexedElement}</code> the given <code>{@link CustomOption}</code> is referring to. This
+ * method will check first the source of the last field of the given option (if any.) If the option does not have any
+ * fields, this method will return the root source of the option.
+ * <p>
+ * Example #1
+ *
+ * <pre>
+ * option(myOption) = true;
+ * </pre>
+ *
+ * this method will return the <code>{@link IndexedElement}</code> "myOption" is pointing to.
+ * </p>
+ * <p>
+ * Example #2
+ *
+ * <pre>
+ * option(myOption).foo = true;
+ * </pre>
+ *
+ * this method will return the <code>{@link IndexedElement}</code> "foo" is pointing to.
+ * </p>
+ * @param option the given {@code CustomOption}.
+ * @return the {@code IndexedElement} the given {@code CustomOption} is referring to, or {@code null} if it cannot be
+ * found.
+ */
+ public IndexedElement sourceOf(CustomOption option) {
+ IndexedElement e = sourceOfLastFieldIn(option);
+ if (e == null) {
+ e = rootSourceOf(option);
+ }
+ return e;
+ }
+
+ /**
+ * Returns the last field of the given <code>{@link CustomOption}</code>. In the following example
+ *
+ * <pre>
+ * option(myOption).foo = true;
+ * </pre>
+ *
+ * this method will return the field that "foo" is pointing to.
+ * @param option the given {@code CustomOption}.
+ * @return the last field of the given {@code CustomOption} is referring to, or {@code null} if one cannot be found.
+ */
+ public IndexedElement sourceOfLastFieldIn(CustomOption option) {
+ return findSourceOfLastField(option);
+ }
+
+ /**
+ * Returns the <code>{@link IndexedElement}</code> the given <code>{@link Option}</code> is referring to. In the
+ * following example
+ *
+ * <pre>
+ * option(myOption).foo = true;
+ * </pre>
+ *
+ * this method will return the <code>{@link IndexedElement}</code> "myOption" is pointing to.
+ * @param option the given {@code Option}.
+ * @return the {@code IndexedElement} the given {@code Option} is referring to, or {@code null} if it cannot be found.
+ */
+ public IndexedElement rootSourceOf(Option option) {
+ return findRootSource(option);
+ }
+
+ /**
+ * Returns the <code>{@link IndexedElement}</code> the given <code>{@link CustomFieldOption}</code> is referring to.
+ * This method will check first the source of the last field of the given option (if any.) If the option does not have
+ * any fields, this method will return the root source of the option.
+ * <p>
+ * Example #1
+ *
+ * <pre>
+ * [(myFieldOption) = true];
+ * </pre>
+ *
+ * this method will return the <code>{@link IndexedElement}</code> "myFieldOption" is pointing to.
+ * </p>
+ * <p>
+ * Example #2
+ *
+ * <pre>
+ * [(myOption).foo = true];
+ * </pre>
+ *
+ * this method will return the <code>{@link IndexedElement}</code> "foo" is pointing to.
+ * </p>
+ * @param option the given {@code CustomFieldOption}.
+ * @return the {@code IndexedElement} the given {@code CustomFieldOption} is referring to, or {@code null} if it
+ * cannot be found.
+ */
+ public IndexedElement sourceOf(CustomFieldOption option) {
+ IndexedElement e = sourceOfLastFieldIn(option);
+ if (e == null) {
+ e = rootSourceOf(option);
+ }
+ return e;
+ }
+
+ /**
+ * Returns the last field of the given <code>{@link CustomFieldOption}</code>. In the following example
+ *
+ * <pre>
+ * [(myOption).foo = true];
+ * </pre>
+ *
+ * this method will return the field that "foo" is pointing to.
+ * @param option the given {@code CustomFieldOption}.
+ * @return the last field of the given {@code CustomFieldOption} is referring to, or {@code null} if one cannot be
+ * found.
+ */
+ public IndexedElement sourceOfLastFieldIn(CustomFieldOption option) {
+ return findSourceOfLastField(option);
+ }
+
+ @SuppressWarnings("unchecked")
+ private IndexedElement findSourceOfLastField(EObject e) {
+ List<OptionField> fields = modelObjects.valueOfFeature(e, "fields", List.class);
+ if (fields == null || fields.isEmpty()) {
+ return null;
+ }
+ OptionField last = fields.get(fields.size() - 1);
+ return optionFields.sourceOf(last);
+ }
+
+ /**
+ * Returns the <code>{@link IndexedElement}</code> the given <code>{@link FieldOption}</code> is referring to. In the
+ * following example
+ *
+ * <pre>
+ * [(myFieldOption) = true]
+ * </pre>
+ *
+ * this method will return the <code>{@link IndexedElement}</code> "myFieldOption" is pointing to.
+ * @param option the given {@code FieldOption}.
+ * @return the {@code Property} the given {@code FieldOption} is referring to, or {@code null} if it cannot be found.
+ */
+ public IndexedElement rootSourceOf(FieldOption option) {
+ return findRootSource(option);
+ }
+
+ private IndexedElement findRootSource(EObject e) {
+ OptionSource source = modelObjects.valueOfFeature(e, "source", OptionSource.class);
+ return source == null ? null : source.getTarget();
+ }
+
+ /**
+ * Returns the name of the given <code>{@link IndexedElement}</code> used as a source of an option. If the given
+ * element is a <code>{@link Group}</code>, this method will return its name in lower case.
+ * @param e the given {@code IndexedElement}.
+ * @return the name of the given <code>{@link IndexedElement}</code>.
+ */
+ public String nameForOption(IndexedElement e) {
+ String name = nameResolver.nameOf(e);
+ if (e instanceof Group && !isEmpty(name)) {
+ name = name.toLowerCase();
+ }
+ return name;
+ }
+
+ /**
+ * Returns the name of the given option.
+ * @param option the given option.
+ * @return the name of the given option.
+ */
+ public String nameOf(FieldOption option) {
+ IndexedElement e = rootSourceOf(option);
+ if (e instanceof MessageField) {
+ return ((MessageField) e).getName();
+ }
+ return null;
+ }
+}
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 69e7771..02c5974 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.Options;
+import com.google.eclipse.protobuf.model.util.Options2;
import com.google.eclipse.protobuf.protobuf.*;
import com.google.inject.*;
@@ -22,7 +22,7 @@
@Singleton public class Naming {
@Inject private NameResolver nameResolver;
- @Inject private Options options;
+ @Inject private Options2 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 ae9c04f..1cb7576 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
@@ -25,10 +25,9 @@
*/
class CustomOptionFieldScopeFinder {
- @Inject private FieldOptions fieldOptions;
@Inject private ModelFinder modelFinder;
@Inject private OptionFields optionFields;
- @Inject private Options options;
+ @Inject private Options2 options;
@Inject private QualifiedNameDescriptions qualifiedNameDescriptions;
Collection<IEObjectDescription> findScope(CustomOption option, MessageOptionField field) {
@@ -64,7 +63,7 @@
IEObjectDescriptionsProvider provider) {
IndexedElement e = referredField(field, option.getFields(), new Provider<IndexedElement>() {
@Override public IndexedElement get() {
- return fieldOptions.rootSourceOf(option);
+ return options.rootSourceOf(option);
}
});
if (e != null) {
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 ad59afc..d9742cd 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,8 +25,7 @@
*/
class FieldNotationScopeFinder {
- @Inject private FieldOptions fieldOptions;
- @Inject private Options options;
+ @Inject private Options2 options;
@Inject private ModelFinder modelFinder;
@Inject private QualifiedNameDescriptions qualifiedNameDescriptions;
@@ -55,7 +54,7 @@
}
if (container instanceof CustomFieldOption) {
CustomFieldOption option = (CustomFieldOption) container;
- source = fieldOptions.sourceOf(option);
+ source = options.sourceOf(option);
}
if (container instanceof ComplexValueField) {
source = sourceOf((ComplexValueField) container);
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 58558d2..668900c 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
@@ -39,11 +39,10 @@
@Inject private CustomOptionScopeFinder customOptionScopeFinder;
@Inject private ProtoDescriptorProvider descriptorProvider;
@Inject private FieldNotationScopeFinder fieldNotationScopeFinder;
- @Inject private FieldOptions fieldOptions;
@Inject private ModelFinder modelFinder;
@Inject private LiteralDescriptions literalDescriptions;
@Inject private NativeOptionDescriptions nativeOptionDescriptions;
- @Inject private Options options;
+ @Inject private Options2 options;
@Inject private TypeScopeFinder typeScopeFinder;
@SuppressWarnings("unused") public IScope scope_ComplexTypeLink_target(ComplexTypeLink link, EReference r) {
@@ -100,12 +99,12 @@
}
if (container instanceof NativeFieldOption) {
ProtoDescriptor descriptor = descriptorProvider.primaryDescriptor();
- IndexedElement c = fieldOptions.rootSourceOf((FieldOption) container);
+ IndexedElement c = options.rootSourceOf((FieldOption) container);
anEnum = descriptor.enumTypeOf((MessageField) c);
}
if (container instanceof CustomFieldOption) {
CustomFieldOption option = (CustomFieldOption) container;
- container = fieldOptions.sourceOf(option);
+ container = options.sourceOf(option);
}
if (container instanceof SimpleValueField) {
SimpleValueField field = (SimpleValueField) container;
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 b40e264..45645d4 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
@@ -30,14 +30,14 @@
@Override public void register(EValidatorRegistrar registrar) {}
- @Inject private FieldOptions fieldOptions;
@Inject private IQualifiedNameProvider fqnProvider;
@Inject private MessageFields messageFields;
@Inject private ModelFinder modelFinder;
@Inject private INodes nodes;
+ @Inject private Options2 options;
@Check public void checkValueOfDefaultTypeMatchesFieldType(FieldOption option) {
- if (fieldOptions.isDefaultValueOption(option)) {
+ if (options.isDefaultValueOption(option)) {
MessageField field = (MessageField) option.eContainer();
checkValueTypeMatchesFieldType(option, field);
}