Пример #1
0
        public static string GenerateCodeFunctions(IRelationalTransformation transformation)
        {
            FunctionsInterfaceTemplate.FunctionsInterfaceTemplate template = new FunctionsInterfaceTemplate.FunctionsInterfaceTemplate(transformation);
            string code = template.TransformText();

            return(code);
        }
        private void BaseTest(string transformationName)
        {
            IRelationalTransformation result = importer.ConstructRelationalTransformation(transformationName);

            Assert.NotNull(result);
            Assert.IsNotEmpty(result.Rule, "The constructed QVT transformation has no Rule.");
        }
Пример #3
0
        public static string GenerateCode(IRelationalTransformation transformation, bool useMetamodelInterface)
        {
            TransformationMainTemplate template = new TransformationMainTemplate(transformation, useMetamodelInterface);
            string code = template.TransformText();

            return(code);
        }
Пример #4
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.Identifies == null))
                {
                    LL.MDE.Components.Qvt.Metamodel.EMOF.IClass identifiesCasted = item.As <LL.MDE.Components.Qvt.Metamodel.EMOF.IClass>();
                    if ((identifiesCasted != null))
                    {
                        this._parent.Identifies = identifiesCasted;
                        return;
                    }
                }
                IProperty oppositePartCasted = item.As <IProperty>();

                if ((oppositePartCasted != null))
                {
                    this._parent.OppositePart.Add(oppositePartCasted);
                }
                IProperty partCasted = item.As <IProperty>();

                if ((partCasted != null))
                {
                    this._parent.Part.Add(partCasted);
                }
                if ((this._parent.Transformation == null))
                {
                    IRelationalTransformation transformationCasted = item.As <IRelationalTransformation>();
                    if ((transformationCasted != null))
                    {
                        this._parent.Transformation = transformationCasted;
                        return;
                    }
                }
            }
        private void BaseTest(string transformationName, bool useMetamodelInterface)
        {
            IRelationalTransformation transfo = importer.ConstructRelationalTransformation(transformationName);
            string outputFolder = GetLoader().AbsolutePathToOutput + "/" + transformationName;

            QVTCodeGeneratorHelper.GenerateAllCode(transfo, outputFolder, true);
        }
Пример #6
0
 public static void GenerateAllCode(IRelationalTransformation transformation, string outputFolderAbsolute, bool useMetamodelInterface = true)
 {
     GenerateCode(transformation, outputFolderAbsolute, useMetamodelInterface);
     if (transformation.OwnedOperation.Count > 0)
     {
         GenerateCodeFunctions(transformation, outputFolderAbsolute);
     }
     foreach (IRelation relation in transformation.Rule.OfType <IRelation>())
     {
         GenerateCode(relation, outputFolderAbsolute, useMetamodelInterface);
     }
 }
        /// <summary>
        /// Generates the code for a transformation element of a given EnAr instance.
        /// This method can be called from EnAr UI directly.
        /// </summary>
        /// <param name="eaRepository">The EnAr instance.</param>
        /// <param name="transformationGuid">The identifier of the transformation for code generation.</param>
        /// <param name="absoluteOutputFolder">The output folder to put the code into.</param>
        /// <param name="useMetamodelInterface">If true, the generated code will rely on an IMetamodelInterface object. Otherwise, it will rely on standard C# getters/setters.</param>
        public static void GenerateTransformationCode(Repository eaRepository, string transformationGuid, string absoluteOutputFolder, bool useMetamodelInterface = true)
        {
            // Create hybrid repository of an EA instance
            RepositoryImpl hybridrepo = new RepositoryImpl(eaRepository);

            // Import the transformation as real qvt model
            EnArExplorer              explorer = new EnArExplorer(hybridrepo, eaRepository);
            EnArImporterQVT           importer = new EnArImporterQVT(explorer);
            IRelationalTransformation relationalTransformation = importer.ConstructRelationalTransformationFromGuid(transformationGuid);

            // Generate code from qvt model
            QVTCodeGeneratorHelper.GenerateAllCode(relationalTransformation, absoluteOutputFolder, useMetamodelInterface);
        }
