From 396cd18ca8c7304d2f9563b8d1c579474a4dec4e Mon Sep 17 00:00:00 2001 From: Jette Petzold Date: Wed, 21 Oct 2020 12:28:36 +0200 Subject: [PATCH 01/11] interactive: regions must not be moveable --- .../sccharts/ui/synthesis/SCChartsSynthesis.xtend | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/SCChartsSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/SCChartsSynthesis.xtend index fc5870c7bd..e5fa7daa96 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/SCChartsSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/SCChartsSynthesis.xtend @@ -305,13 +305,23 @@ class SCChartsSynthesis extends AbstractDiagramSynthesis { override List getAdditionalLayoutConfigs(KNode viewModel) { val List additionalLayoutRuns = newArrayList // Add interactive Layout run. - if ((!viewModel.getChildren().isEmpty() && viewModel.getChildren().get(0) - .getProperty(CoreOptions.INTERACTIVE_LAYOUT))) { + if (!viewModel.getChildren().isEmpty() && (viewModel.getChildren().get(0) + .getProperty(CoreOptions.INTERACTIVE_LAYOUT) || isChildInteractive(viewModel))) { additionalLayoutRuns.add(new CompoundGraphElementVisitor( new InteractiveRectPackingGraphVisitor(), new InteractiveLayeredGraphVisitor())); } return additionalLayoutRuns; } + + private def isChildInteractive(KNode node) { + val children = node.getChildren.get(0).getChildren() + for (n : children) { + if (n.getProperty(CoreOptions.INTERACTIVE_LAYOUT)) { + return true + } + } + return false + } } From 5bf7e73aa3ed4f87e7245400858ecf4e802f8037 Mon Sep 17 00:00:00 2001 From: Jette Petzold Date: Fri, 30 Oct 2020 10:51:56 +0100 Subject: [PATCH 02/11] interactive: default value of interactive layout is true for regions --- .../sccharts/ui/synthesis/ControlflowRegionSynthesis.xtend | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ControlflowRegionSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ControlflowRegionSynthesis.xtend index 59b001a851..99a8ffbada 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ControlflowRegionSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ControlflowRegionSynthesis.xtend @@ -75,6 +75,11 @@ class ControlflowRegionSynthesis extends SubSynthesis override performTranformation(ControlflowRegion region) { val node = region.createNode().associateWith(region); + // default value of interactive layout for regions + if (!region.annotations.contains(CoreOptions.INTERACTIVE_LAYOUT)) { + node.setLayoutOption(CoreOptions::INTERACTIVE_LAYOUT, true) + } + node.configureNodeLOD(region) // Set KIdentifier for use with incremental update From 87f8c1640c27863877f644a6aff3409d89ce36d2 Mon Sep 17 00:00:00 2001 From: Soeren Domroes Date: Thu, 20 Oct 2022 18:03:33 +0200 Subject: [PATCH 03/11] Added SCTX constraint serializer. --- .../META-INF/MANIFEST.MF | 3 +- ...ighd.lsp.interactive.IConstraintSerializer | 1 + .../server/SCTXConstraintSerializer.xtend | 109 ++++++++++++++++++ 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 plugins/de.cau.cs.kieler.sccharts.ide/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.IConstraintSerializer create mode 100644 plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXConstraintSerializer.xtend diff --git a/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/MANIFEST.MF b/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/MANIFEST.MF index 7532b7ac9d..0e92675fb8 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/MANIFEST.MF +++ b/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/MANIFEST.MF @@ -21,7 +21,8 @@ Require-Bundle: org.antlr.runtime;bundle-version="[3.2.0,3.2.1)", de.cau.cs.kieler.scl.ide, de.cau.cs.kieler.klighd.lsp, com.google.gson, - de.cau.cs.kieler.kicool.ide + de.cau.cs.kieler.kicool.ide, + org.eclipse.lsp4j Export-Package: de.cau.cs.kieler.sccharts.ide.simulation, de.cau.cs.kieler.sccharts.ide.synthesis, de.cau.cs.kieler.sccharts.ide.text.contentassist.antlr, diff --git a/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.IConstraintSerializer b/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.IConstraintSerializer new file mode 100644 index 0000000000..e534ff9f48 --- /dev/null +++ b/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.IConstraintSerializer @@ -0,0 +1 @@ +de.cau.cs.kieler.sccharts.ide.language.server.SCTXConstraintSerializer \ No newline at end of file diff --git a/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXConstraintSerializer.xtend b/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXConstraintSerializer.xtend new file mode 100644 index 0000000000..b08ac457eb --- /dev/null +++ b/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXConstraintSerializer.xtend @@ -0,0 +1,109 @@ +/* + * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient + * + * http://rtsys.informatik.uni-kiel.de/kieler + * + * Copyright 2022 by + * + Kiel University + * + Department of Computer Science + * + Real-Time and Embedded Systems Group + * + * This code is provided under the terms of the Eclipse Public License (EPL). + */ +package de.cau.cs.kieler.sccharts.ide.language.server + +import de.cau.cs.kieler.annotations.Annotatable +import de.cau.cs.kieler.annotations.AnnotationsFactory +import de.cau.cs.kieler.annotations.TypedStringAnnotation +import de.cau.cs.kieler.klighd.internal.util.KlighdInternalProperties +import de.cau.cs.kieler.klighd.kgraph.KNode +import de.cau.cs.kieler.klighd.lsp.KGraphLanguageClient +import de.cau.cs.kieler.klighd.lsp.KGraphLanguageServerExtension +import de.cau.cs.kieler.klighd.lsp.interactive.ConstraintProperty +import de.cau.cs.kieler.klighd.lsp.interactive.IConstraintSerializer +import de.cau.cs.kieler.sccharts.impl.StateImpl +import java.io.ByteArrayOutputStream +import java.util.HashMap +import java.util.List +import java.util.Map +import org.eclipse.elk.graph.properties.IProperty +import org.eclipse.lsp4j.Position +import org.eclipse.lsp4j.Range +import org.eclipse.lsp4j.TextEdit + +/** + * @author sdo + * + */ +class SCTXConstraintSerializer implements IConstraintSerializer { + + override canHandle(Object graph) { + return graph instanceof StateImpl + } + + override serializeConstraints(List> changedNodes, Object graph, String uri, + KGraphLanguageServerExtension ls, KGraphLanguageClient client) { + changedNodes.forEach[c| + val Annotatable anno = c.KNode.getProperty(KlighdInternalProperties.MODEL_ELEMEMT) as Annotatable + copyConstraintAnnotations(anno, c.KNode, c.property.id, c.property) + ] + // Serialize model into given uri. + val resource = ls.getResource(uri) + + // Get previous file content as String + var outputStream = new ByteArrayOutputStream + resource.save(outputStream, emptyMap) + val codeBefore = outputStream.toString + val Map> changes = newHashMap + // Get changed file as String + outputStream = new ByteArrayOutputStream + resource.save(outputStream, emptyMap) + val String codeAfter = outputStream.toString().trim + + // The range is the length of the previous file. + // Just make sure the range is big enough + val Range range = new Range(new Position(0, 0), new Position(codeBefore.split("\r\n|\r|\n").length * 2, 0)) + val TextEdit textEdit = new TextEdit(range, codeAfter) + changes.put(uri, #[textEdit]); + client.replaceContentInFile(uri, codeAfter, range) + } + + /** + * Copies an arbitrary IProperty of a KNode to a State if the value on the KNode + * is different to the value on the State. + * If the new value on the KNode was the default value of the property + * then the property is set to null on the State. + * @param state The target sate + * @param kNode The source KNode of the property + * @param annotation The annotation that should be set + * @param prop Determines which IProperty should be copied + */ + static def copyConstraintAnnotations(Annotatable state, KNode kNode, String annotation, IProperty prop) { + val String value = "" + kNode.getProperty(prop) + + val anns = state.getAnnotations().filter(TypedStringAnnotation) + + // remove old annotation if it exists + var TypedStringAnnotation removeA = null + for (ann : anns) { + if (ann.type.equals(annotation)) { + removeA = ann + } + } + if (removeA !== null) { + state.annotations.remove(removeA) + } + + // add annotation with new value if the value is not the default one + if (kNode.getProperty(prop) !== null && !kNode.getProperty(prop).equals(prop.^default)) { + var newA = AnnotationsFactory::eINSTANCE.createTypedStringAnnotation => [ + it.name = "layout" + it.type = annotation + it.values += value + ] + state.annotations.add(newA) + } + + } + +} From 6737be3bfa498afff57bcbb3c230b884cb96cf9c Mon Sep 17 00:00:00 2001 From: Soeren Domroes Date: Fri, 21 Oct 2022 13:12:54 +0200 Subject: [PATCH 04/11] scharts.ide: Added interactive node id provider for SCTX. --- ...ler.klighd.lsp.interactive.INodeIdProvider | 1 + .../server/SCTXConstraintSerializer.xtend | 1 - .../language/server/SCTXNodeIdProvider.xtend | 36 +++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 plugins/de.cau.cs.kieler.sccharts.ide/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.INodeIdProvider create mode 100644 plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXNodeIdProvider.xtend diff --git a/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.INodeIdProvider b/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.INodeIdProvider new file mode 100644 index 0000000000..8f56e1e350 --- /dev/null +++ b/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.INodeIdProvider @@ -0,0 +1 @@ +de.cau.cs.kieler.sccharts.ide.language.server.SCTXNodeIdProvider \ No newline at end of file diff --git a/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXConstraintSerializer.xtend b/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXConstraintSerializer.xtend index b08ac457eb..31ffcfb831 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXConstraintSerializer.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXConstraintSerializer.xtend @@ -23,7 +23,6 @@ import de.cau.cs.kieler.klighd.lsp.interactive.ConstraintProperty import de.cau.cs.kieler.klighd.lsp.interactive.IConstraintSerializer import de.cau.cs.kieler.sccharts.impl.StateImpl import java.io.ByteArrayOutputStream -import java.util.HashMap import java.util.List import java.util.Map import org.eclipse.elk.graph.properties.IProperty diff --git a/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXNodeIdProvider.xtend b/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXNodeIdProvider.xtend new file mode 100644 index 0000000000..e6ec9d1c06 --- /dev/null +++ b/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXNodeIdProvider.xtend @@ -0,0 +1,36 @@ +/* + * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient + * + * http://rtsys.informatik.uni-kiel.de/kieler + * + * Copyright 2022 by + * + Kiel University + * + Department of Computer Science + * + Real-Time and Embedded Systems Group + * + * This code is provided under the terms of the Eclipse Public License (EPL). + */ +package de.cau.cs.kieler.sccharts.ide.language.server + +import de.cau.cs.kieler.klighd.lsp.interactive.INodeIdProvider +import de.cau.cs.kieler.sccharts.impl.ScopeImpl + +/** + * Service class that returns the id of regions or states. + * + * @author sdo + * + */ +class SCTXNodeIdProvider implements INodeIdProvider { + + override canHandle(Object graph) { + return graph instanceof ScopeImpl + } + + override getNodeId(Object element) { + if (element instanceof ScopeImpl) { + return element.name + } + } + +} From 697e3b9c0088fc1181d76df83f9c2fc6656333b0 Mon Sep 17 00:00:00 2001 From: Soeren Domroes Date: Mon, 24 Oct 2022 15:16:45 +0200 Subject: [PATCH 05/11] scharts.ide.interactive: Remove NodeIdProvider service interface. --- ...ler.klighd.lsp.interactive.INodeIdProvider | 1 - .../language/server/SCTXNodeIdProvider.xtend | 36 ------------------- 2 files changed, 37 deletions(-) delete mode 100644 plugins/de.cau.cs.kieler.sccharts.ide/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.INodeIdProvider delete mode 100644 plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXNodeIdProvider.xtend diff --git a/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.INodeIdProvider b/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.INodeIdProvider deleted file mode 100644 index 8f56e1e350..0000000000 --- a/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.INodeIdProvider +++ /dev/null @@ -1 +0,0 @@ -de.cau.cs.kieler.sccharts.ide.language.server.SCTXNodeIdProvider \ No newline at end of file diff --git a/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXNodeIdProvider.xtend b/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXNodeIdProvider.xtend deleted file mode 100644 index e6ec9d1c06..0000000000 --- a/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXNodeIdProvider.xtend +++ /dev/null @@ -1,36 +0,0 @@ -/* - * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient - * - * http://rtsys.informatik.uni-kiel.de/kieler - * - * Copyright 2022 by - * + Kiel University - * + Department of Computer Science - * + Real-Time and Embedded Systems Group - * - * This code is provided under the terms of the Eclipse Public License (EPL). - */ -package de.cau.cs.kieler.sccharts.ide.language.server - -import de.cau.cs.kieler.klighd.lsp.interactive.INodeIdProvider -import de.cau.cs.kieler.sccharts.impl.ScopeImpl - -/** - * Service class that returns the id of regions or states. - * - * @author sdo - * - */ -class SCTXNodeIdProvider implements INodeIdProvider { - - override canHandle(Object graph) { - return graph instanceof ScopeImpl - } - - override getNodeId(Object element) { - if (element instanceof ScopeImpl) { - return element.name - } - } - -} From f7bf8dce8bf7ad4dc1c73b2480ecc7d07a06962c Mon Sep 17 00:00:00 2001 From: Soeren Domroes Date: Mon, 7 Nov 2022 17:16:42 +0100 Subject: [PATCH 06/11] scharts.ide/ui: Documentation, setting interactive layout in synthesis removed. --- .../server/SCTXConstraintSerializer.xtend | 35 ++++++++++--------- .../ControlflowRegionSynthesis.xtend | 5 --- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXConstraintSerializer.xtend b/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXConstraintSerializer.xtend index 31ffcfb831..16bd665877 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXConstraintSerializer.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ide/src/de/cau/cs/kieler/sccharts/ide/language/server/SCTXConstraintSerializer.xtend @@ -31,6 +31,8 @@ import org.eclipse.lsp4j.Range import org.eclipse.lsp4j.TextEdit /** + * Serialize a constraint for an SCChart node (region or state) as a layout annotation. + * * @author sdo * */ @@ -72,29 +74,30 @@ class SCTXConstraintSerializer implements IConstraintSerializer { * is different to the value on the State. * If the new value on the KNode was the default value of the property * then the property is set to null on the State. - * @param state The target sate - * @param kNode The source KNode of the property - * @param annotation The annotation that should be set - * @param prop Determines which IProperty should be copied + * + * @param state The target state. + * @param kNode The source KNode of the property. + * @param annotation The annotation that should be set. + * @param property Determines which IProperty should be copied. */ - static def copyConstraintAnnotations(Annotatable state, KNode kNode, String annotation, IProperty prop) { - val String value = "" + kNode.getProperty(prop) + static def copyConstraintAnnotations(Annotatable state, KNode kNode, String annotation, IProperty property) { + val String value = "" + kNode.getProperty(property) - val anns = state.getAnnotations().filter(TypedStringAnnotation) + val annotations = state.getAnnotations().filter(TypedStringAnnotation) - // remove old annotation if it exists - var TypedStringAnnotation removeA = null - for (ann : anns) { - if (ann.type.equals(annotation)) { - removeA = ann + // Remove old annotation if it exists. + var TypedStringAnnotation annotationToRemove = null + for (a : annotations) { + if (a.type.equals(annotation)) { + annotationToRemove = a } } - if (removeA !== null) { - state.annotations.remove(removeA) + if (annotationToRemove !== null) { + state.annotations.remove(annotationToRemove) } - // add annotation with new value if the value is not the default one - if (kNode.getProperty(prop) !== null && !kNode.getProperty(prop).equals(prop.^default)) { + // Add annotation with new value if the value is not the default one. + if (kNode.getProperty(property) !== null && !kNode.getProperty(property).equals(property.^default)) { var newA = AnnotationsFactory::eINSTANCE.createTypedStringAnnotation => [ it.name = "layout" it.type = annotation diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ControlflowRegionSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ControlflowRegionSynthesis.xtend index 8784fb3767..e1f0e4047c 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ControlflowRegionSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/ControlflowRegionSynthesis.xtend @@ -77,11 +77,6 @@ class ControlflowRegionSynthesis extends SubSynthesis override performTranformation(ControlflowRegion region) { val node = region.createNode().associateWith(region); - // default value of interactive layout for regions - if (!region.annotations.contains(CoreOptions.INTERACTIVE_LAYOUT)) { - node.setLayoutOption(CoreOptions::INTERACTIVE_LAYOUT, true) - } - node.configureNodeLOD(region) // Set KIdentifier for use with incremental update From c746ab72a5f423a9dd503e43f08abd40e6676358 Mon Sep 17 00:00:00 2001 From: Soeren Domroes Date: Tue, 8 Nov 2022 17:13:12 +0100 Subject: [PATCH 07/11] Add MrTree lS extension and configuration. --- .../de/cau/cs/kieler/language/server/LSCreator.xtend | 5 +++++ .../de.cau.cs.kieler.scg.klighd/META-INF/MANIFEST.MF | 3 ++- .../klighd/ssa/domtree/DominatorTreeSynthesis.xtend | 12 +++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/LSCreator.xtend b/plugins/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/LSCreator.xtend index 497aac4575..2f30a7a42f 100644 --- a/plugins/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/LSCreator.xtend +++ b/plugins/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/LSCreator.xtend @@ -17,6 +17,7 @@ import de.cau.cs.kieler.core.services.KielerServiceLoader import de.cau.cs.kieler.kgraph.text.services.KGraphGrammarAccess import de.cau.cs.kieler.klighd.lsp.KGraphLanguageClient import de.cau.cs.kieler.klighd.lsp.interactive.layered.LayeredInteractiveLanguageServerExtension +import de.cau.cs.kieler.klighd.lsp.interactive.mrtree.MrTreeInteractiveLanguageServerExtension import de.cau.cs.kieler.klighd.lsp.interactive.rectpacking.RectpackingInteractiveLanguageServerExtension import de.cau.cs.kieler.klighd.lsp.launch.AbstractLsCreator import java.util.List @@ -37,6 +38,8 @@ class LSCreator extends AbstractLsCreator { RectpackingInteractiveLanguageServerExtension rectPack + MrTreeInteractiveLanguageServerExtension mrTree + List diagramHighlighters List iLanguageServerExtensions @@ -54,6 +57,7 @@ class LSCreator extends AbstractLsCreator { override getLanguageServerExtensions() { constraints = injector.getInstance(LayeredInteractiveLanguageServerExtension) rectPack = injector.getInstance(RectpackingInteractiveLanguageServerExtension) + mrTree = injector.getInstance(MrTreeInteractiveLanguageServerExtension) iLanguageServerExtensions = newArrayList(constraints, rectPack) for (lse : KielerServiceLoader.load(ILanguageServerContribution)) { iLanguageServerExtensions.add(lse.getLanguageServerExtension(injector)) @@ -75,6 +79,7 @@ class LSCreator extends AbstractLsCreator { } constraints.client = languageClient as KGraphLanguageClient rectPack.client = languageClient as KGraphLanguageClient + mrTree.client = languageClient as KGraphLanguageClient diagramHighlighters = newArrayList for (iLSdhc : KielerServiceLoader.load(ILSDiagramHighlighterContribution)) { var highlighter = iLSdhc.getHighlighter(injector) diff --git a/plugins/de.cau.cs.kieler.scg.klighd/META-INF/MANIFEST.MF b/plugins/de.cau.cs.kieler.scg.klighd/META-INF/MANIFEST.MF index 08d4ad264f..7d264e3dd1 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/META-INF/MANIFEST.MF +++ b/plugins/de.cau.cs.kieler.scg.klighd/META-INF/MANIFEST.MF @@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.elk.core;bundle-version="0.7.1", de.cau.cs.kieler.kicool.ui, de.cau.cs.kieler.simulation.ide, de.cau.cs.kieler.simulation.ui, - de.cau.cs.kieler.annotations.ide + de.cau.cs.kieler.annotations.ide, + org.eclipse.elk.alg.mrtree Bundle-RequiredExecutionEnvironment: JavaSE-11 Export-Package: de.cau.cs.kieler.scg.klighd Bundle-ActivationPolicy: lazy diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ssa/domtree/DominatorTreeSynthesis.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ssa/domtree/DominatorTreeSynthesis.xtend index 527644312c..c4cb5785ec 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ssa/domtree/DominatorTreeSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ssa/domtree/DominatorTreeSynthesis.xtend @@ -16,6 +16,7 @@ package de.cau.cs.kieler.scg.klighd.ssa.domtree import com.google.inject.Inject import de.cau.cs.kieler.annotations.extensions.AnnotationsExtensions import de.cau.cs.kieler.klighd.LightDiagramServices +import de.cau.cs.kieler.klighd.SynthesisOption import de.cau.cs.kieler.klighd.internal.util.SourceModelTrackingAdapter import de.cau.cs.kieler.klighd.kgraph.KNode import de.cau.cs.kieler.klighd.krendering.SimpleUpdateStrategy @@ -33,13 +34,15 @@ import de.cau.cs.kieler.scg.SchedulingBlock import de.cau.cs.kieler.scg.extensions.SCGControlFlowExtensions import de.cau.cs.kieler.scg.extensions.SCGCoreExtensions import de.cau.cs.kieler.scg.processors.ssa.DominatorTree +import java.util.List import java.util.Map +import org.eclipse.elk.alg.mrtree.options.EdgeRoutingMode +import org.eclipse.elk.alg.mrtree.options.MrTreeOptions +import org.eclipse.elk.alg.mrtree.options.OrderWeighting import org.eclipse.elk.core.options.CoreOptions import org.eclipse.elk.core.options.Direction import static extension de.cau.cs.kieler.klighd.syntheses.DiagramSyntheses.* -import de.cau.cs.kieler.klighd.SynthesisOption -import java.util.List class DominatorTreeSynthesis extends AbstractDiagramSynthesis { @@ -133,8 +136,11 @@ class DominatorTreeSynthesis extends AbstractDiagramSynthesis { nodes.entrySet.forEach[nodes.createDTEdge(value, key, dt)] val dtDiagram = createNode - dtDiagram.addLayoutParam(CoreOptions::ALGORITHM, "org.eclipse.elk.mrtree") + dtDiagram.addLayoutParam(CoreOptions::ALGORITHM, MrTreeOptions.ALGORITHM_ID) dtDiagram.addLayoutParam(CoreOptions::DIRECTION, Direction.DOWN) + dtDiagram.addLayoutParam(MrTreeOptions::EDGE_ROUTING_MODE, EdgeRoutingMode.AvoidOverlap) + dtDiagram.addLayoutParam(MrTreeOptions::WEIGHTING, OrderWeighting.NONE) + dtDiagram.addLayoutParam(MrTreeOptions::COMPACTION, false) dtDiagram.children += nodes.values return dtDiagram From 9eb7cc2ce8ab8afa92d5c42812d3c8d3b0d97771 Mon Sep 17 00:00:00 2001 From: Soeren Domroes Date: Fri, 11 Nov 2022 16:00:30 +0100 Subject: [PATCH 08/11] Added Mrtree so supported ls extensions. --- .../src/de/cau/cs/kieler/language/server/LSCreator.xtend | 2 +- .../scg/klighd/ssa/domtree/DominatorTreeSynthesis.xtend | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/LSCreator.xtend b/plugins/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/LSCreator.xtend index 2f30a7a42f..f2456ded4a 100644 --- a/plugins/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/LSCreator.xtend +++ b/plugins/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/LSCreator.xtend @@ -58,7 +58,7 @@ class LSCreator extends AbstractLsCreator { constraints = injector.getInstance(LayeredInteractiveLanguageServerExtension) rectPack = injector.getInstance(RectpackingInteractiveLanguageServerExtension) mrTree = injector.getInstance(MrTreeInteractiveLanguageServerExtension) - iLanguageServerExtensions = newArrayList(constraints, rectPack) + iLanguageServerExtensions = newArrayList(constraints, rectPack, mrTree) for (lse : KielerServiceLoader.load(ILanguageServerContribution)) { iLanguageServerExtensions.add(lse.getLanguageServerExtension(injector)) } diff --git a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ssa/domtree/DominatorTreeSynthesis.xtend b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ssa/domtree/DominatorTreeSynthesis.xtend index c4cb5785ec..8abbec5285 100644 --- a/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ssa/domtree/DominatorTreeSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.scg.klighd/src/de/cau/cs/kieler/scg/klighd/ssa/domtree/DominatorTreeSynthesis.xtend @@ -138,8 +138,8 @@ class DominatorTreeSynthesis extends AbstractDiagramSynthesis { val dtDiagram = createNode dtDiagram.addLayoutParam(CoreOptions::ALGORITHM, MrTreeOptions.ALGORITHM_ID) dtDiagram.addLayoutParam(CoreOptions::DIRECTION, Direction.DOWN) - dtDiagram.addLayoutParam(MrTreeOptions::EDGE_ROUTING_MODE, EdgeRoutingMode.AvoidOverlap) - dtDiagram.addLayoutParam(MrTreeOptions::WEIGHTING, OrderWeighting.NONE) + dtDiagram.addLayoutParam(MrTreeOptions::EDGE_ROUTING_MODE, EdgeRoutingMode.AVOID_OVERLAP) + dtDiagram.addLayoutParam(MrTreeOptions::WEIGHTING, OrderWeighting.MODEL_ORDER) dtDiagram.addLayoutParam(MrTreeOptions::COMPACTION, false) dtDiagram.children += nodes.values From 110e5e3bf45d7f0b87d4d18515b5f3b234f7fa78 Mon Sep 17 00:00:00 2001 From: Soeren Domroes Date: Thu, 7 Mar 2024 18:24:41 +0100 Subject: [PATCH 09/11] Fixed SCTX Serializer. --- ...cs.kieler.klighd.lsp.interactive.IConstraintSerializer | 2 +- .../server/sccharts/SCTXConstraintSerializer.xtend | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/language-server/de.cau.cs.kieler.language.server/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.IConstraintSerializer b/language-server/de.cau.cs.kieler.language.server/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.IConstraintSerializer index e534ff9f48..c20236902b 100644 --- a/language-server/de.cau.cs.kieler.language.server/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.IConstraintSerializer +++ b/language-server/de.cau.cs.kieler.language.server/META-INF/services/de.cau.cs.kieler.klighd.lsp.interactive.IConstraintSerializer @@ -1 +1 @@ -de.cau.cs.kieler.sccharts.ide.language.server.SCTXConstraintSerializer \ No newline at end of file +de.cau.cs.kieler.language.server.sccharts.SCTXConstraintSerializer \ No newline at end of file diff --git a/language-server/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/sccharts/SCTXConstraintSerializer.xtend b/language-server/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/sccharts/SCTXConstraintSerializer.xtend index 85f594897e..d7f3c717e9 100644 --- a/language-server/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/sccharts/SCTXConstraintSerializer.xtend +++ b/language-server/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/sccharts/SCTXConstraintSerializer.xtend @@ -44,10 +44,6 @@ class SCTXConstraintSerializer implements IConstraintSerializer { override serializeConstraints(List> changedNodes, Object graph, String uri, KGraphLanguageServerExtension ls, KGraphLanguageClient client) { - changedNodes.forEach[c| - val Annotatable anno = c.KNode.getProperty(KlighdInternalProperties.MODEL_ELEMEMT) as Annotatable - copyConstraintAnnotations(anno, c.KNode, c.property.id, c.property) - ] // Serialize model into given uri. val resource = ls.getResource(uri) @@ -56,6 +52,10 @@ class SCTXConstraintSerializer implements IConstraintSerializer { resource.save(outputStream, emptyMap) val codeBefore = outputStream.toString val Map> changes = newHashMap + changedNodes.forEach[c| + val Annotatable anno = c.KNode.getProperty(KlighdInternalProperties.MODEL_ELEMENT) as Annotatable + copyConstraintAnnotations(anno, c.KNode, c.property.id, c.property) + ] // Get changed file as String outputStream = new ByteArrayOutputStream resource.save(outputStream, emptyMap) From 3b4a82e2edb112a7eb79fa8fa0151ade9f616eaf Mon Sep 17 00:00:00 2001 From: Soeren Domroes Date: Wed, 13 Mar 2024 16:48:35 +0100 Subject: [PATCH 10/11] interactive: Serializer uses klighd.lsp helper methods. --- .../sccharts/SCTXConstraintSerializer.xtend | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/language-server/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/sccharts/SCTXConstraintSerializer.xtend b/language-server/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/sccharts/SCTXConstraintSerializer.xtend index d7f3c717e9..d83623f460 100644 --- a/language-server/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/sccharts/SCTXConstraintSerializer.xtend +++ b/language-server/de.cau.cs.kieler.language.server/src/de/cau/cs/kieler/language/server/sccharts/SCTXConstraintSerializer.xtend @@ -17,18 +17,13 @@ import de.cau.cs.kieler.annotations.AnnotationsFactory import de.cau.cs.kieler.annotations.TypedStringAnnotation import de.cau.cs.kieler.klighd.internal.util.KlighdInternalProperties import de.cau.cs.kieler.klighd.kgraph.KNode -import de.cau.cs.kieler.klighd.lsp.KGraphLanguageClient -import de.cau.cs.kieler.klighd.lsp.KGraphLanguageServerExtension import de.cau.cs.kieler.klighd.lsp.interactive.ConstraintProperty import de.cau.cs.kieler.klighd.lsp.interactive.IConstraintSerializer +import de.cau.cs.kieler.klighd.lsp.interactive.InteractiveUtil import de.cau.cs.kieler.sccharts.impl.StateImpl -import java.io.ByteArrayOutputStream import java.util.List -import java.util.Map import org.eclipse.elk.graph.properties.IProperty -import org.eclipse.lsp4j.Position -import org.eclipse.lsp4j.Range -import org.eclipse.lsp4j.TextEdit +import org.eclipse.emf.ecore.resource.Resource /** * Serialize a constraint for an SCChart node (region or state) as a layout annotation. @@ -42,31 +37,18 @@ class SCTXConstraintSerializer implements IConstraintSerializer { return graph instanceof StateImpl } - override serializeConstraints(List> changedNodes, Object graph, String uri, - KGraphLanguageServerExtension ls, KGraphLanguageClient client) { - // Serialize model into given uri. - val resource = ls.getResource(uri) - + override serializeConstraints(List> changedNodes, Object graph, Resource resource) { // Get previous file content as String - var outputStream = new ByteArrayOutputStream - resource.save(outputStream, emptyMap) - val codeBefore = outputStream.toString - val Map> changes = newHashMap + + val codeBefore = InteractiveUtil.serializeResource(resource) changedNodes.forEach[c| val Annotatable anno = c.KNode.getProperty(KlighdInternalProperties.MODEL_ELEMENT) as Annotatable copyConstraintAnnotations(anno, c.KNode, c.property.id, c.property) ] // Get changed file as String - outputStream = new ByteArrayOutputStream - resource.save(outputStream, emptyMap) - val String codeAfter = outputStream.toString().trim + val String codeAfter = InteractiveUtil.serializeResource(resource) - // The range is the length of the previous file. - // Just make sure the range is big enough - val Range range = new Range(new Position(0, 0), new Position(codeBefore.split("\r\n|\r|\n").length * 2, 0)) - val TextEdit textEdit = new TextEdit(range, codeAfter) - changes.put(uri, #[textEdit]); - client.replaceContentInFile(uri, codeAfter, range) + return InteractiveUtil.calculateTextEdit(codeBefore, codeAfter) } /** From 98d54fe4e309afd74eb85a6eeaf6b5901c11b2a6 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Mon, 6 May 2024 14:01:13 +0200 Subject: [PATCH 11/11] removed lsp4j dependency in sccharts.ide --- plugins/de.cau.cs.kieler.sccharts.ide/META-INF/MANIFEST.MF | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/MANIFEST.MF b/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/MANIFEST.MF index b00cba54e4..fc7cef17cc 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/MANIFEST.MF +++ b/plugins/de.cau.cs.kieler.sccharts.ide/META-INF/MANIFEST.MF @@ -19,8 +19,7 @@ Require-Bundle: org.antlr.runtime;bundle-version="[3.2.0,3.2.1)", de.cau.cs.kieler.simulation.ide, de.cau.cs.kieler.scl.ide, com.google.gson, - de.cau.cs.kieler.kicool.ide, - org.eclipse.lsp4j + de.cau.cs.kieler.kicool.ide Export-Package: de.cau.cs.kieler.sccharts.ide.simulation, de.cau.cs.kieler.sccharts.ide.synthesis, de.cau.cs.kieler.sccharts.ide.text.contentassist.antlr,