@@ -52,6 +52,7 @@ import org.eclipse.xtext.ide.server.ILanguageServerExtension
5252import org.eclipse.xtext.ide.server.concurrent.RequestManager
5353import org.eclipse.xtext.resource.XtextResourceSet
5454import org.eclipse.xtext.util.CancelIndicator
55+ import de.cau.cs.kieler.core.services.KielerLanguage
5556
5657/**
5758 * 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
6364class KiCoolLanguageServerExtension implements ILanguageServerExtension , KiCoolCommandExtension , ILanguageClientProvider {
6465
6566 protected static val LOG = Logger . getLogger(KiCoolLanguageServerExtension )
67+
68+ protected static val LANGUAGES = KielerLanguage . getAllRegisteredLanguages()
6669
6770 @Inject @Accessors(PUBLIC_GETTER ) RequestManager requestManager
6871
@@ -305,16 +308,29 @@ class KiCoolLanguageServerExtension implements ILanguageServerExtension, KiCoolC
305308 * @return CS specified by the above parameters.
306309 */
307310 def getCompilationSystems (String uri , int index , boolean filterForSimulation , boolean snapshotModel ) {
308- var Object model
311+ var Class<?> modelClass
309312 if (snapshotModel && diagramState !== null && diagramState. getKGraphContext(uri) !== null ) {
310- model = diagramState. getKGraphContext(uri). inputModel
313+ modelClass = diagramState. getKGraphContext(uri). inputModel? . class
311314 } else if (index != - 1 ) {
312- model = this . objectMap. get(uri). get(index)
315+ modelClass = this . objectMap. get(uri). get(index)? . class
313316 } 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+ }
316332 }
317- return getCompilationSystems(model , filterForSimulation, snapshotModel)
333+ return getCompilationSystems(modelClass , filterForSimulation, snapshotModel)
318334 }
319335
320336 /**
@@ -324,10 +340,10 @@ class KiCoolLanguageServerExtension implements ILanguageServerExtension, KiCoolC
324340 * @param filterForSimulation true if only simulation cs should be returned
325341 * @return CS specified by the above parameters.
326342 */
327- def getCompilationSystems (Object model , boolean filterForSimulation , boolean snapshotModel ) {
343+ def getCompilationSystems (Class<?> modelClass , boolean filterForSimulation , boolean snapshotModel ) {
328344 this . getSystemsThread = new GetSystemsThread ([
329- if (model !== null && model . class !== modelClassFilter) {
330- modelClassFilter = model . class
345+ if (modelClass !== null && modelClass !== modelClassFilter) {
346+ modelClassFilter = modelClass
331347 }
332348 var systems = getSystemModels(true , modelClassFilter)
333349 var systemDescriptions = getSystemDescription(systems, snapshotModel)
0 commit comments