/*
Highlight lines when a multi line comment is still 'open'
(ie. matching end delimiter has not yet been encountered)
345941
private boolean commentLinesBefore( String content, int line )
  {
    int offset = _root.getElement( line ).getStartOffset();
    // Start of comment not found, nothing to do
    int startDelimiter = lastIndexOf( content, getStartDelimiter(), offset - 2 );
    if( startDelimiter < 0 )
    {
      return false;
    }
    // Matching start/end of comment found, nothing to do
    int endDelimiter = indexOf( content, getEndDelimiter(), startDelimiter );
    if( endDelimiter < offset & endDelimiter != -1 )
    {
      return false;
    }
    // End of comment not found, highlight the lines
    setCharacterAttributes( startDelimiter, offset - startDelimiter + 1, _comment, false );
    return true;
  }
533755
function() {
        var line, lines = this.sourceText.split(/\n/mg),
            lineLen = lines.length;

        var inCommenting, curComment, closeCommentIdx;

        for (var i = 0; i < lineLen; ++i) {
            line = lines[i].trim();
            if (line.startsWith('/**')) {
                inCommenting = true;
                curComment = new Comment();
                //Comment closed has to starts with "*/"
            } else if (line.startsWith('*/')) {
                inCommenting = false;
                closeCommentIdx = i;
            } else if (!inCommenting && (1 === i - closeCommentIdx) && /(\bfunction\b\s*?(\w+?)\s*\(([^\(\)]*)\))|((\w+)?\s*(?::|=)\s*function\s*\(([^\(\)]*)\))/.test(line)) {
                curComment.setFunc(RegExp.$2 || RegExp.$5, RegExp.$3 || RegExp.$6);
                if ('string' !== typeof curComment.getTag('ignore')) {
                    this.Comments.push(curComment);
                }
                curComment = null;
            } else if (!inCommenting && (1 === i - closeCommentIdx) && /(\w+)\s*(?::|=)(?!\s*function)/.test(line)) {
                curComment.setAttr(RegExp.$1);
                if ('string' !== typeof curComment.getTag('ignore')) {
                    this.Comments.push(curComment);
                }
                curComment = null;
            } else if (inCommenting) {
                line = line.replace(/^\*/, '').trim();
                if (/^@(\w+)([^\r\n]*)/.test(line)) {
                    curComment.addTag(RegExp.$1, RegExp.$2 || "");
                } else {
                    curComment.addDesc(line);
                }
            }

        } //for

        this._merge();
    }
990737
def highlight_at!(y, x)
      update_highlighter if @highlighter_tokens.nil?

      fail(HighlighterUnknownSegment, "line: #{y}") if @highlighter_tokens[@offset_y + y].nil?
      fail(HighlighterUnknownSegment, "line: #{y} char: #{x}") if @highlighter_tokens[@offset_y + y][x].nil?

      @highlighter_tokens[@offset_y + y][x]
    end
1162998
function stripTrailingComment(line, comment) {

            // loc.column is zero-indexed
            return line.slice(0, comment.loc.start.column).replace(/\s+$/u, "");
        }
645370
def _in_multi_line(self, line):
        """"""

        # we are only looking for explicitly joined lines here, not
        # implicit ones (i.e. brackets, braces etc.).  this is just to
        # guard against the possibility of modifying the space inside of
        # a literal multiline string with unfortunately placed
        # whitespace

        current_state = (self.backslashed or self.triplequoted)

        if re.search(r"\\$", line):
            self.backslashed = True
        else:
            self.backslashed = False

        triples = len(re.findall(r"\"\"\"|\'\'\'", line))
        if triples == 1 or triples % 2 != 0:
            self.triplequoted = not self.triplequoted

        return current_state
405520
function isTripleSlashComment(comment) {
                // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
                // so that we don't end up computing comment string and doing match for all // comments
                if (currentText.charCodeAt(comment.pos + 1) === 47 /* slash */ &&
                    comment.pos + 2 < comment.end &&
                    currentText.charCodeAt(comment.pos + 2) === 47 /* slash */) {
                    var textSubStr = currentText.substring(comment.pos, comment.end);
                    return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
                        textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ?
                        true : false;
                }
                return false;
            }
726561
def clear_highlight(self, src_id, line_start=0, line_end=-1, async_=None,
                        **kwargs):
        """"""
        async_ = check_async(async_, kwargs, True)
        self.request('nvim_buf_clear_highlight', src_id,
                     line_start, line_end, async_=async_)
1026361
def highlight_current_line(self):
        """"""
        selection = TextDecoration(self.textCursor())
        selection.format.setProperty(QTextFormat.FullWidthSelection,
                                     to_qvariant(True))
        selection.format.setBackground(self.currentline_color)
        selection.cursor.clearSelection()
        self.set_extra_selections('current_line', [selection])
        self.update_extra_selections()
