@@ -82,6 +82,10 @@ object Build {
82
82
bootstrapFromPublishedJars := false
83
83
)
84
84
85
+ // Only available in vscode-dotty
86
+ lazy val unpublish = taskKey[Unit ](" Unpublish a package" )
87
+
88
+
85
89
86
90
lazy val commonSettings = publishSettings ++ Seq (
87
91
organization := dottyOrganization,
@@ -762,7 +766,20 @@ object DottyInjectedPlugin extends AutoPlugin {
762
766
libraryDependencies ++= Seq (
763
767
" org.eclipse.lsp4j" % " org.eclipse.lsp4j" % " 0.2.0" ,
764
768
Dependencies .`jackson-databind`
765
- )
769
+ ),
770
+ javaOptions := (javaOptions in `dotty-compiler-bootstrapped`).value,
771
+
772
+ run := Def .inputTaskDyn {
773
+ val inputArgs = spaceDelimited(" <arg>" ).parsed
774
+
775
+ val mainClass = " dotty.tools.languageserver.Main"
776
+ val extensionPath = (baseDirectory in `vscode-dotty`).value.getAbsolutePath
777
+
778
+ val codeArgs = if (inputArgs.isEmpty) List ((baseDirectory.value / " .." ).getAbsolutePath) else inputArgs
779
+ val allArgs = List (" -client_command" , " code" , s " --extensionDevelopmentPath= $extensionPath" ) ++ codeArgs
780
+
781
+ runTask(Runtime , mainClass, allArgs : _* )
782
+ }.dependsOn(compile in (`vscode-dotty`, Compile )).evaluated
766
783
)
767
784
768
785
/** A sandbox to play with the Scala.js back-end of dotty.
@@ -896,6 +913,95 @@ object DottyInjectedPlugin extends AutoPlugin {
896
913
}).evaluated
897
914
)
898
915
916
+ lazy val `vscode-dotty` = project.in(file(" vscode-dotty" )).
917
+ settings(commonSettings).
918
+ settings(
919
+ EclipseKeys .skipProject := true ,
920
+
921
+ version := " 0.0.1" , // Keep in sync with package.json
922
+
923
+ autoScalaLibrary := false ,
924
+ publishArtifact := false ,
925
+ includeFilter in unmanagedSources := NothingFilter | " *.ts" | " **.json" ,
926
+ watchSources in Global ++= (unmanagedSources in Compile ).value,
927
+ compile in Compile := {
928
+ val coursier = baseDirectory.value / " out/coursier"
929
+ val packageJson = baseDirectory.value / " package.json"
930
+ if (! coursier.exists || packageJson.lastModified > coursier.lastModified) {
931
+ val exitCode = new java.lang.ProcessBuilder (" npm" , " run" , " update-all" )
932
+ .directory(baseDirectory.value)
933
+ .inheritIO()
934
+ .start()
935
+ .waitFor()
936
+ if (exitCode != 0 )
937
+ throw new FeedbackProvidedException {
938
+ override def toString = " 'npm run update-all' in vscode-dotty failed"
939
+ }
940
+ }
941
+ val tsc = baseDirectory.value / " node_modules" / " .bin" / " tsc"
942
+ val exitCode = new java.lang.ProcessBuilder (tsc.getAbsolutePath, " --pretty" , " --project" , baseDirectory.value.getAbsolutePath)
943
+ .inheritIO()
944
+ .start()
945
+ .waitFor()
946
+ if (exitCode != 0 )
947
+ throw new FeedbackProvidedException {
948
+ override def toString = " tsc in vscode-dotty failed"
949
+ }
950
+ sbt.inc.Analysis .Empty
951
+ },
952
+ sbt.Keys .`package`:= {
953
+ val exitCode = new java.lang.ProcessBuilder (" vsce" , " package" )
954
+ .directory(baseDirectory.value)
955
+ .inheritIO()
956
+ .start()
957
+ .waitFor()
958
+ if (exitCode != 0 )
959
+ throw new FeedbackProvidedException {
960
+ override def toString = " vsce package failed"
961
+ }
962
+
963
+ baseDirectory.value / s " dotty- ${version.value}.vsix "
964
+ },
965
+ unpublish := {
966
+ val exitCode = new java.lang.ProcessBuilder (" vsce" , " unpublish" )
967
+ .directory(baseDirectory.value)
968
+ .inheritIO()
969
+ .start()
970
+ .waitFor()
971
+ if (exitCode != 0 )
972
+ throw new FeedbackProvidedException {
973
+ override def toString = " vsce unpublish failed"
974
+ }
975
+ },
976
+ publish := {
977
+ val exitCode = new java.lang.ProcessBuilder (" vsce" , " publish" )
978
+ .directory(baseDirectory.value)
979
+ .inheritIO()
980
+ .start()
981
+ .waitFor()
982
+ if (exitCode != 0 )
983
+ throw new FeedbackProvidedException {
984
+ override def toString = " vsce publish failed"
985
+ }
986
+ },
987
+ run := Def .inputTask {
988
+ val inputArgs = spaceDelimited(" <arg>" ).parsed
989
+ val codeArgs = if (inputArgs.isEmpty) List ((baseDirectory.value / " .." ).getAbsolutePath) else inputArgs
990
+ val extensionPath = baseDirectory.value.getAbsolutePath
991
+ val processArgs = List (" code" , s " --extensionDevelopmentPath= ${extensionPath}" ) ++ codeArgs
992
+
993
+ val exitCode = new java.lang.ProcessBuilder (processArgs : _* )
994
+ .inheritIO()
995
+ .start()
996
+ .waitFor()
997
+ if (exitCode != 0 )
998
+ throw new FeedbackProvidedException {
999
+ override def toString = " Running Visual Studio Code failed"
1000
+ }
1001
+ }.dependsOn(compile in Compile ).evaluated
1002
+ )
1003
+
1004
+
899
1005
lazy val publishSettings = Seq (
900
1006
publishMavenStyle := true ,
901
1007
isSnapshot := version.value.contains(" SNAPSHOT" ),
0 commit comments