File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -177,8 +177,11 @@ object Scanners {
177177 /** All doc comments kept by their end position in a `Map` */
178178 private [this ] var docstringMap : SortedMap [Int , Comment ] = SortedMap .empty
179179
180- /* All comments positions will be stored in this */
181- var commentPositions : mutable.MutableList [Position ] = mutable.MutableList ()
180+ /* A Buffer for comment positions */
181+ private [this ] val commentPosBuf = new mutable.ListBuffer [Position ]
182+
183+ /** Return a list of all the comment positions */
184+ def commentPositions : List [Position ] = commentPosBuf.toList
182185
183186 private [this ] def addComment (comment : Comment ): Unit = {
184187 val lookahead = lookaheadReader()
@@ -619,7 +622,7 @@ object Scanners {
619622 if (keepComments) {
620623 val pos = Position (start, charOffset - 1 , start)
621624 val comment = Comment (pos, flushBuf(commentBuf))
622- commentPositions += pos
625+ commentPosBuf += pos
623626
624627 if (comment.isDocComment) {
625628 addComment(comment)
Original file line number Diff line number Diff line change @@ -49,11 +49,6 @@ object SyntaxHighlighting {
4949 highlightRange(pos.start, pos.end, color)
5050 }
5151
52- def highlightComments (commentsPos : mutable.MutableList [Position ]): Unit = {
53- for (pos <- commentsPos)
54- highlightPosition(pos,CommentColor )
55- }
56-
5752 val scanner = new Scanner (source)
5853 while (scanner.token != EOF ) {
5954 val start = scanner.offset
@@ -87,7 +82,9 @@ object SyntaxHighlighting {
8782 }
8883 }
8984
90- highlightComments(scanner.commentPositions)
85+ scanner.commentPositions.foreach {
86+ highlightPosition(_,CommentColor )
87+ }
9188
9289 object TreeHighlighter extends untpd.UntypedTreeTraverser {
9390 import untpd ._
You can’t perform that action at this time.
0 commit comments