@@ -52,6 +52,7 @@ import org.eclipse.xtext.ide.server.ILanguageServerExtension
52
52
import org.eclipse.xtext.ide.server.concurrent.RequestManager
53
53
import org.eclipse.xtext.resource.XtextResourceSet
54
54
import org.eclipse.xtext.util.CancelIndicator
55
+ import de.cau.cs.kieler.core.services.KielerLanguage
55
56
56
57
/**
57
58
* Implements methods to extend the LSP to allow compilation. Moreover, getting compilation systems and showing
@@ -63,6 +64,8 @@ import org.eclipse.xtext.util.CancelIndicator
63
64
class KiCoolLanguageServerExtension implements ILanguageServerExtension , KiCoolCommandExtension , ILanguageClientProvider {
64
65
65
66
protected static val LOG = Logger . getLogger(KiCoolLanguageServerExtension )
67
+
68
+ protected static val LANGUAGES = KielerLanguage . getAllRegisteredLanguages()
66
69
67
70
@Inject @Accessors(PUBLIC_GETTER ) RequestManager requestManager
68
71
@@ -305,16 +308,29 @@ class KiCoolLanguageServerExtension implements ILanguageServerExtension, KiCoolC
305
308
* @return CS specified by the above parameters.
306
309
*/
307
310
def getCompilationSystems (String uri , int index , boolean filterForSimulation , boolean snapshotModel ) {
308
- var Object model
311
+ var Class<?> modelClass
309
312
if (snapshotModel && diagramState !== null && diagramState. getKGraphContext(uri) !== null ) {
310
- model = diagramState. getKGraphContext(uri). inputModel
313
+ modelClass = diagramState. getKGraphContext(uri). inputModel? . class
311
314
} else if (index != - 1 ) {
312
- model = this . objectMap. get(uri). get(index)
315
+ modelClass = this . objectMap. get(uri). get(index)? . class
313
316
} else {
314
- // get model of model specified by uri
315
- model = getModelFromUri(uri)
317
+ for (l : LANGUAGES ) {
318
+ for (ext: l. supportedResourceExtensions) {
319
+ if (uri. endsWith(ext)) {
320
+ if (l. supportedModels. size == 1 ) {
321
+ modelClass = l. supportedModels. head
322
+ } else {
323
+ modelClass = l. supportedModels. get(l. supportedResourceExtensions. indexOf(ext))
324
+ }
325
+ }
326
+ }
327
+ }
328
+ if (modelClass == = null ) {
329
+ // get model of model specified by uri (reparsing)
330
+ modelClass = getModelFromUri(uri)? . class
331
+ }
316
332
}
317
- return getCompilationSystems(model , filterForSimulation, snapshotModel)
333
+ return getCompilationSystems(modelClass , filterForSimulation, snapshotModel)
318
334
}
319
335
320
336
/**
@@ -324,10 +340,10 @@ class KiCoolLanguageServerExtension implements ILanguageServerExtension, KiCoolC
324
340
* @param filterForSimulation true if only simulation cs should be returned
325
341
* @return CS specified by the above parameters.
326
342
*/
327
- def getCompilationSystems (Object model , boolean filterForSimulation , boolean snapshotModel ) {
343
+ def getCompilationSystems (Class<?> modelClass , boolean filterForSimulation , boolean snapshotModel ) {
328
344
this . getSystemsThread = new GetSystemsThread ([
329
- if (model !== null && model . class !== modelClassFilter) {
330
- modelClassFilter = model . class
345
+ if (modelClass !== null && modelClass !== modelClassFilter) {
346
+ modelClassFilter = modelClass
331
347
}
332
348
var systems = getSystemModels(true , modelClassFilter)
333
349
var systemDescriptions = getSystemDescription(systems, snapshotModel)
0 commit comments