Code cleanup.
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/ProtobufElements.java b/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/Finder.java
similarity index 89%
rename from com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/ProtobufElements.java
rename to com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/Finder.java
index fc6af47..42533d9 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/ProtobufElements.java
+++ b/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/Finder.java
@@ -6,7 +6,7 @@
*
* http://www.eclipse.org/legal/epl-v10.html
*/
-package com.google.eclipse.protobuf.ui.util;
+package com.google.eclipse.protobuf.junit;
import static org.eclipse.xtext.EcoreUtil2.getAllContentsOfType;
@@ -17,7 +17,7 @@
/**
* @author alruiz@google.com (Alex Ruiz)
*/
-public final class ProtobufElements {
+public final class Finder {
public static Literal findLiteral(String name, Protobuf root) {
List<Literal> literals = getAllContentsOfType(root, Literal.class);
@@ -33,5 +33,5 @@
return null;
}
- private ProtobufElements() {}
+ private Finder() {}
}
diff --git a/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/XtextRule.java b/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/XtextRule.java
index c33160c..2c6e584 100644
--- a/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/XtextRule.java
+++ b/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/XtextRule.java
@@ -42,6 +42,10 @@
return injector.getInstance(type);
}
+ public Protobuf parse(StringBuilder text) {
+ return parse(text.toString());
+ }
+
public Protobuf parse(String text) {
ProtobufParser parser = injector.getInstance(ProtobufParser.class);
IParseResult parseResult = parser.parse(new InputStreamReader(new StringInputStream(text)));
@@ -55,8 +59,7 @@
this.base = base;
}
- /** {@inheritDoc} */
- public void evaluate() throws Throwable {
+ @Override public void evaluate() throws Throwable {
setUpInjector();
base.evaluate();
}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Literals_calculateIndexOf_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Literals_calculateIndexOf_Test.java
index e56893c..933702e 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Literals_calculateIndexOf_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Literals_calculateIndexOf_Test.java
@@ -8,7 +8,7 @@
*/
package com.google.eclipse.protobuf.ui.util;
-import static com.google.eclipse.protobuf.ui.util.ProtobufElements.findLiteral;
+import static com.google.eclipse.protobuf.junit.Finder.findLiteral;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
@@ -38,7 +38,7 @@
proto.append("enum PhoneType {")
.append(" MOBILE = 1; ")
.append("} ");
- Protobuf root = xtext.parse(proto.toString());
+ Protobuf root = xtext.parse(proto);
Literal mobile = findLiteral("MOBILE", root);
int index = literals.calculateIndexOf(mobile);
assertThat(index, equalTo(0));
@@ -51,7 +51,7 @@
.append(" HOME = 5; ")
.append(" WORK = 9; ")
.append("} ");
- Protobuf root = xtext.parse(proto.toString());
+ Protobuf root = xtext.parse(proto);
Literal work = findLiteral("WORK", root);
int index = literals.calculateIndexOf(work);
assertThat(index, equalTo(6));
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Properties_calculateTagNumberOf_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Properties_calculateTagNumberOf_Test.java
index 6c8c05c..0bc06db 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Properties_calculateTagNumberOf_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Properties_calculateTagNumberOf_Test.java
@@ -8,7 +8,7 @@
*/
package com.google.eclipse.protobuf.ui.util;
-import static com.google.eclipse.protobuf.ui.util.ProtobufElements.findProperty;
+import static com.google.eclipse.protobuf.junit.Finder.findProperty;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
@@ -38,7 +38,7 @@
proto.append("message Person { ")
.append(" required string name = 2;")
.append("} ");
- Protobuf root = xtext.parse(proto.toString());
+ Protobuf root = xtext.parse(proto);
Property name = findProperty("name", root);
int index = properties.calculateTagNumberOf(name);
assertThat(index, equalTo(1));
@@ -50,7 +50,7 @@
.append(" required string name = 6;")
.append(" required int32 id = 8; ")
.append("} ");
- Protobuf root = xtext.parse(proto.toString());
+ Protobuf root = xtext.parse(proto);
Property id = findProperty("id", root);
int index = properties.calculateTagNumberOf(id);
assertThat(index, equalTo(7));
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Properties_isBool_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Properties_isBool_Test.java
index c859b75..d598d0b 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Properties_isBool_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Properties_isBool_Test.java
@@ -8,7 +8,7 @@
*/
package com.google.eclipse.protobuf.ui.util;
-import static com.google.eclipse.protobuf.ui.util.ProtobufElements.findProperty;
+import static com.google.eclipse.protobuf.junit.Finder.findProperty;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
@@ -38,7 +38,7 @@
proto.append("message Person { ")
.append(" optional bool active = 1;")
.append("} ");
- Protobuf root = xtext.parse(proto.toString());
+ Protobuf root = xtext.parse(proto);
Property active = findProperty("active", root);
assertThat(properties.isBool(active), equalTo(true));
}
@@ -48,7 +48,7 @@
proto.append("message Person { ")
.append(" optional string name = 1;")
.append("} ");
- Protobuf root = xtext.parse(proto.toString());
+ Protobuf root = xtext.parse(proto);
Property name = findProperty("name", root);
assertThat(properties.isBool(name), equalTo(false));
}
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Properties_isString_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Properties_isString_Test.java
index dad29f4..f85bc79 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Properties_isString_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Properties_isString_Test.java
@@ -8,7 +8,7 @@
*/
package com.google.eclipse.protobuf.ui.util;
-import static com.google.eclipse.protobuf.ui.util.ProtobufElements.findProperty;
+import static com.google.eclipse.protobuf.junit.Finder.findProperty;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
@@ -38,7 +38,7 @@
proto.append("message Person { ")
.append(" optional string name = 1;")
.append("} ");
- Protobuf root = xtext.parse(proto.toString());
+ Protobuf root = xtext.parse(proto);
Property name = findProperty("name", root);
assertThat(properties.isString(name), equalTo(true));
}
@@ -48,7 +48,7 @@
proto.append("message Person { ")
.append(" optional bool active = 1;")
.append("} ");
- Protobuf root = xtext.parse(proto.toString());
+ Protobuf root = xtext.parse(proto);
Property active = findProperty("active", root);
assertThat(properties.isString(active), equalTo(false));
}