Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
63d3a35
compiler util: collect comments during Scanner phase and store it in …
rochala May 12, 2023
fde037a
metals initial version: 41e96ee33f82 copied into dotty
rochala May 12, 2023
9f271fe
changes: make mtags compile in dotty, changes metals code and adds ne…
rochala May 12, 2023
38f58dc
additions: copy tests from metals version: 41e96ee33f82 , create diff…
rochala May 12, 2023
1a02dbf
refactor: change package from scala.meta to dotty.tools.pc
rochala May 12, 2023
fffe497
refactor: organize imports, unify formatting with mtags in metals
rochala May 12, 2023
3e857a2
update Build.scala and build.sbt to support nonbootstrapped compiler,…
rochala May 16, 2023
e643f9f
implement FIXME from previous commit
rochala May 16, 2023
3bf65da
add nightly mtags-shared as dependency instead of local snapshot
rochala May 17, 2023
34814ce
remove unnecessary changes in Comments.scala
rochala May 17, 2023
f2d8c64
remove metals wrappers around compiler implementation created to work…
rochala May 22, 2023
32c50e0
update NOTICE.md
rochala May 22, 2023
d823951
use java8 compatible api
rochala May 23, 2023
7074f0d
Mock Symbol Search documentation and definition
rochala May 26, 2023
122f36f
Revert incorrectly removed line
rochala May 26, 2023
421380c
fix build.sbt and windows tests
rochala May 26, 2023
f59457c
Filter tests to contain only completions that should be available on …
rochala May 27, 2023
6ad9dc7
Bump presentatation compiler to c8ef4e0
rochala Jun 15, 2023
5ee339d
use compiler printer instead of ShortenedNames with ShortType
rochala Jul 3, 2023
aa7542f
undo unnecessary changes, add -Wunsued:all, remove unused
rochala Jul 3, 2023
2d6aff2
Remove -Wunused from build.sbt, undo scalafmt
rochala Jul 3, 2023
9856331
apply review comments, inline toTextPrefix
rochala Jul 5, 2023
0869f93
update metals to latest commit - 7d0397b
rochala Jul 5, 2023
ae8ee2f
remove check for JavaStatic, as they are no longer necessary
rochala Jul 6, 2023
2b34077
remove flaky mock
rochala Jul 6, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
implement FIXME from previous commit
  • Loading branch information
rochala committed Jun 15, 2023
commit e643f9ff1c26843b0597ec45490e092f657123fe
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import java.util as ju
import scala.jdk.CollectionConverters._
import scala.meta.pc.OffsetParams

import dotty.tools.dotc.core.Comments.Comment
import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.interactive.Interactive
import dotty.tools.dotc.interactive.InteractiveDriver
Expand Down Expand Up @@ -36,7 +37,7 @@ class SelectionRangeProvider(
def selectionRange(): List[SelectionRange] =
given ctx: Context = driver.currentCtx

val selectionRanges = params.asScala.toList.map { param =>
params.asScala.toList.map { param =>

val uri = param.uri
val filePath = Paths.get(uri)
Expand All @@ -53,10 +54,22 @@ class SelectionRangeProvider(
selectionRange
}

bareRanges.reduceRight(setParent)
}
val comments = driver.compilationUnits.get(uri).map(_.comments).toList.flatten

val commentRanges = comments.find(_.span.contains(pos.span)).map { comment =>
val startLine = source.offsetToLine(comment.span.start)
val endLine = source.offsetToLine(comment.span.end)
val startChar = source.column(comment.span.start)
val endChar = source.column(comment.span.end)

selectionRanges
new SelectionRange():
setRange(new lsp4j.Range(lsp4j.Position(startLine, startChar), lsp4j.Position(endLine, endChar)))
}.toList

(commentRanges ++ bareRanges)
.reduceRightOption(setParent)
.getOrElse(new SelectionRange())
}
end selectionRange

private def setParent(
Expand Down Expand Up @@ -88,55 +101,3 @@ class SelectionRangeProvider(
child

end SelectionRangeProvider

// FIXME: update with latest mtags implementation, requires rewrite to dotty because fo scalameta

// object SelectionRangeProvider:

// import dotty.tools.dotc.ast.tpd

// def commentRangesFromTokens(
// tokenList: List[Token],
// cursorStart: SourcePosition,
// offsetStart: Int
// ) =
// val cursorStartShifted = cursorStart.start - offsetStart

// tokenList
// .collect { case x: Comment =>
// (x.start, x.end, x.pos)
// }
// .collect {
// case (commentStart, commentEnd, _)
// if commentStart <= cursorStartShifted && cursorStartShifted <= commentEnd =>
// cursorStart
// .withStart(commentStart + offsetStart)
// .withEnd(commentEnd + offsetStart)
// .toLsp

// }
// end commentRangesFromTokens

// /** get comments under cursor */
// def getCommentRanges(
// cursor: SourcePosition,
// path: List[tpd.Tree],
// srcText: String
// )(using Context): List[lsp4j.Range] =
// val (treeStart, treeEnd) = path.headOption
// .map(t => (t.sourcePos.start, t.sourcePos.end))
// .getOrElse((0, srcText.size))

// // only parse comments from first range to reduce computation
// val srcSliced = srcText.slice(treeStart, treeEnd)

// val tokens = srcSliced.tokenize.toOption
// if tokens.isEmpty then Nil
// else
// commentRangesFromTokens(
// tokens.toList.flatten,
// cursor,
// treeStart
// )
// end getCommentRanges
// end SelectionRangeProvider
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import org.junit.Test

class SelectionRangeCommentSuite extends BaseSelectionRangeSuite:

// FIXME requires latest implementation from mtags for SelectionRangeProvider
@Ignore
@Test def `match` =
check(
"""|object Main extends App {
Expand Down