Package org.eclipse.xtext.scoping

Examples of org.eclipse.xtext.scoping.IScope


      return Collections.<EObject> emptyList();

    final String crossRefString = getCrossRefNodeAsString(node);
    if (crossRefString != null && !crossRefString.equals("")) {
      linkNode = node;
      final IScope scope = getScope(context, ref);
      linkNode = null;
      QualifiedName qualifiedLinkName =  qualifiedNameConverter.toQualifiedName(crossRefString);
      IEObjectDescription eObjectDescription = scope.getSingleElement(qualifiedLinkName);
      if (eObjectDescription != null)
        return Collections.singletonList(eObjectDescription.getEObjectOrProxy());
    }
    return Collections.emptyList();
  }
View Full Code Here


  // service ABC {
  //   option (code) = 68;
  // }
  @Test public void should_support_Service_options() {
    Option option = xtext.find("code", ")", Option.class);
    IScope scope = scopeProvider.scope_OptionSource_target(option.getSource(), reference);
    assertThat(descriptionsIn(scope), containAll("code", "proto.code", "google.proto.code", "com.google.proto.code",
                                                 ".com.google.proto.code",
                                                 "info", "proto.info", "google.proto.info", "com.google.proto.info",
                                                 ".com.google.proto.info"));
  }
View Full Code Here

  // enum PhoneType {
  //   HOME = 0 [(active) = true];
  // }
  @Test public void should_provide_fields_for_custom_field_option() {
    CustomFieldOption option = xtext.find("active", ")", CustomFieldOption.class);
    IScope scope = scopeProvider.scope_OptionSource_target(option.getSource(), reference);
    assertThat(descriptionsIn(scope), containAll("active", ".active"));
  }
View Full Code Here

  // message Summary {
  //   repeated base.shared.Type type = 1;
  // }
  @Test public void should_include_package_intersection() {
    MessageField field = xtext.find("type", " =", MessageField.class);
    IScope scope = scopeProvider.scope_ComplexTypeLink_target((ComplexTypeLink) field.getType(), reference);
    assertThat(descriptionsIn(scope), contain("base.shared.Type", "proto.base.shared.Type",
                                              "google.proto.base.shared.Type", "com.google.proto.base.shared.Type"));
  }
View Full Code Here

  //     optional MyGroup mygroup = 2207766;
  //   }
  // }
  @Test public void should_treat_groups_as_types() {
    MessageField field = xtext.find("mygroup", MessageField.class);
    IScope scope = scopeProvider.scope_ComplexTypeLink_target((ComplexTypeLink) field.getType(), reference);
    assertThat(descriptionsIn(scope), contain("Root.MyGroup", "MyGroup"));
  }
View Full Code Here

  // }
  @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

  //     required int64 groupId = 2;
  //   }
  // }
  @Test public void should_provide_fields_for_native_option() {
    NativeFieldOption option = xtext.find("deprecated", NativeFieldOption.class);
    IScope scope = scopeProvider.scope_OptionSource_target(option.getSource(), reference);
    Group group = xtext.find("membership", Group.class);
    ProtoDescriptor descriptor = descriptorProvider.primaryDescriptor();
    Collection<MessageField> optionSources = descriptor.availableOptionsFor(group);
    assertThat(descriptionsIn(scope), containAll(optionSources));
  }
View Full Code Here

  //     required int64 groupId = 2;
  //   }
  // }
  @Test public void should_provide_fields_for_custom_option() {
    CustomFieldOption option = xtext.find("code", ")", CustomFieldOption.class);
    IScope scope = scopeProvider.scope_OptionSource_target(option.getSource(), reference);
    assertThat(descriptionsIn(scope), containAll("code", "proto.code", "google.proto.code", "com.google.proto.code",
                                                 ".com.google.proto.code",
                                                 "info", "proto.info", "google.proto.info", "com.google.proto.info",
                                                 ".com.google.proto.info"));
  }
View Full Code Here

  // message Summary {
  //   repeated base.shared.Outer.Type type = 1;
  // }
  @Test public void should_include_package_intersection() {
    MessageField field = xtext.find("type", " =", MessageField.class);
    IScope scope = scopeProvider.scope_ComplexTypeLink_target((ComplexTypeLink) field.getType(), reference);
    assertThat(descriptionsIn(scope), contain("base.shared.Outer.Type", "proto.base.shared.Outer.Type",
                                              "google.proto.base.shared.Outer.Type",
                                              "com.google.proto.base.shared.Outer.Type"));
  }
View Full Code Here

  //   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

TOP

Related Classes of org.eclipse.xtext.scoping.IScope

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.