Package com.google.eclipse.protobuf.protobuf

Examples of com.google.eclipse.protobuf.protobuf.Literal


  // enum Status {
  //   DRAFT = 0;
  //   READY = 1;
  // }
  @Test public void should_find_closest_type_possible() {
    Literal active = xtext.find("ACTIVE", " = 0", Literal.class);
    MessageField field = xtext.find("status", MessageField.class);
    ComplexTypeLink link = (ComplexTypeLink) field.getType();
    IScope scope = scopeProvider.scope_ComplexTypeLink_target(link, reference);
    EObject status = descriptionsIn(scope).objectDescribedAs("Status");
    assertSame(active.eContainer(), status);
  }
View Full Code Here


  //
  // enum PhoneType {
  //   HOME = 0;
  // }
  @Test public void should_return_label_for_literal() {
    Literal literal = xtext.find("HOME", Literal.class);
    Object label = labels.labelFor(literal);
    assertThat(label, instanceOf(StyledString.class));
    StyledString labelText = (StyledString) label;
    assertThat(labelText.getString(), equalTo("HOME [0]"));
   }
View Full Code Here

  //
  // enum PhoneType {
  //   HOME = 0;
  // }
  @Test public void should_return_name_of_Literal() {
    Literal literal = xtext.find("HOME", Literal.class);
    String name = resolver.nameOf(literal);
    assertThat(name, equalTo("HOME"));
  }
View Full Code Here

  //
  // enum PhoneType {
  //   MOBILE = 1;
  // }
  @Test public void should_return_zero_for_first_and_only_literal() {
    Literal mobile = xtext.find("MOBILE", Literal.class);
    long index = literals.calculateNewIndexOf(mobile);
    assertThat(index, equalTo(0L));
  }
View Full Code Here

  //   MOBILE = 1;
  //   HOME = 5;
  //   WORK = 9;
  // }
  @Test public void should_return_max_index_value_plus_one_for_new_literal() {
    Literal work = xtext.find("WORK", Literal.class);
    long index = literals.calculateNewIndexOf(work);
    assertThat(index, equalTo(6L));
  }
View Full Code Here

            if (model instanceof FieldOption) {
              FieldOption option = (FieldOption) model;
              model = option.eContainer();
            }
            if (model instanceof Literal) {
              Literal literal = (Literal) model;
              if (shouldCalculateIndex(literal, LITERAL__INDEX)) {
                long index = literals.calculateNewIndexOf(literal);
                literal.setIndex(index);
                commentsToUpdate.add(Tuples.create(model, index));
                shouldInsertSemicolon.set(false);
              }
            }
            if (model instanceof MessageField) {
View Full Code Here

  //
  // enum PhoneType {
  //   HOME = 0;
  // }
  @Test public void should_return_image_for_literal() {
    Literal literal = xtext.find("HOME", Literal.class);
    String image = images.imageFor(literal);
    assertThat(image, equalTo("literal.gif"));
    assertThat(image, existsInProject());
  }
View Full Code Here

    if (o instanceof Import) {
      Import anImport = (Import) o;
      return labelFor(anImport);
    }
    if (o instanceof Literal) {
      Literal literal = (Literal) o;
      return labelFor(literal);
    }
    if (o instanceof MessageField) {
      MessageField field = (MessageField) o;
      return labelFor(field);
View Full Code Here

    }
    if (!(value instanceof LiteralLink)) {
      error(expectedIdentifier, ABSTRACT_OPTION__VALUE);
      return true;
    }
    Literal literal = ((LiteralLink) value).getTarget();
    if (!anEnum.equals(literal.eContainer())) {
      QualifiedName enumFqn = fqnProvider.getFullyQualifiedName(anEnum);
      String literalName = nodes.textOf(nodeForValueFeatureIn(option));
      String msg = String.format(literalNotInEnum, enumFqn, literalName);
      error(msg, ABSTRACT_OPTION__VALUE);
    }
View Full Code Here

TOP

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

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.