Fixed: [Issue 165] Editor cannot parse unit64 value
18446744073709551615.
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/builder/protoc/ProtocMarkerFactory_createErrorIfNecessary_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/builder/protoc/ProtocMarkerFactory_createErrorIfNecessary_Test.java
index f081c72..090dae6 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/builder/protoc/ProtocMarkerFactory_createErrorIfNecessary_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/builder/protoc/ProtocMarkerFactory_createErrorIfNecessary_Test.java
@@ -9,7 +9,7 @@
package com.google.eclipse.protobuf.ui.builder.protoc;
import static com.google.eclipse.protobuf.junit.stubs.resources.MarkerStub.error;
-import static org.eclipse.xtext.ui.MarkerTypes.FAST_VALIDATION;
+import static com.google.eclipse.protobuf.ui.validation.ProtobufResourceUIValidatorExtension.EDITOR_CHECK;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
@@ -38,7 +38,7 @@
file = new FileStub();
file.setLocation(new Path("home/alex/protos/test1.proto"));
file.createMarker(PROTOC);
- fastValidationMarker = error(FAST_VALIDATION, "Expected field name.", 68);
+ fastValidationMarker = error(EDITOR_CHECK, "Expected field name.", 68);
file.addMarker(fastValidationMarker);
markerFactory = new ProtocMarkerFactory(file);
}
diff --git a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext
index d104050..42cff33 100644
--- a/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext
+++ b/com.google.eclipse.protobuf/src/com/google/eclipse/protobuf/Protobuf.xtext
@@ -236,7 +236,9 @@
target=DOUBLE;
terminal DOUBLE returns ecore::EDouble:
- (('-')? (NUMBER)* ('.' (NUMBER)+)? (('e'|'E')('-')? (NUMBER)+)?) | 'nan' | 'inf' | '-inf';
+ ('-')? (NUMBER)* ('.' (NUMBER)+)? |
+ ('-')? (NUMBER)+ (('e'|'E')('-')? (NUMBER)+) |
+ 'nan' | 'inf' | '-inf';
terminal NUMBER:
'0'..'9';
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 ee113a4..e6a89ef 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
@@ -33,6 +33,15 @@
@Override public Long toValue(String string, INode node) throws ValueConverterException {
if (isEmpty(string)) throw new ValueConverterException("Couldn't convert empty string to long.", node, null);
try {
+ return Long.parseLong(string, 10);
+ } catch (NumberFormatException e) {
+ return parseAgain(string, node);
+ }
+ }
+
+ private Long parseAgain(String string, INode node) {
+ // error could be overflow, parse again with BigInteger.
+ try {
BigInteger value = new BigInteger(string, 10);
long longValue = value.longValue();
return longValue != -1 ? longValue : 1L;