Пример #8
0
        /// <summary>
        /// Gets called when the parent model element of the current model element changes
        /// </summary>
        /// <param name="oldParent">The old parent model element</param>
        /// <param name="newParent">The new parent model element</param>
        protected override void OnParentChanged(IModelElement newParent, IModelElement oldParent)
        {
            IRelationalTransformation oldTransformation = ModelHelper.CastAs <IRelationalTransformation>(oldParent);
            IRelationalTransformation newTransformation = ModelHelper.CastAs <IRelationalTransformation>(newParent);

            if ((oldTransformation != null))
            {
                oldTransformation.OwnedKey.Remove(this);
            }
            if ((newTransformation != null))
            {
                newTransformation.OwnedKey.Add(this);
            }
            ValueChangedEventArgs e = new ValueChangedEventArgs(oldTransformation, newTransformation);

            this.OnTransformationChanged(e);
            this.OnPropertyChanged("Transformation", e);
        }
Пример #9
0
        public static void GenerateCodeFunctions(IRelationalTransformation transformation, string outputFolderAbsolute)
        {
            string code = GenerateCodeFunctions(transformation);

            try
            {
                code = CodeFormatter.Format(code);
            }
            catch (Exception)
            {
                // TODO
            }
            if (!Directory.Exists(outputFolderAbsolute))
            {
                Directory.CreateDirectory(outputFolderAbsolute);
            }
            File.WriteAllText(PrepareOutputFolderString(outputFolderAbsolute) + QvtCodeGeneratorStrings.GetFileNameFunctions(transformation), code);
        }
        public TransformationMainTemplate(IRelationalTransformation transformation, bool useMetamodelInterface = true)
        {
            this.Transformation        = transformation;
            this.useMetamodelInterface = useMetamodelInterface;

            foreach (IRelation relation in transformation.Rule.OfType <IRelation>())
            {
                foreach (IRelationDomain domain in relation.Domain.OfType <IRelationDomain>())
                {
                    if (Validator.IsValidTargetDomain(domain) && transformation.ModelParameter.Contains(domain.TypedModel))
                    {
                        if (domain.IsCheckable.HasValue && domain.IsCheckable.Value)
                        {
                            validCheckTargetParams.Add(domain.TypedModel);
                        }
                        if (domain.IsEnforceable.HasValue && domain.IsEnforceable.Value)
                        {
                            validEnforceTargetParams.Add(domain.TypedModel);
                        }
                    }
                }
            }
        }
 public void GenerateAttributesAndConstructor(IRelationalTransformation transformation)
 {
 }
 public FunctionsInterfaceTemplate(IRelationalTransformation Transformation)
 {
     this.Transformation = Transformation;
 }
