3
3
*
4
4
* http://rtsys.informatik.uni-kiel.de/kieler
5
5
*
6
- * Copyright 2018 by
6
+ * Copyright 2018-2024 by
7
7
* + Kiel University
8
8
* + Department of Computer Science
9
9
* + Real-Time and Embedded Systems Group
@@ -21,14 +21,16 @@ import de.cau.cs.kieler.kicool.compilation.CompilationContext
21
21
import de.cau.cs.kieler.kicool.compilation.Compile
22
22
import de.cau.cs.kieler.kicool.deploy.ProjectInfrastructure
23
23
import de.cau.cs.kieler.kicool.environments.Environment
24
- import de.cau.cs.kieler.kicool.ide.klighd.models.CodePlaceHolder
25
24
import de.cau.cs.kieler.kicool.ide.view.IdeCompilerView
26
25
import de.cau.cs.kieler.klighd.lsp.KGraphDiagramState
27
26
import de.cau.cs.kieler.klighd.lsp.KGraphLanguageServerExtension
28
27
import de.cau.cs.kieler.language.server.ILanguageClientProvider
29
28
import de.cau.cs.kieler.language.server.KeithLanguageClient
30
- import de.cau.cs.kieler.language.server.kicool.data.CodeOfModel
31
29
import de.cau.cs.kieler.language.server.kicool.data.CompilationResults
30
+ import de.cau.cs.kieler.language.server.kicool.data.CompileParam
31
+ import de.cau.cs.kieler.language.server.kicool.data.DidCompileParam
32
+ import de.cau.cs.kieler.language.server.kicool.data.SendCompilationSystemsParam
33
+ import de.cau.cs.kieler.language.server.kicool.data.ShowParam
32
34
import de.cau.cs.kieler.language.server.kicool.data.SnapshotDescription
33
35
import de.cau.cs.kieler.language.server.kicool.data.SystemDescription
34
36
import de.cau.cs.kieler.language.server.registration.RegistrationLanguageServerExtension
@@ -152,22 +154,23 @@ class KiCoolLanguageServerExtension implements ILanguageServerExtension, KiCoolC
152
154
/**
153
155
* Called by the client to compile a model
154
156
*
155
- * @param uri The uri string of the model to compile (for snapshot compilation this is the uri of the original model.
156
- * @param clientId The id of the diagram client.
157
- * @param command The compilation system used to compile.
158
- * @param inplace Whether in-place compilation should be used.
159
- * @param showResultingModel Whether the final model should be shown in the diagram specified by clientId.
160
- * @param snapshot Whether the model to compile is a snapshot model.
157
+ * @param param with: <br >
158
+ * - uri The uri string of the model to compile (for snapshot compilation this is the uri of the original model. <br >
159
+ * - clientId The id of the diagram client. <br >
160
+ * - command The compilation system used to compile. <br >
161
+ * - inplace Whether in-place compilation should be used. <br >
162
+ * - showResultingModel Whether the final model should be shown in the diagram specified by clientId. <br >
163
+ * - snapshot Whether the model to compile is a snapshot model.
161
164
*/
162
- override compile (String uri , String clientId , String command , boolean inplace , boolean showResultingModel , boolean snapshot ) {
163
- val decodedUri = URLDecoder . decode(uri, " UTF-8" )
165
+ override compile (CompileParam param ) {
166
+ val decodedUri = URLDecoder . decode(param . uri, " UTF-8" )
164
167
try {
165
168
var Object model
166
169
// Get input model for compilation.
167
- if (snapshot) {
170
+ if (param . snapshot) {
168
171
// Abort if no diagram can be found.
169
172
if (diagramState == = null || diagramState. getKGraphContext(decodedUri) == = null ) {
170
- client. compile( null , decodedUri, true , 0 , 1000 )
173
+ client. didCompile( new DidCompileParam ( null , decodedUri, true , 0 , 1000 ) )
171
174
return
172
175
}
173
176
model = diagramState. getKGraphContext(decodedUri). inputModel
@@ -176,12 +179,12 @@ class KiCoolLanguageServerExtension implements ILanguageServerExtension, KiCoolC
176
179
}
177
180
// Abort if no model to compile could be found.
178
181
if (model == = null ) {
179
- client. compile( null , decodedUri, true , 0 , 1000 )
182
+ client. didCompile( new DidCompileParam ( null , decodedUri, true , 0 , 1000 ) )
180
183
return
181
184
}
182
185
183
- this . currentContext = createContextAndStartCompilationThread(model, command, inplace, this . currentContext,
184
- decodedUri, clientId, showResultingModel)
186
+ this . currentContext = createContextAndStartCompilationThread(model, param . command, param . inplace, this . currentContext,
187
+ decodedUri, param . clientId, param . showResultingModel)
185
188
} catch ( Exception e) {
186
189
e. printStackTrace()
187
190
sendError(e. toString())
@@ -250,27 +253,28 @@ class KiCoolLanguageServerExtension implements ILanguageServerExtension, KiCoolC
250
253
/**
251
254
* Display the current snapshot given by uri and index on the diagram widget given by the clientId.
252
255
*
253
- * @param uri uri of model
254
- * @param clientId id of diagramServer
255
- * @param index index of snapshot. -1 equals the original model.
256
+ * @param param with: <br >
257
+ * - uri uri of model <br >
258
+ * - clientId id of diagramServer <br >
259
+ * - index index of snapshot. -1 equals the original model.
256
260
* @return completable future with index and id of showed model
257
261
*/
258
- override show (String uri , String clientId , int index ) {
259
- val decodedUri = URLDecoder . decode(uri, " UTF-8" )
262
+ override show (ShowParam param ) {
263
+ val decodedUri = URLDecoder . decode(param . uri, " UTF-8" )
260
264
var Object model
261
- if (index == - 1 ) {
265
+ if (param . index == - 1 ) {
262
266
// Get model specified by uri
263
267
model = getModelFromUri(decodedUri)
264
268
} else {
265
269
// Get snapshot model from the compilation snapshots
266
- model = this . objectMap. get(decodedUri). get(index)
270
+ model = this . objectMap. get(decodedUri). get(param . index)
267
271
}
268
272
269
273
// Send model to client.
270
274
val modelToSend = model
271
275
return requestManager. runRead [ cancelIndicator |
272
- currentIndex = index
273
- showSnapshot(decodedUri, clientId, modelToSend, cancelIndicator, false )
276
+ currentIndex = param . index
277
+ showSnapshot(decodedUri, param . clientId, modelToSend, cancelIndicator, false )
274
278
]
275
279
}
276
280
@@ -285,7 +289,7 @@ class KiCoolLanguageServerExtension implements ILanguageServerExtension, KiCoolC
285
289
try {
286
290
val systemDescriptions = getCompilationSystems(decodedUri, - 1 , false , false )
287
291
val snapshotSystemDescriptions = getCompilationSystems(decodedUri, - 1 , false , true )
288
- client. sendCompilationSystems(systemDescriptions, snapshotSystemDescriptions)
292
+ client. sendCompilationSystems(new SendCompilationSystemsParam ( systemDescriptions, snapshotSystemDescriptions) )
289
293
} catch (Exception e) {
290
294
e. printStackTrace()
291
295
sendError(" Could not retrieve compilation systems" + e)
@@ -436,7 +440,7 @@ class KiCoolLanguageServerExtension implements ILanguageServerExtension, KiCoolC
436
440
var future = new CompletableFuture ()
437
441
future. complete(void )
438
442
future. thenAccept [
439
- client. compile (new CompilationResults (this . snapshotMap. get(uri)), uri, finished, currentIndex, maxIndex)
443
+ client. didCompile (new DidCompileParam ( new CompilationResults (this . snapshotMap. get(uri)), uri, finished, currentIndex, maxIndex) )
440
444
]. exceptionally [ throwable |
441
445
LOG . error(' Error while sending compilation results.' , throwable)
442
446
sendError(' Error while sending compilation results.' + throwable)
@@ -470,34 +474,34 @@ class KiCoolLanguageServerExtension implements ILanguageServerExtension, KiCoolC
470
474
471
475
}
472
476
473
- override getCodeOfModel (String kgraphElementId , String clientId ) {
474
- if (this . diagramState. viewer !== null ) {
475
- val Object inputModel = diagramState. viewer. viewContext. inputModel
476
- // Get uri of original model file
477
- val uri = diagramState. getURIString(clientId)
478
- // Get KNode that holds the code that should be displayed
479
- val kNode = diagramState. getIdToKGraphMap(uri). get(kgraphElementId);
480
- // Get model string
481
- val CodePlaceHolder codeModel = if (inputModel instanceof CodePlaceHolder ) {
482
- inputModel as CodePlaceHolder
483
- } else if (kNode !== null ) {
484
- // if input model is not CodePlaceHolder check if clicked node is associated with it
485
- var Object domainElement = diagramState. viewer. viewContext. getSourceElement(kNode)
486
- if (domainElement instanceof CodePlaceHolder ) {
487
- domainElement as CodePlaceHolder
488
- }
489
- }
490
- // Get name of file
491
- val code = new CodeOfModel (codeModel. name, codeModel. code)
492
- return requestManager. runRead[ cancelIndicator |
493
- code
494
- ]
495
- } else {
496
- return requestManager. runRead[ cancelIndicator |
497
- new CodeOfModel (" Error" , " On error occurred while trying to get the code." )
498
- ]
499
- }
500
- }
477
+ // override getCodeOfModel(String kgraphElementId, String clientId) {
478
+ // if (this.diagramState.viewer !== null) {
479
+ // val Object inputModel = diagramState.viewer.viewContext.inputModel
480
+ // // Get uri of original model file
481
+ // val uri = diagramState.getURIString(clientId)
482
+ // // Get KNode that holds the code that should be displayed
483
+ // val kNode = diagramState.getIdToKGraphMap(uri).get(kgraphElementId);
484
+ // // Get model string
485
+ // val CodePlaceHolder codeModel = if (inputModel instanceof CodePlaceHolder) {
486
+ // inputModel as CodePlaceHolder
487
+ // } else if (kNode !== null) {
488
+ // // if input model is not CodePlaceHolder check if clicked node is associated with it
489
+ // var Object domainElement = diagramState.viewer.viewContext.getSourceElement(kNode)
490
+ // if (domainElement instanceof CodePlaceHolder) {
491
+ // domainElement as CodePlaceHolder
492
+ // }
493
+ // }
494
+ // // Get name of file
495
+ // val code = new CodeOfModel(codeModel.name, codeModel.code)
496
+ // return requestManager.runRead[ cancelIndicator |
497
+ // code
498
+ // ]
499
+ // } else {
500
+ // return requestManager.runRead[ cancelIndicator |
501
+ // new CodeOfModel("Error", "On error occurred while trying to get the code.")
502
+ // ]
503
+ // }
504
+ // }
501
505
502
506
/**
503
507
* Register observer to be included on start of new compilation.
0 commit comments