Package org.eclipse.xtext.resource

Examples of org.eclipse.xtext.resource.XtextResource


        "  'title2':\n    owner  => 777,\n    ensure => present\n}\n";
    String fmt2 = //
    "file {\n  'title':\n    owner  => 777,\n    ensure => present;\n\n" + //
        "  'title2':\n    owner  => 777,\n    ensure => present;\n}\n";

    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting with node model should produce wanted result", fmt, s);

    brutalDetachNodeModel(r.getContents().get(0));
    s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting without node model should produce wanted result", fmt2, s);
  }
View Full Code Here


  @Test
  public void test_Resource_OneBody() throws Exception {
    String code = "file { 'title': owner => 777, ensure => present }";
    String fmt = "file { 'title':\n  owner  => 777,\n  ensure => present\n}\n";
    String fmt2 = "file { 'title':\n  owner  => 777,\n  ensure => present,\n}\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting with node-model should produce wanted result", fmt, s);

    brutalDetachNodeModel(r.getContents().get(0));
    s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting without node-model should produce wanted result", fmt2, s);
  }
View Full Code Here

  @Test
  public void test_Resource_OneBody_NoTitle() throws Exception {
    String code = "File { owner => 777, ensure => present }";
    String fmt = "File {\n  owner  => 777,\n  ensure => present\n}\n";
    String fmt2 = "File {\n  owner  => 777,\n  ensure => present,\n}\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", fmt, s);

    brutalDetachNodeModel(r.getContents().get(0));
    s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting without node-model should produce wanted result", fmt2, s);
  }
View Full Code Here

        + "  }"; //
    String code3 = /*
            */"\n}\n";

    String code = code1 + code2 + code3;
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", code, s);

    s = serializeFormatted(r.getContents().get(0), new TextRegion(10, 47));
    assertEquals("formatting should produce wanted result", code2, s);

  }
View Full Code Here

    // String original = "before${var}/after${1+2}$$${$var}";
    // String formatted = doubleQuote("before${var}/after${1 + 2}$$${$var}");
    String code = "$a = " + doubleQuote("${1+2}");
    String formatted = "$a = " + doubleQuote("${1 + 2}");
    formatted += "\n";
    XtextResource r = getResourceFromString(code);
    EObject result = r.getContents().get(0);
    assertTrue("Should be a PuppetManifest", result instanceof PuppetManifest);
    result = ((PuppetManifest) result).getStatements().get(0);
    assertTrue("Should be a DoubleQuotedString", result instanceof AssignmentExpression);

    String s = serializeFormatted(r.getContents().get(0));
    if(theDebugAcceptor != null)
      System.err.println(theDebugAcceptor.toString());
    assertEquals("Serialization of interpolated string should produce same result", formatted, s);
  }
View Full Code Here

  @Test
  public void test_Serialize_arrayNoSpaces() throws Exception {
    String code = "$a=['10','20']";
    String fmt = "$a = [ '10' , '20' ]";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("serialization should produce expected one-spaced result", fmt, s);
  }
View Full Code Here

  @Test
  public void test_Serialize_arrayWithComments() throws Exception {
    String code = "/*1*/$a/*2*/=/*3*/[/*4*/'10'/*5*/,/*6*/'20'/*7*/]/*8*/";
    String fmt = "/*1*/ $a /*2*/ = /*3*/ [ /*4*/ '10' /*5*/ , /*6*/ '20' /*7*/ ] /*8*/";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("serialization should produce expected on-spaced result", fmt, s);
  }
View Full Code Here

  @Test
  public void test_Serialize_shortArrayWithComments() throws Exception {
    String code = "[a /*1*/]/*2*/";
    String fmt = "[ a /*1*/ ] /*2*/";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("serialization should produce expected one-spaced result", fmt, s);
  }
View Full Code Here

  }

  @Test
  public void test_Serialize_LeadingComments() throws Exception {
    String code = "# 1. sl cmnt\n" + "# 2. sl cmnt\n" + "$a\n";
    XtextResource r = getResourceFromString(code);
    String s = serialize(r.getContents().get(0));
    assertEquals("serialization should produce same result", code, s);

  }
View Full Code Here

  }

  @Test
  public void test_Serialize_SmokeTest() throws Exception {
    String code = "$a\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("serialization should produce same result", code, s);

    s = serialize(r.getContents().get(0));
    assertEquals("formatted serialization should produce same result", code, s);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.resource.XtextResource

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.