Commit 755e8b36 authored by Daniel Ratiu's avatar Daniel Ratiu
Browse files

now ITypeScope and IFunctionScope are extended to know about the types and...

now ITypeScope and IFunctionScope are extended to know about the types and functions defined in their scope
refs 1507
parent 0a9f128c
......@@ -11,16 +11,26 @@
</eOperations>
<eOperations name="getDefinitionElement" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/ITypeDefinition">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return org.fortiss.af3.component.utils.ComponentArchitectureUtils.getDefinitionElement(this, type);"/>
<details key="body" value="return ComponentArchitectureStaticImpl.getDefinitionElement(this, type);"/>
</eAnnotations>
<eParameters name="type" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IType"/>
</eOperations>
<eOperations name="getDefinitionElement" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IFunctionDefinition">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return org.fortiss.af3.component.utils.ComponentArchitectureUtils.getDefinitionElement(this, call);"/>
<details key="body" value="return ComponentArchitectureStaticImpl.getDefinitionElement(this, call);"/>
</eAnnotations>
<eParameters name="call" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/FunctionCallBase"/>
</eOperations>
<eOperations name="getTypeDefinitionsList" upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/ITypeDefinition">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return ComponentArchitectureStaticImpl.getTypeDefinitionsList(this);"/>
</eAnnotations>
</eOperations>
<eOperations name="getFunctionDefinitionsList" upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IFunctionDefinition">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return ComponentArchitectureStaticImpl.getFunctionDefinitionsList(this);"/>
</eAnnotations>
</eOperations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Component" eSuperTypes="platform:/resource/org.fortiss.tooling.base/model/base.ecore#//base/HierarchicElementBase platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IVariableScope">
<eOperations name="getOutputPorts" upperBound="-1" eType="#//OutputPort">
......@@ -234,6 +244,16 @@
</eAnnotations>
<eParameters name="tpe" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IType"/>
</eOperations>
<eOperations name="getFunctionDefinitionsList" upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IFunctionDefinition">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return LibraryComponentPackageStaticImpl.getFunctionDefinitionsList(this);"/>
</eAnnotations>
</eOperations>
<eOperations name="getTypeDefinitionsList" upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/ITypeDefinition">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return LibraryComponentPackageStaticImpl.getTypeDefinitionsList(this);"/>
</eAnnotations>
</eOperations>
<eStructuralFeatures xsi:type="ecore:EReference" name="dataDictionary" eType="ecore:EClass platform:/resource/org.fortiss.af3.expression/model/expression.ecore#//DataDictionary"
containment="true"/>
</eClassifiers>
......
......@@ -20,6 +20,8 @@
<genOperations ecoreOperation="component.ecore#//ComponentArchitecture/getDefinitionElement.1">
<genParameters ecoreParameter="component.ecore#//ComponentArchitecture/getDefinitionElement.1/call"/>
</genOperations>
<genOperations ecoreOperation="component.ecore#//ComponentArchitecture/getTypeDefinitionsList"/>
<genOperations ecoreOperation="component.ecore#//ComponentArchitecture/getFunctionDefinitionsList"/>
</genClasses>
<genClasses ecoreClass="component.ecore#//Component">
<genOperations ecoreOperation="component.ecore#//Component/getOutputPorts"/>
......@@ -88,6 +90,8 @@
<genOperations ecoreOperation="component.ecore#//LibraryComponentPackage/getDefinitionElement.1">
<genParameters ecoreParameter="component.ecore#//LibraryComponentPackage/getDefinitionElement.1/tpe"/>
</genOperations>
<genOperations ecoreOperation="component.ecore#//LibraryComponentPackage/getFunctionDefinitionsList"/>
<genOperations ecoreOperation="component.ecore#//LibraryComponentPackage/getTypeDefinitionsList"/>
</genClasses>
<nestedGenPackages prefix="Behavior" basePackage="org.fortiss.af3.component.model"
disposableProviderFactory="true" ecorePackage="component.ecore#//behavior">
......
/*--------------------------------------------------------------------------+
$Id$
| |
| Copyright 2012 ForTISS GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.model.impl;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.generalizeList;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import org.eclipse.emf.common.util.EList;
import org.fortiss.af3.component.model.ComponentArchitecture;
import org.fortiss.af3.expression.model.DataDictionary;
import org.fortiss.af3.project.model.typesystem.FunctionCallBase;
import org.fortiss.af3.project.model.typesystem.IFunctionDefinition;
import org.fortiss.af3.project.model.typesystem.IType;
import org.fortiss.af3.project.model.typesystem.ITypeDefinition;
/**
* The complex implementation for methods of {@link ComponentArchitectureImpl}.
*
* @author ratiu
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 3D7A9BF8AD35E1E57D20D9A13FF7BDE4
*/
public class ComponentArchitectureStaticImpl {
/** Returns the type definitions that are belonging to this architecture. */
static EList<ITypeDefinition> getTypeDefinitionsList(ComponentArchitecture ca) {
DataDictionary dict = findAssociatedDataDictionary(ca);
if(dict != null) {
return generalizeList(ITypeDefinition.class, dict.getTypeDefinitionsList());
}
return null;
}
/** Returns the function definitions that are belonging to this architecture. */
static EList<IFunctionDefinition> getFunctionDefinitionsList(ComponentArchitecture ca) {
DataDictionary dict = findAssociatedDataDictionary(ca);
if(dict != null) {
return generalizeList(IFunctionDefinition.class, dict.getFunctionsList());
}
return null;
}
/** Delegates the function definition lookup to the data dictionary. */
static IFunctionDefinition getDefinitionElement(ComponentArchitecture componentArchitecture,
FunctionCallBase call) {
DataDictionary dict = findAssociatedDataDictionary(componentArchitecture);
if(dict != null) {
return dict.getDefinitionElement(call);
}
return null;
}
/** Delegates the type definition lookup to the data dictionary. */
static ITypeDefinition getDefinitionElement(ComponentArchitecture ca, IType type) {
DataDictionary dict = findAssociatedDataDictionary(ca);
if(dict != null) {
return dict.getDefinitionElement(type);
}
return null;
}
/** Finds the associated data-dictionary to this component architecture. */
private static DataDictionary findAssociatedDataDictionary(ComponentArchitecture ca) {
return pickFirstInstanceOf(DataDictionary.class, ca.eContainer().eContents());
}
}
......@@ -17,9 +17,12 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.model.impl;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.generalizeList;
import org.eclipse.emf.common.util.EList;
import org.fortiss.af3.component.model.LibraryComponent;
import org.fortiss.af3.component.model.LibraryComponentPackage;
import org.fortiss.af3.expression.model.DataDictionary;
import org.fortiss.af3.expression.model.definitions.FunctionDefinition;
import org.fortiss.af3.expression.model.definitions.TypeDefinition;
import org.fortiss.af3.expression.model.definitions.library.LibraryFunctionDefinition;
......@@ -38,7 +41,7 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
* @version $Rev: 18709 $
* @ConQAT.Rating GREEN Hash: 599ABC343FC6D6494DF926BB19B3472E
*/
public class LibraryComponentPackageStaticImpl {
class LibraryComponentPackageStaticImpl {
/**
* Returns the URI of this library component package.
......@@ -47,7 +50,7 @@ public class LibraryComponentPackageStaticImpl {
* the library component package
* @return URI of library component package
*/
public static String getURI(LibraryComponentPackage pack) {
static String getURI(LibraryComponentPackage pack) {
if(pack.eContainer() instanceof LibraryComponentPackage) {
return ((LibraryComponentPackage)pack.eContainer()).getURI() + "." + pack.getName();
}
......@@ -61,7 +64,7 @@ public class LibraryComponentPackageStaticImpl {
* the library component package
* @return library components contained in this package
*/
public static EList<LibraryComponent> getLibraryComponents(LibraryComponentPackage pack) {
static EList<LibraryComponent> getLibraryComponents(LibraryComponentPackage pack) {
return EcoreUtils.pickInstanceOf(LibraryComponent.class, pack.getLibraryElementsList());
}
......@@ -72,8 +75,7 @@ public class LibraryComponentPackageStaticImpl {
* the library component package
* @return type definitions contained in this package
*/
public static EList<LibraryTypeDefinition> getLibraryTypeDefinitions(
LibraryComponentPackage pack) {
static EList<LibraryTypeDefinition> getLibraryTypeDefinitions(LibraryComponentPackage pack) {
return EcoreUtils
.pickInstanceOf(LibraryTypeDefinition.class, pack.getLibraryElementsList());
}
......@@ -85,26 +87,46 @@ public class LibraryComponentPackageStaticImpl {
* the library component package
* @return function definitions contained in this package
*/
public static EList<LibraryFunctionDefinition> getLibraryFunctionDefinitions(
static EList<LibraryFunctionDefinition> getLibraryFunctionDefinitions(
LibraryComponentPackage pack) {
return EcoreUtils.pickInstanceOf(LibraryFunctionDefinition.class,
pack.getLibraryElementsList());
}
/** If this package contains a DataDictionary, it is looked for the FunctionDefinition. */
public static IFunctionDefinition getDefinitionElement(LibraryComponentPackage pack,
static IFunctionDefinition getDefinitionElement(LibraryComponentPackage pack,
FunctionCallBase fc) {
if(pack.getDataDictionary() == null) {
DataDictionary dd = pack.getDataDictionary();
if(dd == null) {
return null;
}
return pack.getDataDictionary().getDefinitionElement(fc);
return dd.getDefinitionElement(fc);
}
/** If this package contains a DataDictionary, it is looked for the TypeDefinition. */
public static ITypeDefinition getDefinitionElement(LibraryComponentPackage pack, IType tpe) {
if(pack.getDataDictionary() == null) {
static ITypeDefinition getDefinitionElement(LibraryComponentPackage pack, IType tpe) {
DataDictionary dd = pack.getDataDictionary();
if(dd == null) {
return null;
}
return dd.getDefinitionElement(tpe);
}
/** Returns the type definitions that are belonging to this architecture. */
static EList<ITypeDefinition> getTypeDefinitionsList(LibraryComponentPackage pack) {
DataDictionary dd = pack.getDataDictionary();
if(dd == null) {
return null;
}
return generalizeList(ITypeDefinition.class, dd.getTypeDefinitionsList());
}
/** Returns the function definitions that are belonging to this architecture. */
static EList<IFunctionDefinition> getFunctionDefinitionsList(LibraryComponentPackage pack) {
DataDictionary dd = pack.getDataDictionary();
if(dd == null) {
return null;
}
return pack.getDataDictionary().getDefinitionElement(tpe);
return generalizeList(IFunctionDefinition.class, dd.getFunctionsList());
}
}
......@@ -20,7 +20,6 @@ package org.fortiss.af3.component.utils;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.findContentElementByNameAndClass;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
import java.util.ArrayList;
import java.util.LinkedList;
......@@ -42,10 +41,6 @@ import org.fortiss.af3.component.model.impl.CausalityComponentSpecificationImpl;
import org.fortiss.af3.expression.model.DataDictionary;
import org.fortiss.af3.expression.utils.DataDictionaryUtils;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.project.model.typesystem.FunctionCallBase;
import org.fortiss.af3.project.model.typesystem.IFunctionDefinition;
import org.fortiss.af3.project.model.typesystem.IType;
import org.fortiss.af3.project.model.typesystem.ITypeDefinition;
import org.fortiss.af3.project.model.typesystem.IVariableDefinition;
import org.fortiss.tooling.base.model.element.IModelElementSpecification;
import org.fortiss.tooling.kernel.model.INamedElement;
......@@ -402,44 +397,6 @@ public class ComponentArchitectureUtils {
return (FileProject)parent;
}
/**
* Delegates the type definition lookup to the data dictionary.
*
* @param componentArchitecture
* the architecture
* @param type
* the type
* @return the type definition or {@code null} if no data dictionary exists.
*/
public static ITypeDefinition getDefinitionElement(ComponentArchitecture componentArchitecture,
IType type) {
DataDictionary dict = getRootElement(componentArchitecture, DataDictionary.class);
if(dict != null) {
return dict.getDefinitionElement(type);
}
return null;
}
/**
* Delegates the function definition lookup to the data dictionary.
*
* @param componentArchitecture
* the architecture
* @param call
* the function call
* @return the type definition or {@code null} if no data dictionary exists.
*/
public static IFunctionDefinition getDefinitionElement(
ComponentArchitecture componentArchitecture, FunctionCallBase call) {
DataDictionary dict =
pickFirstInstanceOf(DataDictionary.class, componentArchitecture.eContainer()
.eContents());
if(dict != null) {
return dict.getDefinitionElement(call);
}
return null;
}
/**
* Computes the port that represent input data for this sink.
*
......
......@@ -8,7 +8,7 @@
<details key="documentation" value="Instance of the micro type system."/>
</eAnnotations>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="DataDictionary" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//IProjectRootElement platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/ITypeScope platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IFunctionScope">
<eClassifiers xsi:type="ecore:EClass" name="DataDictionary" eSuperTypes="platform:/resource/org.fortiss.tooling.kernel/model/kernel.ecore#//IProjectRootElement">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="Root element for type and function definitions."/>
</eAnnotations>
......
......@@ -423,6 +423,16 @@
</eAnnotations>
<eParameters name="type" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IType"/>
</eOperations>
<eOperations name="getTypeDefinitionsList" upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/ITypeDefinition">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return org.fortiss.af3.mira.utils.MiraUtils.getTypeDefinitionsList(this);"/>
</eAnnotations>
</eOperations>
<eOperations name="getFunctionDefinitionsList" upperBound="-1" eType="ecore:EClass platform:/resource/org.fortiss.af3.project/model/project.ecore#//typesystem/IFunctionDefinition">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="body" value="return org.fortiss.af3.mira.utils.MiraUtils.getFunctionDefinitionsList(this);"/>
</eAnnotations>
</eOperations>
</eClassifiers>
</eSubpackages>
<eSubpackages name="glossary" nsURI="http://www.fortiss.org/af3/mira/glossary" nsPrefix="org-fortiss-af3-mira-glossary">
......
......@@ -234,6 +234,8 @@
<genOperations ecoreOperation="mira.ecore#//functional/FormalSpecification/getDefinitionElement.1">
<genParameters ecoreParameter="mira.ecore#//functional/FormalSpecification/getDefinitionElement.1/type"/>
</genOperations>
<genOperations ecoreOperation="mira.ecore#//functional/FormalSpecification/getTypeDefinitionsList"/>
<genOperations ecoreOperation="mira.ecore#//functional/FormalSpecification/getFunctionDefinitionsList"/>
</genClasses>
</nestedGenPackages>
<nestedGenPackages prefix="Glossary" basePackage="org.fortiss.af3.mira.model"
......
......@@ -20,6 +20,7 @@ package org.fortiss.af3.mira.utils;
import static org.conqat.lib.commons.string.StringUtils.isEmpty;
import static org.eclipse.emf.ecore.util.EcoreUtil.delete;
import static org.fortiss.tooling.kernel.utils.EMFResourceUtils.loadModelFromFile;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.generalizeList;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getRootElement;
......@@ -814,19 +815,43 @@ public class MiraUtils {
return null;
}
/** Return types defined in the data dictionary */
public static EList<ITypeDefinition> getTypeDefinitionsList(FormalSpecification formalspec) {
DataDictionary dict = findDataDictionary(formalspec);
if(dict != null) {
return generalizeList(ITypeDefinition.class, dict.getTypeDefinitionsList());
}
return null;
}
/** Return functions defined in the data dictionary */
public static EList<IFunctionDefinition> getFunctionDefinitionsList(
FormalSpecification formalspec) {
DataDictionary dict = findDataDictionary(formalspec);
if(dict != null) {
return generalizeList(IFunctionDefinition.class, dict.getFunctionsList());
}
return null;
}
/** Return the function defined in the data dictionary for a given call. */
public static IFunctionDefinition getDefinitionElement(FormalSpecification formalspec,
FunctionCallBase call) {
DataDictionary dict = getRootElement(formalspec, DataDictionary.class);
DataDictionary dict = findDataDictionary(formalspec);
if(dict != null) {
return dict.getDefinitionElement(call);
}
return null;
}
/** Finds the data dictionary corresponding to this formal specification. */
private static DataDictionary findDataDictionary(FormalSpecification formalspec) {
return getRootElement(formalspec, DataDictionary.class);
}
/** Return types defined in the data dictionary */
public static ITypeDefinition getDefinitionElement(FormalSpecification formalspec, IType type) {
DataDictionary dict = getRootElement(formalspec, DataDictionary.class);
DataDictionary dict = findDataDictionary(formalspec);
if(dict != null) {
return dict.getDefinitionElement(type);
}
......
......@@ -74,6 +74,7 @@
<eOperations name="getDefinitionElement" eType="#//typesystem/ITypeDefinition">
<eParameters name="type" eType="#//typesystem/IType"/>
</eOperations>
<eOperations name="getTypeDefinitionsList" upperBound="-1" eType="#//typesystem/ITypeDefinition"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ITypeDefinition" abstract="true" interface="true">
<eOperations name="createIType" eType="#//typesystem/IType"/>
......@@ -100,6 +101,7 @@
<eOperations name="getDefinitionElement" eType="#//typesystem/IFunctionDefinition">
<eParameters name="type" eType="#//typesystem/FunctionCallBase"/>
</eOperations>
<eOperations name="getFunctionDefinitionsList" upperBound="-1" eType="#//typesystem/IFunctionDefinition"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="IFunctionDefinition" abstract="true"
interface="true"/>
......
......@@ -37,6 +37,7 @@
<genOperations ecoreOperation="project.ecore#//typesystem/ITypeScope/getDefinitionElement">
<genParameters ecoreParameter="project.ecore#//typesystem/ITypeScope/getDefinitionElement/type"/>
</genOperations>
<genOperations ecoreOperation="project.ecore#//typesystem/ITypeScope/getTypeDefinitionsList"/>
</genClasses>
<genClasses image="false" ecoreClass="project.ecore#//typesystem/ITypeDefinition">
<genOperations ecoreOperation="project.ecore#//typesystem/ITypeDefinition/createIType"/>
......@@ -52,6 +53,7 @@
<genOperations ecoreOperation="project.ecore#//typesystem/IFunctionScope/getDefinitionElement">
<genParameters ecoreParameter="project.ecore#//typesystem/IFunctionScope/getDefinitionElement/type"/>
</genOperations>
<genOperations ecoreOperation="project.ecore#//typesystem/IFunctionScope/getFunctionDefinitionsList"/>
</genClasses>
<genClasses image="false" ecoreClass="project.ecore#//typesystem/IFunctionDefinition"/>
<genClasses image="false" ecoreClass="project.ecore#//typesystem/IVariableScope">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment