Package org.eclipse.xtext.resource

Examples of org.eclipse.xtext.resource.XtextResource


  @Test
  public void test_CommentShouldNotBeMovedToNextLine() throws Exception {
    // issue caused linebreaks between comment and statement to be removed
    String code = "$a = 10 # comment\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce same result", code, s);

  }
View Full Code Here


  @Test
  public void test_CommentShouldNotBeMovedToPreviousLine() throws Exception {
    // issue caused linebreaks between comment and statement to be removed
    String code = "$a = 10\n# comment\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce same result", code, s);
  }
View Full Code Here

  @Test
  public void test_CommentShouldNotBeTurnedIntoDocumentation() throws Exception {
    // issue caused linebreaks after comment, before statement to be removed
    String code = "# wtf\n\nclass foo {\n}\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", code, s);

    code = "/* wtf */\n\nclass foo {\n}\n";
    r = getResourceFromString(code);
    s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", code, s);
  }
View Full Code Here

  @Test
  public void test_DocumentationShouldStickToElement() throws Exception {
    // issue caused documentation comment to be separated from its element
    String code = "class foo {\n}\n# doc\nclass foo {\n}\n";
    String fmt = "class foo {\n}\n\n# doc\nclass foo {\n}\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", fmt, s);

    code = "class foo {\n}\n/* doc */\nclass foo {\n}\n";
    fmt = "class foo {\n}\n\n/* doc */\nclass foo {\n}\n";
    r = getResourceFromString(code);
    s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", fmt, s);
  }
View Full Code Here

  }

  @Test
  public void test_IndentsBracketsOk() throws Exception {
    String code = "file { \"x\":\n  notify => Service[\"y\"],\n}\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", code, s);
  }
View Full Code Here

    String code = "$a = 10\n" + //
        "$b = \"123${a}234\"\n" + //
        "\n" + //
        "class x {\n" + //
        "}\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", code, s);
  }
View Full Code Here

  @Test
  public void test_List() throws Exception {
    String code = "$a=[\"10\",'20']";
    String fmt = "$a = [\"10\", '20']\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", fmt, s);
  }
View Full Code Here

  @Test
  public void test_List_WithComments() 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 */\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", fmt, s);
  }
View Full Code Here

  @Test
  public void test_NoFunnyLeadingInsert() throws Exception {
    // one issue caused a space to be inserted when the first element was a comment
    String code = "# wtf\n$a = 1\n";
    XtextResource r = getResourceFromString(code);
    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", code, s);

    code = "/* wtf */\n$a = 1\n";
    r = getResourceFromString(code);
    s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", code, s);
  }
View Full Code Here

  @Test
  public void test_OptionalTrailingBreaks() throws Exception {
    String code = "file{'afile':owner=>'foo'}\n\n\n\n\n";
    String fmt = "file { 'afile':\n  owner => 'foo'\n}\n\n";
    XtextResource r = getResourceFromString(code);

    String s = serializeFormatted(r.getContents().get(0));
    assertEquals("formatting should produce wanted result", fmt, 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.