diff --git a/bin/test.sh b/bin/test.sh index 239c9f9bd59..2ba6fd3c664 100755 --- a/bin/test.sh +++ b/bin/test.sh @@ -15,8 +15,8 @@ cat ~/.local/share/scalacli/bloop/daemon/output rm .jvmopts touch .jvmopts -echo "-Xss4m" >> .jvmopts -echo "-Xmx1G" >> .jvmopts +echo "-Xss4m" >> .jvmopts +echo "-Xmx2G" >> .jvmopts echo "-XX:ReservedCodeCacheSize=1024m" >> .jvmopts echo "-XX:+TieredCompilation" >> .jvmopts echo "-Dfile.encoding=UTF-8" >> .jvmopts diff --git a/build.sbt b/build.sbt index 48847293353..ffcbf396782 100644 --- a/build.sbt +++ b/build.sbt @@ -198,6 +198,7 @@ val sharedScalacOptions = List( ) val sharedSettings = sharedJavacOptions ++ sharedScalacOptions ++ List( + Compile / packageDoc / publishArtifact := false, libraryDependencies ++= crossSetting( scalaVersion.value, if2 = List( @@ -316,8 +317,6 @@ val mtagsSettings = List( (ThisBuild / baseDirectory).value / "mtags", scalaVersion.value, ), - // @note needed to deal with issues with dottyDoc - Compile / doc / sources := Seq.empty, libraryDependencies ++= Seq( "com.lihaoyi" %% "geny" % V.genyVersion, "com.thoughtworks.qdox" % "qdox" % V.qdox, // for java mtags diff --git a/mtags/src/main/scala-3/scala/meta/internal/pc/PcDefinitionProvider.scala b/mtags/src/main/scala-3/scala/meta/internal/pc/PcDefinitionProvider.scala index c8dd4cd124c..a8e72ebc293 100644 --- a/mtags/src/main/scala-3/scala/meta/internal/pc/PcDefinitionProvider.scala +++ b/mtags/src/main/scala-3/scala/meta/internal/pc/PcDefinitionProvider.scala @@ -1,6 +1,8 @@ package scala.meta.internal.pc +import java.net.URI import java.nio.file.Paths +import java.time.LocalDateTime import java.util.ArrayList import scala.annotation.tailrec @@ -19,7 +21,9 @@ import dotty.tools.dotc.core.Flags import dotty.tools.dotc.core.Flags.ModuleClass import dotty.tools.dotc.core.Symbols.* import dotty.tools.dotc.interactive.Interactive +import dotty.tools.dotc.interactive.Interactive.Include import dotty.tools.dotc.interactive.InteractiveDriver +import dotty.tools.dotc.transform.SymUtils.isLocal import dotty.tools.dotc.util.SourceFile import dotty.tools.dotc.util.SourcePosition import org.eclipse.lsp4j.Location @@ -51,10 +55,10 @@ class PcDefinitionProvider( given ctx: Context = driver.localContext(params) val indexedContext = IndexedContext(ctx) val result = - if findTypeDef then findTypeDefinitions(path, pos, indexedContext) - else findDefinitions(path, pos, indexedContext) + if findTypeDef then findTypeDefinitions(path, pos, indexedContext, uri) + else findDefinitions(path, pos, indexedContext, uri) - if result.locations().isEmpty() then fallbackToUntyped(pos)(using ctx) + if result.locations().isEmpty() then fallbackToUntyped(pos, uri)(using ctx) else result end definitions @@ -70,23 +74,25 @@ class PcDefinitionProvider( * @param pos cursor position * @return definition result */ - private def fallbackToUntyped(pos: SourcePosition)(using Context) = + private def fallbackToUntyped(pos: SourcePosition, uri: URI)(using Context) = lazy val untpdPath = NavigateAST .untypedPath(pos.span) .collect { case t: untpd.Tree => t } - definitionsForSymbol(untpdPath.headOption.map(_.symbol).toList, pos) + definitionsForSymbol(untpdPath.headOption.map(_.symbol).toList, uri, pos) end fallbackToUntyped private def findDefinitions( path: List[Tree], pos: SourcePosition, indexed: IndexedContext, + uri: URI, ): DefinitionResult = import indexed.ctx definitionsForSymbol( MetalsInteractive.enclosingSymbols(path, pos, indexed), - pos, + uri, + pos ) end findDefinitions @@ -94,6 +100,7 @@ class PcDefinitionProvider( path: List[Tree], pos: SourcePosition, indexed: IndexedContext, + uri: URI, ): DefinitionResult = import indexed.ctx val enclosing = path.expandRangeToEnclosingApply(pos) @@ -106,16 +113,17 @@ class PcDefinitionProvider( case Nil => path.headOption match case Some(value: Literal) => - definitionsForSymbol(List(value.tpe.widen.typeSymbol), pos) + definitionsForSymbol(List(value.tpe.widen.typeSymbol), uri, pos) case _ => DefinitionResultImpl.empty case _ => - definitionsForSymbol(typeSymbols, pos) + definitionsForSymbol(typeSymbols, uri, pos) end findTypeDefinitions private def definitionsForSymbol( symbols: List[Symbol], - pos: SourcePosition, + uri: URI, + pos: SourcePosition )(using ctx: Context): DefinitionResult = symbols match case symbols @ (sym :: other) => @@ -123,8 +131,8 @@ class PcDefinitionProvider( if isLocal then @tailrec def findDefsForSymbol(sym: Symbol): DefinitionResult = - val defs = - Interactive.findDefinitions(List(sym), driver, false, false) + val include = Include.definitions | Include.local + val defs = Interactive.findTreesMatching(driver.openedTrees(uri), include, sym) defs.headOption match case Some(srcTree) => val pos = srcTree.namePos