Replaced usage of StringBuilder with MultiLineTextBuilder. Fixed broken
tests.
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/XtextRule.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/XtextRule.java
index aae9b9a..982e8ed 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/XtextRule.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/core/XtextRule.java
@@ -13,6 +13,7 @@
import static org.eclipse.emf.ecore.util.EcoreUtil.resolveAll;
import static org.eclipse.xtext.util.CancelIndicator.NullImpl;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.Protobuf;
import com.google.inject.Injector;
@@ -44,7 +45,7 @@
return injector;
}
- public Protobuf parse(StringBuilder text) {
+ public Protobuf parse(MultiLineTextBuilder text) {
return parse(text.toString());
}
@@ -52,7 +53,6 @@
XtextResource resource = resourceFrom(new StringInputStream(text));
IParseResult parseResult = resource.getParseResult();
if (!parseResult.hasSyntaxErrors()) return (Protobuf) parseResult.getRootASTElement();
- Iterable<INode> syntaxErrors = parseResult.getSyntaxErrors();
StringBuilder builder = new StringBuilder();
builder.append("Syntax errors:");
for (INode error : parseResult.getSyntaxErrors())
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/util/MultiLineTextBuilder.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/util/MultiLineTextBuilder.java
new file mode 100644
index 0000000..31890f9
--- /dev/null
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/junit/util/MultiLineTextBuilder.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2011 Google Inc.
+ *
+ * All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.junit.util;
+
+import static com.google.eclipse.protobuf.junit.util.SystemProperties.lineSeparator;
+
+/**
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public class MultiLineTextBuilder {
+
+ private final StringBuilder builder = new StringBuilder();
+
+ public MultiLineTextBuilder append(String s) {
+ builder.append(s).append(lineSeparator());
+ return this;
+ }
+
+ @Override public String toString() {
+ return builder.toString();
+ }
+}
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider_getFullyQualifiedName_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider_getFullyQualifiedName_Test.java
index ff5ee63..99a401e 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider_getFullyQualifiedName_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/naming/ProtobufQualifiedNameProvider_getFullyQualifiedName_Test.java
@@ -17,6 +17,7 @@
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.*;
/**
@@ -35,7 +36,7 @@
}
@Test public void should_include_existing_package_name_as_part_of_message_FQN() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("package fqn.test; ")
.append(" ")
.append("message Person { ")
@@ -48,7 +49,7 @@
}
@Test public void should_include_existing_package_name_as_part_of_property_FQN() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("package fqn.test; ")
.append(" ")
.append("message Person { ")
@@ -61,7 +62,7 @@
}
@Test public void should_not_include_package_name_as_part_of_message_FQN_if_package_is_not_specified() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional string name = 1;")
.append("} ");
@@ -72,7 +73,7 @@
}
@Test public void should_not_include_package_name_as_part_of_property_FQN_if_package_is_not_specified() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional string name = 1;")
.append("} ");
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider_namesOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider_namesOf_Test.java
index 55e1202..a49bdad 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider_namesOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/scoping/LocalNamesProvider_namesOf_Test.java
@@ -16,11 +16,14 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.naming.QualifiedName;
-import org.junit.*;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
import com.google.eclipse.protobuf.junit.core.XtextRule;
-import com.google.eclipse.protobuf.protobuf.*;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.Enum;
+import com.google.eclipse.protobuf.protobuf.Protobuf;
/**
* Tests for <code>{@link LocalNamesProvider#namesOf(EObject)}</code>.
@@ -38,7 +41,7 @@
}
@Test public void should_return_all_possible_local_names() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("package test.alternative.names; ");
proto.append(" ");
proto.append("message Person { ");
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ModelNodes_firstNodeForFeature_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ModelNodes_firstNodeForFeature_Test.java
index 6da5d5b..3c8bd79 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ModelNodes_firstNodeForFeature_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ModelNodes_firstNodeForFeature_Test.java
@@ -14,6 +14,7 @@
import static org.junit.Assert.assertThat;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.*;
import org.eclipse.emf.ecore.*;
@@ -36,7 +37,7 @@
}
@Test public void should_return_first_node_for_feature() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional bool active = 1;")
.append("} ");
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_isBool_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_isBool_Test.java
index e30879e..4015f3b 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_isBool_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_isBool_Test.java
@@ -15,6 +15,7 @@
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.Property;
import com.google.eclipse.protobuf.protobuf.Protobuf;
@@ -34,7 +35,7 @@
}
@Test public void should_return_true_if_property_is_bool() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional bool active = 1;")
.append("} ");
@@ -44,7 +45,7 @@
}
@Test public void should_return_false_if_property_is_not_bool() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional string name = 1;")
.append("} ");
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_isPrimitive_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_isPrimitive_Test.java
index 384664d..a5a657b 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_isPrimitive_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_isPrimitive_Test.java
@@ -15,6 +15,7 @@
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.Property;
import com.google.eclipse.protobuf.protobuf.Protobuf;
@@ -34,7 +35,7 @@
}
@Test public void should_return_true_if_property_is_primitive() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Primitives { ")
.append(" optional float float_1 = 1; ")
.append(" optional int32 int32_1 = 2; ")
@@ -53,7 +54,7 @@
}
@Test public void should_return_false_if_property_is_not_primitive() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Types { ")
.append(" optional string string_1 = 1; ")
.append(" optional bytes bytes_1 = 2; ")
@@ -61,7 +62,7 @@
.append("} ")
.append(" ")
.append("message Person { ")
- .append(" optional string name = 1 ")
+ .append(" optional string name = 1; ")
.append("} ");
Protobuf root = xtext.parse(proto);
for (Property p : allProperties(root))
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_isString_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_isString_Test.java
index 595b89b..2965711 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_isString_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_isString_Test.java
@@ -15,6 +15,7 @@
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.Property;
import com.google.eclipse.protobuf.protobuf.Protobuf;
@@ -34,7 +35,7 @@
}
@Test public void should_return_true_if_property_is_string() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional string name = 1;")
.append("} ");
@@ -44,7 +45,7 @@
}
@Test public void should_return_false_if_property_is_not_string() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional bool active = 1;")
.append("} ");
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_typeNameOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_typeNameOf_Test.java
index 1a08d4b..0a1aa33 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_typeNameOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/Properties_typeNameOf_Test.java
@@ -15,6 +15,7 @@
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.Property;
import com.google.eclipse.protobuf.protobuf.Protobuf;
@@ -34,7 +35,7 @@
}
@Test public void should_return_name_of_scalar() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional string name = 1;")
.append("} ");
@@ -44,7 +45,7 @@
}
@Test public void should_return_name_of_type() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional string name = 1; ")
.append(" optional PhoneNumber number = 2;")
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_enumTypeOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_enumTypeOf_Test.java
index 2c3cf12..d6207c4 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_enumTypeOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_enumTypeOf_Test.java
@@ -16,6 +16,7 @@
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.*;
import com.google.eclipse.protobuf.protobuf.Enum;
@@ -35,7 +36,7 @@
}
@Test public void should_return_enum_if_property_type_is_enum() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("enum PhoneType { ")
.append(" MOBILE = 0; ")
.append(" HOME = 1; ")
@@ -52,7 +53,7 @@
}
@Test public void should_return_null_if_property_type_is_not_enum() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional string name = 1;")
.append("} ");
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_importsIn_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_importsIn_Test.java
index bc73f66..1fbf47c 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_importsIn_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_importsIn_Test.java
@@ -16,6 +16,7 @@
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.*;
/**
@@ -34,9 +35,9 @@
}
@Test public void should_return_all_imports() {
- StringBuilder proto = new StringBuilder();
- proto.append("import \"luke.proto\"")
- .append("import \"leia.proto\"");
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
+ proto.append("import \"luke.proto\";")
+ .append("import \"leia.proto\";");
Protobuf root = xtext.parse(proto);
List<Import> allImports = finder.importsIn(root);
assertThat(allImports.size(), equalTo(2));
@@ -45,7 +46,7 @@
}
@Test public void should_return_empty_if_no_imports_found() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("enum PhoneType {")
.append(" MOBILE = 0; ")
.append(" HOME = 1; ")
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_packageOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_packageOf_Test.java
index 92cae55..3ac4bda 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_packageOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_packageOf_Test.java
@@ -17,6 +17,7 @@
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.*;
import com.google.eclipse.protobuf.protobuf.Package;
@@ -36,7 +37,7 @@
}
@Test public void should_return_package_if_proto_has_one() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("package person.test; ")
.append(" ")
.append("message Person { ")
@@ -49,7 +50,7 @@
}
@Test public void should_return_null_if_proto_does_not_have_package() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional int32 id = 1;")
.append("} ");
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_rootOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_rootOf_Test.java
index 4dfd649..475b9e6 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_rootOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_rootOf_Test.java
@@ -16,6 +16,7 @@
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.Property;
import com.google.eclipse.protobuf.protobuf.Protobuf;
@@ -35,7 +36,7 @@
}
@Test public void should_return_root_of_proto() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional string name = 1;")
.append("} ");
diff --git a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_scalarTypeOf_Test.java b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_scalarTypeOf_Test.java
index 9aa0af3..8b6d071 100644
--- a/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_scalarTypeOf_Test.java
+++ b/com.google.eclipse.protobuf.test/src/com/google/eclipse/protobuf/util/ProtobufElementFinder_scalarTypeOf_Test.java
@@ -16,6 +16,7 @@
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.*;
/**
@@ -34,7 +35,7 @@
}
@Test public void should_return_scalar_if_property_type_is_scalar() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional int32 id = 1;")
.append("} ");
@@ -45,7 +46,7 @@
}
@Test public void should_return_null_if_property_type_is_not_scalar() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("enum PhoneType { ")
.append(" MOBILE = 0; ")
.append(" HOME = 1; ")
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/commands/CommentNodesFinder_matchingCommentNode_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/commands/CommentNodesFinder_matchingCommentNode_Test.java
index faaf723..bbf9db4 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/commands/CommentNodesFinder_matchingCommentNode_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/commands/CommentNodesFinder_matchingCommentNode_Test.java
@@ -9,12 +9,12 @@
package com.google.eclipse.protobuf.ui.commands;
import static com.google.eclipse.protobuf.junit.util.Finder.findProperty;
-import static com.google.eclipse.protobuf.junit.util.SystemProperties.lineSeparator;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.*;
import org.eclipse.emf.ecore.EObject;
@@ -39,11 +39,11 @@
}
@Test public void should_return_matching_single_line_comment_of_element() {
- StringBuilder proto = new StringBuilder();
- proto.append("message Person { ").append(lineSeparator())
- .append(" // Indicates whether the person is active or not.").append(lineSeparator())
- .append(" optional bool active = 1;").append(lineSeparator())
- .append("} ");
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
+ proto.append("message Person { ")
+ .append(" // Indicates whether the person is active or not.")
+ .append(" optional bool active = 1; ")
+ .append("} ");
Protobuf root = xtext.parse(proto);
Property active = findProperty("active", root);
INode node = finder.matchingCommentNode(active, Pattern.compile(".*"));
@@ -51,13 +51,13 @@
}
@Test public void should_return_matching_multi_line_comment_of_element() {
- StringBuilder proto = new StringBuilder();
- proto.append("message Person { ").append(lineSeparator())
- .append(" /*").append(lineSeparator())
- .append(" * Indicates whether the person is active or not.").append(lineSeparator())
- .append(" */").append(lineSeparator())
- .append(" optional bool active = 1;").append(lineSeparator())
- .append("} ");
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
+ proto.append("message Person { ")
+ .append(" /* ")
+ .append(" * Indicates whether the person is active or not.")
+ .append(" */ ")
+ .append(" optional bool active = 1; ")
+ .append("} ");
Protobuf root = xtext.parse(proto);
Property active = findProperty("active", root);
INode node = finder.matchingCommentNode(active, Pattern.compile(".*"));
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/documentation/SingleLineCommentDocumentationProvider_getDocumentation_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/documentation/SingleLineCommentDocumentationProvider_getDocumentation_Test.java
index 99d5a9b..fa4c7f5 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/documentation/SingleLineCommentDocumentationProvider_getDocumentation_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/documentation/SingleLineCommentDocumentationProvider_getDocumentation_Test.java
@@ -9,11 +9,11 @@
package com.google.eclipse.protobuf.ui.documentation;
import static com.google.eclipse.protobuf.junit.util.Finder.findProperty;
-import static com.google.eclipse.protobuf.junit.util.SystemProperties.lineSeparator;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertThat;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.*;
import org.eclipse.emf.ecore.EObject;
@@ -35,11 +35,11 @@
}
@Test public void should_return_single_line_comment_of_element() {
- StringBuilder proto = new StringBuilder();
- proto.append("message Person { ").append(lineSeparator())
- .append(" // Indicates whether the person is active or not.").append(lineSeparator())
- .append(" optional bool active = 1;").append(lineSeparator())
- .append("} ");
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
+ proto.append("message Person { ")
+ .append(" // Indicates whether the person is active or not.")
+ .append(" optional bool active = 1; ")
+ .append("} ");
Protobuf root = xtext.parse(proto);
Property active = findProperty("active", root);
String documentation = provider.getDocumentation(active);
@@ -47,7 +47,7 @@
}
@Test public void should_return_empty_String_if_element_does_not_have_single_line_comment() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" optional bool active = 1;")
.append("} ");
diff --git a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Fields_calculateTagNumberOf_Test.java b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Fields_calculateTagNumberOf_Test.java
index c117191..a045b1d 100644
--- a/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Fields_calculateTagNumberOf_Test.java
+++ b/com.google.eclipse.protobuf.ui.test/src/com/google/eclipse/protobuf/ui/util/Fields_calculateTagNumberOf_Test.java
@@ -15,6 +15,7 @@
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.*;
/**
@@ -33,7 +34,7 @@
}
@Test public void should_return_one_for_first_and_only_property() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" required string name = 2;")
.append("} ");
@@ -44,7 +45,7 @@
}
@Test public void should_return_max_tag_number_value_plus_one_for_new_property() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("message Person { ")
.append(" required string name = 6;")
.append(" required int32 id = 8; ")
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 29b8c9c..be5b537 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
@@ -15,6 +15,7 @@
import org.junit.*;
import com.google.eclipse.protobuf.junit.core.XtextRule;
+import com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder;
import com.google.eclipse.protobuf.protobuf.Literal;
import com.google.eclipse.protobuf.protobuf.Protobuf;
@@ -34,7 +35,7 @@
}
@Test public void should_return_zero_for_first_and_only_literal() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("enum PhoneType {")
.append(" MOBILE = 1; ")
.append("} ");
@@ -45,7 +46,7 @@
}
@Test public void should_return_max_index_value_plus_one_for_new_literal() {
- StringBuilder proto = new StringBuilder();
+ MultiLineTextBuilder proto = new MultiLineTextBuilder();
proto.append("enum PhoneType {")
.append(" MOBILE = 1; ")
.append(" HOME = 5; ")