}
return _xblockexpression;
}
public String getHighlightedHtmlCode(final String code, final LangDef language) {
final Common lexer = new Common();
String _unescapeXdocChars = this.unescapeXdocChars(code);
ANTLRStringStream _aNTLRStringStream = new ANTLRStringStream(_unescapeXdocChars);
lexer.setCharStream(_aNTLRStringStream);
Set<String> _xifexpression = null;
boolean _notEquals = (!Objects.equal(language, null));
if (_notEquals) {
EList<String> _keywords = language.getKeywords();
final Function1<String, String> _function = new Function1<String, String>() {
public String apply(final String it) {
return Utils.this.unescapeXdocChars(it);
}
};
List<String> _map = ListExtensions.<String, String>map(_keywords, _function);
_xifexpression = IterableExtensions.<String>toSet(_map);
} else {
_xifexpression = CollectionLiterals.<String>emptySet();
}
final Set<String> keywords = _xifexpression;
Token token = lexer.nextToken();
final StringBuilder result = new StringBuilder();
while ((token.getType() != Token.EOF)) {
{
int _type = token.getType();
final int t = _type;
boolean _matched = false;
if (!_matched) {
if (Objects.equal(t, Common.ID)) {
_matched=true;
String _text = token.getText();
boolean _contains = keywords.contains(_text);
if (_contains) {
StringBuilder _append = result.append("<span class=\"keyword\">");
String _text_1 = token.getText();
String _whitespace2Entities = this.whitespace2Entities(_text_1);
StringBuilder _append_1 = _append.append(_whitespace2Entities);
_append_1.append("</span>");
} else {
String _text_2 = token.getText();
result.append(_text_2);
}
}
}
if (!_matched) {
if (Objects.equal(t, Common.WS)) {
_matched=true;
String _text_3 = token.getText();
String _whitespace2Entities_1 = this.whitespace2Entities(_text_3);
result.append(_whitespace2Entities_1);
}
}
if (!_matched) {
if ((((((t == Common.STRING) || (t == Common.RICH_TEXT)) || (t == Common.RICH_TEXT_END)) || (t == Common.RICH_TEXT_START)) || (t == Common.RICH_TEXT_INBETWEEN))) {
_matched=true;
StringBuilder _append_2 = result.append("<span class=\"string\">");
String _text_4 = token.getText();
String _whitespace2Entities_2 = this.whitespace2Entities(_text_4);
StringBuilder _append_3 = _append_2.append(_whitespace2Entities_2);
_append_3.append("</span>");
}
}
if (!_matched) {
if (((((t == Common.COMMENT_RICH_TEXT_END) || (t == Common.COMMENT_RICH_TEXT_INBETWEEN)) || (t == Common.ML_COMMENT)) || (t == Common.SL_COMMENT))) {
_matched=true;
StringBuilder _append_4 = result.append("<span class=\"comment\">");
String _text_5 = token.getText();
String _whitespace2Entities_3 = this.whitespace2Entities(_text_5);
StringBuilder _append_5 = _append_4.append(_whitespace2Entities_3);
_append_5.append("</span>");
}
}
if (!_matched) {
String _text_6 = token.getText();
String _whitespace2Entities_4 = this.whitespace2Entities(_text_6);
result.append(_whitespace2Entities_4);
}
Token _nextToken = lexer.nextToken();
token = _nextToken;
}
}
return result.toString();
}