Package com.google.eclipse.protobuf.protobuf

Examples of com.google.eclipse.protobuf.protobuf.TypeLink


  // message FieldType {
  //   optional google.protobuf.FieldDescriptorProto.Type type = 1;
  // }
  @Test public void should_see_types_from_descriptor_other_than_Messages() {
    MessageField field = xtext.find("type", MessageField.class);
    TypeLink type = field.getType();
    IScope scope = scopeProvider.scope_ComplexTypeLink_target((ComplexTypeLink) type, reference);
    assertThat(descriptionsIn(scope), contain("google.protobuf.FieldDescriptorProto.Type"));
  }
View Full Code Here


  private void highlight(MessageField field, IHighlightedPositionAcceptor acceptor) {
    highlightPropertyType(field, acceptor);
  }

  private void highlightPropertyType(MessageField field, IHighlightedPositionAcceptor acceptor) {
    TypeLink link = field.getType();
    if (!(link instanceof ComplexTypeLink)) {
      return;
    }
    ComplexType type = ((ComplexTypeLink) link).getTarget();
    if (type instanceof Message) {
View Full Code Here

   * {@code fixed64}, {@code sfixed32}, {@code sfixed64} and {@code bool}.
   * @param field the given field.
   * @return {@code true} if the type of the given field is primitive, {@code false} otherwise.
   */
  public boolean isPrimitive(MessageField field) {
    TypeLink link = field.getType();
    if (!(link instanceof ScalarTypeLink)) {
      return false;
    }
    String typeName = ((ScalarTypeLink) link).getTarget().getName();
    return !STRING.hasValue(typeName) && !BYTES.hasValue(typeName);
View Full Code Here

  public boolean isUnsignedInteger(MessageField field) {
    return isScalarType(field, FIXED32, FIXED64, UINT32, UINT64);
  }

  private boolean isScalarType(MessageField field, CommonKeyword... scalarNames) {
    TypeLink link = field.getType();
    if (link instanceof ScalarTypeLink) {
      String typeName = ((ScalarTypeLink) link).getTarget().getName();
      for (CommonKeyword scalarName : scalarNames) {
        if (scalarName.hasValue(typeName)) {
          return true;
View Full Code Here

   * Returns the type of the given field.
   * @param field the given field.
   * @return the type of the given field.
   */
  public ComplexType typeOf(MessageField field) {
    TypeLink link = field.getType();
    if (link instanceof ComplexTypeLink) {
      return ((ComplexTypeLink) link).getTarget();
    }
    return null;
  }
View Full Code Here

   * Returns the scalar type of the given field, only if the type of the given field is a scalar.
   * @param field the given field.
   * @return the scalar type of the given field or {@code null} if the type of the given field is not a scalar.
   */
  public ScalarType scalarTypeOf(MessageField field) {
    TypeLink link = (field).getType();
    if (link instanceof ScalarTypeLink) {
      return ((ScalarTypeLink) link).getTarget();
    }
    return null;
  }
View Full Code Here

  @Override public boolean matchesSafely(MessageField item) {
    return typeName.equals(typeNameOf(item));
  }

  private String typeNameOf(MessageField field) {
    TypeLink link = field.getType();
    if (link instanceof ScalarTypeLink) {
      return ((ScalarTypeLink) link).getTarget().getName();
    }
    if (link instanceof ComplexTypeLink) {
      ComplexType type = ((ComplexTypeLink) link).getTarget();
      return type == null ? null : type.getName();
    }
    return link.toString();
  }
View Full Code Here

TOP

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

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.