Package org.eclipse.xtext.naming

Examples of org.eclipse.xtext.naming.QualifiedName


    assertThat(fqn.getSegments(), equalTo(expectedSegments));
  }

  @Test public void should_create_qualified_name_from_string_with_whitespace() {
    String s = "com.google. proto.  Test";
    QualifiedName fqn = converter.toQualifiedName(s);
    List<String> expectedSegments = newArrayList("com", "google", "proto", "Test");
    assertThat(fqn.getSegments(), equalTo(expectedSegments));
  }
View Full Code Here


    assertThat(fqn.getSegments(), equalTo(expectedSegments));
  }

  @Test public void should_create_qualified_name_from_string_with_line_returns() {
    String s = "com.google.\nproto.\n\nTest";
    QualifiedName fqn = converter.toQualifiedName(s);
    List<String> expectedSegments = newArrayList("com", "google", "proto", "Test");
    assertThat(fqn.getSegments(), equalTo(expectedSegments));
  }
View Full Code Here

    assertThat(fqn.getSegments(), equalTo(expectedSegments));
  }

  @Test public void should_create_qualified_name_from_string_with_whitespace_and_line_returns() {
    String s = "com.\ngoogle. proto.\n Test";
    QualifiedName fqn = converter.toQualifiedName(s);
    List<String> expectedSegments = newArrayList("com", "google", "proto", "Test");
    assertThat(fqn.getSegments(), equalTo(expectedSegments));
  }
View Full Code Here

  @Rule public XtextRule xtext = overrideRuntimeModuleWith(unitTestModule());

  @Inject private QualifiedNames qualifiedNames;

  @Test public void should_add_leading_dot() {
    QualifiedName name = QualifiedName.create("jedis", "Luke");
    QualifiedName withLeadingDot = qualifiedNames.addLeadingDot(name);
    assertThat(withLeadingDot.toString(), equalTo(".jedis.Luke"));
  }
View Full Code Here

    QualifiedName withLeadingDot = qualifiedNames.addLeadingDot(name);
    assertThat(withLeadingDot.toString(), equalTo(".jedis.Luke"));
  }

  @Test public void should_not_add_leading_dot_if_qualified_name_already_has_it() {
    QualifiedName name = QualifiedName.create("", "jedis", "Luke");
    QualifiedName withLeadingDot = qualifiedNames.addLeadingDot(name);
    assertThat(withLeadingDot.toString(), equalTo(".jedis.Luke"));
  }
View Full Code Here

    }
  }

  private void proposeAndAccept(IEObjectDescription d, String proposalFormat, String displayFormat, Image image,
      ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
    QualifiedName name = d.getName();
    String proposalText = name.toString();
    if (!isEmpty(proposalFormat)) {
      proposalText = String.format(proposalFormat, proposalText);
    }
    String lastSegment = name.getLastSegment();
    if (!isEmpty(displayFormat)) {
      lastSegment = String.format(displayFormat, lastSegment);
    }
    String display = String.format("%s - %s", lastSegment, name.toString());
    ICompletionProposal proposal = createCompletionProposal(proposalText, display, image, context);
    acceptor.accept(proposal);
  }
View Full Code Here

  private boolean areNamesEqual(String expected, Object e, List<SearchOption> options) {
    String realExpected = expected;
    if (realExpected.indexOf(".") != -1 && !(e instanceof Package)) {
      String[] segments = expected.split("\\.");
      QualifiedName qualifiedName = QualifiedName.create(segments);
      realExpected = qualifiedName.getLastSegment();
    }
    String actual = nameOf(e);
    if (options.contains(IGNORE_CASE)) {
      return realExpected.equalsIgnoreCase(actual);
    }
View Full Code Here

  //   optional string name = 1;
  // }
  @Test public void should_cache_qualified_names() {
    Message message = xtext.find("Person", Message.class);
    when(namingStrategy.nameOf(message)).thenReturn(pair(NameType.NORMAL, "Person"));
    QualifiedName qualifiedName = provider.getFullyQualifiedName(message, namingStrategy);
    assertThat(qualifiedName.toString(), equalTo("fqn.test.Person"));
    for (int i = 0; i < 10; i++) {
      // these calls should hit the cache
      assertSame(qualifiedName, provider.getFullyQualifiedName(message, namingStrategy));
    }
    verify(namingStrategy, times(1)).nameOf(message);
View Full Code Here

   */
  public boolean areRelated(Package p1, Package p2) {
    if (p1 == null || p2 == null) {
      return false;
    }
    QualifiedName name1 = nameOf(p1);
    QualifiedName name2 = nameOf(p2);
    if (name1 == null || name2 == null) {
      return false;
    }
    if (name1.equals(name2)) {
      return true;
View Full Code Here

   * @param name the base name.
   * @return a collection containing the created qualified names, or an empty list if the name of the given package
   * contains zero or one segments.
   */
  public Collection<QualifiedName> addPackageNameSegments(Package p, QualifiedName name) {
    QualifiedName current = name;
    List<String> segments = segmentsOf(p);
    int segmentCount = segments.size();
    if (segmentCount <= 1) {
      return emptyList();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.naming.QualifiedName

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.