In progress: [Issue 164] Validate that the default value of a field
matches the type of such field.

Changed overflow value from -1L to 1L in HexValueConverter. This way,
validation of negative value for unsigned integers won't fail.
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/HEXValueConverter_toValue_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/HEXValueConverter_toValue_Test.java
index aeb48ee..f20884b 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/HEXValueConverter_toValue_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/conversion/HEXValueConverter_toValue_Test.java
@@ -45,7 +45,7 @@
       { "0xA", 10L },
       { "0xFF", 255L },
       { "-0x80000000", -2147483648L },
-      { "0xffffffffffffffff", -1L } // overflow
+      { "0xffffffffffffffff", 1L } // overflow
     });
   }
 
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 43a7618..42f3808 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
@@ -39,7 +39,8 @@
     String withoutZeroX = removeZeroX(string);
     try {
       BigInteger value = new BigInteger(withoutZeroX, 16);
-      return value.longValue();
+      long longValue = value.longValue();
+      return longValue != -1 ? longValue : 1L;
     } catch (NumberFormatException e) {
       throw parsingError(string, node, e);
     }
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 dde430a..dee2050 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
@@ -77,7 +77,7 @@
       return true;
     }
     if (messageFields.isUnsignedInteger(field)) {
-      Long longValue = ((LongLink) value).getTarget();
+      long longValue = longValueIn(value);
       if (longValue < 0) {
         error(expectedPositiveNumber, FIELD_OPTION__VALUE);
       }
@@ -89,6 +89,18 @@
     return value instanceof LongLink || value instanceof HexNumberLink;
   }
 
+  private long longValueIn(Value value) {
+    if (value instanceof LongLink) {
+      LongLink link = (LongLink) value;
+      return link.getTarget();
+    }
+    if (value instanceof HexNumberLink) {
+      HexNumberLink link = (HexNumberLink) value;
+      return link.getTarget();
+    }
+    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();