Пример #13
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");
            this.Write("\r\n");
            this.Write("\r\n\r\n\r\n");
            this.Write("\r\n\r\nusing System;\r\nusing System.Collections.Generic; \r\nusing System.Linq;\r\nusing " +
                       "LL.MDE.Components.Qvt.Common;\r\n");

            #line 23 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"

            // Small hack to bypass limitation of ForTea plugin ( https://github.com/MrJul/ForTea/issues/3 )
            // We redeclare members so that ForTea finds them, and enables code completion etc.
            // The errors can be ignored, as the generated .cs file compiles correctly.
            IRelationalTransformation transformation           = this.Transformation;
            ISet <ITypedModel>        validEnforceTargetParams = this.validEnforceTargetParams;
            bool useMetamodelInterface = this.useMetamodelInterface;


            #line default
            #line hidden
            this.Write("\r\n");

            #line 32 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            // Generating of the "usings", for each package of each metamodel used in the transformation
            foreach (IPackage package in transformation.ModelParameter.Select(p => p.UsedPackage).SelectMany(i => i).Distinct())
            {
            #line default
            #line hidden
                this.Write("\r\nusing ");

            #line 36 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(package.Name));

            #line default
            #line hidden
                this.Write(";\r\n\r\n");

            #line 38 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            }

            #line default
            #line hidden
            this.Write("\r\n");

            #line 40 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            // Generation of the namespace

            #line default
            #line hidden

            #line 41 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(QvtCodeGeneratorStrings.Namespace(transformation)));

            #line default
            #line hidden
            this.Write(" \r\n{ \r\n\r\n\r\n");

            #line 45 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            // Generation of the Transfo class

            #line default
            #line hidden
            this.Write("public class ");

            #line 46 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(QvtCodeGeneratorStrings.TransformationName(transformation)));

            #line default
            #line hidden
            this.Write(" : GeneratedTransformation {\r\n\r\n\r\n \tprivate readonly ");

            #line 49 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(nameof(IMetaModelInterface)));

            #line default
            #line hidden
            this.Write(" editor;");

            #line 49 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"


            bool hasFunctions = !transformation.OwnedOperation.IsNullOrEmpty();
            // Functions object, if any functions are defined
            if (hasFunctions)
            {
            #line default
            #line hidden
                this.Write("public readonly ");

            #line 55 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(QvtCodeGeneratorStrings.FunctionsInterfaceName(transformation)));

            #line default
            #line hidden
                this.Write(" Functions;");

            #line 55 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            }

            // Storing each relation instance once
            foreach (IRelation relation in transformation.Rule.OfType <IRelation>())
            {
            #line default
            #line hidden
                this.Write(" public readonly ");

            #line 61 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(QvtCodeGeneratorStrings.RelationClassName(relation)));

            #line default
            #line hidden
                this.Write(" ");

            #line 61 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(QvtCodeGeneratorStrings.RelationClassName(relation)));

            #line default
            #line hidden
                this.Write("; ");

            #line 61 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            }

            // Dictionnaries for keys
            foreach (IKey key in transformation.OwnedKey)
            {
                IList <IProperty> allKeyProperties = new List <IProperty>();
                allKeyProperties.AddRange(key.Part);
                allKeyProperties.AddRange(key.PropertyPaths().Select(pp => pp.Properties.Last()));
                string tupleTypes = string.Join(",", allKeyProperties.Select(p => p.Type.GetRealTypeName()));


            #line default
            #line hidden
                this.Write("internal readonly Dictionary<Tuple<");

            #line 71 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(tupleTypes));

            #line default
            #line hidden
                this.Write(">, ");

            #line 71 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(key.Identifies.GetRealTypeName()));

            #line default
            #line hidden
                this.Write("> ");

            #line 71 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(QvtCodeGeneratorStrings.KeyDictionnaryName(key)));

            #line default
            #line hidden
                this.Write(" = new Dictionary<Tuple<");

            #line 71 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(tupleTypes));

            #line default
            #line hidden
                this.Write(">, ");

            #line 71 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(key.Identifies.GetRealTypeName()));

            #line default
            #line hidden
                this.Write(">();");

            #line 71 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            }

            // Constructor


            #line default
            #line hidden
            this.Write("public ");

            #line 75 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(QvtCodeGeneratorStrings.TransformationName(transformation)));

            #line default
            #line hidden
            this.Write(" (");

            #line 75 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(nameof(IMetaModelInterface)));

            #line default
            #line hidden
            this.Write(" editor ");

            #line 75 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(hasFunctions ? ", " + QvtCodeGeneratorStrings.FunctionsInterfaceName(transformation) + " Functions" : ""));

            #line default
            #line hidden
            this.Write(") {\r\n\r\n\t\t\tthis.editor = editor;");

            #line 77 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"

            foreach (IRelation relation in transformation.Rule.OfType <IRelation>())
            {
            #line default
            #line hidden
                this.Write("  this.");

            #line 80 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(QvtCodeGeneratorStrings.RelationClassName(relation)));

            #line default
            #line hidden
                this.Write(" = new ");

            #line 80 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(QvtCodeGeneratorStrings.RelationClassName(relation)));

            #line default
            #line hidden
                this.Write("(editor, this); \r\n\t\t");

            #line 81 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"

                if (hasFunctions)
                {
            #line default
            #line hidden
                    this.Write("this.Functions = Functions;");

            #line 84 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                }
            }


            #line default
            #line hidden
            this.Write("}");

            #line 87 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"



            foreach (IRelation relation in transformation.Rule.OfType <IRelation>().Where(r => r.IsTopLevel.GetValueOrDefault(false)))
            {
            #line default
            #line hidden
                this.Write("public void ");

            #line 93 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(relation.Name));

            #line default
            #line hidden
                this.Write(" (");

            #line 93 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(RelationTemplateHelper.GenerateRelationParams(true, relation)));

            #line default
            #line hidden
                this.Write(") {\r\n\t\t");

            #line 94 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(QvtCodeGeneratorStrings.RelationClassName(relation)));

            #line default
            #line hidden
                this.Write(".CheckAndEnforce(");

            #line 94 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(RelationTemplateHelper.GenerateRelationParams(false, relation)));

            #line default
            #line hidden
                this.Write(") ;\r\n\t}");

            #line 95 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            }



            #line default
            #line hidden
            this.Write("public override void CallTopRelation (string topRelationName, List<object> parame" +
                       "ters)\r\n\t{\r\n\t\tswitch (topRelationName)\r\n\t\t{\r\n\t\t\t");

            #line 103 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            foreach (IRelation relation in transformation.Rule.OfType <IRelation>().Where(r => r.IsTopLevel.GetValueOrDefault(false)))
            {
            #line default
            #line hidden
                this.Write("\t\t\t\tcase \"");

            #line 105 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(relation.Name));

            #line default
            #line hidden
                this.Write("\":\r\n\t\t\t\t\t");

            #line 106 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(relation.Name));

            #line default
            #line hidden
                this.Write("(");

            #line 106 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(",", relation.Domain.OfType <IRelationDomain>().Select(
                                                                                   d => "(" + d.RootVariable.Type.GetRealTypeName() + ")parameters[" + relation.Domain.IndexOf(d) + "]"))));

            #line default
            #line hidden
                this.Write(");\r\n\t\t\t\t\treturn;\r\n\t\t\t");

            #line 109 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\TransformationTemplate\TransformationMainTemplate.tt"
            }

            #line default
            #line hidden
            this.Write("\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t} // end class\r\n} // end namespace\r\n");
            return(this.GenerationEnvironment.ToString());
        }
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");
            this.Write("\r\n\r\n");

            #line 18 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\FunctionsInterfaceTemplate\FunctionsInterfaceTemplate.tt"


            // Small hack to bypass limitation of ForTea plugin ( https://github.com/MrJul/ForTea/issues/3 )
            // We redeclare members so that ForTea finds them, and enables code completion etc.
            // The errors can be ignored, as the generated .cs file compiles correctly.
            IRelationalTransformation Transformation = this.Transformation;


            #line default
            #line hidden
            this.Write("\r\n\r\n");

            #line 27 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\FunctionsInterfaceTemplate\FunctionsInterfaceTemplate.tt"
            // Generation of the namespace

            #line default
            #line hidden

            #line 28 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\FunctionsInterfaceTemplate\FunctionsInterfaceTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(QvtCodeGeneratorStrings.Namespace(Transformation)));

            #line default
            #line hidden
            this.Write(" \r\n{\r\n    public interface ");

            #line 30 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\FunctionsInterfaceTemplate\FunctionsInterfaceTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(QvtCodeGeneratorStrings.FunctionsInterfaceName(Transformation)));

            #line default
            #line hidden
            this.Write("\r\n    {");

            #line 31 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\FunctionsInterfaceTemplate\FunctionsInterfaceTemplate.tt"

            foreach (IFunction function in Transformation.OwnedOperation.OfType <IFunction>())
            {
                IList <string> args = function.OwnedParameter.Select(p => p.Type.GetRealTypeName() + " " + p.Name).ToList();


            #line default
            #line hidden

            #line 35 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\FunctionsInterfaceTemplate\FunctionsInterfaceTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(function.Type == null ? "void" : function.Type.GetRealTypeName()));

            #line default
            #line hidden
                this.Write(" ");

            #line 35 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\FunctionsInterfaceTemplate\FunctionsInterfaceTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(function.Name));

            #line default
            #line hidden
                this.Write("(");

            #line 35 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\FunctionsInterfaceTemplate\FunctionsInterfaceTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(",", args)));

            #line default
            #line hidden
                this.Write(" );");

            #line 35 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.CodeGenerator\CodeGeneration\FunctionsInterfaceTemplate\FunctionsInterfaceTemplate.tt"
            }


            #line default
            #line hidden
            this.Write("}\r\n}\r\n\r\n\r\n\r\n\r\n\r\n");
            return(this.GenerationEnvironment.ToString());
        }
 public QVTConcreteSyntaxTemplate(IRelationalTransformation transformation)
 {
     this.transformation = transformation;
 }
 public static string GetFileNameFunctions(IRelationalTransformation transformation)
 {
     return(FunctionsInterfaceName(transformation) + ".cs");
 }