884989
@Override
    public void highlight(StringBuilder out, List<String> lines, String meta) {
        out.append("<pre");
        if (StringUtils.isNotBlank(meta)) {
            out.append(" class='brush:" + meta + "'");
        }
        out.append(">");
        for (String line : lines) {
            for (int i = 0; i < line.length(); i++) {
                final char c;
                switch (c = line.charAt(i)) {
                    case '&':
                        out.append("&amp;");
                        break;
                    case '<':
                        out.append("&lt;");
                        break;
                    case '>':
                        out.append("&gt;");
                        break;
                    default:
                        out.append(c);
                        break;
                }
            }
            out.append('\n');
        }
        out.append("</pre>");
    }
662474
def next_code_is_indented(lines):
    """"""
    for line in lines:
        if _BLANK_LINE.match(line) or _PY_COMMENT.match(line):
            continue
        return _PY_INDENTED.match(line)
    return False
774041
function getLastCommentLineOfBlock(commentStartLine) {
            const currentCommentEnd = commentEndLine[commentStartLine];

            return commentEndLine[currentCommentEnd + 1] ? getLastCommentLineOfBlock(currentCommentEnd + 1) : currentCommentEnd;
        }
926538
public static String commentLine( String line ) {

		String result = line;
		if( ! Utils.isEmptyOrWhitespaces( line )
				&& ! line.trim().startsWith( ParsingConstants.COMMENT_DELIMITER ))
			result = ParsingConstants.COMMENT_DELIMITER + line;

		return result;
	}
791661
function hasNewlineAfter(node) {
            const lastToken = getLastTokenOnLine(node);
            const tokenAfter = sourceCode.getTokenAfter(lastToken, { includeComments: true });

            return tokenAfter.loc.start.line - lastToken.loc.end.line >= 2;
        }
980331
def highlight_block(self, text):
        """"""
        text = to_text_string(text)
        previous_state = tbh.get_state(self.currentBlock().previous())
        
        if previous_state == self.COMMENT:
            self.setFormat(0, len(text), self.formats["comment"])
        else:
            previous_state = self.NORMAL
            self.setFormat(0, len(text), self.formats["normal"])
        
        tbh.set_state(self.currentBlock(), previous_state)
        match = self.PROG.search(text)        

        match_count = 0
        n_characters = len(text)
        # There should never be more matches than characters in the text.
        while match and match_count < n_characters:
            match_dict = match.groupdict()
            for key, value in list(match_dict.items()):
                if value:
                    start, end = match.span(key)
                    if previous_state == self.COMMENT:
                        if key == "multiline_comment_end":
                            tbh.set_state(self.currentBlock(), self.NORMAL)
                            self.setFormat(end, len(text),
                                           self.formats["normal"])
                        else:
                            tbh.set_state(self.currentBlock(), self.COMMENT)
                            self.setFormat(0, len(text),
                                           self.formats["comment"])
                    else:
                        if key == "multiline_comment_start":
                            tbh.set_state(self.currentBlock(), self.COMMENT)
                            self.setFormat(start, len(text),
                                           self.formats["comment"])
                        else:
                            tbh.set_state(self.currentBlock(), self.NORMAL)
                            try:
                                self.setFormat(start, end-start,
                                               self.formats[key])
                            except KeyError:
                                # happens with unmatched end-of-comment;
                                # see issue 1462
                                pass
            
            match = self.PROG.search(text, match.end())
            match_count += 1
        
        self.highlight_spaces(text)
1083092
private void commentLinesAfter( String content, int line ) {
        int offset = rootElement.getElement(line).getEndOffset();
        // End of comment not found, nothing to do
        int endDelimiter = indexOf(content, getEndDelimiter(), offset);
        if (endDelimiter < 0)
            return;
        // Matching start/end of comment found, comment the lines
        int startDelimiter = lastIndexOf(content, getStartDelimiter(), endDelimiter);
        if (startDelimiter < 0 || startDelimiter <= offset) {
            doc.setCharacterAttributes(offset, endDelimiter - offset + 1, comment, false);
        }
    }
1273832
function(line, isInComment) {
  while (true || line.length > 0) {
    var startIndex = line.indexOf('{-');
    var endIndex = line.indexOf('-}');
    var singleLineComment = line.indexOf('--');

    // when we have a single line comment
    if (singleLineComment > -1 && !isInComment) {
      line = line.substr(0, singleLineComment);
      continue;
    }

    // when there's no comment chars
    if (startIndex === -1 && endIndex === -1) {
      return {
        line: isInComment ? '' : line,
        isInComment: isInComment,
      };
    }

    // when there's a start and end
    if (startIndex > -1 && endIndex > -1) {
      line = line.substr(0, startIndex) + line.substr(endIndex + 2);
      continue;
    }

    // when there's a start, but no end
    if (startIndex > -1)
      return { line: line.substr(0, startIndex), isInComment: true };

    // when there's an end, but no start
    if (endIndex > -1 && isInComment)
      return { line: line.substr(endIndex + 2), isInComment: false };
  }

  return { line: '', isInComment: isInComment };
}
739155
function lineComment(editor) {
        editor = editor || EditorManager.getFocusedEditor();
        if (!editor) {
            return;
        }

        editor.setSelections(editor.document.doMultipleEdits(_getLineCommentEdits(editor, editor.getSelections(), "line")));
    }