Skip to content

How to create CodeLineVisitor? #171

Closed Answered by minhnt3
minhnt3 asked this question in Q&A
Discussion options

You must be logged in to vote

I did it, so I close this issue now.

extension CustomLintResolverExt on CustomLintResolver {
  void getLineContents(void Function(CodeLine codeLine) onCodeLine) {
    for (final startOffset in lineInfo.lineStarts) {
      final lineCount = lineInfo.lineStarts.length;
      final lineNumber = lineInfo.getLocation(startOffset).lineNumber;
      if (lineNumber <= lineCount - 1) {
        final startOffsetOfNextLine = lineInfo.getOffsetOfLineAfter(startOffset);
        final lineLength = startOffsetOfNextLine - startOffset - 1;
        onCodeLine(
          CodeLine(
            lineNumber: lineNumber,
            lineOffset: startOffset,
            lineLength: lineLength,
            conten…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by minhnt3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant