Skip to content

Fix BuildInfo scope in scala3-presentation-compiler, improve debugging support #18332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions docs/_docs/contributing/debugging/ide-debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ The debugger should start and pause on your breakpoint.

![Start debugger](/images/contribution/start-debugger.jpg)

If you are working on presentation compiler module, there is an easier way to start the debugger, without need of custom `launch.json`.
It can be accomplished by running `Debug Test` code lens on exact test case.

![Debug test via code lens](/images/contribution/debug-test-code-lens.jpg)

The second way to run presentation compiler tests is to use test explorer tab which lists all available test cases.
The debugger is started either by pressing debug button or by selecting `Debug Test` option from the menu.

![Debug test via code lens](/images/contribution/debug-test-explorer.jpg)

## Using the debugger

### Navigating the call stack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import scala.meta.pc.*
import dotty.tools.dotc.reporting.StoreReporter
import dotty.tools.pc.completions.CompletionProvider
import dotty.tools.pc.completions.OverrideCompletions
import dotty.tools.pc.util.BuildInfo
import dotty.tools.pc.buildinfo.BuildInfo

import org.eclipse.lsp4j.DocumentHighlight
import org.eclipse.lsp4j.TextEdit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import dotty.tools.dotc.util.Spans.Span
import dotty.tools.dotc.util.SrcPos
import dotty.tools.pc.AutoImports.AutoImportsGenerator
import dotty.tools.pc.completions.OverrideCompletions.OverrideExtractor
import dotty.tools.pc.util.BuildInfo
import dotty.tools.pc.buildinfo.BuildInfo
import dotty.tools.pc.utils.MtagsEnrichments.*

class Completions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import java.nio.charset.StandardCharsets
import java.nio.file.{Files, Path}
import java.util.Comparator
import java.util.concurrent.{Executors, ScheduledExecutorService}
import java.lang.management.ManagementFactory

import scala.collection.immutable
import scala.meta.internal.jdk.CollectionConverters.*
Expand All @@ -13,7 +14,7 @@ import scala.meta.pc.{PresentationCompiler, PresentationCompilerConfig}

import dotty.tools.pc.*
import dotty.tools.pc.ScalaPresentationCompiler
import dotty.tools.pc.util.BuildInfo
import dotty.tools.pc.tests.buildinfo.BuildInfo
import dotty.tools.pc.utils._

import org.eclipse.lsp4j.MarkupContent
Expand All @@ -27,6 +28,8 @@ object TestResources:

@RunWith(classOf[ReusableClassRunner])
abstract class BasePCSuite extends PcAssertions:
private val isDebug = ManagementFactory.getRuntimeMXBean.getInputArguments.toString.contains("-agentlib:jdwp")

val tmp = Files.createTempDirectory("stable-pc-tests")
val executorService: ScheduledExecutorService =
Executors.newSingleThreadScheduledExecutor()
Expand All @@ -51,7 +54,7 @@ abstract class BasePCSuite extends PcAssertions:
.newInstance("", myclasspath.asJava, scalacOpts.asJava)

protected def config: PresentationCompilerConfig =
PresentationCompilerConfigImpl().copy(snippetAutoIndent = false)
PresentationCompilerConfigImpl().copy(snippetAutoIndent = false, timeoutDelay = if isDebug then 3600 else 5)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's smart. I'll use the idea in other projects :)


private def inspectDialect(filename: String, code: String) =
val file = tmp.resolve(filename)
Expand Down
3 changes: 2 additions & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1217,8 +1217,9 @@ object Build {
dottyLib :: scalaLib
// Nil
},
Compile / buildInfoPackage := "dotty.tools.pc.util",
Compile / buildInfoPackage := "dotty.tools.pc.buildinfo",
Compile / buildInfoKeys := Seq(scalaVersion),
Test / buildInfoPackage := "dotty.tools.pc.tests.buildinfo",
Test / buildInfoKeys := Seq(scalaVersion, ideTestsDependencyClasspath)
) ++ BuildInfoPlugin.buildInfoScopedSettings(Compile) ++
BuildInfoPlugin.buildInfoScopedSettings(Test) ++
Expand Down