Пример #17
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("\r\n");

            #line 9 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
            IRelationalTransformation transformation = this.transformation;

            #line default
            #line hidden
            this.Write("\r\ntransformation ");

            #line 11 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(transformation.Name));

            #line default
            #line hidden
            this.Write(" (");

            #line 11 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(string.Join(",", transformation.ModelParameter.Select(p => p.Name + ":" + p.UsedPackage.First().Name))));

            #line default
            #line hidden
            this.Write(")\r\n{\r\n");

            #line 13 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
            PushIndent();

            #line default
            #line hidden

            #line 14 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
            foreach (IRelation relation in transformation.Rule.OfType <IRelation>())
            {
            #line default
            #line hidden

            #line 16 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(relation.IsTopLevel.GetValueOrDefault(false) ? "top " : ""));

            #line default
            #line hidden
                this.Write("relation ");

            #line 16 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(relation.Name));

            #line default
            #line hidden
                this.Write("\r\n{\r\n");

            #line 18 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                PushIndent();

            #line default
            #line hidden

            #line 19 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                foreach (IVariable variable in relation.Variable)
                {
            #line default
            #line hidden

            #line 21 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(variable.Name));

            #line default
            #line hidden
                    this.Write(": ");

            #line 21 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                    this.Write(this.ToStringHelper.ToStringWithCulture(variable.Type.Name));

            #line default
            #line hidden
                    this.Write(";\r\n");

            #line 22 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                } // End foreach variable

            #line default
            #line hidden
                this.Write("\r\n");

            #line 24 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                foreach (IRelationDomain domain in relation.Domain.OfType <IRelationDomain>())
                {
                    if (domain.TypedModel != null)
                    {
            #line default
            #line hidden

            #line 28 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(!domain.IsEnforceable.GetValueOrDefault(false) ? "checkonly " : "enforce "));

            #line default
            #line hidden
                        this.Write("domain ");

            #line 28 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(domain.TypedModel.Name));

            #line default
            #line hidden
                        this.Write(" ");

            #line 28 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                        GenerateString(domain.Pattern.TemplateExpression as IObjectTemplateExp, true);

            #line default
            #line hidden

            #line 29 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                    }
                    else
                    {
            #line default
            #line hidden
                        this.Write("primitive domain ");

            #line 32 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(domain.RootVariable.Name));

            #line default
            #line hidden
                        this.Write(" : ");

            #line 32 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                        this.Write(this.ToStringHelper.ToStringWithCulture(domain.RootVariable.Type.GetRealTypeName()));

            #line default
            #line hidden
                        this.Write(";\r\n");

            #line 33 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                    }
                } // End foreach domain

            #line default
            #line hidden
                this.Write(" \r\n");

            #line 35 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                PopIndent();

            #line default
            #line hidden
                this.Write("}\r\n");

            #line 37 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                if (relation.Where != null)
                {
            #line default
            #line hidden
                    this.Write("\r\nwhere {\r\n");

            #line 41 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                    PushIndent();

            #line default
            #line hidden

            #line 42 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                    GenerateString(relation.Where);

            #line default
            #line hidden

            #line 43 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                    PopIndent();

            #line default
            #line hidden
                    this.Write("}\r\n        \r\n");

            #line 46 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
                }

            #line default
            #line hidden
                this.Write("\r\n\r\n");

            #line 49 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
            } // End foreach relation

            #line default
            #line hidden

            #line 50 "C:\Users\ebousse\Source\Repos\ChristianDopplerLabors\Software\QvtEnginePerformance\trunk\src\LL.MDE.Components.Qvt.TextConcreteSyntaxGen\QVTConcreteSyntaxTemplate.tt"
            PopIndent();

            #line default
            #line hidden
            this.Write("}");
            return(this.GenerationEnvironment.ToString());
        }
 public static string GetFileName(IRelationalTransformation transformation)
 {
     return("Transformation" + transformation.Name + ".qvt");
 }
 public static string FunctionsInterfaceName(IRelationalTransformation transformation)
 {
     return("IFunctions");
 }