Package com.google.eclipse.protobuf.protobuf

Examples of com.google.eclipse.protobuf.protobuf.MessageField


  //
  // message Person {
  //   optional string name = 1;
  // }
  @Test public void should_return_name_of_scalar() {
    MessageField field = xtext.find("name", MessageField.class);
    assertThat(fields.typeNameOf(field), equalTo("string"));
  }
View Full Code Here


  //   message PhoneNumber {
  //     optional string value = 1;
  //   }
  // }
  @Test public void should_return_name_of_type() {
    MessageField field = xtext.find("number", MessageField.class);
    assertThat(fields.typeNameOf(field), equalTo("PhoneNumber"));
  }
View Full Code Here

  //
  // message Person {
  //   optional bool active = 1;
  // }
  @Test public void should_return_first_node_for_feature() {
    MessageField field = xtext.find("active", MessageField.class);
    INode node = nodes.firstNodeForFeature(field, MESSAGE_FIELD__NAME);
    assertThat(node.getText().trim(), equalTo("active"));
  }
View Full Code Here

  //
  // message Person {
  //  optional String firstName = 6;
  // }
  @Test public void should_return_index_of_MessageField() {
    MessageField field = xtext.find("firstName", MessageField.class);
    long index = indexedElements.indexOf(field);
    assertThat(index, equalTo(6L));
  }
View Full Code Here

  //
  // message Person {
  //  optional String firstName = 6;
  // }
  @Test public void should_return_index_feature_of_MessageField() {
    MessageField field = xtext.find("firstName", MessageField.class);
    EStructuralFeature expected = MESSAGE_FIELD__INDEX;
    assertThat(indexedElements.indexFeatureOf(field), equalTo(expected));
  }
View Full Code Here

                commentsToUpdate.add(Tuples.create(model, index));
                shouldInsertSemicolon.set(false);
              }
            }
            if (model instanceof MessageField) {
              MessageField field = (MessageField) model;
              if (shouldCalculateIndex(field)) {
                long index = indexedElements.calculateNewIndexFor(field);
                field.setIndex(index);
                commentsToUpdate.add(Tuples.create(model, index));
                shouldInsertSemicolon.set(false);
              }
            }
          }
View Full Code Here

  // message Person {
  //   optional long id = 1;
  //   optional string name = 1;
  // }
  @Test public void should_create_error_if_field_does_not_have_unique_tag_number() {
    MessageField field = xtext.find("name", MessageField.class);
    validator.checkTagNumberIsUnique(field);
    String message = "Field number 1 has already been used in \"Person\" by field \"id\".";
    verify(messageAcceptor).acceptError(message, field, MESSAGE_FIELD__INDEX, INSIGNIFICANT_INDEX, INVALID_FIELD_TAG_NUMBER_ERROR);
  }
View Full Code Here

  // message Person {
  //   optional long id = 1;
  //   optional string name = 2;
  // }
  @Test public void should_not_create_error_if_field_has_unique_tag_number() {
    MessageField field = xtext.find("name", MessageField.class);
    validator.checkTagNumberIsUnique(field);
    verifyZeroInteractions(messageAcceptor);
  }
View Full Code Here

  //
  // message Person {
  //   optional long id = 0;
  // }
  @Test public void should_create_error_if_field_index_is_zero() {
    MessageField field = xtext.find("id", MessageField.class);
    validator.checkTagNumberIsGreaterThanZero(field);
    String message = "Field numbers must be positive integers.";
    verify(messageAcceptor).acceptError(message, field, MESSAGE_FIELD__INDEX, INSIGNIFICANT_INDEX,
        INVALID_FIELD_TAG_NUMBER_ERROR);
  }
View Full Code Here

  //
  // message Person {
  //   optional long id = -1;
  // }
  @Test public void should_create_error_if_field_index_is_negative() {
    MessageField field = xtext.find("id", MessageField.class);
    validator.checkTagNumberIsGreaterThanZero(field);
    String message = "Expected field number.";
    verify(messageAcceptor).acceptError(message, field, MESSAGE_FIELD__INDEX, INSIGNIFICANT_INDEX,
        INVALID_FIELD_TAG_NUMBER_ERROR);
  }
View Full Code Here

TOP

Related Classes of com.google.eclipse.protobuf.protobuf.MessageField

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.