Package org.eclipse.xtext.xdoc.xdoc

Examples of org.eclipse.xtext.xdoc.xdoc.LangDef


    Code resultCode = (Code) result.getContents().get(0);
    assertEquals(expectationCodeString, resultCode.getContents());
  }
 
  public void testFormatCode() throws Exception {
    LangDef langDef = XdocFactory.eINSTANCE.createLangDef();
    langDef.getKeywords().add("foo");
    langDef.getKeywords().add("bar");
    langDef.getKeywords().add("baz");
    langDef.getKeywords().add("dfsdf");
    langDef.getKeywords().add("wweee");
    langDef.getKeywords().add("dsfsd");
    final Utils utils = new Utils();
    String code = null;
    StopWatch watch = new StopWatch();
    for (int i = 0; i < 2 ;i++) {
      code = utils.formatCode("mein foo ist bar nicht baz.", langDef);
View Full Code Here


    }
    watch.resetAndLog("keywords");
    assertEquals("mein&nbsp;<span class=\"keyword\">foo</span>&nbsp;ist&nbsp;<span class=\"keyword\">bar</span>&nbsp;nicht&nbsp;<span class=\"keyword\">baz</span>.", code);
  }
  public void testFormatCode_01() throws Exception {
    LangDef langDef = XdocFactory.eINSTANCE.createLangDef();
    langDef.getKeywords().add("foo");
    langDef.getKeywords().add("bar");
    langDef.getKeywords().add("baz");
    langDef.getKeywords().add("dfsdf");
    langDef.getKeywords().add("wweee");
    langDef.getKeywords().add("dsfsd");
    final Utils utils = new Utils();
    String code = utils.formatCode("/* mein foo ist bar nicht baz.*/", langDef);
    assertEquals("<span class=\"comment\">/*&nbsp;mein&nbsp;foo&nbsp;ist&nbsp;bar&nbsp;nicht&nbsp;baz.*/</span>", code);
  }
View Full Code Here

    String code = utils.formatCode("/* mein foo ist bar nicht baz.*/", langDef);
    assertEquals("<span class=\"comment\">/*&nbsp;mein&nbsp;foo&nbsp;ist&nbsp;bar&nbsp;nicht&nbsp;baz.*/</span>", code);
  }
 
  public void testFormatCode_02() throws Exception {
    LangDef langDef = XdocFactory.eINSTANCE.createLangDef();
    langDef.getKeywords().add("foo");
    langDef.getKeywords().add("bar");
    langDef.getKeywords().add("baz");
    langDef.getKeywords().add("dfsdf");
    langDef.getKeywords().add("wweee");
    langDef.getKeywords().add("dsfsd");
    final Utils utils = new Utils();
    String code = utils.formatCode("' mein foo ist bar nicht baz.'", langDef);
    assertEquals("<span class=\"string\">'&nbsp;mein&nbsp;foo&nbsp;ist&nbsp;bar&nbsp;nicht&nbsp;baz.'</span>", code);
  }
View Full Code Here

    // CODE_BLOCK.getName());
    ICompositeNode node = NodeModelUtils.findActualNodeFor(obj);
    if (node == null)
      return;
    int offset = node.getOffset();
    LangDef lang = ((CodeBlock) obj.eContainer()).getLanguage();
    String code = obj.getContents();
    Set<String> keywords = newHashSet();
    if (lang != null && !lang.eIsProxy()) {
      keywords.addAll(lang.getKeywords());
    }
    Common lexer = new Common();
    lexer.setCharStream(new ANTLRStringStream(code));
    CommonToken t = (CommonToken) lexer.nextToken();
    while (t.getType() != Token.EOF) {
View Full Code Here

      CharSequence _xifexpression_1 = null;
      boolean _containerTypeOf = this.containerTypeOf(block, XdocPackage.Literals.TABLE);
      if (_containerTypeOf) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("\\protect\\lstinline");
        LangDef _language = block.getLanguage();
        CharSequence _langSpec = null;
        if (_language!=null) {
          _langSpec=this.langSpec(_language);
        }
        _builder.append(_langSpec, "");
        _builder.append("�");
        EList<EObject> _contents = block.getContents();
        final Function1<EObject, CharSequence> _function = new Function1<EObject, CharSequence>() {
          public CharSequence apply(final EObject it) {
            return LatexGenerator.this.genCode(it);
          }
        };
        List<CharSequence> _map = ListExtensions.<EObject, CharSequence>map(_contents, _function);
        String _join = IterableExtensions.join(_map);
        _builder.append(_join, "");
        _builder.append("�");
        _xifexpression_1 = _builder;
      } else {
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("\\protect\\lstinline");
        LangDef _language_1 = block.getLanguage();
        CharSequence _langSpec_1 = null;
        if (_language_1!=null) {
          _langSpec_1=this.langSpec(_language_1);
        }
        _builder_1.append(_langSpec_1, "");
        _builder_1.append("{");
        EList<EObject> _contents_1 = block.getContents();
        final Function1<EObject, CharSequence> _function_1 = new Function1<EObject, CharSequence>() {
          public CharSequence apply(final EObject it) {
            return LatexGenerator.this.genCode(it);
          }
        };
        List<CharSequence> _map_1 = ListExtensions.<EObject, CharSequence>map(_contents_1, _function_1);
        String _join_1 = IterableExtensions.join(_map_1);
        _builder_1.append(_join_1, "");
        _builder_1.append("}");
        _xifexpression_1 = _builder_1;
      }
      _xifexpression = _xifexpression_1;
    } else {
      StringConcatenation _builder_2 = new StringConcatenation();
      _builder_2.newLine();
      _builder_2.append("\\begin{lstlisting}");
      LangDef _language_2 = block.getLanguage();
      CharSequence _langSpec_2 = null;
      if (_language_2!=null) {
        _langSpec_2=this.langSpec(_language_2);
      }
      _builder_2.append(_langSpec_2, "");
View Full Code Here

        public Boolean apply(final LangDef e) {
          String _name = e.getName();
          return Boolean.valueOf(Objects.equal(_name, "__XdocDefaultLanguage__"));
        }
      };
      final LangDef lang = IterableExtensions.<LangDef>findFirst(_langDefs, _function);
      Collection<String> _xifexpression = null;
      boolean _notEquals = (!Objects.equal(lang, null));
      if (_notEquals) {
        _xifexpression = lang.getKeywords();
      } else {
        _xifexpression = CollectionLiterals.<String>emptySet();
      }
      _xblockexpression = _xifexpression;
    }
