File tree 2 files changed +9
-9
lines changed
compiler/src/dotty/tools/dotc
2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -177,8 +177,11 @@ object Scanners {
177
177
/** All doc comments kept by their end position in a `Map` */
178
178
private [this ] var docstringMap : SortedMap [Int , Comment ] = SortedMap .empty
179
179
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
182
185
183
186
private [this ] def addComment (comment : Comment ): Unit = {
184
187
val lookahead = lookaheadReader()
@@ -619,7 +622,7 @@ object Scanners {
619
622
if (keepComments) {
620
623
val pos = Position (start, charOffset - 1 , start)
621
624
val comment = Comment (pos, flushBuf(commentBuf))
622
- commentPositions += pos
625
+ commentPosBuf += pos
623
626
624
627
if (comment.isDocComment) {
625
628
addComment(comment)
Original file line number Diff line number Diff line change @@ -49,11 +49,6 @@ object SyntaxHighlighting {
49
49
highlightRange(pos.start, pos.end, color)
50
50
}
51
51
52
- def highlightComments (commentsPos : mutable.MutableList [Position ]): Unit = {
53
- for (pos <- commentsPos)
54
- highlightPosition(pos,CommentColor )
55
- }
56
-
57
52
val scanner = new Scanner (source)
58
53
while (scanner.token != EOF ) {
59
54
val start = scanner.offset
@@ -87,7 +82,9 @@ object SyntaxHighlighting {
87
82
}
88
83
}
89
84
90
- highlightComments(scanner.commentPositions)
85
+ scanner.commentPositions.foreach {
86
+ highlightPosition(_,CommentColor )
87
+ }
91
88
92
89
object TreeHighlighter extends untpd.UntypedTreeTraverser {
93
90
import untpd ._
You can’t perform that action at this time.
0 commit comments