Fixed up unit test issues
diff --git a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/bugs/Issue185_CustomOptionsShouldAllowEmptyBracesAsValue_Test.java b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/bugs/Issue185_CustomOptionsShouldAllowEmptyBracesAsValue_Test.java
index cebe45c..bb82dcf 100644
--- a/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/bugs/Issue185_CustomOptionsShouldAllowEmptyBracesAsValue_Test.java
+++ b/com.google.eclipse.protobuf.integration.test/src/com/google/eclipse/protobuf/bugs/Issue185_CustomOptionsShouldAllowEmptyBracesAsValue_Test.java
@@ -8,7 +8,7 @@
*/
package com.google.eclipse.protobuf.bugs;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static com.google.eclipse.protobuf.junit.core.IntegrationTestModule.integrationTestModule;
import static com.google.eclipse.protobuf.junit.core.XtextRule.overrideRuntimeModuleWith;
@@ -17,7 +17,9 @@
import org.junit.Test;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.protobuf.ComplexValue;
import com.google.eclipse.protobuf.protobuf.CustomFieldOption;
+import com.google.eclipse.protobuf.protobuf.Value;
/**
* Tests fix for <a href="http://code.google.com/p/protobuf-dt/issues/detail?id=185">Issue 185</a>.
@@ -47,6 +49,8 @@
// }
@Test public void should_allow_empty_braces_as_value() {
CustomFieldOption option = xtext.find("fileopt", ")", CustomFieldOption.class);
- assertNull(option.getValue());
+ Value value = option.getValue();
+ ComplexValue complexValue = value instanceof ComplexValue ? (ComplexValue) value : null;
+ assertTrue(complexValue != null && complexValue.getFields().isEmpty());
}
}
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/parser/PreferenceDrivenProtobufParser.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/parser/PreferenceDrivenProtobufParser.java
index 6238844..345e829 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/parser/PreferenceDrivenProtobufParser.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/parser/PreferenceDrivenProtobufParser.java
@@ -44,6 +44,6 @@
return root == null || root.getSyntax() == null;
}
- return false;
+ return rootObj == null;
}
}
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 bdfb26b..dddd42f 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
@@ -211,15 +211,11 @@
// { foo: 1, bar: 2 }
ComplexValueCurlyBracket:
- '{'
- fields+=ValueField ((',')? fields+=ValueField)* (',')?
- '}';
+ '{' {ComplexValueCurlyBracket} (fields+=ValueField (',')?)* '}';
// < foo: 1, bar: 2 >
ComplexValueAngleBracket:
- '<'
- fields+=ValueField ((',')? fields+=ValueField)* (',')?
- '>';
+ '<' {ComplexValueAngleBracket} (fields+=ValueField (',')?)* '>';
ValueField:
SimpleValueField | ComplexValueField;