Code cleanup.
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/HEXValueConverter_toValue_withInvalidInput_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/HEXValueConverter_toValue_withInvalidInput_Test.java
index 7696359..7de5b56 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/HEXValueConverter_toValue_withInvalidInput_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/HEXValueConverter_toValue_withInvalidInput_Test.java
@@ -57,12 +57,6 @@
converter.toValue("0x", node);
}
- @Test public void should_throw_error_if_input_does_not_start_with_0x() {
- thrown.expect(ValueConverterException.class);
- thrown.expectMessage("Couldn't convert '65' to long.");
- converter.toValue("65", node);
- }
-
@Test public void should_throw_error_if_conversion_throws_NumberFormatException() {
try {
converter.toValue("0xZ", node);
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 1abde7b..a142e70 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
@@ -31,21 +31,13 @@
*/
public Long toValue(String string, INode node) throws ValueConverterException {
if (isEmpty(string)) throw new ValueConverterException("Couldn't convert empty string to long.", node, null);
- int length = string.length();
- if (length < 3) throw parsingError(string, node);
- if (!string.substring(0, 2).equalsIgnoreCase("0x")) throw parsingError(string, node);
- String val = string.substring(2, length);
try {
- return Long.parseLong(val, 16);
+ return Long.decode(string);
} catch (NumberFormatException e) {
throw parsingError(string, node, e);
}
}
- private ValueConverterException parsingError(String string, INode node) {
- return parsingError(string, node, null);
- }
-
private ValueConverterException parsingError(String string, INode node, Exception cause) {
return new ValueConverterException("Couldn't convert '" + string + "' to long.", node, cause);
}
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 443c974..2d3cc3f 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
@@ -22,8 +22,7 @@
import com.google.eclipse.protobuf.protobuf.*;
import com.google.eclipse.protobuf.protobuf.Package;
-import com.google.eclipse.protobuf.util.FieldOptions;
-import com.google.eclipse.protobuf.util.Properties;
+import com.google.eclipse.protobuf.util.*;
import com.google.inject.Inject;
/**
@@ -35,7 +34,11 @@
@Inject private ImportUriResolver uriResolver;
@Inject private IQualifiedNameProvider qualifiedNameProvider;
@Inject private Properties properties;
+ @Inject private ModelNodes nodes;
+ @Check public void checkComment(EObject o) {
+ }
+
@Check public void checkDefaultValueType(FieldOption option) {
if (!fieldOptions.isDefaultValueOption(option)) return;
Property property = (Property) option.eContainer();