Package org.eclipse.xtext.xdoc.xdoc

Examples of org.eclipse.xtext.xdoc.xdoc.CodeBlock


      }
    } while(toks.length == 3);
  }

  public void testRemoveIndent() throws Exception {
    CodeBlock result = StringFormatter.removeIndent(this.testCodeBlock);
    assertEquals(1, result.getContents().size());
    assertTrue(result.getContents().get(0) instanceof Code);
    Code resultCode = (Code) result.getContents().get(0);
    assertEquals(expectationCodeString, resultCode.getContents());
  }
View Full Code Here


      if (_language_2!=null) {
        _langSpec_2=this.langSpec(_language_2);
      }
      _builder_2.append(_langSpec_2, "");
      _builder_2.newLineIfNotEmpty();
      CodeBlock _removeIndent = StringUtils.removeIndent(block);
      EList<EObject> _contents_2 = _removeIndent.getContents();
      final Function1<EObject, CharSequence> _function_2 = new Function1<EObject, CharSequence>() {
        public CharSequence apply(final EObject e) {
          return LatexGenerator.this.genCode(e);
        }
      };
View Full Code Here

        _builder.append("</span>");
        _xifexpression_1 = _builder;
      } else {
        CharSequence _xblockexpression = null;
        {
          final CodeBlock block = StringUtils.removeIndent(cb);
          StringConcatenation _builder_1 = new StringConcatenation();
          _builder_1.append("<div class=\"literallayout\">");
          _builder_1.newLine();
          _builder_1.append("\t");
          _builder_1.append("<div class=\"incode\">");
          _builder_1.newLine();
          _builder_1.append("\t\t");
          _builder_1.append("<p class=\"code\">");
          _builder_1.newLine();
          {
            EList<EObject> _contents_2 = block.getContents();
            for(final EObject code : _contents_2) {
              _builder_1.append("\t\t\t");
              LangDef _language_1 = cb.getLanguage();
              CharSequence _generateCode_1 = this.generateCode(code, _language_1);
              _builder_1.append(_generateCode_1, "\t\t\t");
View Full Code Here

  public void setUp() {
    LangDef _createLangDef = XdocFactory.eINSTANCE.createLangDef();
    this.testLangDef = _createLangDef;
    EList<String> _keywords = this.testLangDef.getKeywords();
    Iterables.<String>addAll(_keywords, ((Iterable<? extends String>)Conversions.doWrapArray(this.testKeyWords)));
    CodeBlock _createCodeBlock = XdocFactory.eINSTANCE.createCodeBlock();
    this.testCodeBlock = _createCodeBlock;
    final Code testCode = XdocFactory.eINSTANCE.createCode();
    testCode.setContents(this.testCodeString);
    EList<EObject> _contents = this.testCodeBlock.getContents();
    _contents.add(testCode);
View Full Code Here

    Document doc = (Document) file.getMainSection();
    EList<TextOrMarkup> contents = doc.getChapters().get(0)
        .getContents();
    TextOrMarkup textOrMarkup = contents.get(0);
    assertEquals(1, textOrMarkup.getContents().size());
    CodeBlock cb = (CodeBlock) textOrMarkup.getContents().get(0);
    Code code = (Code) cb.getContents().get(0);
    assertEquals("\nclass Foo {\n"
        + "public static void main(String\\[\\] args){\n"
        + "System.out.println(\"Hello World\\n\");\n" + "}\n" + "}\n",
        code.getContents());
    textOrMarkup = contents.get(1);
    cb = (CodeBlock) textOrMarkup.getContents().get(0);
    assertEquals(0, cb.getContents().size());
  }
View Full Code Here

    XdocFile file = getDocFromFile(TEST_FILE_DIR
        + "codeWithLanguageTest.xdoc");
    Document abstractSection = (Document) file.getMainSection();
    TextOrMarkup textOrMarkup = abstractSection.getChapters().get(0).getContents().get(0);
    assertEquals(1, textOrMarkup.getContents().size());
    CodeBlock cb = (CodeBlock) textOrMarkup.getContents().get(0);
    assertEquals("\n\t/* a testclass */\n"
        + "\tclass Foo {\n"
        + "\t\tpublic static void main(String\\[\\] args){\n"
        + "\t\t\tSystem.out.println(\"Hello World\"+'\\n'); // say \"hello\"\n"
        + "\t\t}\n"
        + "\t}\n",
        ((Code) cb.getContents().get(0)).getContents());
    assertEquals("Java", cb.getLanguage().getName());
  }
View Full Code Here

      EList<EObject> _contents = textOrMarkup.getContents();
      int _size = _contents.size();
      Assert.assertEquals(1, _size);
      EList<EObject> _contents_1 = textOrMarkup.getContents();
      EObject _head_1 = IterableExtensions.<EObject>head(_contents_1);
      CodeBlock cb = ((CodeBlock) _head_1);
      EList<EObject> _contents_2 = cb.getContents();
      EObject _head_2 = IterableExtensions.<EObject>head(_contents_2);
      final Code code = ((Code) _head_2);
      StringConcatenation _builder = new StringConcatenation();
      _builder.newLine();
      _builder.append("class Foo {");
      _builder.newLine();
      _builder.append("public static void main(String\\[\\] args){");
      _builder.newLine();
      _builder.append("System.out.println(\"Hello World\\n\");");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      _builder.append("}");
      _builder.newLine();
      String _string = _builder.toString();
      String _contents_3 = code.getContents();
      Assert.assertEquals(_string, _contents_3);
      Iterable<TextOrMarkup> _tail = IterableExtensions.<TextOrMarkup>tail(contents);
      TextOrMarkup _head_3 = IterableExtensions.<TextOrMarkup>head(_tail);
      textOrMarkup = _head_3;
      EList<EObject> _contents_4 = textOrMarkup.getContents();
      EObject _head_4 = IterableExtensions.<EObject>head(_contents_4);
      cb = ((CodeBlock) _head_4);
      EList<EObject> _contents_5 = cb.getContents();
      int _size_1 = _contents_5.size();
      Assert.assertEquals(0, _size_1);
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
View Full Code Here

      EList<EObject> _contents_1 = textOrMarkup.getContents();
      int _size = _contents_1.size();
      Assert.assertEquals(1, _size);
      EList<EObject> _contents_2 = textOrMarkup.getContents();
      EObject _get_1 = _contents_2.get(0);
      final CodeBlock cb = ((CodeBlock) _get_1);
      StringConcatenation _builder = new StringConcatenation();
      _builder.newLine();
      _builder.append("\t", "");
      _builder.append("/* a testclass */");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("class Foo {");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("public static void main(String\\[\\] args){");
      _builder.newLine();
      _builder.append("\t\t\t");
      _builder.append("System.out.println(\"Hello World\"+\'\\n\'); // say \"hello\"");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("}");
      _builder.newLine();
      String _string = _builder.toString();
      EList<EObject> _contents_3 = cb.getContents();
      EObject _head = IterableExtensions.<EObject>head(_contents_3);
      String _contents_4 = ((Code) _head).getContents();
      Assert.assertEquals(_string, _contents_4);
      LangDef _language = cb.getLanguage();
      String _name = _language.getName();
      Assert.assertEquals("Java", _name);
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.xdoc.xdoc.CodeBlock

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.