Package com.google.eclipse.protobuf.junit.util

Examples of com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder


*/
public class PreferenceDrivenProtobufParser_doParse_Test {
  private static String proto1;

  @BeforeClass public static void setUpOnce() {
    MultiLineTextBuilder proto = new MultiLineTextBuilder();
    proto.append("// ignore errors")
         .append("c++header #include 'test/common/proto_class.h'");
    proto1 = proto.toString();
  }
View Full Code Here


  @Test public void should_remove_trailing_whitespace_in_edited_lines_only() {
    initEditor();
    preferences.removeTrailingWhitespace(EDITED_LINES);
    editor.typeText("option optimize_for = SPEED;  ");
    editor.save();
    MultiLineTextBuilder expected = new MultiLineTextBuilder();
    expected.append("syntax = 'proto2';  ")
            .append("import 'google/protobuf/descriptor.proto';  ")
            .append("option optimize_for = SPEED;");
    assertEquals(expected.toString(), editor.getText());
  }
View Full Code Here

  @Test public void should_remove_trailing_whitespace_in_all_lines() {
    initEditor();
    preferences.removeTrailingWhitespace(ALL_LINES);
    editor.typeText("option optimize_for = SPEED;  ");
    editor.save();
    MultiLineTextBuilder expected = new MultiLineTextBuilder();
    expected.append("syntax = 'proto2';")
            .append("import 'google/protobuf/descriptor.proto';")
            .append("option optimize_for = SPEED;");
    assertEquals(expected.toString(), editor.getText());
  }
View Full Code Here

    assertEquals(expected.toString(), editor.getText());
  }

  private void initEditor() {
    preferences.removeTrailingWhitespace(NONE);
    MultiLineTextBuilder text = new MultiLineTextBuilder();
    text.append("syntax = 'proto2';  ")
        .append("import 'google/protobuf/descriptor.proto';  ")
        .append("");
    editor.setText(text.toString());
    editor.save();
    editor.navigateTo(2, 0);
  }
View Full Code Here

    fqn = fqn.indexOf("$") == -1 ? fqn : fqn.substring(0, fqn.indexOf("$"));
    String classFile = fqn + ".java";
    File file = new File("src" + separator + classFile);
    Scanner scanner = null;
    List<String> comments = newArrayList();
    MultiLineTextBuilder comment = new MultiLineTextBuilder();
    try {
      scanner = new Scanner(new FileInputStream(file));
      String line;
      while (scanner.hasNextLine()) {
        line = scanner.nextLine().replaceFirst("^\\s*", "");
        if (line.startsWith(COMMENT_START)) {
          String text = line.substring(COMMENT_START.length());
          if (text.startsWith(" ")) {
            text = text.substring(1);
          }
          comment.append(text);
          continue;
        }
        if (comment.isEmpty()) {
          continue;
        }
        line = line.trim();
        String testName = testName(line);
        if (line.length() == 0 || testName != null) {
          if (!comments.contains(comment)) {
            comments.add(comment.toString());
          }
          comment = new MultiLineTextBuilder();
        }
        if (testName != null) {
          commentsByMethod.put(testName, comments);
          comments = newArrayList();
        }
View Full Code Here

TOP

Related Classes of com.google.eclipse.protobuf.junit.util.MultiLineTextBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.