forked from scalameta/metals
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prioritize build targets with supported Scala versions.
Previously, if two build targets in the repo were eligible for a source file, Metals would sometimes prioritize a target with an unsupported Scala version over a target with a supported Scala version. This resulted in completions/hover/parameterHints not to work while editing cross-built sources. This PR introduces a change to the logic where we select a build target for a given source file. Now we sort the elibible candidates by two criteria: the Scala version and the platform (JVM/JS/Native). This change takes the first step towards scalameta/metals-feature-requests#13, which is about making this logic configurable.
- Loading branch information
Olafur Pall Geirsson
committed
Sep 27, 2019
1 parent
807ca28
commit 468f3ce
Showing
5 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
tests/unit/src/test/scala/tests/BuildTargetsSlowSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package tests | ||
|
||
object BuildTargetsSlowSuite | ||
extends BaseSlowSuite("build-targets") | ||
with TestHovers { | ||
|
||
testAsync("scala-priority") { | ||
for { | ||
_ <- server.initialize( | ||
s"""/metals.json | ||
|{ | ||
| "a": { | ||
| "scalaVersion": "2.10.6", | ||
| "libraryDependencies": ["com.lihaoyi::sourcecode:0.1.7"], | ||
| "additionalSources": [ "shared/Main.scala" ] | ||
| }, | ||
| "b": { | ||
| "scalaVersion": "${BuildInfo.scalaVersion}", | ||
| "libraryDependencies": ["com.lihaoyi::sourcecode:0.1.7"], | ||
| "additionalSources": [ "shared/Main.scala" ] | ||
| } | ||
|} | ||
""".stripMargin | ||
) | ||
// Assert that a supported Scala version target is picked over 2.10. | ||
_ <- server.assertHover( | ||
"shared/Main.scala", | ||
""" | ||
|object Main { | ||
| sourcecode.Line(1).val@@ue | ||
|}""".stripMargin, | ||
"""val value: Int""".hover | ||
) | ||
} yield () | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters