Package com.google.eclipse.protobuf.protobuf

Examples of com.google.eclipse.protobuf.protobuf.Value


  // message Test {
  //   optional string name = 1 [(fileopt) = {}];
  // }
  @Test public void should_allow_empty_braces_as_value() {
    CustomFieldOption option = xtext.find("fileopt", ")", CustomFieldOption.class);
    Value value = option.getValue();
    ComplexValue complexValue = value instanceof ComplexValue ? (ComplexValue) value : null;
    assertTrue(complexValue != null && complexValue.getFields().isEmpty());
  }
View Full Code Here


  // message Test {
  //  optional double timeout = 1 [default = 1.0e7];
  // }
  @Test public void should_not_have_syntax_errors() {
    DefaultValueFieldOption option = xtext.find("default", DefaultValueFieldOption.class);
    Value value = option.getValue();
    assertThat(value, instanceOf(DoubleLink.class));
    DoubleLink link = (DoubleLink) value;
    assertThat(link.getTarget(), equalTo(1.0E7d));
  }
View Full Code Here

  // message Test {
  //  optional float ratio = 1 [default = 1e+25];
  // }
  @Test public void should_not_have_syntax_errors() {
    DefaultValueFieldOption option = xtext.find("default", DefaultValueFieldOption.class);
    Value value = option.getValue();
    assertThat(value, instanceOf(DoubleLink.class));
    DoubleLink link = (DoubleLink) value;
    assertThat(link.getTarget(), equalTo(1.0E25d));
  }
View Full Code Here

    }
  }

  private void highlightOptions(IndexedElement element, IHighlightedPositionAcceptor acceptor) {
    for (FieldOption option : indexedElements.fieldOptionsOf(element)) {
      Value value = option.getValue();
      if (value instanceof LiteralLink) {
        highlightFirstFeature(option, ABSTRACT_OPTION__VALUE, acceptor, ENUM_LITERAL_ID);
        return;
      }
      if (value instanceof NumberLink) {
View Full Code Here

  private void highlight(Option option, IHighlightedPositionAcceptor acceptor) {
    IndexedElement element = options.rootSourceOf(option);
    if (element != null) {
      highlightFirstFeature(option, OPTION__SOURCE, acceptor, DEFAULT_ID);
    }
    Value value = option.getValue();
    if (value instanceof LiteralLink) {
      highlightFirstFeature(option, ABSTRACT_OPTION__VALUE, acceptor, ENUM_LITERAL_ID);
      return;
    }
    if (value instanceof NumberLink) {
View Full Code Here

      validateEnumLiteral(option, anEnum);
    }
  }

  private void validateBool(DefaultValueFieldOption option) {
    Value value = option.getValue();
    if (!(value instanceof BooleanLink)) {
      error(expectedTrueOrFalse, option, ABSTRACT_OPTION__VALUE, EXPECTED_BOOL_ERROR);
    }
  }
View Full Code Here

      error(expectedTrueOrFalse, option, ABSTRACT_OPTION__VALUE, EXPECTED_BOOL_ERROR);
    }
  }

  private void validateFloatingPointNumber(DefaultValueFieldOption option) {
    Value value = option.getValue();
    if (!(value instanceof DoubleLink) && !isInteger(value)) {
      error(expectedNumber, ABSTRACT_OPTION__VALUE);
    }
  }
View Full Code Here

      error(expectedNumber, ABSTRACT_OPTION__VALUE);
    }
  }

  private void validateInteger(DefaultValueFieldOption option) {
    Value value = option.getValue();
    if (!isInteger(value)) {
      error(expectedInteger, ABSTRACT_OPTION__VALUE);
    }
  }
View Full Code Here

  private boolean isInteger(Value value) {
    return value instanceof LongLink || value instanceof HexNumberLink;
  }

  private void validateUnsignedInteger(DefaultValueFieldOption option) {
    Value value = option.getValue();
    long longValue = longValueIn(value);
    if (longValue < 0) {
      error(expectedPositiveNumber, ABSTRACT_OPTION__VALUE);
    }
  }
View Full Code Here

    }
    throw new IllegalArgumentException(value + " does not belong to an integer type");
  }

  private void validateString(DefaultValueFieldOption option) {
    Value value = option.getValue();
    if (!(value instanceof StringLink)) {
      error(expectedString, option, ABSTRACT_OPTION__VALUE, EXPECTED_STRING_ERROR);
    }
  }
View Full Code Here

TOP

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

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.