Skip to content

Commit

Permalink
Incorporated feedback given by @allanrenucci
Browse files Browse the repository at this point in the history
  • Loading branch information
mrveera committed Nov 13, 2018
1 parent d169e36 commit b27e226
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 6 additions & 3 deletions compiler/src/dotty/tools/dotc/parsing/Scanners.scala
Expand Up @@ -177,8 +177,11 @@ object Scanners {
/** All doc comments kept by their end position in a `Map` */
private[this] var docstringMap: SortedMap[Int, Comment] = SortedMap.empty

/* All comments positions will be stored in this */
var commentPositions:mutable.MutableList[Position] = mutable.MutableList()
/* A Buffer for comment positions */
private[this] val commentPosBuf = new mutable.ListBuffer[Position]

/** Return a list of all the comment positions */
def commentPositions: List[Position] = commentPosBuf.toList

private[this] def addComment(comment: Comment): Unit = {
val lookahead = lookaheadReader()
Expand Down Expand Up @@ -619,7 +622,7 @@ object Scanners {
if (keepComments) {
val pos = Position(start, charOffset - 1, start)
val comment = Comment(pos, flushBuf(commentBuf))
commentPositions += pos
commentPosBuf += pos

if (comment.isDocComment) {
addComment(comment)
Expand Down
Expand Up @@ -49,11 +49,6 @@ object SyntaxHighlighting {
highlightRange(pos.start, pos.end, color)
}

def highlightComments(commentsPos: mutable.MutableList[Position]): Unit = {
for (pos <- commentsPos)
highlightPosition(pos,CommentColor)
}

val scanner = new Scanner(source)
while (scanner.token != EOF) {
val start = scanner.offset
Expand Down Expand Up @@ -87,7 +82,9 @@ object SyntaxHighlighting {
}
}

highlightComments(scanner.commentPositions)
scanner.commentPositions.foreach {
highlightPosition(_,CommentColor)
}

object TreeHighlighter extends untpd.UntypedTreeTraverser {
import untpd._
Expand Down

0 comments on commit b27e226

Please sign in to comment.