From b41ac818d72ce1668b528e4ee3582e0286a3f939 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Mon, 11 Mar 2024 11:03:10 +0100 Subject: [PATCH 1/5] update to Sprotty 1.1.1 --- .../category.xml | 2 +- .../pom.xml | 2 +- ...er.klighd.targetplatform-elkNightly.target | 2 +- ...d.targetplatform-piccolo-elkNightly.target | 2 +- ...ieler.klighd.targetplatform-piccolo.target | 2 +- ...cau.cs.kieler.klighd.targetplatform.target | 2 +- .../klighd/lsp/KGraphDiagramServer.xtend | 8 ++--- .../klighd/lsp/KGraphDiagramUpdater.xtend | 33 ++++++++++++------- .../lsp/KGraphLanguageServerExtension.xtend | 3 +- pom.xml | 2 +- 10 files changed, 33 insertions(+), 25 deletions(-) diff --git a/build/de.cau.cs.kieler.klighd.repository/category.xml b/build/de.cau.cs.kieler.klighd.repository/category.xml index 7d0c7f9d5..004bcf59f 100644 --- a/build/de.cau.cs.kieler.klighd.repository/category.xml +++ b/build/de.cau.cs.kieler.klighd.repository/category.xml @@ -69,5 +69,5 @@ - + diff --git a/build/de.cau.cs.kieler.klighd.repository/pom.xml b/build/de.cau.cs.kieler.klighd.repository/pom.xml index eb94937db..536997d14 100644 --- a/build/de.cau.cs.kieler.klighd.repository/pom.xml +++ b/build/de.cau.cs.kieler.klighd.repository/pom.xml @@ -64,7 +64,7 @@ https://download.eclipse.org/tools/orbit/simrel/orbit-aggregation/release/4.30.0 - https://rtsys.informatik.uni-kiel.de/~kieler/updatesite/sprotty/0.9.0/ + https://rtsys.informatik.uni-kiel.de/~kieler/updatesite/sprotty/1.1.1/ siteTemplate diff --git a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-elkNightly.target b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-elkNightly.target index 3d08e692f..103fdaa2a 100644 --- a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-elkNightly.target +++ b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-elkNightly.target @@ -45,7 +45,7 @@ - + \ No newline at end of file diff --git a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo-elkNightly.target b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo-elkNightly.target index 8f00f2b0c..c0a3afcb9 100644 --- a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo-elkNightly.target +++ b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo-elkNightly.target @@ -49,7 +49,7 @@ - + \ No newline at end of file diff --git a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo.target b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo.target index d1f752741..de4c726b4 100644 --- a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo.target +++ b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo.target @@ -49,7 +49,7 @@ - + \ No newline at end of file diff --git a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform.target b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform.target index 9ec8e1d19..2e5b3a4d8 100644 --- a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform.target +++ b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform.target @@ -45,7 +45,7 @@ - + \ No newline at end of file diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramServer.xtend b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramServer.xtend index d67576498..5b9a9160d 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramServer.xtend +++ b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramServer.xtend @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2018-2022 by + * Copyright 2018-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -384,11 +384,9 @@ class KGraphDiagramServer extends LanguageAwareDiagramServer { * FIXME Remove this if UpdateModelAction has a cause. */ override protected handle(RequestModelAction request) { - if (model.type == 'NONE' && diagramLanguageServer !== null) { - if (!request.requestId.nullOrEmpty) - LOG.warn("Model requests are not supported by the Xtext diagram server.") + if (diagramLanguageServer !== null) { copyOptions(request) - diagramLanguageServer.diagramUpdater.updateDiagram(this) + diagramLanguageServer.diagramUpdater.updateDiagram(this, request) } else { super.handle(request) } diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramUpdater.xtend b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramUpdater.xtend index 9755d54f2..7c6905338 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramUpdater.xtend +++ b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramUpdater.xtend @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2019, 2020, 2021 by + * Copyright 2019-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -37,10 +37,12 @@ import java.util.Map import java.util.concurrent.CompletableFuture import org.eclipse.emf.common.util.URI import org.eclipse.emf.ecore.EObject +import org.eclipse.sprotty.Action import org.eclipse.sprotty.IDiagramServer import org.eclipse.sprotty.SGraph import org.eclipse.sprotty.SModelElement import org.eclipse.sprotty.xtext.ILanguageAwareDiagramServer +import org.eclipse.sprotty.xtext.LanguageAwareDiagramServer import org.eclipse.sprotty.xtext.ls.DiagramLanguageServer import org.eclipse.sprotty.xtext.ls.DiagramUpdater import org.eclipse.xtext.util.CancelIndicator @@ -137,7 +139,19 @@ class KGraphDiagramUpdater extends DiagramUpdater { } override protected doUpdateDiagrams(String uri, List diagramServers) { - if (diagramServers.empty) { + diagramServers.forEach[updateDiagram(it as LanguageAwareDiagramServer, null)] + return CompletableFuture.completedFuture(null) + } + + override updateDiagram(LanguageAwareDiagramServer server_, Action cause) { + if (!(server_ instanceof KGraphDiagramServer)) return super.updateDiagram(server_, cause) + + val server = server_ as KGraphDiagramServer + val uri = server.sourceUri + if (uri.isNullOrEmpty) { + val exc = new RuntimeException("Missing property 'sourceUri'.") + server.rejectRemoteRequest(cause, exc) +// LOG.error("Failed to update diagram.", exc) return CompletableFuture.completedFuture(null) } return (languageServer as KGraphLanguageServerExtension).doRead(uri) [ resource, ci | @@ -166,16 +180,13 @@ class KGraphDiagramUpdater extends DiagramUpdater { new StringBuilder, [builder, error | builder.append("\n" + error)]).toString model = new MessageModel("The model contains errors:\n" + errors) } - val model_ = model; - (diagramServers as List).forEach [ KGraphDiagramServer server | - // Only update an erroneous model if there was no diagram shown before. - if (!hasErrors || server.currentRoot.type == "NONE") { - synchronized (diagramState) { - prepareModel(server, model_, uri) - updateLayout(server) - } + // Only update an erroneous model if there was no diagram shown before. + if (!hasErrors || server.currentRoot.type == "NONE") { + synchronized (diagramState) { + prepareModel(server, model, uri) + updateLayout(server) } - ] + } return null as Void ] } diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphLanguageServerExtension.xtend b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphLanguageServerExtension.xtend index 087b62b7b..4d707ad41 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphLanguageServerExtension.xtend +++ b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphLanguageServerExtension.xtend @@ -134,8 +134,7 @@ class KGraphLanguageServerExtension extends SyncDiagramLanguageServer override accept(ActionMessage message) { if (message.action instanceof RequestModelAction) { val action = message.action as RequestModelAction - val diagramType = action.diagramType - ?: action.options.get(DiagramOptions.OPTION_DIAGRAM_TYPE) + val diagramType = action.options.get(DiagramOptions.OPTION_DIAGRAM_TYPE) val server = diagramServerManager.getDiagramServer(diagramType, message.clientId) // If a diagram server is requested for the same client, but a different source file, then close the old server. // If the server does not have options yet, the server has not been used yet and does not need to be relaunched. diff --git a/pom.xml b/pom.xml index 8a6fd02f4..d012394f1 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 7.0.0 3.32.0 0.21.1 - 0.9.0 + 1.1.1 0.1.0 3.124.200 2.7.3 From 0a2319b2573f8b1ed7c0702d4f8833a9e55a2f3c Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Tue, 12 Mar 2024 17:36:45 +0100 Subject: [PATCH 2/5] removed Plugin nature from LSP, it should only be used as a plain Maven artifact. Update to lsp4j 0.22.0 (maven dependency only) --- .../category.xml | 3 --- .../pom.xml | 2 -- ...er.klighd.targetplatform-elkNightly.target | 4 --- ...d.targetplatform-piccolo-elkNightly.target | 4 --- ...ieler.klighd.targetplatform-piccolo.target | 4 --- ...cau.cs.kieler.klighd.targetplatform.target | 4 --- .../de.cau.cs.kieler.klighd.lsp/.classpath | 26 ++++++++++++++++--- plugins/de.cau.cs.kieler.klighd.lsp/.project | 11 -------- .../org.eclipse.core.resources.prefs | 1 + .../org.eclipse.xtend.core.Xtend.prefs | 2 ++ plugins/de.cau.cs.kieler.klighd.lsp/pom.xml | 1 - pom.xml | 2 +- 12 files changed, 27 insertions(+), 37 deletions(-) diff --git a/build/de.cau.cs.kieler.klighd.repository/category.xml b/build/de.cau.cs.kieler.klighd.repository/category.xml index 004bcf59f..5216ede61 100644 --- a/build/de.cau.cs.kieler.klighd.repository/category.xml +++ b/build/de.cau.cs.kieler.klighd.repository/category.xml @@ -60,8 +60,6 @@ - - @@ -69,5 +67,4 @@ - diff --git a/build/de.cau.cs.kieler.klighd.repository/pom.xml b/build/de.cau.cs.kieler.klighd.repository/pom.xml index 536997d14..cfa0d42fc 100644 --- a/build/de.cau.cs.kieler.klighd.repository/pom.xml +++ b/build/de.cau.cs.kieler.klighd.repository/pom.xml @@ -63,8 +63,6 @@ https://xtext.github.io/download/updates/releases/2.1.1/> https://download.eclipse.org/tools/orbit/simrel/orbit-aggregation/release/4.30.0 - - https://rtsys.informatik.uni-kiel.de/~kieler/updatesite/sprotty/1.1.1/ siteTemplate diff --git a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-elkNightly.target b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-elkNightly.target index 103fdaa2a..2a3c0eccd 100644 --- a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-elkNightly.target +++ b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-elkNightly.target @@ -43,9 +43,5 @@ - - - - \ No newline at end of file diff --git a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo-elkNightly.target b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo-elkNightly.target index c0a3afcb9..fc4b1e392 100644 --- a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo-elkNightly.target +++ b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo-elkNightly.target @@ -47,9 +47,5 @@ - - - - \ No newline at end of file diff --git a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo.target b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo.target index de4c726b4..8c9f1fff6 100644 --- a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo.target +++ b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform-piccolo.target @@ -47,9 +47,5 @@ - - - - \ No newline at end of file diff --git a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform.target b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform.target index 2e5b3a4d8..19e50c619 100644 --- a/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform.target +++ b/build/de.cau.cs.kieler.klighd.targetplatform/de.cau.cs.kieler.klighd.targetplatform.target @@ -43,9 +43,5 @@ - - - - \ No newline at end of file diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/.classpath b/plugins/de.cau.cs.kieler.klighd.lsp/.classpath index 7cd7b128b..59a498ec0 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/.classpath +++ b/plugins/de.cau.cs.kieler.klighd.lsp/.classpath @@ -5,8 +5,28 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/.project b/plugins/de.cau.cs.kieler.klighd.lsp/.project index 27cf23a80..918374c6f 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/.project +++ b/plugins/de.cau.cs.kieler.klighd.lsp/.project @@ -15,16 +15,6 @@ - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - org.eclipse.m2e.core.maven2Builder @@ -35,6 +25,5 @@ org.eclipse.jdt.core.javanature org.eclipse.xtext.ui.shared.xtextNature org.eclipse.m2e.core.maven2Nature - org.eclipse.pde.PluginNature diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/.settings/org.eclipse.core.resources.prefs b/plugins/de.cau.cs.kieler.klighd.lsp/.settings/org.eclipse.core.resources.prefs index 7a5313928..505845e4f 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/.settings/org.eclipse.core.resources.prefs +++ b/plugins/de.cau.cs.kieler.klighd.lsp/.settings/org.eclipse.core.resources.prefs @@ -1,3 +1,4 @@ eclipse.preferences.version=1 encoding/=UTF-8 encoding/src=UTF-8 +encoding/xtend-gen=UTF-8 diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/.settings/org.eclipse.xtend.core.Xtend.prefs b/plugins/de.cau.cs.kieler.klighd.lsp/.settings/org.eclipse.xtend.core.Xtend.prefs index 56e3bbe88..2b65c6b65 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/.settings/org.eclipse.xtend.core.Xtend.prefs +++ b/plugins/de.cau.cs.kieler.klighd.lsp/.settings/org.eclipse.xtend.core.Xtend.prefs @@ -2,5 +2,7 @@ BuilderConfiguration.is_project_specific=true eclipse.preferences.version=1 outlet.DEFAULT_OUTPUT.hideLocalSyntheticVariables=true outlet.DEFAULT_OUTPUT.installDslAsPrimarySource=false +outlet.DEFAULT_OUTPUT.sourceFolder.src-gen.directory=xtend-gen outlet.DEFAULT_OUTPUT.sourceFolder.src.directory=xtend-gen +outlet.DEFAULT_OUTPUT.sourceFolder.xtend-gen.directory=xtend-gen outlet.DEFAULT_OUTPUT.userOutputPerSourceFolder=true diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/pom.xml b/plugins/de.cau.cs.kieler.klighd.lsp/pom.xml index 01029cca8..2c75eb316 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/pom.xml +++ b/plugins/de.cau.cs.kieler.klighd.lsp/pom.xml @@ -10,7 +10,6 @@ de.cau.cs.kieler.klighd.lsp - eclipse-plugin KIELER Lightweight Diagrams as Language Server KIELER Lightweight Diagrams as Language Server diff --git a/pom.xml b/pom.xml index d012394f1..37b93201a 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ 32.1.3-jre 7.0.0 3.32.0 - 0.21.1 + 0.22.0 1.1.1 0.1.0 3.124.200 From 15affb971fb364c20508cc19da72b068deaf72f0 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Fri, 1 Mar 2024 15:26:24 +0100 Subject: [PATCH 3/5] cleaner jars without Xtext and Xtend source and mapping files --- plugins/de.cau.cs.kieler.kgraph.text.ide/build.properties | 2 ++ plugins/de.cau.cs.kieler.kgraph.text.ui/build.properties | 2 ++ plugins/de.cau.cs.kieler.kgraph.text/build.properties | 4 ++++ plugins/de.cau.cs.kieler.klighd.ide/build.properties | 2 ++ .../build.properties | 2 ++ plugins/de.cau.cs.kieler.klighd.lsp/build.properties | 3 ++- plugins/de.cau.cs.kieler.klighd.ui.wizard/build.properties | 2 ++ 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/de.cau.cs.kieler.kgraph.text.ide/build.properties b/plugins/de.cau.cs.kieler.kgraph.text.ide/build.properties index 6b74f11c3..d7ab75e9c 100644 --- a/plugins/de.cau.cs.kieler.kgraph.text.ide/build.properties +++ b/plugins/de.cau.cs.kieler.kgraph.text.ide/build.properties @@ -4,3 +4,5 @@ source.. = src-gen/,\ output.. = bin/ bin.includes = META-INF/,\ . +bin.excludes = **/*.xtend,\ + **/*.java._trace diff --git a/plugins/de.cau.cs.kieler.kgraph.text.ui/build.properties b/plugins/de.cau.cs.kieler.kgraph.text.ui/build.properties index e86a412e6..1a12796b4 100644 --- a/plugins/de.cau.cs.kieler.kgraph.text.ui/build.properties +++ b/plugins/de.cau.cs.kieler.kgraph.text.ui/build.properties @@ -6,4 +6,6 @@ bin.includes = META-INF/,\ about.html,\ icons/,\ plugin.xml +bin.excludes = **/*.xtend,\ + **/*.java._trace diff --git a/plugins/de.cau.cs.kieler.kgraph.text/build.properties b/plugins/de.cau.cs.kieler.kgraph.text/build.properties index 160c5b09a..56e82316d 100644 --- a/plugins/de.cau.cs.kieler.kgraph.text/build.properties +++ b/plugins/de.cau.cs.kieler.kgraph.text/build.properties @@ -6,3 +6,7 @@ bin.includes = model/generated/,\ about.html,\ .,\ plugin.xml +bin.excludes = **/*.xtend,\ + **/*.mwe2,\ + **/*.xtext,\ + **/*.java._trace diff --git a/plugins/de.cau.cs.kieler.klighd.ide/build.properties b/plugins/de.cau.cs.kieler.klighd.ide/build.properties index 74b70cb95..ba5f2edfe 100644 --- a/plugins/de.cau.cs.kieler.klighd.ide/build.properties +++ b/plugins/de.cau.cs.kieler.klighd.ide/build.properties @@ -6,3 +6,5 @@ bin.includes = META-INF/,\ plugin.xml,\ about.html,\ icons/ +bin.excludes = **/*.xtend,\ + **/*.java._trace diff --git a/plugins/de.cau.cs.kieler.klighd.krendering.extensions/build.properties b/plugins/de.cau.cs.kieler.klighd.krendering.extensions/build.properties index 2a2eb15f7..4069920ae 100644 --- a/plugins/de.cau.cs.kieler.klighd.krendering.extensions/build.properties +++ b/plugins/de.cau.cs.kieler.klighd.krendering.extensions/build.properties @@ -4,3 +4,5 @@ output.. = bin/ bin.includes = META-INF/,\ about.html,\ . +bin.excludes = **/*.xtend,\ + **/*.java._trace diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/build.properties b/plugins/de.cau.cs.kieler.klighd.lsp/build.properties index bf12396e8..d41815c23 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/build.properties +++ b/plugins/de.cau.cs.kieler.klighd.lsp/build.properties @@ -5,5 +5,6 @@ bin.includes = .,\ plugin.xml,\ about.html META-INF/, -bin.excludes = **/*.xtend +bin.excludes = **/*.xtend,\ + **/*.java._trace src.includes = about.html diff --git a/plugins/de.cau.cs.kieler.klighd.ui.wizard/build.properties b/plugins/de.cau.cs.kieler.klighd.ui.wizard/build.properties index f07c6a911..f9b252e9c 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui.wizard/build.properties +++ b/plugins/de.cau.cs.kieler.klighd.ui.wizard/build.properties @@ -7,3 +7,5 @@ bin.includes = META-INF/,\ plugin.xml,\ about.html src.includes = about.html +bin.excludes = **/*.xtend,\ + **/*.java._trace From 941eacda68ad7ce3578411cde2702445738cb925 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Wed, 13 Mar 2024 16:30:18 +0100 Subject: [PATCH 4/5] remove code duplications obsolete after Sprotty update --- .../klighd/lsp/KGraphDiagramServer.xtend | 185 ------------------ .../klighd/lsp/KGraphLayoutEngine.xtend | 23 ++- .../cs/kieler/klighd/lsp/model/Actions.xtend | 30 --- 3 files changed, 13 insertions(+), 225 deletions(-) diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramServer.xtend b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramServer.xtend index 5b9a9160d..514b381c8 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramServer.xtend +++ b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramServer.xtend @@ -16,7 +16,6 @@ */ package de.cau.cs.kieler.klighd.lsp -import com.google.common.base.Strings import com.google.common.base.Throwables import com.google.common.io.ByteStreams import com.google.inject.Inject @@ -28,7 +27,6 @@ import de.cau.cs.kieler.klighd.ViewContext import de.cau.cs.kieler.klighd.kgraph.KNode import de.cau.cs.kieler.klighd.lsp.interactive.layered.LayeredInteractiveActionHandler import de.cau.cs.kieler.klighd.lsp.interactive.rectpacking.RectpackingInteractiveActionHandler -import de.cau.cs.kieler.klighd.lsp.launch.AbstractLanguageServer import de.cau.cs.kieler.klighd.lsp.model.CheckImagesAction import de.cau.cs.kieler.klighd.lsp.model.CheckedImagesAction import de.cau.cs.kieler.klighd.lsp.model.DisplayedActionUIData @@ -51,8 +49,6 @@ import java.util.Base64 import java.util.Collection import java.util.List import java.util.Map -import java.util.concurrent.CompletableFuture -import org.apache.log4j.Logger import org.eclipse.core.runtime.Platform import org.eclipse.elk.core.data.LayoutMetaDataService import org.eclipse.elk.core.data.LayoutOptionData @@ -68,10 +64,7 @@ import org.eclipse.sprotty.IDiagramSelectionListener import org.eclipse.sprotty.ILayoutEngine import org.eclipse.sprotty.IModelUpdateListener import org.eclipse.sprotty.IPopupModelFactory -import org.eclipse.sprotty.LayoutAction import org.eclipse.sprotty.RejectAction -import org.eclipse.sprotty.RequestBoundsAction -import org.eclipse.sprotty.RequestModelAction import org.eclipse.sprotty.SModelCloner import org.eclipse.sprotty.SModelElement import org.eclipse.sprotty.SModelRoot @@ -88,7 +81,6 @@ import org.eclipse.xtend.lib.annotations.Accessors * @author nre */ class KGraphDiagramServer extends LanguageAwareDiagramServer { - static val LOG = Logger.getLogger(KGraphDiagramServer) @Inject protected LayeredInteractiveActionHandler constraintActionHandler @@ -121,31 +113,6 @@ class KGraphDiagramServer extends LanguageAwareDiagramServer { @Accessors(PUBLIC_GETTER) protected Object modelLock = new Object - /** - * Needed for KeithUpdateModelAction - * - * FIXME Remove this if UpdateModelAction has a cause. - */ - protected String lastSubmittedModelType - - /** - * Needed for KeithUpdateModelAction - * - * FIXME Remove this if UpdateModelAction has a cause. - */ - protected int revision = 0 - - /** - * Needed for KeithUpdateModelAction - * - * FIXME Remove this if UpdateModelAction has a cause. - */ - new() { - currentRoot = new SModelRoot(); - currentRoot.setType("NONE"); - currentRoot.setId("ROOT"); - } - /** * Prepares the client side update of the model by processing the potentially needed images on the client. Checks * for client-side cached images with the {@link CheckImagesAction}. If the corresponding response to the @@ -269,149 +236,6 @@ class KGraphDiagramServer extends LanguageAwareDiagramServer { notificationHandler.sendErrorAndThrow(e) } } - - /** - * Submit a new or updated model to the client. If client layout is required, a {@link RequestBoundsAction} - * is sent, otherwise either a {@link SetModelAction} or an {@link UpdateModelAction} is sent depending on - * the {@code update} parameter. - * Needed for KeithUpdateModelAction - * - * FIXME Remove this if UpdateModelAction has a cause. - */ - override CompletableFuture submitModel(SModelRoot newRoot, boolean update, Action cause) { - if (needsClientLayout(newRoot)) { - if (!needsServerLayout(newRoot, cause)) { - // In this case the client won't send us the computed bounds - dispatch(new RequestBoundsAction(newRoot)); - val IModelUpdateListener listener = getModelUpdateListener(); - if (listener !== null) { - listener.modelSubmitted(newRoot, this); - } - } else { - return request(new RequestBoundsAction(newRoot)).handle([response, exception | { - if (exception !== null) { - LOG.error("RequestBoundsAction failed with an exception.", exception); - } else { - try { - var SModelRoot model = handle(response); - if (model !== null) - doSubmitModel(model, true, cause); - } catch (Exception exc) { - LOG.error("Exception while processing ComputedBoundsAction.", exc); - } - } - return null; - }]) - } - } else { - doSubmitModel(newRoot, update, cause); - } - return CompletableFuture.completedFuture(null); - } - - /** - * Needed for KeithUpdateModelAction - * - * FIXME Remove this if UpdateModelAction has a cause. - */ - override CompletableFuture setModel(SModelRoot newRoot) { - if (newRoot === null) - throw new NullPointerException(); - synchronized(modelLock) { - newRoot.setRevision(revision + 1); - revision++ - currentRoot = newRoot; - } - return submitModel(newRoot, false, null); - } - - /** - * Needed for KeithUpdateModelAction - * - * FIXME Remove this if UpdateModelAction has a cause. - */ - override CompletableFuture updateModel(SModelRoot newRoot) { - if (newRoot === null) - throw new IllegalArgumentException("updateModel() cannot be called with null"); - synchronized(modelLock) { - currentRoot = newRoot; - newRoot.setRevision(revision + 1); - revision++ - } - return submitModel(newRoot, true, null); - } - - - /** - * Needed for KeithUpdateModelAction - * - * FIXME Remove this if UpdateModelAction has a cause. - */ - def void doSubmitModel(SModelRoot newRoot, boolean update, Action cause) { - val ILayoutEngine layoutEngine = getLayoutEngine(); - if (needsServerLayout(newRoot, cause)) { - AbstractLanguageServer.addToMainThreadQueue([ - layoutEngine.layout(newRoot, cause) - ]) - } - synchronized (modelLock) { - if (newRoot.getRevision() == revision) { - var String modelType = newRoot.getType(); - if (cause instanceof RequestModelAction - && !Strings.isNullOrEmpty((cause as RequestModelAction).getRequestId())) { - var RequestModelAction request = cause as RequestModelAction; - var SetModelAction response = new SetModelAction(newRoot); - response.setResponseId(request.getRequestId()); - dispatch(response); - } else if (update && modelType !== null && modelType.equals(lastSubmittedModelType)) { - dispatch(new UpdateModelAction(newRoot)); - } else { - dispatch(new SetModelAction(newRoot)); - } - lastSubmittedModelType = modelType; - var IModelUpdateListener listener = getModelUpdateListener(); - if (listener !== null) { - listener.modelSubmitted(newRoot, this); - } - } - } - } - - /** - * Taken from {@code DefaultDiagramServer.handle(RequestModelAction)} to use this getModel. - * Needed for KeithUpdateModelAction - * - * FIXME Remove this if UpdateModelAction has a cause. - */ - override protected handle(RequestModelAction request) { - if (diagramLanguageServer !== null) { - copyOptions(request) - diagramLanguageServer.diagramUpdater.updateDiagram(this, request) - } else { - super.handle(request) - } - } - - /** - * Taken from {@code DefaultDiagramServer.handle(LayoutAction)} to use this getModel. - * Needed for KeithUpdateModelAction - * - * FIXME Remove this if UpdateModelAction has a cause. - */ - override void handle(LayoutAction action) { - if (needsServerLayout(model,action)) { - // Clone the current model, as it has already been sent to the client with the old revision - val SModelCloner cloner = getSModelCloner(); - val SModelRoot newRoot = cloner.clone(model); - synchronized(modelLock) { - newRoot.setRevision(revision + 1); - revision++ - currentRoot = newRoot; - } - // the actual layout is performed in doSubmitModel - doSubmitModel(newRoot, true, action); - } - } /** * Called when a {@link PerformActionAction} is received. @@ -632,15 +456,6 @@ class KGraphDiagramServer extends LanguageAwareDiagramServer { } newModel = false } - - /** - * Needed for KeithUpdateModelAction - * - * FIXME Remove this if UpdateModelAction has a cause. - */ - override SModelRoot getModel() { - return currentRoot; - } // Repeat injection of multiple methods of the DefaultDiagramServer as the javax.inject->jakarta.inject transition // broke something here. diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphLayoutEngine.xtend b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphLayoutEngine.xtend index 68be39e76..ff598dc4e 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphLayoutEngine.xtend +++ b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphLayoutEngine.xtend @@ -3,7 +3,7 @@ * * http://rtsys.informatik.uni-kiel.de/kieler * - * Copyright 2018-2023 by + * Copyright 2018-2024 by * + Kiel University * + Department of Computer Science * + Real-Time and Embedded Systems Group @@ -18,6 +18,7 @@ package de.cau.cs.kieler.klighd.lsp import com.google.inject.Inject import de.cau.cs.kieler.klighd.LightDiagramLayoutConfig +import de.cau.cs.kieler.klighd.lsp.launch.AbstractLanguageServer import de.cau.cs.kieler.klighd.lsp.utils.KGraphMappingUtil import de.cau.cs.kieler.klighd.lsp.utils.RenderingPreparer import java.io.ByteArrayOutputStream @@ -48,16 +49,18 @@ class KGraphLayoutEngine extends ElkLayoutEngine { public static val LOG = Logger.getLogger(KGraphLayoutEngine) override layout(SModelRoot root, Action cause) { - synchronized (diagramState) { - if (root instanceof SGraph) { - // The layout is executed on the KGraph, not the SGraph. So get the KGraph belonging to this SGraph from - // the KGraphContext. - onlyLayoutOnKGraph(root.id) - - // map layouted KGraph to SGraph - KGraphMappingUtil.mapLayout(diagramState.getKGraphToSModelElementMap(root.id)) + AbstractLanguageServer.addToMainThreadQueue([ + synchronized (diagramState) { + if (root instanceof SGraph) { + // The layout is executed on the KGraph, not the SGraph. So get the KGraph belonging to this SGraph from + // the KGraphContext. + onlyLayoutOnKGraph(root.id) + + // map layouted KGraph to SGraph + KGraphMappingUtil.mapLayout(diagramState.getKGraphToSModelElementMap(root.id)) + } } - } + ]) } /** diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/model/Actions.xtend b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/model/Actions.xtend index 75aa467b6..6682e4dbd 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/model/Actions.xtend +++ b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/model/Actions.xtend @@ -239,36 +239,6 @@ class RefreshLayoutAction implements Action { } } -/** - * Updates the model and sends the cause to the client. - * Extends to UpdateModelAction. - * FIXME Remove this if the UpdateModelAction includes a cause. - * - * @author sdo - */ -@Accessors -@EqualsHashCode -@ToString(skipNulls = true) -public class KeithUpdateModelAction extends UpdateModelAction { - public static val KIND = 'updateModel' - String kind = KIND - - - SModelRoot newRoot - Boolean animate - Action cause - - new() {} - new(Consumer initializer) { - initializer.accept(this) - } - - new(SModelRoot newRoot, Action cause) { - this.newRoot = newRoot - this.cause = cause - } -} - /** * Sent from client to request a certain piece of the diagram. * From 408ed0282edc4e4278fd5649c18e2f8424b743d7 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Wed, 13 Mar 2024 16:33:06 +0100 Subject: [PATCH 5/5] remove injection duplications obsolete after Sprotty update --- .../klighd/lsp/KGraphDiagramServer.xtend | 52 ------------------- 1 file changed, 52 deletions(-) diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramServer.xtend b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramServer.xtend index 514b381c8..d8347dd08 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramServer.xtend +++ b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/KGraphDiagramServer.xtend @@ -57,15 +57,7 @@ import org.eclipse.elk.graph.properties.IProperty import org.eclipse.emf.ecore.EObject import org.eclipse.sprotty.Action import org.eclipse.sprotty.ActionMessage -import org.eclipse.sprotty.ComputedBoundsApplicator -import org.eclipse.sprotty.IDiagramExpansionListener -import org.eclipse.sprotty.IDiagramOpenListener -import org.eclipse.sprotty.IDiagramSelectionListener -import org.eclipse.sprotty.ILayoutEngine -import org.eclipse.sprotty.IModelUpdateListener -import org.eclipse.sprotty.IPopupModelFactory import org.eclipse.sprotty.RejectAction -import org.eclipse.sprotty.SModelCloner import org.eclipse.sprotty.SModelElement import org.eclipse.sprotty.SModelRoot import org.eclipse.sprotty.SelectAction @@ -456,48 +448,4 @@ class KGraphDiagramServer extends LanguageAwareDiagramServer { } newModel = false } - - // Repeat injection of multiple methods of the DefaultDiagramServer as the javax.inject->jakarta.inject transition - // broke something here. - // TODO: remove when not necessary anymore - - @Inject - override setModelUpdateListener(IModelUpdateListener listener) { - super.modelUpdateListener = listener; - } - - @Inject - override setLayoutEngine(ILayoutEngine engine) { - super.layoutEngine = engine; - } - - @Inject - override setComputedBoundsApplicator(ComputedBoundsApplicator computedBoundsApplicator) { - super.computedBoundsApplicator = computedBoundsApplicator; - } - - @Inject - override setPopupModelFactory(IPopupModelFactory factory) { - super.popupModelFactory = factory; - } - - @Inject - override setSelectionListener(IDiagramSelectionListener listener) { - super.selectionListener = listener; - } - - @Inject - override setExpansionListener(IDiagramExpansionListener diagramExpansionListener) { - super.expansionListener = diagramExpansionListener; - } - - @Inject - override setOpenListener(IDiagramOpenListener diagramOpenListener) { - super.openListener = diagramOpenListener; - } - - @Inject - override setSModelCloner(SModelCloner smodelCloner) { - super.SModelCloner = smodelCloner; - } }