@@ -170,6 +170,9 @@ object DottyIDEPlugin extends AutoPlugin {
170
170
override def requires : Plugins = plugins.JvmPlugin
171
171
override def trigger = allRequirements
172
172
173
+ private val artifactFile = new File (" .dotty-ide-artifact" )
174
+ private val configFile = new File (" .dotty-ide.json" )
175
+
173
176
def configureIDE = Command .command(" configureIDE" ) { origState =>
174
177
val (dottyVersion, projRefs, dottyState) = dottySetup(origState)
175
178
val configs0 = runInAllIDEConfigurations(projectConfig, projRefs, dottyState).flatten
@@ -184,7 +187,7 @@ object DottyIDEPlugin extends AutoPlugin {
184
187
val dlsVersion = dottyVersion
185
188
.replace(" -nonbootstrapped" , " " ) // The language server is only published bootstrapped
186
189
val dlsBinaryVersion = dlsVersion.split(" \\ ." ).take(2 ).mkString(" ." )
187
- val pwArtifact = new PrintWriter (" .dotty-ide-artifact " )
190
+ val pwArtifact = new PrintWriter (artifactFile )
188
191
try {
189
192
pwArtifact.println(s " ch.epfl.lamp:dotty-language-server_ ${dlsBinaryVersion}: ${dlsVersion}" )
190
193
} finally {
@@ -193,7 +196,7 @@ object DottyIDEPlugin extends AutoPlugin {
193
196
194
197
val mapper = new ObjectMapper
195
198
mapper.writerWithDefaultPrettyPrinter()
196
- .writeValue(new File ( " .dotty-ide.json " ) , configs.toArray)
199
+ .writeValue(configFile , configs.toArray)
197
200
198
201
origState
199
202
}
@@ -205,6 +208,23 @@ object DottyIDEPlugin extends AutoPlugin {
205
208
origState
206
209
}
207
210
211
+ def launchIDE = Command .command(" launchIDE" ) { state0 =>
212
+ val state1 = try {
213
+ Command .process(" configureIDE" , state0)
214
+ } catch {
215
+ case i : Incomplete =>
216
+ if (artifactFile.exists && configFile.exists) {
217
+ state0.log.error(" IDE configuration failed, launching the IDE using the previous configuration" )
218
+ state0 : State
219
+ } else {
220
+ state0.log.error(" IDE configuration failed and no previous configuration found" )
221
+ state0.log.error(" Please fix the compilation errors then run 'launchIDE' again" )
222
+ throw i
223
+ }
224
+ }
225
+ Command .process(" runCode" , state1)
226
+ }
227
+
208
228
private def projectConfigTask (config : Configuration ): Initialize [Task [Option [ProjectConfig ]]] = Def .taskDyn {
209
229
if ((sources in config).value.isEmpty) Def .task { None }
210
230
else Def .task {
@@ -240,7 +260,7 @@ object DottyIDEPlugin extends AutoPlugin {
240
260
)
241
261
242
262
override def buildSettings : Seq [Setting [_]] = Seq (
243
- commands ++= Seq (configureIDE, compileForIDE),
263
+ commands ++= Seq (configureIDE, compileForIDE, launchIDE ),
244
264
245
265
excludeFromIDE := false ,
246
266
0 commit comments