View Full Code Here

   * <!-- end-user-doc -->
   * @generated
   */
  public void setLanguage(LangDef newLanguage)
  {
    LangDef oldLanguage = language;
    language = newLanguage;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XdocPackage.CODE_BLOCK__LANGUAGE, oldLanguage, language));
  }
View Full Code Here

      StringConcatenation _builder = new StringConcatenation();
      _builder.append("<span class=\"inlinecode\">");
      EList<EObject> _contents = cb.getContents();
      EObject _head = IterableExtensions.<EObject>head(_contents);
      CharSequence _generateCode = this.generateCode(((Code) _head));
      LangDef _language = cb.getLanguage();
      String _formatCode = this.utils.formatCode(_generateCode, _language);
      _builder.append(_formatCode, "");
      _builder.append("</span>");
      _xifexpression = _builder;
    } else {
      CharSequence _xblockexpression = null;
      {
        final int indentToRemove = this.utils.calcIndent(cb);
        Iterable<EObject> _xifexpression_1 = null;
        EList<EObject> _contents_1 = cb.getContents();
        int _size = _contents_1.size();
        boolean _greaterThan = (_size > 2);
        if (_greaterThan) {
          EList<EObject> _contents_2 = cb.getContents();
          Iterable<EObject> _tail = IterableExtensions.<EObject>tail(_contents_2);
          EList<EObject> _contents_3 = cb.getContents();
          int _size_1 = _contents_3.size();
          int _minus = (_size_1 - 2);
          _xifexpression_1 = IterableExtensions.<EObject>take(_tail, _minus);
        } else {
          _xifexpression_1 = Collections.EMPTY_LIST;
        }
        final Iterable<EObject> list = _xifexpression_1;
        EList<EObject> _contents_4 = cb.getContents();
        EObject _head_1 = IterableExtensions.<EObject>head(_contents_4);
        CharSequence _generateCode_1 = this.generateCode(_head_1);
        String _trimLines = this.trimLines(_generateCode_1, indentToRemove);
        final String first = _trimLines.replaceAll("\\A(\\s*\n)*", "");
        String _xifexpression_2 = null;
        EList<EObject> _contents_5 = cb.getContents();
        EObject _last = IterableExtensions.<EObject>last(_contents_5);
        EList<EObject> _contents_6 = cb.getContents();
        EObject _head_2 = IterableExtensions.<EObject>head(_contents_6);
        boolean _notEquals = (!Objects.equal(_last, _head_2));
        if (_notEquals) {
          EList<EObject> _contents_7 = cb.getContents();
          EObject _last_1 = IterableExtensions.<EObject>last(_contents_7);
          CharSequence _generateCode_2 = this.generateCode(_last_1);
          String _trimLines_1 = this.trimLines(_generateCode_2, indentToRemove);
          _xifexpression_2 = _trimLines_1.replaceAll("(\\s*\n)*\\Z", "");
        } else {
          String _xblockexpression_1 = null;
          {
            first.replaceAll("(\\s*\n)*\\Z", "");
            _xblockexpression_1 = "";
          }
          _xifexpression_2 = _xblockexpression_1;
        }
        final String last = _xifexpression_2;
        StringConcatenation _builder_1 = new StringConcatenation();
        _builder_1.append("<div class=\"literallayout\">");
        _builder_1.newLine();
        _builder_1.append("<div class=\"incode\">");
        _builder_1.newLine();
        _builder_1.append("<p class=\"code\">");
        _builder_1.newLine();
        LangDef _language_1 = cb.getLanguage();
        String _formatCode_1 = this.utils.formatCode(first, _language_1);
        _builder_1.append(_formatCode_1, "");
        _builder_1.newLineIfNotEmpty();
        {
          for(final EObject code : list) {
            CharSequence _generateCode_3 = this.generateCode(code);
            String _trimLines_2 = this.trimLines(_generateCode_3, indentToRemove);
            LangDef _language_2 = cb.getLanguage();
            String _formatCode_2 = this.utils.formatCode(_trimLines_2, _language_2);
            _builder_1.append(_formatCode_2, "");
            _builder_1.newLineIfNotEmpty();
          }
        }
        LangDef _language_3 = cb.getLanguage();
        String _formatCode_3 = this.utils.formatCode(last, _language_3);
        _builder_1.append(_formatCode_3, "");
        _builder_1.newLineIfNotEmpty();
        _builder_1.append("</p>");
        _builder_1.newLine();
View Full Code Here

      if (_isInlineCode) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("<span class=\"inlinecode\">");
        EList<EObject> _contents_1 = cb.getContents();
        EObject _head = IterableExtensions.<EObject>head(_contents_1);
        LangDef _language = cb.getLanguage();
        CharSequence _generateCode = this.generateCode(((Code) _head), _language);
        _builder.append(_generateCode, "");
        _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");
              _builder_1.newLineIfNotEmpty();
            }
          }
View Full Code Here

      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.LangDef

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.