|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038310 is a reply to message #1038167] |
Wed, 10 April 2013 18:09 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
|
Hi,
you can write a generator that does everything you want.
Here is a fast and stupid variant.
package org.eclipse.xtext.example.domainmodel
import org.eclipse.xtext.xbase.compiler.JvmModelGenerator
import org.eclipse.emf.ecore.EObject
import org.eclipse.xtext.generator.IFileSystemAccess
import org.eclipse.xtext.example.domainmodel.domainmodel.DomainModel
import org.eclipse.xtext.example.domainmodel.domainmodel.Entity
import org.eclipse.xtext.naming.IQualifiedNameProvider
import com.google.inject.Inject
import org.eclipse.xtext.example.domainmodel.domainmodel.Operation
import org.eclipse.xtext.xbase.XExpression
import org.eclipse.xtext.xbase.XBlockExpression
import org.eclipse.xtext.xbase.XFeatureCall
class MySuperGen extends JvmModelGenerator {
@Inject extension IQualifiedNameProvider
def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
) {
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
fsa.generateFile(e.fullyQualifiedName.toString+".txt",'''
«FOR op : e.features.filter(typeof(Operation))»
«op.name»:
«op.body.print»
«ENDFOR»
''')
}
}
def dispatch print(XExpression e) '''
//TODO
'''
def dispatch print(XBlockExpression e) '''
«FOR ex : e.expressions»
«ex.print»
«ENDFOR»
'''
def dispatch print(XFeatureCall e) '''
«e.feature.simpleName»
'''
}
@Override
public Class<? extends IGenerator> bindIGenerator() {
return MySuperGen.class;
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1038383 is a reply to message #1038372] |
Wed, 10 April 2013 20:17 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
|
And here the variant that directly creates -png files
def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
) {
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
for (op : e.features.filter(typeof(Operation))) {
val content = '''
«op.body.print»
'''.toString
if (fsa instanceof IFileSystemAccessExtension3) {
val out = new ByteArrayOutputStream()
new SourceStringReader(content).generateImage(out)
(fsa as IFileSystemAccessExtension3).generateFile(op.fullyQualifiedName.toString+".png",new ByteArrayInputStream(out.toByteArray))
} else {
fsa.generateFile(op.fullyQualifiedName.toString+".txt",content)
}
}
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039489 is a reply to message #1039479] |
Fri, 12 April 2013 08:14 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Hao Zhang![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Hao.Zhang%40dlr.de) Messages: 107 Registered: April 2013 |
Senior Member |
|
|
The content of the "MANIFEST.MF" of the "domainmodel" project is as follows. Does this mean I can get generated UML activity diagram via the adopted generator which is defined in the "class MySuperGen extends JvmModelGenerator"?
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Xtext Domainmodel Example
Bundle-Vendor: Eclipse Modeling Project
Bundle-Version: 2.3.0.qualifier
Bundle-SymbolicName: org.eclipse.xtext.example.domainmodel; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.xtext;bundle-version="2.3.0";visibility:=reexport,
org.eclipse.xtext.generator;bundle-version="2.3.0";resolution:=optional;x-installation:=greedy,
org.eclipse.xtend;bundle-version="1.1.0",
org.eclipse.xtend.typesystem.emf;bundle-version="1.0.1",
org.eclipse.xpand;bundle-version="1.1.0",
org.eclipse.xtext.util;bundle-version="2.3.0",
org.eclipse.emf.ecore,
org.eclipse.emf.common,
org.eclipse.emf.mwe2.launch;bundle-version="2.0.0";resolution:=optional;x-installation:=greedy,
org.antlr.runtime;bundle-version="[3.2.0,3.2.1)",
org.eclipse.xtext.xbase;bundle-version="2.3.0",
org.eclipse.xtext.common.types,
org.eclipse.xtext.xbase.lib;bundle-version="2.3.0";visibility:=reexport,
org.eclipse.xtext.ui.codetemplates;bundle-version="2.0.0",
net.sourceforge.plantuml.eclipse;bundle-version="1.1.8"
Export-Package: org.eclipse.xtext.example.domainmodel,
org.eclipse.xtext.example.domainmodel.domainmodel,
org.eclipse.xtext.example.domainmodel.domainmodel.impl,
org.eclipse.xtext.example.domainmodel.domainmodel.util,
org.eclipse.xtext.example.domainmodel.formatting,
org.eclipse.xtext.example.domainmodel.jvmmodel,
org.eclipse.xtext.example.domainmodel.parser.antlr,
org.eclipse.xtext.example.domainmodel.parser.antlr.internal,
org.eclipse.xtext.example.domainmodel.services,
org.eclipse.xtext.example.domainmodel.validation,
org.eclipse.xtext.example.domainmodel.valueconverter,
org.eclipse.xtext.example.domainmodel.serializer
Bundle-ClassPath: lib/plantuml.jar,
.
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Import-Package: org.apache.log4j,
org.apache.commons.logging
Christian Dietrich wrote on Fri, 12 April 2013 04:03Hi,
i dont know if this came clear; plantuml has nothing todo with xtext.
=> it is a complete "selfmade" solution by you
you have to download plantuml.
(1) for the main include the jar your preferred way
(2)for the adopted generatorthrow it into a lib folder in the domainmdodel project
and edit the manifest e.g
Bundle-ClassPath: lib/plantuml.jar,
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1039726 is a reply to message #1039721] |
Fri, 12 April 2013 14:04 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Hao Zhang![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Hao.Zhang%40dlr.de) Messages: 107 Registered: April 2013 |
Senior Member |
|
|
Now it works, but if I change the code into the following code:
def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
) {
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
// output for image in editor
fsa.generateFile(e.fullyQualifiedName.toString+".txt",'''
«FOR op : e.features.filter(typeof(Operation))»
«op.name»:
«op.body.print»
«ENDFOR»
''')
}
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
for (op : e.features.filter(typeof(Operation))) {
val content = '''
«op.body.print»
'''.toString
if (fsa instanceof IFileSystemAccessExtension3) {
val out = new ByteArrayOutputStream()
new SourceStringReader(content).generateImage(out)
(fsa as IFileSystemAccessExtension3).generateFile(op.fullyQualifiedName.toString+".png",new ByteArrayInputStream(out.toByteArray))
} else {
fsa.generateFile(op.fullyQualifiedName.toString+".txt",content)
}
}
}
}
the error information appears, and the code cannot be automatically generated. What would be the mistake? Thank you!
!SESSION 2013-04-12 16:01:03.374 -----------------------------------------------
eclipse.buildId=M20130204-1200
java.version=1.7.0_17
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.sdk.ide
Command-line arguments: -product org.eclipse.sdk.ide -data D:\TodayNewEight/../runtime-TodayNewEight -dev file:D:/TodayNewEight/.metadata/.plugins/org.eclipse.pde.core/New_configuration/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog
!ENTRY org.eclipse.update.configurator 4 0 2013-04-12 16:01:04.824
!MESSAGE Unable to find feature.xml in directory: C:\eclipsexText64\features\org.eclipse.equinox.p2.discovery.feature_1.0.100.v20120524-0542-4-Bh9oB58A5N9L28PCQ
!ENTRY org.eclipse.egit.ui 2 0 2013-04-12 16:01:23.111
!MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level
Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory.
The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in
this system level configuration. The Git installation location can be configured on the
Team > Git > Configuration preference page's 'System Settings' tab.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
@startuml
(*)
--> (*)
^^^^^^^
Syntax Error?
@startuml
(*)
--> (*)
^^^^^^^
Syntax Error?
!ENTRY org.eclipse.egit.ui 2 0 2013-04-12 16:01:23.173
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'H:\'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
@startuml
(*)
--> (*)
^^^^^^^
Syntax Error?
0 [Worker-3] ERROR org.eclipse.xtext.builder.BuilderParticipant - Error during compilation of 'platform:/resource/sad/src/NewTryFile.dmodel'.
java.lang.IllegalArgumentException: Already known: //TODO\n
at net.sourceforge.plantuml.cucadiagram.CucaDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.ActivityDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.command.CommandLinkLongActivity2.executeNow(Unknown Source)
at net.sourceforge.plantuml.command.CommandMultilines2.execute(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.manageMultiline(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.executeUmlCommand(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.<init>(Unknown Source)
at net.sourceforge.plantuml.PSystemBuilder.createPSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.createSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.getSystem(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen._internalDoGenerate(MySuperGen.java:104)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen.internalDoGenerate(MySuperGen.java:197)
at org.eclipse.xtext.xbase.compiler.JvmModelGenerator.doGenerate(JvmModelGenerator.java:181)
at org.eclipse.xtext.builder.BuilderParticipant.handleChangedContents(BuilderParticipant.java:291)
at org.eclipse.xtext.builder.BuilderParticipant.build(BuilderParticipant.java:221)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:60)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:170)
at org.eclipse.xtext.builder.impl.XtextBuilder.fullBuild(XtextBuilder.java:194)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:89)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at org.eclipse.xtext.builder.impl.BuildScheduler$BuildJob.run(BuildScheduler.java:178)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
!ENTRY org.apache.log4j 4 0 2013-04-12 16:01:23.361
!MESSAGE org.eclipse.xtext.builder.BuilderParticipant - Error during compilation of 'platform:/resource/sad/src/NewTryFile.dmodel'.
!STACK 0
java.lang.IllegalArgumentException: Already known: //TODO\n
at net.sourceforge.plantuml.cucadiagram.CucaDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.ActivityDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.command.CommandLinkLongActivity2.executeNow(Unknown Source)
at net.sourceforge.plantuml.command.CommandMultilines2.execute(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.manageMultiline(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.executeUmlCommand(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.<init>(Unknown Source)
at net.sourceforge.plantuml.PSystemBuilder.createPSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.createSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.getSystem(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen._internalDoGenerate(MySuperGen.java:104)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen.internalDoGenerate(MySuperGen.java:197)
at org.eclipse.xtext.xbase.compiler.JvmModelGenerator.doGenerate(JvmModelGenerator.java:181)
at org.eclipse.xtext.builder.BuilderParticipant.handleChangedContents(BuilderParticipant.java:291)
at org.eclipse.xtext.builder.BuilderParticipant.build(BuilderParticipant.java:221)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:60)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:170)
at org.eclipse.xtext.builder.impl.XtextBuilder.fullBuild(XtextBuilder.java:194)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:89)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
at org.eclipse.core.internal.resources.Project.build(Project.java:124)
at org.eclipse.xtext.builder.impl.BuildScheduler$BuildJob.run(BuildScheduler.java:178)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
@startuml
(*)
--> (*)
^^^^^^^
Syntax Error?
@startuml
(*)
--> (*)
^^^^^^^
Syntax Error?
@startuml
(*)
--> (*)
^^^^^^^
Syntax Error?
8113 [Worker-7] ERROR org.eclipse.xtext.builder.BuilderParticipant - Error during compilation of 'platform:/resource/sad/src/NewTryFile.dmodel'.
java.lang.IllegalArgumentException: Already known: //TODO\n
at net.sourceforge.plantuml.cucadiagram.CucaDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.ActivityDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.command.CommandLinkLongActivity2.executeNow(Unknown Source)
at net.sourceforge.plantuml.command.CommandMultilines2.execute(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.manageMultiline(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.executeUmlCommand(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.<init>(Unknown Source)
at net.sourceforge.plantuml.PSystemBuilder.createPSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.createSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.getSystem(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen._internalDoGenerate(MySuperGen.java:104)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen.internalDoGenerate(MySuperGen.java:197)
at org.eclipse.xtext.xbase.compiler.JvmModelGenerator.doGenerate(JvmModelGenerator.java:181)
at org.eclipse.xtext.builder.BuilderParticipant.handleChangedContents(BuilderParticipant.java:291)
at org.eclipse.xtext.builder.BuilderParticipant.build(BuilderParticipant.java:221)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:60)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:170)
at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:146)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:95)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
!ENTRY org.apache.log4j 4 0 2013-04-12 16:01:31.459
!MESSAGE org.eclipse.xtext.builder.BuilderParticipant - Error during compilation of 'platform:/resource/sad/src/NewTryFile.dmodel'.
!STACK 0
java.lang.IllegalArgumentException: Already known: //TODO\n
at net.sourceforge.plantuml.cucadiagram.CucaDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.ActivityDiagram.createLeaf(Unknown Source)
at net.sourceforge.plantuml.activitydiagram.command.CommandLinkLongActivity2.executeNow(Unknown Source)
at net.sourceforge.plantuml.command.CommandMultilines2.execute(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.manageMultiline(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.executeUmlCommand(Unknown Source)
at net.sourceforge.plantuml.PSystemSingleBuilder.<init>(Unknown Source)
at net.sourceforge.plantuml.PSystemBuilder.createPSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.createSystem(Unknown Source)
at net.sourceforge.plantuml.BlockUml.getSystem(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at net.sourceforge.plantuml.SourceStringReader.generateImage(Unknown Source)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen._internalDoGenerate(MySuperGen.java:104)
at org.eclipse.xtext.example.domainmodel.generator.MySuperGen.internalDoGenerate(MySuperGen.java:197)
at org.eclipse.xtext.xbase.compiler.JvmModelGenerator.doGenerate(JvmModelGenerator.java:181)
at org.eclipse.xtext.builder.BuilderParticipant.handleChangedContents(BuilderParticipant.java:291)
at org.eclipse.xtext.builder.BuilderParticipant.build(BuilderParticipant.java:221)
at org.eclipse.xtext.builder.impl.RegistryBuilderParticipant.build(RegistryBuilderParticipant.java:60)
at org.eclipse.xtext.builder.impl.XtextBuilder.doBuild(XtextBuilder.java:170)
at org.eclipse.xtext.builder.impl.XtextBuilder.incrementalBuild(XtextBuilder.java:146)
at org.eclipse.xtext.builder.impl.XtextBuilder.build(XtextBuilder.java:95)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Christian Dietrich wrote on Fri, 12 April 2013 09:54def dispatch CharSequence print(XFeatureCall e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1041764 is a reply to message #1041066] |
Mon, 15 April 2013 14:38 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Hao Zhang![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Hao.Zhang%40dlr.de) Messages: 107 Registered: April 2013 |
Senior Member |
|
|
I modfied the "print" methods as follows:
def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
) {
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
fsa.generateFile(e.fullyQualifiedName.toString+".txt",'''
«FOR op : e.features.filter(typeof(Operation))»
«op.name»:
««« @startuml
««« (*)
««« «FOR ex : op.body SEPARATOR "\n"» --> "«ex.print»"
«««
««« «ENDFOR»
««« --> (*)
««« @enduml
@startuml
««« (*) --> «op.body.print»
(*) --> «op.print»
--> (*)
@enduml
«ENDFOR»
''')
}
}
def dispatch print(Operation operation)'''
{
«val node = NodeModelUtils::findActualNodeFor(operation)»
«FOR oneNode : node.children»
«oneNode.print»
«ENDFOR»
}
'''
def dispatch CharSequence print(ICompositeNode curNode)
'''«FOR oneNode : curNode.children»
«IF oneNode instanceof XIfExpression»
"«oneNode.print»"
«ELSEIF oneNode instanceof XFeatureCall»
--> "«(oneNode as XFeatureCall).feature.simpleName»"
«ENDIF»
«ENDFOR»'''
def dispatch CharSequence print(ILeafNode curNode)
'''-->"«curNode.text»"'''
The behavior code in the ".dmodel" file is as follows:
op activityInOneDay(): void {
//if (getUp())
//{
haveBreakfast();
//}
workAtHome();
haveLunch();
}
In the end, the generated ".txt" file is as follows:
activityInOneDay:
@startuml
(*) --> {
}
--> (*)
@enduml
I have no idea how to print the behavior and get the activity diagram by using "NodeModelUtils". Hope somebody could provide some information. Thank you in advance!
[Updated on: Mon, 15 April 2013 14:39] Report message to a moderator
|
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1041922 is a reply to message #1041849] |
Mon, 15 April 2013 19:18 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Hao Zhang![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Hao.Zhang%40dlr.de) Messages: 107 Registered: April 2013 |
Senior Member |
|
|
Thank you very much for your reply!
At the moment, I would like to generate an activity diagram based on the behavior (function) code, which might include the "for", "while", or "switch" statement. Honestly, I do not know I have to traverse the AST or CST or both. Thank you again!
By the way, what is "RuleCall" and "downcasting"?
Christian Dietrich wrote on Mon, 15 April 2013 13:00Hi,
the nodes are the text, so instanceof will never work
so do you want to traverse the AST (EObjects) or the CST (Nodes) or both?
for the CST two hints:
- node.getText() gives you the text in the file
- node.getGrammarElement() gives you an EObject that describes what xtext actually did
this may be: Assignment, RuleCall, CrossReference etc. (by downcasting you get more infos)
[Updated on: Mon, 15 April 2013 19:19] Report message to a moderator
|
|
|
|
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1042314 is a reply to message #1041963] |
Tue, 16 April 2013 09:06 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Hao Zhang![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Hao.Zhang%40dlr.de) Messages: 107 Registered: April 2013 |
Senior Member |
|
|
First, I can debug the "print" method. But, suddenly, I cannot catch the "breakpoints" that I have marked and the ".txt"files, ".java" files all disappear in the run-time eclipse. Now, I can only have the information in the "Console", which can be seen as follows. What might be the reason?
Besides this, I have not found the right function to traverse the "children" of an "operation". So hard....
!SESSION 2013-04-16 11:00:42.174 -----------------------------------------------
eclipse.buildId=M20130204-1200
java.version=1.7.0_17
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.sdk.ide
Command-line arguments: -product org.eclipse.sdk.ide -data D:\TodayNewEight/../runtime-TodayNewEight -dev file:D:/TodayNewEight/.metadata/.plugins/org.eclipse.pde.core/New_configuration/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog
!ENTRY org.eclipse.update.configurator 4 0 2013-04-16 11:00:43.625
!MESSAGE Unable to find feature.xml in directory: C:\eclipsexText64\features\org.eclipse.equinox.p2.discovery.feature_1.0.100.v20120524-0542-4-Bh9oB58A5N9L28PCQ
!ENTRY org.eclipse.egit.ui 2 0 2013-04-16 11:00:58.181
!MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level
Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory.
The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in
this system level configuration. The Git installation location can be configured on the
Team > Git > Configuration preference page's 'System Settings' tab.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!ENTRY org.eclipse.egit.ui 2 0 2013-04-16 11:00:58.181
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'H:\'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
[Updated on: Tue, 16 April 2013 09:10] Report message to a moderator
|
|
|
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1043116 is a reply to message #1043099] |
Wed, 17 April 2013 09:53 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
|
Hi,
sorry i do not have the time do your work since it is NOT trivial. so it may be very hard for you as a beginner.
xbase is a gpl so the expressions to handle may be very very complex. too complex for an acitivity diagram.
this is why i am not sure if xbase is at all the right tool for your purpose.
never the less i still dont get the point why you dont use the ast traversal
as we started.
you would have implemented XIfExpression and everything would be fine.
(of course you have to structure the template so that it creates a plantuml valid output)
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1043184 is a reply to message #1043141] |
Wed, 17 April 2013 11:41 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Hao Zhang![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Hao.Zhang%40dlr.de) Messages: 107 Registered: April 2013 |
Senior Member |
|
|
Sorry, the traverse of ast still has some problems.
For example, the "print" methods are as follows.
def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
) {
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
fsa.generateFile(e.fullyQualifiedName.toString+".txt",'''
«FOR op : e.features.filter(typeof(Operation))»
«op.name»:
@startuml
(*) --> «op.body.print»
--> (*)
@enduml
«ENDFOR»
''')
}
}
def dispatch CharSequence print(XIfExpression e)
// '''if «IF e.^if instanceof XFeatureCall» "«(e.^if as XFeatureCall).feature.simpleName»" «ENDIF» then
'''if "«e.^if.print»" then
-->[true] «e.then.print»
else
-->[false]«e.^else.print»
endif'''
def dispatch CharSequence print(XExpression e) '''
//TODO + «e.eClass»
'''
def dispatch CharSequence print(Void e) '''
"null"
'''
def dispatch print(XBlockExpression e) '''
«FOR ex : e.expressions SEPARATOR "\n"»«ex.print» «ENDFOR»
'''
def dispatch CharSequence print(XFeatureCall e)
'''--> "«e.feature.simpleName»"'''
The "op activityInOneDay()" is as follows.
op activityInOneDay(): void {
if (getUp())
{
haveBreakfast();
}
else
{
Sleep();
}
workAtHome();
haveLunch();
}
However, the generated plantuml string is as follows:
@startuml
(*) --> if "--> "getUp"" then
-->[true] --> "haveBreakfast"
else
-->[false]--> "Sleep"
endif
--> "workAtHome"
--> "haveLunch"
--> (*)
@enduml
But, the expected plantuml string is as follows. I have no idea how to get it from the "print" methods:
@startuml
(*) --> if " "getUp"" then
-->[true] "haveBreakfast"
else
-->[false]"Sleep"
endif
--> "workAtHome"
--> "haveLunch"
--> (*)
@enduml
Another problem is, even with the correct plantuml string, the generated activity diagram is as follows:
![index.php/fa/14398/0/](index.php/fa/14398/0/)
As you might see from the image, the logic is not correct. Could you have some idea?
Attachment: Untitled.png
(Size: 14.02KB, Downloaded 1279 times)
[Updated on: Wed, 17 April 2013 11:44] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1043982 is a reply to message #1043971] |
Thu, 18 April 2013 10:48 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Hao Zhang![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Hao.Zhang%40dlr.de) Messages: 107 Registered: April 2013 |
Senior Member |
|
|
Thank you for your attention!
Yes, you are right. I just take it as an example. What I actually want could be more complex. For example, the corrected "op activityInOneDay()" could be as follows.
op activityInOneDay(): void
{
if(getUp())
{
haveBreakfast();
workAtHome();
haveLunch();
return;
}
else
{
stayInBed();
if (hasGoodMood)
{
watchTV();
}
}
if (timeIsAfterElevenPM())
{
SleepInBedAgain();
}
return;
}
Since I do not have my work laptop with me. I cannot make sure that I can create a correct plantuml string.
Claudio Heeg wrote on Thu, 18 April 2013 06:28I see - but doesn't that operation describe something different from what you actually want?
Unless I'm missing something, like this you'd only have an option between having breakfast or sleeping, after that working at home and having lunch happen anyway, due to them not being outside of the selection.
op activityInOneDay(): void {
if (getUp()) {
haveBreakfast();
workAtHome();
haveLunch();
} else {
Sleep();
}
}
Shouldn't that be what you want? Again, I could be missing something here.
[Updated on: Thu, 18 April 2013 10:54] Report message to a moderator
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1043985 is a reply to message #1043982] |
Thu, 18 April 2013 10:54 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Claudio Heeg![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=7892142%40googlemail.com) Messages: 75 Registered: April 2013 |
Member |
|
|
Well, to cover those cases, you'll have to change the editor accordingly, easy as that.
What you would want to do, I think, would be firstly checking if there is a return statement in any of the branches, and if there is, terminate that activity with --> (*). If there's not, you could look at the next statement outside the if/else and add it to the end of either branch.
That's just a spontaneous idea of how to get a proper diagram going, as for the concrete generator implementation, that's your task.
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1043990 is a reply to message #1043985] |
Thu, 18 April 2013 11:02 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Hao Zhang![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Hao.Zhang%40dlr.de) Messages: 107 Registered: April 2013 |
Senior Member |
|
|
Yes, this is my task. Thank you very much for your idea!
Claudio Heeg wrote on Thu, 18 April 2013 06:54Well, to cover those cases, you'll have to change the editor accordingly, easy as that.
What you would want to do, I think, would be firstly checking if there is a return statement in any of the branches, and if there is, terminate that activity with --> (*). If there's not, you could look at the next statement outside the if/else and add it to the end of either branch.
That's just a spontaneous idea of how to get a proper diagram going, as for the concrete generator implementation, that's your task.
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1044721 is a reply to message #1043990] |
Fri, 19 April 2013 08:45 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Hao Zhang![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Hao.Zhang%40dlr.de) Messages: 107 Registered: April 2013 |
Senior Member |
|
|
I think this is the basic idea to draw a correct activity diagram.
Hao Zhang wrote on Thu, 18 April 2013 07:02Yes, this is my task. Thank you very much for your idea!
Claudio Heeg wrote on Thu, 18 April 2013 06:54Well, to cover those cases, you'll have to change the editor accordingly, easy as that.
What you would want to do, I think, would be firstly checking if there is a return statement in any of the branches, and if there is, terminate that activity with --> (*). If there's not, you could look at the next statement outside the if/else and add it to the end of either branch.
That's just a spontaneous idea of how to get a proper diagram going, as for the concrete generator implementation, that's your task.
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1044948 is a reply to message #1044721] |
Fri, 19 April 2013 14:46 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Hao Zhang![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Hao.Zhang%40dlr.de) Messages: 107 Registered: April 2013 |
Senior Member |
|
|
Currently, the op activityInOneDay is as follows. I still cannot get the correct plantuml string.
op activityInOneDay(): void {
if (getUp())
{
haveBreakfast();
}
else
{
sleep();
return;
}
workAtHome();
haveLunch();
return;
}
The "print" methods are as follows:
def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
) {
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
fsa.generateFile(e.fullyQualifiedName.toString+".txt",'''
«FOR op : e.features.filter(typeof(Operation))»
«op.name»:
@startuml
(*) --> «op.body.print»
««« --> (*)
@enduml
«ENDFOR»
''')
}
}
def dispatch CharSequence print(XIfExpression e)
// '''if «IF e.^if instanceof XFeatureCall» "«(e.^if as XFeatureCall).feature.simpleName»" «ENDIF» then
'''if «e.^if.print» then
-->[true] «e.then.print»
else
-->[false]«e.^else.print»
endif'''
def dispatch CharSequence print(XExpression e) '''
//TODO + «e.eClass»
'''
def dispatch CharSequence print(Void e) '''
"null"
'''
def dispatch print(XBlockExpression e) '''
«FOR ex : e.expressions SEPARATOR " \n-->"» «ex.print» «ENDFOR»
'''
def dispatch CharSequence print(XFeatureCall e)
'''"«e.feature.simpleName»"'''
def dispatch CharSequence print(XMemberFeatureCall e)
// '''"«e.feature.simpleName»"'''
'''"«e.feature.identifier»"'''
def dispatch CharSequence print(XReturnExpression e)
'''(*)'''
The generated plantuml string is as follows:
@startuml
(*) --> if "getUp" then
-->[true] "haveBreakfast"
else
-->[false] "sleep"
--> (*)
endif
--> "workAtHome"
--> "haveLunch"
--> (*)
@enduml
But I am expecting the plantuml is :
@startuml
(*) --> if "getUp" then
-->[true] "haveBreakfast"
--> "workAtHome"
--> "haveLunch"
--> (*)
else
-->[false] "sleep"
--> (*)
endif
@enduml
Could anybody give me some hints how to create the correct plantuml string? Thank you in advance!
[Updated on: Fri, 19 April 2013 14:48] Report message to a moderator
|
|
|
|
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1045420 is a reply to message #1045157] |
Sat, 20 April 2013 07:54 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
|
Sorry i dont believe what we are doing here leads to anything.
it is an algorithmic thing that has nothing todo with xtext.
one problem is that plantuml syntax sucks at this point
the flollowing might be a starting point it might be a dead end too.
and you will ask again and i will not have the time to do the job!
class MySuperGen extends JvmModelGenerator {
@Inject extension IQualifiedNameProvider
def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
) {
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
for (op : e.features.filter(typeof(Operation))) {
val content = '''
@startuml
(*) --> «op.body.print(newArrayList(),"")»
««« --> (*)
@enduml
'''.toString
fsa.generateFile(op.fullyQualifiedName.toString+".txt",content)
if (fsa instanceof IFileSystemAccessExtension3) {
val out = new ByteArrayOutputStream()
new SourceStringReader(content).generateImage(out)
(fsa as IFileSystemAccessExtension3).generateFile(op.fullyQualifiedName.toString+".png",new ByteArrayInputStream(out.toByteArray))
} else {
}
}
}
}
def dispatch CharSequence print(XIfExpression e, List<XExpression> queue, String iffi)
// '''if «IF e.^if instanceof XFeatureCall» "«(e.^if as XFeatureCall).feature.simpleName»" «ENDIF» then
'''if TODO then
«e.then.print(queue,"[true]")»
else
«e.^else.print(queue, "[false]")»
endif'''
def dispatch CharSequence print(XExpression e, List<XExpression> queue, String iffi) '''
//TODO + «e.eClass»
«handleQueue(queue,"")»
'''
def dispatch CharSequence print(Void e, List<XExpression> queue, String iffi) '''
--> «iffi» "null"
«handleQueue(queue,"")»
'''
def dispatch print(XBlockExpression e, List<XExpression> queue, String iffi)
{
val newQueue = newArrayList()
newQueue.addAll(e.expressions)
newQueue.addAll(queue)
handleQueue(newQueue, iffi)
}
def handleQueue(List<XExpression> queue, String iffi) {
if (queue.size > 0) {
print(queue.head, queue.tail.toList, iffi)
} else {
''''''
}
}
def dispatch CharSequence print(XFeatureCall e, List<XExpression> queue, String iffi)
'''--> «iffi» "«e.feature.simpleName»"
«handleQueue(queue, "")»'''
def dispatch CharSequence print(XMemberFeatureCall e, List<XExpression> queue, String iffi)
// '''"«e.feature.simpleName»"'''
'''--> «iffi» "«e.feature.identifier»"
«handleQueue(queue,"")»'''
def dispatch CharSequence print(XReturnExpression e, List<XExpression> queue, String iffi)
'''--> (*)'''
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1045446 is a reply to message #1045420] |
Sat, 20 April 2013 08:46 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Hao Zhang![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Hao.Zhang%40dlr.de) Messages: 107 Registered: April 2013 |
Senior Member |
|
|
Thank you for your time and your help for the long time!!
I really appreciate very much your help. I will try your code on the coming Monday.
I am wondering if xtext or xbase can provide API for the generated ast tree, like a visitor() method with the defined LL(1)? It is really hard for people who are not from computer science.And I hope plantuml could pay attention to this problem in the future.
Christian Dietrich wrote on Sat, 20 April 2013 03:54Sorry i dont believe what we are doing here leads to anything.
it is an algorithmic thing that has nothing todo with xtext.
one problem is that plantuml syntax sucks at this point
the flollowing might be a starting point it might be a dead end too.
and you will ask again and i will not have the time to do the job!
class MySuperGen extends JvmModelGenerator {
@Inject extension IQualifiedNameProvider
def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
) {
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
for (op : e.features.filter(typeof(Operation))) {
val content = '''
@startuml
(*) --> «op.body.print(newArrayList(),"")»
««« --> (*)
@enduml
'''.toString
fsa.generateFile(op.fullyQualifiedName.toString+".txt",content)
if (fsa instanceof IFileSystemAccessExtension3) {
val out = new ByteArrayOutputStream()
new SourceStringReader(content).generateImage(out)
(fsa as IFileSystemAccessExtension3).generateFile(op.fullyQualifiedName.toString+".png",new ByteArrayInputStream(out.toByteArray))
} else {
}
}
}
}
def dispatch CharSequence print(XIfExpression e, List<XExpression> queue, String iffi)
// '''if «IF e.^if instanceof XFeatureCall» "«(e.^if as XFeatureCall).feature.simpleName»" «ENDIF» then
'''if TODO then
«e.then.print(queue,"[true]")»
else
«e.^else.print(queue, "[false]")»
endif'''
def dispatch CharSequence print(XExpression e, List<XExpression> queue, String iffi) '''
//TODO + «e.eClass»
«handleQueue(queue,"")»
'''
def dispatch CharSequence print(Void e, List<XExpression> queue, String iffi) '''
--> «iffi» "null"
«handleQueue(queue,"")»
'''
def dispatch print(XBlockExpression e, List<XExpression> queue, String iffi)
{
val newQueue = newArrayList()
newQueue.addAll(e.expressions)
newQueue.addAll(queue)
handleQueue(newQueue, iffi)
}
def handleQueue(List<XExpression> queue, String iffi) {
if (queue.size > 0) {
print(queue.head, queue.tail.toList, iffi)
} else {
''''''
}
}
def dispatch CharSequence print(XFeatureCall e, List<XExpression> queue, String iffi)
'''--> «iffi» "«e.feature.simpleName»"
«handleQueue(queue, "")»'''
def dispatch CharSequence print(XMemberFeatureCall e, List<XExpression> queue, String iffi)
// '''"«e.feature.simpleName»"'''
'''--> «iffi» "«e.feature.identifier»"
«handleQueue(queue,"")»'''
def dispatch CharSequence print(XReturnExpression e, List<XExpression> queue, String iffi)
'''--> (*)'''
}
[Updated on: Sat, 20 April 2013 10:51] Report message to a moderator
|
|
|
Re: Is it possible to export the behaviors in the .dmodel file into diagram like UML's activity diag [message #1046683 is a reply to message #1045420] |
Mon, 22 April 2013 08:21 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Hao Zhang![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=Hao.Zhang%40dlr.de) Messages: 107 Registered: April 2013 |
Senior Member |
|
|
So far as now, the code works perfect. Thank you very much for your contribution!
Christian Dietrich wrote on Sat, 20 April 2013 03:54Sorry i dont believe what we are doing here leads to anything.
it is an algorithmic thing that has nothing todo with xtext.
one problem is that plantuml syntax sucks at this point
the flollowing might be a starting point it might be a dead end too.
and you will ask again and i will not have the time to do the job!
class MySuperGen extends JvmModelGenerator {
@Inject extension IQualifiedNameProvider
def dispatch internalDoGenerate(DomainModel m, IFileSystemAccess fsa
) {
for (e : m.eAllContents.toIterable.filter(typeof(Entity))) {
for (op : e.features.filter(typeof(Operation))) {
val content = '''
@startuml
(*) --> «op.body.print(newArrayList(),"")»
««« --> (*)
@enduml
'''.toString
fsa.generateFile(op.fullyQualifiedName.toString+".txt",content)
if (fsa instanceof IFileSystemAccessExtension3) {
val out = new ByteArrayOutputStream()
new SourceStringReader(content).generateImage(out)
(fsa as IFileSystemAccessExtension3).generateFile(op.fullyQualifiedName.toString+".png",new ByteArrayInputStream(out.toByteArray))
} else {
}
}
}
}
def dispatch CharSequence print(XIfExpression e, List<XExpression> queue, String iffi)
// '''if «IF e.^if instanceof XFeatureCall» "«(e.^if as XFeatureCall).feature.simpleName»" «ENDIF» then
'''if TODO then
«e.then.print(queue,"[true]")»
else
«e.^else.print(queue, "[false]")»
endif'''
def dispatch CharSequence print(XExpression e, List<XExpression> queue, String iffi) '''
//TODO + «e.eClass»
«handleQueue(queue,"")»
'''
def dispatch CharSequence print(Void e, List<XExpression> queue, String iffi) '''
--> «iffi» "null"
«handleQueue(queue,"")»
'''
def dispatch print(XBlockExpression e, List<XExpression> queue, String iffi)
{
val newQueue = newArrayList()
newQueue.addAll(e.expressions)
newQueue.addAll(queue)
handleQueue(newQueue, iffi)
}
def handleQueue(List<XExpression> queue, String iffi) {
if (queue.size > 0) {
print(queue.head, queue.tail.toList, iffi)
} else {
''''''
}
}
def dispatch CharSequence print(XFeatureCall e, List<XExpression> queue, String iffi)
'''--> «iffi» "«e.feature.simpleName»"
«handleQueue(queue, "")»'''
def dispatch CharSequence print(XMemberFeatureCall e, List<XExpression> queue, String iffi)
// '''"«e.feature.simpleName»"'''
'''--> «iffi» "«e.feature.identifier»"
«handleQueue(queue,"")»'''
def dispatch CharSequence print(XReturnExpression e, List<XExpression> queue, String iffi)
'''--> (*)'''
}
|
|
|