Code cleanup.
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 1dfcd33..bc3a913 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
@@ -1,10 +1,9 @@
/*
* 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
- *
+ *
+ * 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;
@@ -17,7 +16,7 @@
import org.eclipse.xtext.scoping.impl.ImportUriResolver;
import org.eclipse.xtext.validation.IResourceValidator;
-import com.google.eclipse.protobuf.conversion.*;
+import com.google.eclipse.protobuf.conversion.ProtobufTerminalConverters;
import com.google.eclipse.protobuf.linking.ProtobufResource;
import com.google.eclipse.protobuf.naming.ProtobufQualifiedNameProvider;
import com.google.eclipse.protobuf.parser.Proto2OnlyParser;
@@ -27,8 +26,7 @@
import com.google.inject.Binder;
/**
- * Use this class to register components to be used at runtime / without the
- * Equinox extension registry.
+ * 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 {
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 d061543..21c9eb4 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
@@ -13,8 +13,7 @@
*/
public class ProtobufStandaloneSetup extends ProtobufStandaloneSetupGenerated {
- public static void doSetup() {
- new ProtobufStandaloneSetup().createInjectorAndDoEMFRegistration();
- }
+ 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 9a4086c..364cd70 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
@@ -9,7 +9,6 @@
package com.google.eclipse.protobuf.conversion;
import static java.lang.Double.*;
-import static java.lang.Double.NaN;
import static org.eclipse.xtext.util.Strings.isEmpty;
import org.eclipse.xtext.conversion.ValueConverterException;
@@ -28,7 +27,7 @@
* @param string the given input.
* @param node the parsed node including hidden parts.
* @return the new {@code float}.
- * @throws ValueConverterException if the given input is {@code null}, empty or does not represent a floating-point
+ * @throws ValueConverterException if the given input is {@code null}, empty or does not represent a floating-point
* number.
*/
@Override public Double toValue(String string, INode node) throws ValueConverterException {
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 42f3808..08d5813 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
@@ -10,12 +10,12 @@
import static org.eclipse.xtext.util.Strings.isEmpty;
+import java.math.BigInteger;
+
import org.eclipse.xtext.conversion.ValueConverterException;
import org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter;
import org.eclipse.xtext.nodemodel.INode;
-import java.math.BigInteger;
-
/**
* Converts hexadecimal numbers to {@code long}s.
*
@@ -24,7 +24,7 @@
public class HEXValueConverter extends AbstractLexerBasedConverter<Long> {
private static final String[] VALID_PREFIXES = { "0x", "-0x", "0X", "-0x" };
-
+
/**
* Creates an {@code int} from the given input, if the given input represents an hexadecimal number.
* @param string the given input.
@@ -52,7 +52,7 @@
}
return false;
}
-
+
private String removeZeroX(String string) {
if (string.startsWith("-")) {
String withoutSign = string.substring(3, string.length());
@@ -60,7 +60,7 @@
}
return string.substring(2, string.length());
}
-
+
private ValueConverterException parsingError(String string, INode node) {
return parsingError(string, node, null);
}
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 e6a89ef..67f05f5 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.conversion;
@@ -18,7 +18,7 @@
/**
* Converts numbers to {@code long}s.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class LONGValueConverter extends AbstractLexerBasedConverter<Long> {
@@ -38,7 +38,7 @@
return parseAgain(string, node);
}
}
-
+
private Long parseAgain(String string, INode node) {
// error could be overflow, parse again with BigInteger.
try {
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 47f60ec..d613bdf 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
@@ -1,18 +1,18 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.conversion;
-import com.google.inject.Inject;
-
import org.eclipse.xtext.common.services.DefaultTerminalConverters;
import org.eclipse.xtext.conversion.*;
+import com.google.inject.Inject;
+
/**
* @author alruiz@google.com (Alex Ruiz)
*/
@@ -22,24 +22,20 @@
@Inject private HEXValueConverter hexValueConverter;
@Inject private LONGValueConverter longValueConverter;
@Inject private STRINGValueConverter stringValueConverter;
-
- @ValueConverter(rule = "DOUBLE")
- public IValueConverter<Double> DOUBLE() {
+
+ @ValueConverter(rule = "DOUBLE") public IValueConverter<Double> DOUBLE() {
return doubleValueConverter;
}
-
- @ValueConverter(rule = "HEX")
- public IValueConverter<Long> HEX() {
+
+ @ValueConverter(rule = "HEX") public IValueConverter<Long> HEX() {
return hexValueConverter;
}
-
- @ValueConverter(rule = "LONG")
- public IValueConverter<Long> LONG() {
+
+ @ValueConverter(rule = "LONG") public IValueConverter<Long> LONG() {
return longValueConverter;
}
- @ValueConverter(rule = "STRING")
- @Override public IValueConverter<String> STRING() {
+ @ValueConverter(rule = "STRING") @Override public IValueConverter<String> STRING() {
return stringValueConverter;
}
}
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 e3af982..591efb7 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.conversion;
@@ -19,15 +19,14 @@
/**
* Converts multi-line strings to {@code String}s.
- *
+ *
* @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) {
+ @Override protected String toEscapedString(String value) {
if (value == null) return null;
return '"' + convertToJavaString(removeLineBreaksFrom(value), false) + '"';
}
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 c49fbaf..b91e8e2 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
@@ -1,9 +1,8 @@
/*
* 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
+ * 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
*/
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 353ea83..69889d4 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
@@ -19,14 +19,12 @@
// looking for. The code was too complicated and if the grammar changed for some reason, we had to change our
// implementation anyway.
-
BOOL("bool"), BYTES("bytes"), CLOSING_BRACKET("]"), CLOSING_CURLY_BRACKET("}"), DEFAULT("default"), DOUBLE("double"),
EQUAL("="), FALSE("false"), FIXED32("fixed32"), FIXED64("fixed64"), FLOAT("float"), INT32("int32"), INT64("int64"),
NAN("nan"), OPENING_BRACKET("["), OPENING_CURLY_BRACKET("{"), SEMICOLON(";"), SFIXED32("sfixed32"),
SFIXED64("sfixed64"), STRING("string"), SYNTAX("syntax"), TRUE("true"), SINT32("sint32"), SINT64("sint64"),
UINT32("unit32"), UINT64("uint64");
-
private final String value;
private CommonKeyword(String value) {
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 770fa44..5220657 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
@@ -1,9 +1,9 @@
/*
* 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.grammar;
@@ -21,16 +21,14 @@
*
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class Keywords {
+@Singleton public class Keywords {
private final Set<String> keywords;
- @Inject
- public Keywords(IGrammarAccess grammarAccess) {
+ @Inject public Keywords(IGrammarAccess grammarAccess) {
keywords = getAllKeywords(grammarAccess.getGrammar());
}
-
+
/**
* Indicates whether the given {@code String} is a keyword or not.
* @param s the given {@code String}.
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/ValidSyntax.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/ValidSyntax.java
index c57cf8c..f82e527 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/ValidSyntax.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/grammar/ValidSyntax.java
@@ -1,9 +1,9 @@
/*
* 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.grammar;
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 2a3d2d6..0c9cd7f 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
@@ -1,10 +1,9 @@
/*
* 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
- *
+ *
+ * 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.linking;
@@ -17,7 +16,7 @@
/**
* <code>{@link Diagnostic}</code> that supports appending text to its message.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufDiagnostic extends AbstractDiagnostic {
@@ -29,7 +28,9 @@
public ProtobufDiagnostic(String code, String[] data, String message, INode node) {
validate(data);
- if (node == null) throw new NullPointerException("node should not be null");
+ if (node == null) {
+ throw new NullPointerException("node should not be null");
+ }
this.code = code;
this.data = copyOf(data, data.length);
this.message = new StringBuilder();
@@ -69,7 +70,7 @@
public void appendToMessage(String s) {
message.append(s);
}
-
+
@Override public int hashCode() {
final int prime = 31;
int result = 1;
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 f2f5d4c..047baf8 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
@@ -1,9 +1,8 @@
/*
* 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
+ * 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
*/
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/FieldOptions.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/FieldOptions.java
index 59641d5..2567562 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/FieldOptions.java
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/model/util/FieldOptions.java
@@ -18,8 +18,7 @@
*
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class FieldOptions {
+@Singleton public class FieldOptions {
private @Inject OptionFields optionFields;
@@ -46,39 +45,45 @@
}
/**
- * 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.
+ * 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.
+ * @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.
@@ -97,15 +102,16 @@
}
/**
- * Returns the last field of the given <code>{@link CustomFieldOption}</code>.
- * In the following example
+ * 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.
+ * found.
*/
public IndexedElement sourceOfLastFieldIn(CustomFieldOption option) {
List<OptionField> fields = option.getFields();
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 95bcc68..525bead 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
@@ -23,8 +23,7 @@
*
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class INodes {
+@Singleton public class INodes {
/**
* Returns the first node that was used to assign values to the given feature for 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 4fbe746..1341247 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
@@ -8,19 +8,18 @@
*/
package com.google.eclipse.protobuf.model.util;
+import org.eclipse.emf.common.util.URI;
+
import com.google.eclipse.protobuf.protobuf.Import;
import com.google.eclipse.protobuf.scoping.ProtoDescriptorProvider;
import com.google.inject.*;
-import org.eclipse.emf.common.util.URI;
-
/**
* Utility methods related to imports.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class Imports {
+@Singleton public class Imports {
@Inject private ProtoDescriptorProvider descriptorProvider;
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 a131513..d01d4cd 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
@@ -8,29 +8,28 @@
*/
package com.google.eclipse.protobuf.model.util;
-import com.google.eclipse.protobuf.protobuf.*;
-import com.google.inject.*;
-
-import org.eclipse.emf.ecore.*;
-
-import java.util.*;
-
import static com.google.eclipse.protobuf.protobuf.ProtobufPackage.Literals.*;
import static java.lang.Math.max;
import static java.util.Collections.emptyList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.*;
+
+import com.google.eclipse.protobuf.protobuf.*;
+import com.google.inject.Singleton;
+
/**
* Utility methods related to <code>{@link IndexedElement}</code>s.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class IndexedElements {
+@Singleton public class IndexedElements {
/**
* Returns the name of the given <code>{@link IndexedElement}</code>.
* @param e the given {@code IndexedElement}.
- * @return the name of the given {@code IndexedElement}, or {@code null} if the given {@code IndexedElement} is
+ * @return the name of the given {@code IndexedElement}, or {@code null} if the given {@code IndexedElement} is
* {@code null}.
*/
public String nameOf(IndexedElement e) {
@@ -48,29 +47,29 @@
/**
* Returns the name of the given <code>{@link IndexedElement}</code>.
* @param e the given {@code IndexedElement}.
- * @return the name of the given {@code IndexedElement}, or {@code Long.MIN_VALUE} if the given {@code IndexedElement}
- * is {@code null}..
+ * @return the name of the given {@code IndexedElement}, or {@code Long.MIN_VALUE} if the given {@code IndexedElement}
+ * is {@code null}.
*/
public long indexOf(IndexedElement e) {
if (e == null) return Long.MIN_VALUE;
- return (e instanceof Group) ? ((Group) e).getIndex() : ((MessageField) e).getIndex();
+ return (e instanceof Group) ? ((Group) e).getIndex() : ((MessageField) e).getIndex();
}
-
+
/**
* Returns the "index" feature of the given <code>{@link IndexedElement}</code>.
* @param e the given {@code IndexedElement}.
- * @return the "index" feature of the given {@code IndexedElement}, or {@code null} if the given
+ * @return the "index" feature of the given {@code IndexedElement}, or {@code null} if the given
* {@code IndexedElement} is {@code null}.
*/
public EStructuralFeature indexFeatureOf(IndexedElement e) {
if (e == null) return null;
- return (e instanceof Group) ? GROUP__INDEX : MESSAGE_FIELD__INDEX;
+ return (e instanceof Group) ? GROUP__INDEX : MESSAGE_FIELD__INDEX;
}
-
+
/**
* Returns the options of the given <code>{@link IndexedElement}</code>.
* @param e the given {@code IndexedElement}.
- * @return the options of the given {@code IndexedElement}, or an empty list if the given {@code IndexedElement} is
+ * @return the options of the given {@code IndexedElement}, or an empty list if the given {@code IndexedElement} is
* {@code null}.
*/
public List<FieldOption> fieldOptionsOf(IndexedElement e) {
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 16df608..cd85958 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
@@ -1,9 +1,9 @@
/*
* 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;
@@ -17,11 +17,10 @@
/**
* Utility methods related to <code>{@link MessageField}</code>s.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class MessageFields {
+@Singleton public class MessageFields {
/**
* Indicates whether the modifier of the given field is <code>{@link Modifier#OPTIONAL}</code>.
@@ -33,9 +32,9 @@
}
/**
- * Indicates whether the type of the given field is primitive. Primitive types include: {@code double},
- * {@code float}, {@code int32}, {@code int64}, {@code uint32}, {@code uint64}, {@code sint32}, {@code sint64},
- * {@code fixed32}, {@code fixed64}, {@code sfixed32}, {@code sfixed64} and {@code bool}.
+ * Indicates whether the type of the given field is primitive. Primitive types include: {@code double}, {@code float},
+ * {@code int32}, {@code int64}, {@code uint32}, {@code uint64}, {@code sint32}, {@code sint64}, {@code fixed32},
+ * {@code fixed64}, {@code sfixed32}, {@code sfixed64} and {@code bool}.
* @param field the given field.
* @return {@code true} if the type of the given field is primitive, {@code false} otherwise.
*/
@@ -101,7 +100,7 @@
return isScalarType(field, FIXED32, FIXED64, UINT32, UINT64);
}
- private boolean isScalarType(MessageField field, CommonKeyword...scalarNames) {
+ private boolean isScalarType(MessageField field, CommonKeyword... scalarNames) {
TypeLink link = field.getType();
if (link instanceof ScalarTypeLink) {
String typeName = ((ScalarTypeLink) link).getTarget().getName();
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 ef43699..bdc18cc 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
@@ -12,10 +12,7 @@
import static org.eclipse.emf.ecore.util.EcoreUtil.getAllContents;
import static org.eclipse.xtext.EcoreUtil2.getAllContentsOfType;
-import com.google.eclipse.protobuf.protobuf.*;
-import com.google.eclipse.protobuf.protobuf.Enum;
-import com.google.eclipse.protobuf.protobuf.Package;
-import com.google.inject.Singleton;
+import java.util.*;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
@@ -23,16 +20,18 @@
import org.eclipse.xtext.parser.IParseResult;
import org.eclipse.xtext.resource.XtextResource;
-import java.util.*;
+import com.google.eclipse.protobuf.protobuf.*;
+import com.google.eclipse.protobuf.protobuf.Enum;
+import com.google.eclipse.protobuf.protobuf.Package;
+import com.google.inject.Singleton;
/**
* Utility methods to find elements in a parser proto file.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class ModelFinder {
-
+@Singleton public class ModelFinder {
+
/**
* Returns all the <strong>local</strong> extensions of the given message.
* @param message the given message.
@@ -41,7 +40,7 @@
public Collection<TypeExtension> localExtensionsOf(Message message) {
return extensionsOf(message, rootOf(message));
}
-
+
public Collection<TypeExtension> extensionsOf(Message message, Protobuf root) {
Set<TypeExtension> extensions = new HashSet<TypeExtension>();
for (TypeExtension extension : getAllContentsOfType(root, TypeExtension.class)) {
@@ -50,7 +49,7 @@
}
return extensions;
}
-
+
/**
* Returns the message from the given extension.
* @param extension the given extension.
@@ -69,20 +68,24 @@
* @return the message type of the given field or {@code null} if the type of the given field is not message.
*/
public Message messageTypeOf(MessageField field) {
- ComplexType type = typeOf(field);
- return (type instanceof Message) ? (Message) type : null;
+ return fieldType(field, Message.class);
}
-
+
/**
* Returns the enum type of the given field, only if the type of the given field is an enum.
* @param field the given field.
* @return the enum type of the given field or {@code null} if the type of the given field is not enum.
*/
public Enum enumTypeOf(MessageField field) {
- ComplexType type = typeOf(field);
- return (type instanceof Enum) ? (Enum) type : null;
+ return fieldType(field, Enum.class);
}
-
+
+ private <T extends ComplexType> T fieldType(MessageField field, Class<T> typeClazz) {
+ ComplexType type = typeOf(field);
+ if (typeClazz.isInstance(type)) return typeClazz.cast(type);
+ return null;
+ }
+
/**
* Returns the type of the given field.
* @param field the given field.
@@ -90,8 +93,10 @@
*/
public ComplexType typeOf(MessageField field) {
TypeLink link = field.getType();
- if (!(link instanceof ComplexTypeLink)) return null;
- return ((ComplexTypeLink) link).getTarget();
+ if (link instanceof ComplexTypeLink) {
+ return ((ComplexTypeLink) link).getTarget();
+ }
+ return null;
}
/**
@@ -101,8 +106,7 @@
*/
public ScalarType scalarTypeOf(MessageField p) {
TypeLink link = (p).getType();
- if (link instanceof ScalarTypeLink)
- return ((ScalarTypeLink) link).getTarget();
+ if (link instanceof ScalarTypeLink) return ((ScalarTypeLink) link).getTarget();
return null;
}
@@ -110,12 +114,14 @@
* Returns the package of the proto file containing the given object.
* @param o the given object.
* @return the package of the proto file containing the given object or {@code null} if the proto file does not have a
- * package.
+ * package.
*/
public Package packageOf(EObject o) {
Protobuf root = rootOf(o);
for (ProtobufElement e : root.getElements()) {
- if (e instanceof Package) return (Package) e;
+ if (e instanceof Package) {
+ return (Package) e;
+ }
}
return null;
}
@@ -127,7 +133,9 @@
*/
public Protobuf rootOf(EObject o) {
EObject current = o;
- while (!(current instanceof Protobuf)) current = current.eContainer();
+ while (!(current instanceof Protobuf)) {
+ current = current.eContainer();
+ }
return (Protobuf) current;
}
@@ -139,7 +147,9 @@
public List<Import> importsIn(Protobuf root) {
List<Import> imports = new ArrayList<Import>();
for (ProtobufElement e : root.getElements()) {
- if (e instanceof Import) imports.add((Import) e);
+ if (e instanceof Import) {
+ imports.add((Import) e);
+ }
}
return unmodifiableList(imports);
}
@@ -152,7 +162,9 @@
public List<Import> publicImportsIn(Protobuf root) {
List<Import> imports = new ArrayList<Import>();
for (ProtobufElement e : root.getElements()) {
- if (e instanceof PublicImport) imports.add((Import) e);
+ if (e instanceof PublicImport) {
+ imports.add((Import) e);
+ }
}
return unmodifiableList(imports);
}
@@ -180,8 +192,10 @@
public Collection<MessageField> propertiesOf(Message message) {
List<MessageField> properties = new ArrayList<MessageField>();
- for (MessageElement e :message.getElements()) {
- if (e instanceof MessageField) properties.add((MessageField) e);
+ for (MessageElement e : message.getElements()) {
+ if (e instanceof MessageField) {
+ properties.add((MessageField) e);
+ }
}
return unmodifiableList(properties);
}
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 77bfc8a..1f8ea5f 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
@@ -1,9 +1,9 @@
/*
* 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;
@@ -16,8 +16,7 @@
*
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class OptionFields {
+@Singleton public class OptionFields {
/**
* Returns the field the given option field is referring to.
@@ -25,12 +24,8 @@
* @return the field the given option field is referring to, or {@code null} if one cannot be found.
*/
public IndexedElement sourceOf(OptionField field) {
- if (field instanceof MessageOptionField) {
- return ((MessageOptionField) field).getTarget();
- }
- if (field instanceof ExtensionOptionField) {
- return ((ExtensionOptionField) field).getTarget();
- }
+ if (field instanceof MessageOptionField) { return ((MessageOptionField) field).getTarget(); }
+ if (field instanceof ExtensionOptionField) { return ((ExtensionOptionField) field).getTarget(); }
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
index f1b2c5f..725623c 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
@@ -10,37 +10,40 @@
import static org.eclipse.xtext.util.Strings.isEmpty;
+import java.util.List;
+
import com.google.eclipse.protobuf.protobuf.*;
import com.google.inject.*;
-import java.util.List;
-
/**
* Utility methods related to <code>{@link Option}</code>.
*
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class Options {
+@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.
+ * 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;
+ * 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;
+ * 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}.
@@ -52,17 +55,18 @@
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;
+ * 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.
+ * @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();
@@ -70,11 +74,12 @@
}
/**
- * Returns the last field of the given <code>{@link CustomOption}</code>.
- * In the following example
+ * Returns the last field of the given <code>{@link CustomOption}</code>. In the following example
+ *
* <pre>
- * option (myOption).foo = true;
+ * 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.
@@ -85,7 +90,7 @@
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.
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 4e2f435..9dcfdc9 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
@@ -1,9 +1,9 @@
/*
* 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;
@@ -28,7 +28,7 @@
@Inject private final IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl();
/**
- * Indicates whether the given packages are "related." "Related" means that the names of the packages are equal or one
+ * Indicates whether the given packages are "related." "Related" means that the names of the packages are equal or one
* package is a sub-package of the other one.
* @param p1 package to verify against {@code p2}.
* @param p2 package to verify against {@code p1}.
@@ -43,7 +43,6 @@
return (isSubPackage(name1, name2));
}
-
private boolean isSubPackage(QualifiedName name1, QualifiedName name2) {
List<String> segments = name2.getSegments();
int segment2Count = segments.size();
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 bdf371a..57bf7e7 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
@@ -17,8 +17,7 @@
*
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class Protobufs {
+@Singleton public class Protobufs {
/**
* Indicates whether the given <code>{@link Protobuf}</code> is not {@code null} and has "proto2" syntax.
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 400ba72..5e8fc1f 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
@@ -1,9 +1,9 @@
/*
* 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;
@@ -19,17 +19,16 @@
*
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class QualifiedNames {
+@Singleton public class QualifiedNames {
public QualifiedName createFqn(List<String> segments) {
return QualifiedName.create(asArray(segments));
}
-
+
private String[] asArray(List<String> list) {
return list.toArray(new String[list.size()]);
}
-
+
public QualifiedName addLeadingDot(QualifiedName name) {
if (name.getFirstSegment().equals("")) return name;
List<String> segments = new ArrayList<String>();
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 4a91872..b6b16e5 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
@@ -1,37 +1,36 @@
/*
* 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
- *
+ *
+ * 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.emf.common.util.URI.createURI;
-import com.google.eclipse.protobuf.protobuf.Import;
-import com.google.inject.Inject;
-
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.*;
import org.eclipse.xtext.scoping.impl.ImportUriResolver;
+import com.google.eclipse.protobuf.protobuf.Import;
+import com.google.inject.Inject;
+
/**
* Utility methods related to <code>{@link Resource}</code>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class Resources {
@Inject private ImportUriResolver uriResolver;
-
+
/**
* Finds in the given <code>{@link ResourceSet}</code> the resource referred by the URI of the given import.
* @param anImport the given import.
* @param resourceSet a collection of resources.
- * @return the resource referred by the URI of the given import, or {@code null} is the given {@code ResourceSet} does
+ * @return the resource referred by the URI of the given import, or {@code null} is the given {@code ResourceSet} does
* not contain the resource.
*/
public Resource importedResource(Import anImport, ResourceSet resourceSet) {
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 35b12b9..274b8b0 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
@@ -1,9 +1,9 @@
/*
* 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.naming;
@@ -17,11 +17,11 @@
/**
* @author alruiz@google.com (Alex Ruiz)
*/
-@ImplementedBy(ProtobufQualifiedNameProvider.class)
-public interface IProtobufQualifiedNameProvider extends IQualifiedNameProvider {
+@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
+ * 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.
* @param e the given object.
* @return the qualified name of the given object, to be used in an option.
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 03340b4..2e4bc9f 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
@@ -1,9 +1,9 @@
/*
* 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.naming;
@@ -27,18 +27,20 @@
* Provides alternative qualified names for protobuf elements.
* <p>
* For example, given the following proto element:
+ *
* <pre>
* package test.alternative.names;
- *
+ *
* message Person {
* optional string name = 1;
- *
+ *
* enum PhoneType {
* HOME = 0;
* WORK = 1;
* }
* }
* </pre>
+ *
* The default qualified name for {@code PhoneType} is {@code alternative.names.Person.PhoneType}. The problem is that
* protoc also recognizes the following as qualified names:
* <ul>
@@ -51,7 +53,7 @@
* <p>
* This class provides the non-default qualified names recognized by protoc.
* </p>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class LocalNamesProvider {
@@ -67,11 +69,11 @@
public List<QualifiedName> names(EObject e) {
return allNames(e, DEFAULT);
}
-
+
public List<QualifiedName> namesForOption(EObject e) {
return allNames(e, OPTION);
}
-
+
private List<QualifiedName> allNames(final EObject e, final NamingUsage usage) {
Pair<EObject, String> key = pair(e, "localFqns");
return cache.get(key, e.eResource(), new Provider<List<QualifiedName>>() {
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 ba95742..1ec1323 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
@@ -20,8 +20,7 @@
* TODO test
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class NameResolver {
+@Singleton public class NameResolver {
public String nameOf(EObject o) {
if (o instanceof DefaultValueFieldOption) {
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 c1406d0..826c2ad 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
@@ -1,9 +1,9 @@
/*
* 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.naming;
@@ -19,14 +19,13 @@
*
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class Naming {
+@Singleton public class Naming {
@Inject private NameResolver nameResolver;
@Inject private Options options;
/**
- * Returns the name of the given object. If the name will be used for an option and if the given object is a
+ * Returns the name of the given object. If the name will be used for an option and if the given object is a
* <code>{@link Group}</code>, this method will return the name of the group in lower case.
* @param e the given object.
* @param usage indicates how the returned name will be used.
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 b455d55..7bacc62 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
@@ -1,9 +1,9 @@
/*
* 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.naming;
@@ -25,11 +25,11 @@
/**
* Provides fully-qualified names for protobuf elements.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
-public class ProtobufQualifiedNameProvider extends IQualifiedNameProvider.AbstractImpl
- implements IProtobufQualifiedNameProvider {
+public class ProtobufQualifiedNameProvider extends IQualifiedNameProvider.AbstractImpl implements
+ IProtobufQualifiedNameProvider {
@Inject private final IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl();
@Inject private final IResourceScopeCache cache = IResourceScopeCache.NullImpl.INSTANCE;
@@ -46,7 +46,7 @@
@Override public QualifiedName getFullyQualifiedNameForOption(EObject e) {
return getFullyQualifiedName(e, OPTION);
}
-
+
private QualifiedName getFullyQualifiedName(final EObject e, final NamingUsage usage) {
Pair<EObject, String> key = pair(e, "fqn");
return cache.get(key, e.eResource(), new Provider<QualifiedName>() {
@@ -58,9 +58,7 @@
while (current.eContainer() != null) {
current = current.eContainer();
QualifiedName parentsQualifiedName = getFullyQualifiedName(current, usage);
- if (parentsQualifiedName != null) {
- return parentsQualifiedName.append(qualifiedName);
- }
+ if (parentsQualifiedName != null) { return parentsQualifiedName.append(qualifiedName); }
}
return addPackage(e, qualifiedName);
}
@@ -68,8 +66,7 @@
}
private QualifiedName addPackage(EObject obj, QualifiedName qualifiedName) {
- if (qualifiedName == null || obj instanceof Package)
- return qualifiedName;
+ if (qualifiedName == null || obj instanceof Package) return qualifiedName;
Package p = finder.packageOf(obj);
if (p == null) return qualifiedName;
List<String> segments = packages.segmentsOf(p);
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 9b923c1..484d306 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
@@ -1,9 +1,8 @@
/*
* 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
+ * 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
*/
@@ -17,6 +16,6 @@
* @author alruiz@google.com (Alex Ruiz)
*/
public class NonProto2Protobuf extends ProtobufImpl {
-
+
NonProto2Protobuf() {}
}
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 5fc0fa0..400893e 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
@@ -1,10 +1,9 @@
/*
* 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
- *
+ *
+ * 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;
@@ -19,22 +18,19 @@
/**
* Parser that only parses protocol buffers with "proto2" syntax, older syntax is ignored completely.
- *
+ *
* @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 '<'" };
+ 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 '<'" };
- @Override
- protected IParseResult doParse(String ruleName, CharStream in, NodeModelBuilder builder, int initialLookAhead) {
+ @Override protected IParseResult doParse(String ruleName, CharStream in, NodeModelBuilder builder,
+ int initialLookAhead) {
IParseResult result = super.doParse(ruleName, in, builder, initialLookAhead);
// TODO ignore this check via preferences in open source version.
- if (isNonProto2(result)) {
- return new ParseResult(new NonProto2Protobuf(), result.getRootNode(), false);
- }
+ if (isNonProto2(result)) { return new ParseResult(new NonProto2Protobuf(), result.getRootNode(), false); }
return result;
}
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 0a70a85..7d2c5a8 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
@@ -1,27 +1,28 @@
/*
* 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.resource;
-import com.google.inject.Inject;
-
import org.eclipse.emf.ecore.*;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.xtext.resource.*;
import org.eclipse.xtext.resource.IGlobalServiceProvider.ResourceServiceProviderImpl;
+import org.eclipse.xtext.resource.*;
+
+import com.google.inject.Inject;
/**
* @author alruiz@google.com (Alex Ruiz)
*/
public class ResourceServiceProvider extends ResourceServiceProviderImpl {
- @Inject public ResourceServiceProvider(IResourceServiceProvider.Registry registry, IResourceServiceProvider provider) {
+ @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 aab7e7c..698c656 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
@@ -113,8 +113,8 @@
return packages.areRelated(aPackage, p);
}
- private Collection<IEObjectDescription> imported(Package fromImporter, Package fromImported,
- Resource resource, ScopeFinder scopeFinder, Object criteria) {
+ private Collection<IEObjectDescription> imported(Package fromImporter, Package fromImported, Resource resource,
+ ScopeFinder scopeFinder, Object criteria) {
Set<IEObjectDescription> descriptions = new HashSet<IEObjectDescription>();
TreeIterator<Object> contents = getAllContents(resource, true);
while (contents.hasNext()) {
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 00ab0d6..dbfc52a 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
@@ -11,14 +11,14 @@
import static java.util.Collections.*;
import static org.eclipse.xtext.resource.EObjectDescription.create;
-import com.google.eclipse.protobuf.model.util.*;
-import com.google.eclipse.protobuf.protobuf.*;
-import com.google.inject.*;
+import java.util.*;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.resource.IEObjectDescription;
-import java.util.*;
+import com.google.eclipse.protobuf.model.util.*;
+import com.google.eclipse.protobuf.protobuf.*;
+import com.google.inject.*;
/**
* @author alruiz@google.com (Alex Ruiz)
@@ -69,7 +69,7 @@
return emptySet();
}
- private IndexedElement referredField(OptionField field, List<OptionField> allFields,
+ private IndexedElement referredField(OptionField field, List<OptionField> allFields,
Provider<IndexedElement> provider) {
OptionField previous = null;
boolean isFirstField = true;
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 7089de5..f27edd7 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
@@ -64,8 +64,7 @@
}
private OptionType optionTypeFrom(Object criteria) {
- if (!(criteria instanceof OptionType))
- throw new IllegalArgumentException("Search criteria should be OptionType");
+ if (!(criteria instanceof OptionType)) throw new IllegalArgumentException("Search criteria should be OptionType");
return (OptionType) criteria;
}
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 c656fac..f4bfdea 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
@@ -17,8 +17,7 @@
*
* @author alruiz@google.com (Alex Ruiz)
*/
-@Singleton
-public class ExtensionRegistryProvider implements Provider<IExtensionRegistry> {
+@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 aabaaa8..19a9c3a 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
@@ -64,7 +64,7 @@
FieldName name = field.getName();
return (name == null) ? null : name.getTarget();
}
-
+
private Collection<IEObjectDescription> propertiesInTypeOf(MessageField field) {
Set<IEObjectDescription> descriptions = new HashSet<IEObjectDescription>();
Message fieldType = modelFinder.messageTypeOf(field);
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 fdaac22..afb2052 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
@@ -15,11 +15,10 @@
/**
* Resolves "import" URIs.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
-@ImplementedBy(NullFileUriResolver.class)
-public interface IFileUriResolver {
+@ImplementedBy(NullFileUriResolver.class) public interface IFileUriResolver {
/**
* Resolves the given '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 b91dbe8..ddeac6d 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
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 4af132a..0a499ea 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
@@ -25,16 +25,16 @@
class NativeOptionDescriptions {
@Inject private ProtoDescriptorProvider descriptorProvider;
-
- Collection <IEObjectDescription> sources(NativeOption option) {
+
+ Collection<IEObjectDescription> sources(NativeOption option) {
return allSources(option);
}
- Collection <IEObjectDescription> sources(NativeFieldOption option) {
+ Collection<IEObjectDescription> sources(NativeFieldOption option) {
return allSources(option);
}
- private Collection <IEObjectDescription> allSources(EObject option) {
+ private Collection<IEObjectDescription> allSources(EObject option) {
ProtoDescriptor descriptor = descriptorProvider.primaryDescriptor();
Collection<MessageField> optionSources = descriptor.availableOptionsFor(option.eContainer());
if (optionSources.isEmpty()) return emptyList();
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 cb654fc..0273084 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
@@ -21,8 +21,8 @@
*/
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 49a36fd..318d115 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
@@ -1,9 +1,8 @@
/*
* 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
+ * 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
*/
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 0e59191..19c7b43 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
@@ -34,7 +34,7 @@
/**
* Contains the elements from descriptor.proto (provided with protobuf's library.)
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtoDescriptor {
@@ -134,11 +134,11 @@
/**
* Returns the options available for the given option or option container. The returned options are defined in
- * {@code google/protobuf/descriptor.proto} (more details can be found
- * <a href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
+ * {@code google/protobuf/descriptor.proto} (more details can be found <a
+ * href=http://code.google.com/apis/protocolbuffers/docs/proto.html#options" target="_blank">here</a>.)
* @param o the given option or option container.
* @return the options available for the given option or option container, or an empty collection if the are not any
- * options available.
+ * options available.
*/
public Collection<MessageField> availableOptionsFor(EObject o) {
EObject target = o;
@@ -148,8 +148,7 @@
return optionsOfType(type);
}
- @VisibleForTesting
- Collection<MessageField> optionsOfType(OptionType type) {
+ @VisibleForTesting Collection<MessageField> optionsOfType(OptionType type) {
return unmodifiableCollection(optionsByType.get(type).values());
}
@@ -168,11 +167,10 @@
return (isEmpty(typeName)) ? null : enumByName(typeName.trim());
}
- @VisibleForTesting
- Enum enumByName(String name) {
+ @VisibleForTesting Enum enumByName(String name) {
return enumsByName.get(name);
}
-
+
/**
* Returns all types in descriptor.proto.
* @return all types in descriptor.proto.
@@ -193,8 +191,7 @@
return importUri;
}
- @VisibleForTesting
- MessageField option(String name, OptionType type) {
+ @VisibleForTesting MessageField option(String name, OptionType type) {
Map<String, MessageField> optionByName = optionsByType.get(type);
return (optionByName != null) ? optionByName.get(name) : null;
}
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 c1c47ed..897bb10 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
@@ -23,11 +23,10 @@
/**
* Provider of <code>{@link ProtoDescriptor}</code>s.
- *
+ *
* @author Alex Ruiz
*/
-@Singleton
-public class ProtoDescriptorProvider {
+@Singleton public class ProtoDescriptorProvider {
private static final String EXTENSION_ID = "com.google.eclipse.protobuf.descriptorSource";
@@ -123,9 +122,7 @@
String path = e.getAttribute("path");
if (isEmpty(path)) return null;
StringBuilder uri = new StringBuilder();
- uri.append("platform:/plugin/")
- .append(e.getContributor().getName()).append("/")
- .append(path);
+ uri.append("platform:/plugin/").append(e.getContributor().getName()).append("/").append(path);
return URI.createURI(uri.toString());
}
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 8c32dbf..320a2ed 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
@@ -19,10 +19,10 @@
* "platform:/resource/proto1.proto" is understood by EMF but not by protoc. The URI in the proto file needs to be
* simply "proto1.proto" for protoc to understand it.
* <p>
- * This {@link ImportUriResolver} adds "platform:/resource" to any URI if is not specified, so EMF can find the
- * imported resource.
+ * This {@link ImportUriResolver} adds "platform:/resource" to any URI if is not specified, so EMF can find the imported
+ * resource.
* </p>
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufImportUriResolver extends ImportUriResolver {
@@ -30,8 +30,8 @@
@Inject private IFileUriResolver delegate;
/**
- * If the given {@code EObject} is a <code>{@link Import}</code>, this method will add "platform:/resource" to the
- * URI of such import if not specified already.
+ * If the given {@code EObject} is a <code>{@link Import}</code>, this method will add "platform:/resource" to the URI
+ * of such import if not specified already.
* @param from the given element to resolve.
* @return the {@code String} representation of the given object's {@code URI}.
*/
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 28a1eb3..1883da8 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
@@ -25,9 +25,9 @@
/**
* Custom scoping description.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
- *
+ *
* @see <a href="http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping">Xtext Scoping</a>
*/
public class ProtobufScopeProvider extends AbstractDeclarativeScopeProvider implements Scoping {
@@ -46,12 +46,9 @@
@Inject private Options options;
@Inject private TypeScopeFinder typeScopeFinder;
- @SuppressWarnings("unused")
- public IScope scope_ComplexTypeLink_target(ComplexTypeLink link, EReference r) {
+ @SuppressWarnings("unused") public IScope scope_ComplexTypeLink_target(ComplexTypeLink link, EReference r) {
EObject c = link.eContainer();
- if (c instanceof MessageField) {
- return createScope(allPossibleTypesFor((MessageField) c));
- }
+ if (c instanceof MessageField) { return createScope(allPossibleTypesFor((MessageField) c)); }
Set<IEObjectDescription> descriptions = emptySet();
return createScope(descriptions);
}
@@ -60,8 +57,7 @@
return astWalker.traverseAst(field, typeScopeFinder, ComplexType.class);
}
- @SuppressWarnings("unused")
- public IScope scope_ExtensibleTypeLink_target(ExtensibleTypeLink link, EReference r) {
+ @SuppressWarnings("unused") public IScope scope_ExtensibleTypeLink_target(ExtensibleTypeLink link, EReference r) {
return createScope(extensibleTypesFor(link));
}
@@ -74,8 +70,7 @@
return astWalker.traverseAst(root, typeScopeFinder, ExtensibleType.class);
}
- @SuppressWarnings("unused")
- public IScope scope_MessageLink_target(MessageLink link, EReference r) {
+ @SuppressWarnings("unused") public IScope scope_MessageLink_target(MessageLink link, EReference r) {
return createScope(messagesFor(link));
}
@@ -88,8 +83,7 @@
return astWalker.traverseAst(root, typeScopeFinder, Message.class);
}
- @SuppressWarnings("unused")
- public IScope scope_LiteralLink_target(LiteralLink link, EReference r) {
+ @SuppressWarnings("unused") public IScope scope_LiteralLink_target(LiteralLink link, EReference r) {
EObject container = link.eContainer();
Enum anEnum = null;
if (container instanceof DefaultValueFieldOption) {
@@ -123,8 +117,7 @@
return createScope(literalDescriptions.literalsOf(anEnum));
}
- @SuppressWarnings("unused")
- public IScope scope_OptionSource_target(OptionSource source, EReference r) {
+ @SuppressWarnings("unused") public IScope scope_OptionSource_target(OptionSource source, EReference r) {
EObject c = source.eContainer();
if (c instanceof NativeOption) {
NativeOption option = (NativeOption) c;
@@ -164,8 +157,7 @@
return descriptions;
}
- @SuppressWarnings("unused")
- public IScope scope_OptionField_target(OptionField field, EReference r) {
+ @SuppressWarnings("unused") public IScope scope_OptionField_target(OptionField field, EReference r) {
return createScope(allPossibleSourcesOf(field));
}
@@ -174,16 +166,12 @@
EObject container = field.eContainer();
if (container instanceof CustomOption) {
CustomOption option = (CustomOption) container;
- if (field instanceof MessageOptionField) {
- return findSources(option, (MessageOptionField) field);
- }
+ if (field instanceof MessageOptionField) { return findSources(option, (MessageOptionField) field); }
return findSources(option, (ExtensionOptionField) field);
}
if (container instanceof CustomFieldOption) {
CustomFieldOption option = (CustomFieldOption) container;
- if (field instanceof MessageOptionField) {
- return findSources(option, (MessageOptionField) field);
- }
+ if (field instanceof MessageOptionField) { return findSources(option, (MessageOptionField) field); }
return findSources(option, (ExtensionOptionField) field);
}
return emptySet();
@@ -196,7 +184,7 @@
@Override public Collection<IEObjectDescription> allPossibleNormalFieldsOf(CustomFieldOption option) {
return findSources(option, (MessageOptionField) null);
}
-
+
@Override public Collection<IEObjectDescription> allPossibleExtensionFieldsOf(CustomOption option) {
return findSources(option, (ExtensionOptionField) null);
}
@@ -221,26 +209,21 @@
return customOptionFieldScopeFinder.findScope(option, field);
}
- @SuppressWarnings("unused")
- public IScope scope_FieldName_target(FieldName name, EReference r) {
+ @SuppressWarnings("unused") public IScope scope_FieldName_target(FieldName name, EReference r) {
return createScope(findSources(name));
}
private Collection<IEObjectDescription> findSources(FieldName name) {
ComplexValue value = container(name);
if (value == null) return emptySet();
- if (name instanceof NormalFieldName) {
- return allPossibleNamesOfNormalFieldsOf(value);
- }
+ if (name instanceof NormalFieldName) { return allPossibleNamesOfNormalFieldsOf(value); }
return allPossibleNamesOfExtensionFieldsOf(value);
}
private ComplexValue container(FieldName name) {
EObject container = name;
while (container != null) {
- if (container instanceof ComplexValue) {
- return (ComplexValue) container;
- }
+ if (container instanceof ComplexValue) { return (ComplexValue) container; }
container = container.eContainer();
}
return null;
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 7578cc1..51f60b4 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
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 e2f7cc0..488c53c 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
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 b35c088..212fad2 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
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 d50390c..7a8719b 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
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2011 Google Inc.
- *
+ *
* All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
* Public License v1.0 which accompanies this distribution, and is available at
- *
+ *
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.google.eclipse.protobuf.scoping;
@@ -31,7 +31,7 @@
@Inject private ProtoDescriptorProvider descriptorProvider;
@Inject private LocalNamesProvider localNamesProvider;
@Inject private QualifiedNameDescriptions qualifiedNamesDescriptions;
-
+
@Override public Collection<IEObjectDescription> imported(Package fromImporter, Package fromImported, Object target,
Object criteria) {
if (!isInstance(target, criteria)) return emptySet();
@@ -64,12 +64,12 @@
descriptions.addAll(qualifiedNamesDescriptions.qualifiedNames(e));
return descriptions;
}
-
+
private boolean isInstance(Object target, Object criteria) {
Class<?> targetType = targetTypeFrom(criteria);
return targetType.isInstance(target);
}
-
+
private Class<?> targetTypeFrom(Object criteria) {
if (criteria instanceof Class<?>) return (Class<?>) criteria;
throw new IllegalArgumentException("Search criteria should be Class<?>");
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 62f539d..a141bce 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
@@ -1,9 +1,9 @@
/*
* 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.util;
@@ -12,7 +12,7 @@
/**
* Utility methods related to <code>{@link Closeable}</code>s.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class Closeables {
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 4ad10b4..3405700 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
@@ -1,9 +1,9 @@
/*
* 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.util;
@@ -14,7 +14,7 @@
public final class CommonWords {
private static final String SPACE = " ";
-
+
/**
* Returns a single space.
* @return a single space.
@@ -22,6 +22,6 @@
public static String space() {
return SPACE;
}
-
+
private CommonWords() {}
}
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 f5e9e7d..6c2d8ac 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
@@ -1,9 +1,9 @@
/*
* 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.util;
@@ -16,6 +16,6 @@
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/Strings.java b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/util/Strings.java
index b909361..0c2c520 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
@@ -1,16 +1,16 @@
/*
* 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.util;
/**
* Utility methods related to {@code String}.s
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public final class Strings {
@@ -18,7 +18,7 @@
/**
* Returns the given {@code String} in double quotes.
* @param s the given {@code String}, may be {@code null}.
- * @return the given {@code String} in double quotes, or {@code null} if the given {@code String} is {@code null}.
+ * @return the given {@code String} in double quotes, or {@code null} if the given {@code String} is {@code null}.
*/
public static String quote(String s) {
if (s == null) return s;
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 01ee642..91f7260 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
@@ -1,9 +1,9 @@
/*
* 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.util;
@@ -16,10 +16,10 @@
public final class SystemProperties {
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
-
+
public static String lineSeparator() {
return LINE_SEPARATOR;
}
-
+
private SystemProperties() {}
}
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 dee2050..e0b764c 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
@@ -1,9 +1,9 @@
/*
* 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.validation;
@@ -43,7 +43,7 @@
}
}
- private void checkValueTypeMatchesFieldType(FieldOption option, MessageField field) {
+ private void checkValueTypeMatchesFieldType(FieldOption option, MessageField field) {
if (validateBool(option, field)) return;
if (validateFloatingPointNumber(option, field)) return;
if (validateInteger(option, field)) return;
@@ -100,7 +100,7 @@
}
throw new IllegalArgumentException(value + " does not belong to an integer type");
}
-
+
private boolean validateString(FieldOption option, MessageField field) {
if (!messageFields.isBytes(field) && !messageFields.isString(field)) return false;
Value value = option.getValue();
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 08f5396..99c8006 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
@@ -1,9 +1,9 @@
/*
* 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.validation;
@@ -25,7 +25,7 @@
/**
* Verifies that imports only refer to "proto2" files.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class ImportValidator extends AbstractDeclarativeValidator {
@@ -41,8 +41,7 @@
* validator creates warning markers for such imports.
* @param root the root containing the imports to check.
*/
- @Check
- public void checkNonProto2Imports(Protobuf root) {
+ @Check public void checkNonProto2Imports(Protobuf root) {
warnIfNonProto2ImportsFound(root.eResource());
}
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 ed62dc8..cbe6877 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
@@ -1,9 +1,9 @@
/*
* 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.validation;
@@ -39,5 +39,6 @@
Class<Messages> targetType = Messages.class;
NLS.initializeMessages(targetType.getName(), targetType);
}
+
private Messages() {}
}
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 7722c39..ae65427 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
@@ -1,9 +1,9 @@
/*
* 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.validation;
@@ -28,8 +28,8 @@
/**
* @author alruiz@google.com (Alex Ruiz)
*/
-@ComposedChecks(validators = { DataTypeValidator.class, ImportValidator.class })
-public class ProtobufJavaValidator extends AbstractProtobufJavaValidator {
+@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";
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 9704319..2328725 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
@@ -1,9 +1,9 @@
/*
* 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.validation;
@@ -33,7 +33,7 @@
/**
* Adds support for converting scoping errors into warnings if non-proto2 files are imported.
- *
+ *
* @author alruiz@google.com (Alex Ruiz)
*/
public class ProtobufResourceValidator extends ResourceValidatorImpl {
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 b22ad66..236aca8 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
@@ -27,15 +27,13 @@
@Override public SyntaxErrorMessage getSyntaxErrorMessage(IParserErrorContext context) {
String message = context.getDefaultMessage();
EObject currentContext = context.getCurrentContext();
- if (currentContext instanceof MessageField) message = mapToProtocMessage(message, (MessageField) currentContext);
+ if (currentContext instanceof MessageField) message = mapToProtocMessage(message, (MessageField) currentContext);
if (currentContext == null && message.contains("RULE_STRING")) return null;
return new SyntaxErrorMessage(message, SYNTAX_DIAGNOSTIC);
}
private String mapToProtocMessage(String message, MessageField field) {
- if (message.contains("RULE_ID") && field.getName() == null) {
- return expectedFieldName;
- }
+ if (message.contains("RULE_ID") && field.getName() == null) return expectedFieldName;
if (message.equals("mismatched input ';' expecting '='") && field.getIndex() == 0) {
return missingFieldNumber;
}