Skip to content

Commit e9be78e

Browse files
aherlihytgodzik
authored andcommitted
Rename :require to :jar and deprecate :require
[Cherry-picked 4649d5e]
1 parent a40d388 commit e9be78e

File tree

8 files changed

+16
-56
lines changed

8 files changed

+16
-56
lines changed

compiler/src/dotty/tools/repl/ParseResult.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,20 @@ object Load {
5252
val command: String = ":load"
5353
}
5454

55-
/** `:require <path>` adds a jar to the classpath
55+
/** `:require` is a deprecated alias for :jar`
5656
*/
5757
case class Require(path: String) extends Command
5858
object Require {
5959
val command: String = ":require"
6060
}
6161

62+
/** `:jar <path>` adds a jar to the classpath
63+
*/
64+
case class JarCmd(path: String) extends Command
65+
object JarCmd {
66+
val command: String = ":jar"
67+
}
68+
6269
/** `:kind <type>` display the kind of a type. see also :help kind
6370
*/
6471
case class KindOf(expr: String) extends Command
@@ -158,6 +165,7 @@ object ParseResult {
158165
Help.command -> (_ => Help),
159166
Reset.command -> (arg => Reset(arg)),
160167
Imports.command -> (_ => Imports),
168+
JarCmd.command -> (arg => JarCmd(arg)),
161169
KindOf.command -> (arg => KindOf(arg)),
162170
Load.command -> (arg => Load(arg)),
163171
Require.command -> (arg => Require(arg)),

compiler/src/dotty/tools/repl/ReplDriver.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,10 @@ class ReplDriver(settings: Array[String],
518518
}
519519

520520
case Require(path) =>
521+
out.println(":require has been deprecated and replaced with :jar. Please use :jar")
522+
state
523+
524+
case JarCmd(path) =>
521525
val jarFile = AbstractFile.getDirectory(path)
522526
if (jarFile == null)
523527
out.println(s"""Cannot add "$path" to classpath.""")

compiler/test-resources/jars/MyLibrary.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* JAR used for testing repl :require
2+
* JAR used for testing repl :jar
33
* Generated using: mkdir out; scalac -d out MyLibrary.scala; jar cf mylibrary.jar -C out .
44
*/
55
package mylibrary

compiler/test-resources/jars/MyLibrary2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* JAR used for testing repl :require
2+
* JAR used for testing repl :jar
33
* Generated using: mkdir out2; scalac -d out MyLibrary2.scala; jar cf mylibrary2.jar -C out2 .
44
*/
55
package mylibrary2

compiler/test-resources/repl/require-command

Lines changed: 0 additions & 13 deletions
This file was deleted.

compiler/test-resources/repl/require-errors

Lines changed: 0 additions & 8 deletions
This file was deleted.

compiler/test-resources/repl/require-multiple

Lines changed: 0 additions & 32 deletions
This file was deleted.

compiler/test/dotty/tools/repl/TabcompleteTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class TabcompleteTests extends ReplTest {
216216
":exit",
217217
":help",
218218
":imports",
219+
":jar",
219220
":kind",
220221
":load",
221222
":quit",

0 commit comments

Comments
 (0)