Added settings to specify proto2-only checks via an extension point.
Code cleanup.
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/IntegrationTestSetup.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/IntegrationTestSetup.java
index 0935741..527bf13 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/IntegrationTestSetup.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/IntegrationTestSetup.java
@@ -25,15 +25,14 @@
*/
public class IntegrationTestSetup extends ProtobufStandaloneSetup {
- IntegrationTestSetup() {}
+ protected IntegrationTestSetup() {}
@Override
public Injector createInjector() {
return Guice.createInjector(new Module());
}
- private static class Module extends ProtobufRuntimeModule {
- @SuppressWarnings("unused")
+ protected static class Module extends ProtobufRuntimeModule {
public Class<? extends IFileUriResolver> bindFileUriResolver() {
return FileUriResolver.class;
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/UnitTestSetup.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/UnitTestSetup.java
index 0177a82..e5612e6 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/UnitTestSetup.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/UnitTestSetup.java
@@ -20,14 +20,16 @@
*/
public class UnitTestSetup extends ProtobufStandaloneSetup {
- UnitTestSetup() {}
+ protected UnitTestSetup() {}
@Override
public Injector createInjector() {
return Guice.createInjector(new Module());
}
- private static class Module extends ProtobufRuntimeModule {
+ protected static class Module extends ProtobufRuntimeModule {
+ public Module() {}
+
@Override public void configureExtensionRegistry(Binder binder) {
binder.bind(IExtensionRegistry.class).toProvider(ExtensionRegistryProvider.class);
}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/XtextRule.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/XtextRule.java
index f08dcf8..e37f964 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/XtextRule.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/XtextRule.java
@@ -69,7 +69,7 @@
return injector;
}
- private void parseText(String text) {
+ public void parseText(String text) {
boolean ignoreSyntaxErrors = shouldIgnoreSyntaxErrorsIn(text);
resource = resourceFrom(new StringInputStream(text));
IParseResult parseResult = resource.getParseResult();
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser_doParse_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser_doParse_Test.java
index a669172..cb51d2b 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser_doParse_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser_doParse_Test.java
@@ -8,17 +8,19 @@
*/
package com.google.eclipse.protobuf.parser;
-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.IsInstanceOf.instanceOf;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
import org.antlr.runtime.CharStream;
import org.eclipse.xtext.nodemodel.impl.NodeModelBuilder;
import org.junit.*;
-import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.core.*;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.Protobuf;
+import com.google.inject.*;
/**
* Tests for <code>{@link Proto2OnlyParser#doParse(String, CharStream, NodeModelBuilder, int)}</code>.
@@ -27,12 +29,46 @@
*/
public class Proto2OnlyParser_doParse_Test {
- @Rule public XtextRule xtext = createWith(unitTestSetup());
+ private static String proto1;
- // // ignore errors
- // c++header #include "test/common/proto_class.h"
+ @BeforeClass public static void setUpOnce() {
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
+ proto.append("// ignore errors")
+ .append("c++header #include 'test/common/proto_class.h'");
+ proto1 = proto.toString();
+ }
+
+ @Rule public XtextRule xtext = createWith(new Setup());
+
+ private ParserChecksSettingsProvider settingsProvider;
+
+ @Before public void setUp() {
+ settingsProvider = xtext.getInstanceOf(ParserChecksSettingsProvider.class);
+ }
+
@Test public void should_recognize_proto1_syntax() {
+ when(settingsProvider.shouldCheckProto2Only()).thenReturn(true);
+ xtext.parseText(proto1);
Protobuf root = xtext.root();
assertThat(root, instanceOf(NonProto2Protobuf.class));
}
+
+ @Test public void should_not_recognize_proto1_syntax() {
+ when(settingsProvider.shouldCheckProto2Only()).thenReturn(false);
+ xtext.parseText(proto1);
+ Protobuf root = xtext.root();
+ assertNull(root);
+ }
+
+ private static class Setup extends UnitTestSetup {
+ @Override public Injector createInjector() {
+ return Guice.createInjector(new Module() {
+ @SuppressWarnings("unused")
+ public void configureParserChecksSettingsProvider(Binder binder) {
+ binder.bind(ParserChecksSettingsProvider.class).toInstance(mock(ParserChecksSettingsProvider.class));
+ }
+ });
+ }
+ }
+
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/parser/Proto2OnlyCheckPreferenceStoreInitializer.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/parser/Proto2OnlyCheckPreferenceStoreInitializer.java
deleted file mode 100644
index d0ba538..0000000
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/parser/Proto2OnlyCheckPreferenceStoreInitializer.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.ui.preferences.parser;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.xtext.ui.editor.preferences.*;
-
-/**
- * Initializes default values for the "Proto2 only check" preferences.
- *
- * @author alruiz@google.com (Alex Ruiz)
- */
-public class Proto2OnlyCheckPreferenceStoreInitializer implements IPreferenceStoreInitializer {
-
- /** {@inheritDoc} */
- @Override public void initialize(IPreferenceStoreAccess access) {
- IPreferenceStore store = access.getWritablePreferenceStore();
- RawPreferences preferences = new RawPreferences(store);
- preferences.enableProto2OnlyChecks().setDefaultValue(false);
- }
-}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/parser/RawPreferences.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/parser/RawPreferences.java
deleted file mode 100644
index 5ef0403..0000000
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/parser/RawPreferences.java
+++ /dev/null
@@ -1,29 +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.ui.preferences.parser;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import com.google.eclipse.protobuf.ui.preferences.BooleanPreference;
-
-/**
- * @author alruiz@google.com (Alex Ruiz)
- */
-class RawPreferences {
-
- private final BooleanPreference enableProto2OnlyChecks;
-
- RawPreferences(IPreferenceStore store) {
- enableProto2OnlyChecks = new BooleanPreference("compiler.checkProto2", store);
- }
-
- BooleanPreference enableProto2OnlyChecks() {
- return enableProto2OnlyChecks;
- }
-}
diff --git a/com.google.eclipse.protobuf/META-INF/MANIFEST.MF b/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
index 61e6d07..716d6cc 100644
--- a/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
+++ b/com.google.eclipse.protobuf/META-INF/MANIFEST.MF
@@ -22,18 +22,19 @@
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: com.google.eclipse.protobuf,
com.google.eclipse.protobuf.conversion,
+ com.google.eclipse.protobuf.formatting,
com.google.eclipse.protobuf.grammar,
com.google.eclipse.protobuf.model.util,
com.google.eclipse.protobuf.naming,
+ com.google.eclipse.protobuf.parser,
com.google.eclipse.protobuf.parser.antlr,
com.google.eclipse.protobuf.parser.antlr.internal,
com.google.eclipse.protobuf.protobuf,
com.google.eclipse.protobuf.protobuf.impl,
com.google.eclipse.protobuf.protobuf.util,
com.google.eclipse.protobuf.scoping,
+ com.google.eclipse.protobuf.serializer,
com.google.eclipse.protobuf.services,
com.google.eclipse.protobuf.util,
- com.google.eclipse.protobuf.validation,
- com.google.eclipse.protobuf.formatting,
- com.google.eclipse.protobuf.serializer
+ com.google.eclipse.protobuf.validation
diff --git a/com.google.eclipse.protobuf/plugin.xml b/com.google.eclipse.protobuf/plugin.xml
index abdcd04..79c091c 100644
--- a/com.google.eclipse.protobuf/plugin.xml
+++ b/com.google.eclipse.protobuf/plugin.xml
@@ -5,6 +5,7 @@
id="descriptorSource"
name="descriptor-source"
schema="schema/descriptor-source.exsd" />
+ <extension-point id="parserChecks" name="parser-checks" schema="schema/parser-checks.exsd"/>
<extension point="org.eclipse.emf.ecore.generated_package">
<package
uri="http://www.google.com/eclipse/protobuf/Protobuf"
diff --git a/com.google.eclipse.protobuf/schema/descriptor-source.exsd b/com.google.eclipse.protobuf/schema/descriptor-source.exsd
index 5b111be..06934ba 100644
--- a/com.google.eclipse.protobuf/schema/descriptor-source.exsd
+++ b/com.google.eclipse.protobuf/schema/descriptor-source.exsd
@@ -1,92 +1,71 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="com.google.eclipse.protobuf" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
+ <annotation>
+ <appInfo>
+ <meta.schema plugin="com.google.eclipse.protobuf" id="descriptorSource" name="Source of descriptor.proto" />
+ </appInfo>
+ <documentation>Provides the contents of a descriptor.proto file.</documentation>
+ </annotation>
+ <element name="extension">
+ <annotation>
<appInfo>
- <meta.schema plugin="com.google.eclipse.protobuf" id="descriptorSource" name="Source of descriptor.proto"/>
+ <meta.element />
</appInfo>
- <documentation>
- Provides the contents of a descriptor.proto file.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="source"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="source">
- <complexType>
- <attribute name="path" type="string" use="required">
- <annotation>
- <documentation>
- Provides the contents of a descriptor.proto file.
- </documentation>
- <appInfo>
- <meta.attribute kind="resource"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="importUri" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 1.0.3
- </documentation>
- </annotation>
-
-
-
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2011 Google, Inc.
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="source" />
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation></documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation></documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation></documentation>
+ <appInfo>
+ <meta.attribute translatable="true" />
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+ <element name="source">
+ <complexType>
+ <attribute name="path" type="string" use="required">
+ <annotation>
+ <documentation>Provides the contents of a descriptor.proto file.</documentation>
+ <appInfo>
+ <meta.attribute kind="resource" />
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="importUri" type="string" use="required">
+ <annotation>
+ <documentation></documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+ <annotation>
+ <appInfo>
+ <meta.section type="since" />
+ </appInfo>
+ <documentation>1.0.3</documentation>
+ </annotation>
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright" />
+ </appInfo>
+ <documentation>
+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
@@ -94,7 +73,6 @@
Contributors:
Google, Inc. - initial API and implementation
- </documentation>
- </annotation>
-
-</schema>
+ </documentation>
+ </annotation>
+</schema>
\ No newline at end of file
diff --git a/com.google.eclipse.protobuf/schema/parser-checks.exsd b/com.google.eclipse.protobuf/schema/parser-checks.exsd
new file mode 100644
index 0000000..e0b6653
--- /dev/null
+++ b/com.google.eclipse.protobuf/schema/parser-checks.exsd
@@ -0,0 +1,67 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="com.google.eclipse.protobuf" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="com.google.eclipse.protobuf" id="parserChecks" name="parser-checks"/>
+ </appInfo>
+ <documentation>Parser checks for proto files.</documentation>
+ </annotation>
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation></documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation></documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation></documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+ <element name="checks">
+ <complexType>
+ <attribute name="proto2OnlyCheck" type="boolean" use="default" value="false">
+ <annotation>
+ <documentation></documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>1.3</documentation>
+ </annotation>
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+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
+
+Contributors:
+Google, Inc. - initial API and implementation
+ </documentation>
+ </annotation>
+</schema>
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufRuntimeModule.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufRuntimeModule.java
index bc3a913..46a5254 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufRuntimeModule.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufRuntimeModule.java
@@ -29,7 +29,6 @@
* Use this class to register components to be used at runtime / without the Equinox extension registry.
*/
public class ProtobufRuntimeModule extends com.google.eclipse.protobuf.AbstractProtobufRuntimeModule {
-
public Class<? extends IGlobalServiceProvider> bindIGlobalServiceProvider() {
return ResourceServiceProvider.class;
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufStandaloneSetup.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufStandaloneSetup.java
index 21c9eb4..395fb47 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufStandaloneSetup.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/ProtobufStandaloneSetup.java
@@ -12,7 +12,6 @@
* Initialization support for running Xtext languages without Equinox extension registry.
*/
public class ProtobufStandaloneSetup extends ProtobufStandaloneSetupGenerated {
-
public static void doSetup() {
new ProtobufStandaloneSetup().createInjectorAndDoEMFRegistration();
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/DOUBLEValueConverter.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/DOUBLEValueConverter.java
index b4a0508..a85cae5 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/DOUBLEValueConverter.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/DOUBLEValueConverter.java
@@ -23,7 +23,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class DOUBLEValueConverter extends AbstractLexerBasedConverter<Double> {
-
private static final Map<String, Double> PREDEFINED_VALUES = new HashMap<String, Double>();
static {
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/HEXValueConverter.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/HEXValueConverter.java
index 91ae3db..e553950 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/HEXValueConverter.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/HEXValueConverter.java
@@ -22,7 +22,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class HEXValueConverter extends AbstractLexerBasedConverter<Long> {
-
private static final String[] VALID_PREFIXES = { "0x", "-0x", "0X", "-0x" };
/**
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/LONGValueConverter.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/LONGValueConverter.java
index ae399e5..491761f 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/LONGValueConverter.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/LONGValueConverter.java
@@ -22,7 +22,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class LONGValueConverter extends AbstractLexerBasedConverter<Long> {
-
/**
* Creates an {@code int} from the given input, if the given input represents an integer number.
* @param string the given input.
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 6fd3776..d610b47 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
@@ -17,7 +17,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufTerminalConverters extends DefaultTerminalConverters {
-
@Inject private DOUBLEValueConverter doubleValueConverter;
@Inject private HEXValueConverter hexValueConverter;
@Inject private LONGValueConverter longValueConverter;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/STRINGValueConverter.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/STRINGValueConverter.java
index ba1ae52..13a3093 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/STRINGValueConverter.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/conversion/STRINGValueConverter.java
@@ -23,7 +23,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class STRINGValueConverter extends AbstractLexerBasedConverter<String> {
-
private static final Pattern LINE_BREAK = compile("\"[\t\r\n]+\"|'[\t\r\n]+'");
@Override protected String toEscapedString(String value) {
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/formatting/ProtobufFormatter.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/formatting/ProtobufFormatter.java
index b91e8e2..acb0c4b 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/formatting/ProtobufFormatter.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/formatting/ProtobufFormatter.java
@@ -22,7 +22,6 @@
* @see <a href="http://www.eclipse.org/Xtext/documentation/2_0_0/105-formatting.php">Xtext Formatting</a>
*/
public class ProtobufFormatter extends AbstractDeclarativeFormatter {
-
@Override protected void configureFormatting(FormattingConfig c) {
ProtobufGrammarAccess g = (ProtobufGrammarAccess) getGrammarAccess();
c.setLinewrap(0, 1, 2).before(g.getSL_COMMENTRule());
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/CommonKeyword.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/CommonKeyword.java
index 69889d4..43023ae 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/CommonKeyword.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/CommonKeyword.java
@@ -14,7 +14,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public enum CommonKeyword {
-
// we used to get keywords from IGrammarAccess. The problem was that we still had to hard-code the keyword we were
// looking for. The code was too complicated and if the grammar changed for some reason, we had to change our
// implementation anyway.
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/Keywords.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/Keywords.java
index 040d060..b947e60 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/Keywords.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/Keywords.java
@@ -22,7 +22,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class Keywords {
-
private final Set<String> keywords;
/**
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/Syntaxes.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/Syntaxes.java
index 3110ed4..342bf18 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/Syntaxes.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/Syntaxes.java
@@ -12,7 +12,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public final class Syntaxes {
-
/**
* Returns the value to use to in the "syntax" element.
* @return the {@code String} "proto2".
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/linking/ProtobufDiagnostic.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/linking/ProtobufDiagnostic.java
index e0af64b..1d4a3c7 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/linking/ProtobufDiagnostic.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/linking/ProtobufDiagnostic.java
@@ -21,7 +21,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufDiagnostic extends AbstractDiagnostic {
-
private final String code;
private final String[] data;
private final StringBuilder message;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/linking/ProtobufResource.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/linking/ProtobufResource.java
index f84f975..0442d02 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/linking/ProtobufResource.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/linking/ProtobufResource.java
@@ -18,7 +18,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufResource extends LazyLinkingResource {
-
@Override protected Diagnostic createDiagnostic(Triple<EObject, EReference, INode> t, DiagnosticMessage message) {
return new ProtobufDiagnostic(message.getIssueCode(), message.getIssueData(), message.getMessage(), t.getThird());
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/INodes.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/INodes.java
index 66c8fde..45a8df4 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/INodes.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/INodes.java
@@ -24,7 +24,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class INodes {
-
/**
* Returns the first node that was used to assign values to the given feature for the given object.
* @param o the given object.
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Imports.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Imports.java
index 22b556f..bd08c14 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Imports.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Imports.java
@@ -20,7 +20,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class Imports {
-
@Inject private ProtoDescriptorProvider descriptorProvider;
/**
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/MessageFields.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/MessageFields.java
index a9964e0..1889b82 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/MessageFields.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/MessageFields.java
@@ -21,7 +21,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class MessageFields {
-
/**
* Indicates whether the modifier of the given field is <code>{@link Modifier#OPTIONAL}</code>.
* @param field the given field.
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 495e15c..2bc2312 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
@@ -31,7 +31,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class ModelFinder {
-
/**
* Returns all the extensions of the given message declared in the same file as the message.
* @param message the given message.
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
index 2b792d4..eed4df3 100644
--- 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
@@ -18,7 +18,6 @@
* @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.
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/OptionFields.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/OptionFields.java
index 07fc6b8..798d7a9 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/OptionFields.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/OptionFields.java
@@ -17,7 +17,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class OptionFields {
-
/**
* Returns the field the given option field is referring to.
* @param field the given option field.
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 e5e9da2..bfc191d 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 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class Options {
-
@Inject private ModelObjects modelObjects;
@Inject private NameResolver nameResolver;
@Inject private OptionFields optionFields;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Packages.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Packages.java
index b05e9e9..977a953 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Packages.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Packages.java
@@ -24,7 +24,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class Packages {
-
@Inject private final IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl();
/**
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Protobufs.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Protobufs.java
index 57bf7e7..0950e3e 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Protobufs.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Protobufs.java
@@ -18,7 +18,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class Protobufs {
-
/**
* Indicates whether the given <code>{@link Protobuf}</code> is not {@code null} and has "proto2" syntax.
* @param protobuf the {@code Protobuf} to check.
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/QualifiedNames.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/QualifiedNames.java
index ee7fe40..adf5053 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/QualifiedNames.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/QualifiedNames.java
@@ -20,7 +20,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class QualifiedNames {
-
public QualifiedName createFqn(List<String> segments) {
return QualifiedName.create(asArray(segments));
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Resources.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Resources.java
index b6b16e5..e1902ad 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Resources.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/Resources.java
@@ -23,7 +23,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class Resources {
-
@Inject private ImportUriResolver uriResolver;
/**
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/IProtobufQualifiedNameProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/IProtobufQualifiedNameProvider.java
index 65f3c8f..ab9db8c 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/IProtobufQualifiedNameProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/IProtobufQualifiedNameProvider.java
@@ -19,7 +19,6 @@
*/
@ImplementedBy(ProtobufQualifiedNameProvider.class) public interface IProtobufQualifiedNameProvider extends
IQualifiedNameProvider {
-
/**
* Returns the qualified name of the given object, to be used in an option. If the given object is a
* <code>{@link Group}</code>, this methods returns the name in lower case.
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/LocalNamesProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/LocalNamesProvider.java
index d1616e2..474c68e 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/LocalNamesProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/LocalNamesProvider.java
@@ -57,7 +57,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class LocalNamesProvider {
-
@Inject private final IResourceScopeCache cache = IResourceScopeCache.NullImpl.INSTANCE;
@Inject private final IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl();
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 0e7840e..66fd5bd 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
@@ -22,7 +22,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class NameResolver {
-
/**
* Returns the name of the given element.
* @param o the given element.
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..62b3229 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
@@ -20,7 +20,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class Naming {
-
@Inject private NameResolver nameResolver;
@Inject private Options options;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider.java
index 82501ac..c6f458d 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider.java
@@ -30,7 +30,6 @@
*/
public class ProtobufQualifiedNameProvider extends IQualifiedNameProvider.AbstractImpl implements
IProtobufQualifiedNameProvider {
-
@Inject private final IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl();
@Inject private final IResourceScopeCache cache = IResourceScopeCache.NullImpl.INSTANCE;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/NonProto2Protobuf.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/NonProto2Protobuf.java
index cba4895..4ca44a4 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/NonProto2Protobuf.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/NonProto2Protobuf.java
@@ -17,5 +17,8 @@
*/
public class NonProto2Protobuf extends ProtobufImpl {
- NonProto2Protobuf() {}
+ /**
+ * Creates a new <code>{@link NonProto2Protobuf}</code>.
+ */
+ public NonProto2Protobuf() {}
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/ParserChecksSettingsProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/ParserChecksSettingsProvider.java
new file mode 100644
index 0000000..5bd2a67
--- /dev/null
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/ParserChecksSettingsProvider.java
@@ -0,0 +1,59 @@
+/*
+ * 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.parser;
+
+import org.eclipse.core.runtime.*;
+
+import com.google.inject.*;
+
+/**
+ * Provider of settings of parser checks.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+@Singleton public class ParserChecksSettingsProvider {
+ private static final String EXTENSION_ID = "com.google.eclipse.protobuf.parserChecks";
+
+ @Inject private IExtensionRegistry registry;
+
+ private boolean initialized;
+ private boolean proto2OnlyCheck;
+
+ private final Object lock = new Object();
+
+ /**
+ * Indicates whether the parser should ensure .proto files have "proto2" syntax.
+ * @return {@code true} if the parser should ensure .proto files have "proto2" syntax, {@code false} otherwise.
+ */
+ public boolean shouldCheckProto2Only() {
+ ensureIsInitialized();
+ return proto2OnlyCheck;
+ }
+
+ private void ensureIsInitialized() {
+ synchronized (lock) {
+ if (initialized) {
+ return;
+ }
+ initialized = true;
+ initializeFromExtensionPoint();
+ }
+ }
+
+ private void initializeFromExtensionPoint() {
+ IConfigurationElement[] config = registry.getConfigurationElementsFor(EXTENSION_ID);
+ if (config == null) {
+ return;
+ }
+ for (IConfigurationElement e : config) {
+ String proto2OnlyCheckAttribure = e.getAttribute("proto2OnlyCheck");
+ proto2OnlyCheck = Boolean.parseBoolean(proto2OnlyCheckAttribure);
+ }
+ }
+}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser.java
index 1863d8d..b456a0d 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/parser/Proto2OnlyParser.java
@@ -11,10 +11,11 @@
import org.antlr.runtime.CharStream;
import org.eclipse.xtext.nodemodel.*;
import org.eclipse.xtext.nodemodel.impl.NodeModelBuilder;
-import org.eclipse.xtext.parser.IParseResult;
+import org.eclipse.xtext.parser.*;
import com.google.eclipse.protobuf.parser.antlr.ProtobufParser;
import com.google.eclipse.protobuf.protobuf.Protobuf;
+import com.google.inject.Inject;
/**
* Parser that only parses protocol buffers with "proto2" syntax, older syntax is ignored completely.
@@ -22,21 +23,21 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class Proto2OnlyParser extends ProtobufParser {
-
private static final String[] ERRORS_TO_LOOK_FOR = { "missing EOF at 'c'", "missing EOF at 'java'",
"missing EOF at 'parsed'", "missing EOF at 'python'", "no viable alternative at input '<'" };
+ @Inject private ParserChecksSettingsProvider settingsProvider;
+
@Override protected IParseResult doParse(String ruleName, CharStream in, NodeModelBuilder builder,
int initialLookAhead) {
IParseResult result = super.doParse(ruleName, in, builder, initialLookAhead);
- // TODO enable this check via preferences in internal version.
- // if (isNonProto2(result)) {
- // return new ParseResult(new NonProto2Protobuf(), result.getRootNode(), false);
- // }
+ if (settingsProvider.shouldCheckProto2Only() && isNotProto2(result)) {
+ return new ParseResult(new NonProto2Protobuf(), result.getRootNode(), false);
+ }
return result;
}
- private boolean isNonProto2(IParseResult result) {
+ private boolean isNotProto2(IParseResult result) {
if (!result.hasSyntaxErrors()) {
return false;
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/resource/ResourceServiceProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/resource/ResourceServiceProvider.java
index c87cb60..ed1cb45 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/resource/ResourceServiceProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/resource/ResourceServiceProvider.java
@@ -20,7 +20,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class ResourceServiceProvider extends ResourceServiceProviderImpl {
-
@Inject
public ResourceServiceProvider(IResourceServiceProvider.Registry registry, IResourceServiceProvider provider) {
super(registry, provider);
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/AstWalker.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/AstWalker.java
index b385be4..0ce0f45 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/AstWalker.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/AstWalker.java
@@ -27,7 +27,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
class AstWalker {
-
@Inject private ModelFinder modelFinder;
@Inject private Imports imports;
@Inject private Packages packages;
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 2d854f6..1c2c8d6 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
@@ -24,7 +24,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
class CustomOptionFieldScopeFinder {
-
@Inject private ModelFinder modelFinder;
@Inject private OptionFields optionFields;
@Inject private Options options;
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 eabf76f..22f2bfd 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
@@ -26,7 +26,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
class CustomOptionScopeFinder implements ScopeFinder {
-
@Inject private LocalNamesProvider localNamesProvider;
@Inject private ModelFinder modelFinder;
@Inject private QualifiedNameDescriptions qualifiedNamesDescriptions;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ExtensionRegistryProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ExtensionRegistryProvider.java
index 5357c24..d779190 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ExtensionRegistryProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ExtensionRegistryProvider.java
@@ -18,7 +18,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
@Singleton public class ExtensionRegistryProvider implements Provider<IExtensionRegistry> {
-
@Override public IExtensionRegistry get() {
return Platform.getExtensionRegistry();
}
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 bce1500..18a735b 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
@@ -24,7 +24,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
class FieldNotationScopeFinder {
-
@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/IFileUriResolver.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/IFileUriResolver.java
index e2337cf..8482bf9 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/IFileUriResolver.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/IFileUriResolver.java
@@ -18,8 +18,8 @@
*
* @author alruiz@google.com (Alex Ruiz)
*/
-@ImplementedBy(NullFileUriResolver.class) public interface IFileUriResolver {
-
+@ImplementedBy(NullFileUriResolver.class)
+public interface IFileUriResolver {
/**
* Resolves the given 'import' URI.
* @param importUri the 'import' URI.
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 46f9693..0b8cb63 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
@@ -23,7 +23,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
class LiteralDescriptions {
-
Collection<IEObjectDescription> literalsOf(Enum anEnum) {
if (anEnum == null) {
return emptyList();
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 81f731b..9cdd03c 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
@@ -22,7 +22,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
class NativeOptionDescriptions {
-
@Inject private ProtoDescriptorProvider descriptorProvider;
Collection<IEObjectDescription> sources(AbstractOption option) {
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/OptionType.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/OptionType.java
index ad22ddb..9b40452 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/OptionType.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/OptionType.java
@@ -20,9 +20,8 @@
* @author alruiz@google.com (Alex Ruiz)
*/
enum OptionType {
-
- FILE("FileOptions"), MESSAGE("MessageOptions"), FIELD("FieldOptions"), ENUM("EnumOptions"), LITERAL(
- "EnumValueOptions"), SERVICE("ServiceOptions"), RPC("MethodOptions");
+ FILE("FileOptions"), MESSAGE("MessageOptions"), FIELD("FieldOptions"), ENUM("EnumOptions"),
+ LITERAL("EnumValueOptions"), SERVICE("ServiceOptions"), RPC("MethodOptions");
private static final Map<Class<?>, OptionType> OPTION_TYPES_BY_CONTAINER = new HashMap<Class<?>, OptionType>();
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/PackageIntersectionDescriptions.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/PackageIntersectionDescriptions.java
index 60b2ca3..5163a9f 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/PackageIntersectionDescriptions.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/PackageIntersectionDescriptions.java
@@ -25,7 +25,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
class PackageIntersectionDescriptions {
-
@Inject private Packages packages;
@Inject private QualifiedNames qualifiedNames;
@Inject private IQualifiedNameProvider nameProvider;
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 f18dbc6..83c3a7e 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
@@ -38,7 +38,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtoDescriptor {
-
private static final Map<String, OptionType> OPTION_DEFINITION_BY_NAME = new HashMap<String, OptionType>();
static {
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptorProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptorProvider.java
index b3274a5..a7887bc 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptorProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtoDescriptorProvider.java
@@ -27,7 +27,6 @@
* @author Alex Ruiz
*/
@Singleton public class ProtoDescriptorProvider {
-
private static final String EXTENSION_ID = "com.google.eclipse.protobuf.descriptorSource";
@Inject private IParser parser;
@@ -94,7 +93,7 @@
if (descriptorInfos == null) {
descriptorInfos = new LinkedHashMap<String, URI>();
add(defaultDescriptorInfo());
- add(additionalDescriptorInfo());
+ add(descriptorInfoFromExtensionPoint());
}
}
}
@@ -104,10 +103,10 @@
return new ProtoDescriptorInfo("google/protobuf/descriptor.proto", location);
}
- private ProtoDescriptorInfo additionalDescriptorInfo() {
+ private ProtoDescriptorInfo descriptorInfoFromExtensionPoint() {
IConfigurationElement[] config = registry.getConfigurationElementsFor(EXTENSION_ID);
if (config == null) {
- return defaultDescriptorInfo();
+ return null;
}
for (IConfigurationElement e : config) {
ProtoDescriptorInfo info = descriptorInfo(e);
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufImportUriResolver.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufImportUriResolver.java
index 0a4f851..103ff5d 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufImportUriResolver.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ProtobufImportUriResolver.java
@@ -26,7 +26,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufImportUriResolver extends ImportUriResolver {
-
@Inject private IFileUriResolver delegate;
/**
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 1bfbb39..4f02630 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
@@ -31,7 +31,6 @@
* @see <a href="http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping">Xtext Scoping</a>
*/
public class ProtobufScopeProvider extends AbstractDeclarativeScopeProvider implements Scoping {
-
private static final boolean DO_NOT_IGNORE_CASE = false;
@Inject private AstWalker astWalker;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/QualifiedNameDescriptions.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/QualifiedNameDescriptions.java
index e9a14d7..bebb638 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/QualifiedNameDescriptions.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/QualifiedNameDescriptions.java
@@ -24,7 +24,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
class QualifiedNameDescriptions {
-
@Inject private IProtobufQualifiedNameProvider nameProvider;
@Inject private QualifiedNames qualifiedNames;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ScopeFinder.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ScopeFinder.java
index cc62372..62a573b 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ScopeFinder.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/ScopeFinder.java
@@ -19,7 +19,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
interface ScopeFinder {
-
Collection<IEObjectDescription> imported(Package fromImporter, Package fromImported, Object target, Object criteria);
Collection<IEObjectDescription> inDescriptor(Import anImport, Object criteria);
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/Scoping.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/Scoping.java
index b5659a3..eca4181 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/Scoping.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/Scoping.java
@@ -18,7 +18,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public interface Scoping {
-
Collection<IEObjectDescription> allPossibleTypesFor(MessageField field);
Collection<IEObjectDescription> allPossibleTypesFor(TypeExtension extension);
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/TypeScopeFinder.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/TypeScopeFinder.java
index a36eae3..02472f2 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/TypeScopeFinder.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/scoping/TypeScopeFinder.java
@@ -26,7 +26,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
class TypeScopeFinder implements ScopeFinder {
-
@Inject private PackageIntersectionDescriptions packageIntersectionDescriptions;
@Inject private ProtoDescriptorProvider descriptorProvider;
@Inject private LocalNamesProvider localNamesProvider;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Closeables.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Closeables.java
index 88a32ba..466b5cd 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Closeables.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Closeables.java
@@ -16,7 +16,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class Closeables {
-
/**
* Invokes {@code close()} on the given <code>{@link Closeable}</code>, ignoring any thrown exceptions.
* @param c the given {@code Closeable}.
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/CommonWords.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/CommonWords.java
index b74a539..934022e 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/CommonWords.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/CommonWords.java
@@ -12,7 +12,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public final class CommonWords {
-
private static final String SPACE = " ";
/**
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Encodings.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Encodings.java
index f3cc3f8..8357edc 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Encodings.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Encodings.java
@@ -14,7 +14,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public final class Encodings {
-
public static final String UTF_8 = "UTF-8";
private Encodings() {}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Objects.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Objects.java
index 6b8b0b6..254c314 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Objects.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Objects.java
@@ -14,7 +14,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public final class Objects {
-
/** Prime number used to calculate the hash code of objects. */
public static final int HASH_CODE_PRIME = 31;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Strings.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Strings.java
index 0dc138f..59867db 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Strings.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Strings.java
@@ -14,7 +14,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public final class Strings {
-
/**
* Returns the given {@code String} in double quotes.
* @param s the given {@code String}, may be {@code null}.
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/SystemProperties.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/SystemProperties.java
index fa18ab6..43c909b 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/SystemProperties.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/SystemProperties.java
@@ -14,7 +14,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public final class SystemProperties {
-
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
public static String lineSeparator() {
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 821ed43..4f7bbfc 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
@@ -24,7 +24,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class DataTypeValidator extends AbstractDeclarativeValidator {
-
public static final String EXPECTED_BOOL_ERROR = "expectedBool";
public static final String EXPECTED_STRING_ERROR = "expectedString";
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ImportValidator.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ImportValidator.java
index 3f03fb9..70b921e 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ImportValidator.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ImportValidator.java
@@ -29,7 +29,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class ImportValidator extends AbstractDeclarativeValidator {
-
@Inject private ModelFinder finder;
@Inject private Protobufs protobufs;
@Inject private Resources resources;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/Messages.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/Messages.java
index e9afea3..abfff65 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/Messages.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/Messages.java
@@ -14,7 +14,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class Messages extends NLS {
-
public static String expectedFieldName;
public static String expectedFieldNumber;
public static String expectedIdentifier;
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
index 0f3a906..c948992 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufJavaValidator.java
@@ -31,7 +31,6 @@
*/
@ComposedChecks(validators = { DataTypeValidator.class, ImportValidator.class }) public class ProtobufJavaValidator
extends AbstractProtobufJavaValidator {
-
public static final String SYNTAX_IS_NOT_PROTO2_ERROR = "syntaxIsNotProto2";
public static final String INVALID_FIELD_TAG_NUMBER_ERROR = "invalidFieldTagNumber";
public static final String MORE_THAN_ONE_PACKAGE_ERROR = "moreThanOnePackage";
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufResourceValidator.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufResourceValidator.java
index 7583cb0..f161e5a 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufResourceValidator.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufResourceValidator.java
@@ -37,7 +37,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufResourceValidator extends ResourceValidatorImpl {
-
private static final Logger log = Logger.getLogger(ProtobufResourceValidator.class);
@Override public List<Issue> validate(Resource resource, CheckMode mode, CancelIndicator indicator) {
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufSyntaxErrorMessageProvider.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufSyntaxErrorMessageProvider.java
index 34d2f36..49e94ce 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufSyntaxErrorMessageProvider.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/validation/ProtobufSyntaxErrorMessageProvider.java
@@ -23,7 +23,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufSyntaxErrorMessageProvider extends SyntaxErrorMessageProvider {
-
@Override public SyntaxErrorMessage getSyntaxErrorMessage(IParserErrorContext context) {
String message = context.getDefaultMessage();
EObject currentContext = context.getCurrentContext();