Class EcoreModelQuery
- java.lang.Object
-
- net.ssehub.easy.dslCore.ui.hyperlinking.AbstractEcoreModelQuery<de.uni_hildesheim.sse.ivml.Project,ModelElementTypeFinder.ModelElementDescription>
-
- de.uni_hildesheim.sse.ui.hyperlinking.EcoreModelQuery
-
- All Implemented Interfaces:
IEcoreModelQuery<de.uni_hildesheim.sse.ivml.Project,ModelElementTypeFinder.ModelElementDescription>
public class EcoreModelQuery extends AbstractEcoreModelQuery<de.uni_hildesheim.sse.ivml.Project,ModelElementTypeFinder.ModelElementDescription>
-
-
Field Summary
Fields Modifier and Type Field Description static EcoreModelQueryINSTANCEThe instance of thisEcoreModelQueryfor retrieving elements from an Ecore-model.
-
Constructor Summary
Constructors Modifier Constructor Description privateEcoreModelQuery()Constructs an instance of thisEcoreModelQuery.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleancompareByBasicType(de.uni_hildesheim.sse.ivml.VariableDeclaration varDecl, ModelElementTypeFinder.ModelElementDescription elementDescription)Checks whether the givenModelElementTypeFinder.ModelElementDescriptiondescribes the givenVariableDeclaration.private booleancompareByDerivedType(de.uni_hildesheim.sse.ivml.VariableDeclaration varDecl, ModelElementTypeFinder.ModelElementDescription elementDescription)Checks whether the givenModelElementTypeFinder.ModelElementDescriptiondescribes the givenVariableDeclaration.private booleancompareByQualifiedName(de.uni_hildesheim.sse.ivml.VariableDeclaration varDecl, ModelElementTypeFinder.ModelElementDescription elementDescription)Checks whether the givenModelElementTypeFinder.ModelElementDescriptiondescribes the givenVariableDeclaration.private java.lang.StringconstructFullTypeDefinition(de.uni_hildesheim.sse.ivml.Type type)Returns the full type definition based on the givenType.private booleanequalNames(de.uni_hildesheim.sse.ivml.VariableDeclaration varDecl, ModelElementTypeFinder.ModelElementDescription elementDescription)Checks whether the name of the givenVariableDeclarationequals the name of the given {@ ModelElementDescription}.org.eclipse.emf.ecore.EObjectgetEcoreElement(CommonXtextEditor<?,de.uni_hildesheim.sse.ivml.Project> ivmlEditor, ModelElementTypeFinder.ModelElementDescription elementDescription)Returns theEObjectof the parse tree of the givenXtextEditor's resource that matches the element described by the givenModelElementTypeFinder.ModelElementDescription.java.lang.StringgetName(de.uni_hildesheim.sse.ivml.Project project)Returns the name of the project.de.uni_hildesheim.sse.ivml.ProjectgetProject(org.eclipse.xtext.nodemodel.ICompositeNode rootNode)Returns theProjectof the Ecore-model represented by the given root node.protected de.uni_hildesheim.sse.ivml.ProjectgetProject(org.eclipse.xtext.resource.XtextResource resource)Returns theProjectin the given resource (IVML-file).private java.util.List<de.uni_hildesheim.sse.ivml.Typedef>getSpecificTypeDefs(java.util.List<de.uni_hildesheim.sse.ivml.Typedef> typeDefs, ModelElementTypeFinder.ClassType specificType)Creates a sub-list of the given list ofTypedefs in which only type definitions are included that provide the specific type definition described by the givenModelElementTypeFinder.ClassType.private booleanisTypeDefClass(ModelElementTypeFinder.ClassType type)Checks whether the givenModelElementTypeFinder.ClassTypedescribes a type definition in IVML, e.g.: Enum OrderedEnum Compound Mappingprivate booleannotEmpty(ModelElementTypeFinder.ModelElementDescription elementDescription)Checks whether the givenModelElementTypeFinder.ModelElementDescriptionis notnulland all information is available (the nestedStrings are notnullor empty).private org.eclipse.emf.ecore.EObjectprocessCompoundElements(de.uni_hildesheim.sse.ivml.TypedefCompound compound, ModelElementTypeFinder.ModelElementDescription elementDescription)private org.eclipse.emf.ecore.EObjectprocessDecisionVariableDeclarations(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclaration> varDecls, ModelElementTypeFinder.ModelElementDescription elementDescription)Returns anEObjectif this object is part of the given list ofVariableDeclarations and matches the element described by the givenModelElementTypeFinder.ModelElementDescription.private org.eclipse.emf.ecore.EObjectprocessProjectContents(de.uni_hildesheim.sse.ivml.ProjectContents projectContents, ModelElementTypeFinder.ModelElementDescription elementDescription)Returns anEObjectif this object is part of the givenProjectContentsand matches the element described by the givenModelElementTypeFinder.ModelElementDescription.private org.eclipse.emf.ecore.EObjectprocessTypeDefinitions(java.util.List<de.uni_hildesheim.sse.ivml.Typedef> typeDefs, ModelElementTypeFinder.ModelElementDescription elementDescription, ModelElementTypeFinder.ClassType searchType)Returns anEObjectif this object is part of the given list ofTypedefs and matches the element described by the givenModelElementTypeFinder.ModelElementDescription.-
Methods inherited from class net.ssehub.easy.dslCore.ui.hyperlinking.AbstractEcoreModelQuery
getRootNode, getXtextResource, notEmpty, notEmpty, notEmpty
-
-
-
-
Field Detail
-
INSTANCE
public static final EcoreModelQuery INSTANCE
The instance of thisEcoreModelQueryfor retrieving elements from an Ecore-model.
-
-
Constructor Detail
-
EcoreModelQuery
private EcoreModelQuery()
Constructs an instance of thisEcoreModelQuery.
-
-
Method Detail
-
getProject
protected de.uni_hildesheim.sse.ivml.Project getProject(org.eclipse.xtext.resource.XtextResource resource)
Returns theProjectin the given resource (IVML-file).- Parameters:
resource- theXtextResourcefrom which theProjectshould be retrieved- Returns:
- the
Projectin the given resource (IVML-file). May returnnullif the given resource isnull, cannot be parsed, or there is noProjectin that file
-
getProject
public de.uni_hildesheim.sse.ivml.Project getProject(org.eclipse.xtext.nodemodel.ICompositeNode rootNode)
Returns theProjectof the Ecore-model represented by the given root node.- Parameters:
rootNode- theICompositeNodewhich is the root of the Ecore-model from which theProjectshould be retrieved- Returns:
- the
Projectin the given resource (IVML-file). May returnnullif the given root node isnull, or there is noProjectin that file
-
getEcoreElement
public org.eclipse.emf.ecore.EObject getEcoreElement(CommonXtextEditor<?,de.uni_hildesheim.sse.ivml.Project> ivmlEditor, ModelElementTypeFinder.ModelElementDescription elementDescription)
Returns theEObjectof the parse tree of the givenXtextEditor's resource that matches the element described by the givenModelElementTypeFinder.ModelElementDescription. The search for this object will be performed in the Ecore-model of the given IVML-editor's resource only. This requires that it is ensured that the given editor displays an IVML-file which includes the desired element.- Parameters:
ivmlEditor- theXtextEditorwhich displays the IVML-file in which the desired element should be foundelementDescription- theModelElementTypeFinder.ModelElementDescriptionthat describes theVarModelelement that should be found in the parse tree of the given editor's resource- Returns:
- the
EObjectthat matches the element described by the givenModelElementTypeFinder.ModelElementDescription. May returnnullif the element could not be found
-
processProjectContents
private org.eclipse.emf.ecore.EObject processProjectContents(de.uni_hildesheim.sse.ivml.ProjectContents projectContents, ModelElementTypeFinder.ModelElementDescription elementDescription)Returns anEObjectif this object is part of the givenProjectContentsand matches the element described by the givenModelElementTypeFinder.ModelElementDescription.- Parameters:
projectContents- theProjectContentsin which to search for the element described by the givenModelElementTypeFinder.ModelElementDescriptionelementDescription- theModelElementTypeFinder.ModelElementDescriptionthat describes theEObjectto be found in theProjectContents- Returns:
- an
EObjectif this object is part of the given projectsProjectContentsand matches the element described by the givenModelElementTypeFinder.ModelElementDescription;nullotherwise.
-
processDecisionVariableDeclarations
private org.eclipse.emf.ecore.EObject processDecisionVariableDeclarations(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclaration> varDecls, ModelElementTypeFinder.ModelElementDescription elementDescription)Returns anEObjectif this object is part of the given list ofVariableDeclarations and matches the element described by the givenModelElementTypeFinder.ModelElementDescription.- Parameters:
varDecls- the list ofVariableDeclarations in which to search for the element described by the givenModelElementTypeFinder.ModelElementDescriptionelementDescription- theModelElementTypeFinder.ModelElementDescriptionthat describes theEObjectto be found in the list ofVariableDeclarations- Returns:
- an
EObjectif this object is part of the given list ofVariableDeclarations and matches the element described by the givenModelElementTypeFinder.ModelElementDescription;nullotherwise.
-
compareByBasicType
private boolean compareByBasicType(de.uni_hildesheim.sse.ivml.VariableDeclaration varDecl, ModelElementTypeFinder.ModelElementDescription elementDescription)Checks whether the givenModelElementTypeFinder.ModelElementDescriptiondescribes the givenVariableDeclaration. This is done by checking the basic type and the name of theVariableDeclarationagainst the type and the name defined in theModelElementTypeFinder.ModelElementDescription.- Parameters:
varDecl- theVariableDeclarationthat is checked against theModelElementTypeFinder.ModelElementDescriptionby type and nameelementDescription- theModelElementTypeFinder.ModelElementDescriptionthat is checked against theVariableDeclarationby type and name- Returns:
trueif the givenModelElementTypeFinder.ModelElementDescriptiondescribes the givenVariableDeclaration.Falseotherwise.
-
compareByQualifiedName
private boolean compareByQualifiedName(de.uni_hildesheim.sse.ivml.VariableDeclaration varDecl, ModelElementTypeFinder.ModelElementDescription elementDescription)Checks whether the givenModelElementTypeFinder.ModelElementDescriptiondescribes the givenVariableDeclaration. This is done by checking the qualified name of theVariableDeclarationagainst the type defined in theModelElementTypeFinder.ModelElementDescriptionand by checking the name of theVariableDeclarationagainst the name defined in theModelElementTypeFinder.ModelElementDescription.- Parameters:
varDecl- theVariableDeclarationthat is checked against theModelElementTypeFinder.ModelElementDescriptionby qualified name (type) and nameelementDescription- theModelElementTypeFinder.ModelElementDescriptionthat is checked against theVariableDeclarationby qualified name (type) and name- Returns:
trueif the givenModelElementTypeFinder.ModelElementDescriptiondescribes the givenVariableDeclaration.Falseotherwise.
-
compareByDerivedType
private boolean compareByDerivedType(de.uni_hildesheim.sse.ivml.VariableDeclaration varDecl, ModelElementTypeFinder.ModelElementDescription elementDescription)Checks whether the givenModelElementTypeFinder.ModelElementDescriptiondescribes the givenVariableDeclaration. This is done by re-constructing the full type definition under the assumption that the givenVariableDeclarationis constructed by a combination of (derived) types, e.g. sequenceOf(refBy(MyInteger)). This re-constructed type is than checked against the type of the givenModelElementTypeFinder.ModelElementDescription. If this type is equal and the name of theVariableDeclarationand in theModelElementTypeFinder.ModelElementDescriptionare equal, both elements describe the same model element.- Parameters:
varDecl- theVariableDeclarationthat is checked against theModelElementTypeFinder.ModelElementDescriptionby type and nameelementDescription- theModelElementTypeFinder.ModelElementDescriptionthat is checked against theVariableDeclarationby type and name- Returns:
trueif the givenModelElementTypeFinder.ModelElementDescriptiondescribes the givenVariableDeclaration.Falseotherwise.
-
constructFullTypeDefinition
private java.lang.String constructFullTypeDefinition(de.uni_hildesheim.sse.ivml.Type type)
Returns the full type definition based on the givenType. This leads to re-construction of combined types like sequenceOf(refBy(MyInteger)).- Parameters:
type- theTypefrom where to start re-constructing the full type definition by recursively checking the sub-types (any valid combination of derived types, qualified names, and basic types).- Returns:
- the full type definition as a
String. May return an empty String the given type isnull.
-
equalNames
private boolean equalNames(de.uni_hildesheim.sse.ivml.VariableDeclaration varDecl, ModelElementTypeFinder.ModelElementDescription elementDescription)Checks whether the name of the givenVariableDeclarationequals the name of the given {@ ModelElementDescription}. This is done by iterating over all variable declaration parts of theVariableDeclarationand checking whether one of these parts match the name of the {@ ModelElementDescription}.- Parameters:
varDecl- theVariableDeclarationof which all variable declaration parts are checked against the name defined by the given {@ ModelElementDescription}elementDescription- theModelElementTypeFinder.ModelElementDescriptionwhich name is checked against all variable declaration parts of the givenVariableDeclaration- Returns:
trueif the name defined in the givenModelElementTypeFinder.ModelElementDescriptionmatches one variable declaration part of the givenVariableDeclaration.Falseotherwise.
-
processTypeDefinitions
private org.eclipse.emf.ecore.EObject processTypeDefinitions(java.util.List<de.uni_hildesheim.sse.ivml.Typedef> typeDefs, ModelElementTypeFinder.ModelElementDescription elementDescription, ModelElementTypeFinder.ClassType searchType)Returns anEObjectif this object is part of the given list ofTypedefs and matches the element described by the givenModelElementTypeFinder.ModelElementDescription. This method compares a filtered subset of the given list ofTypedef. Which specific type ofTypedefwill be used depends on the givenModelElementTypeFinder.ClassTypesearchType. Currently supported types are:Compound,Enum(which will also includeOrderedEnum, andMapping. Note that this kind of comparison requires to ensure that the givenModelElementTypeFinder.ModelElementDescriptiondescribes aTypedef.- Parameters:
typeDefs- the full list ofTypedefs in which to search for the element described by the givenModelElementTypeFinder.ModelElementDescription. Filtering this full list will be done by this method in accordance to the type defined by searchTypeelementDescription- theModelElementTypeFinder.ModelElementDescriptionthat describes the element for which theEObjectshould be found in the list ofTypedefssearchType- the specific type ofTypedefto look for: one ofModelElementTypeFinder.ClassType- Returns:
- an
EObjectif this object is part of the given list ofTypedefs and matches the element described by the givenModelElementTypeFinder.ModelElementDescriptionnullotherwise.
-
processCompoundElements
private org.eclipse.emf.ecore.EObject processCompoundElements(de.uni_hildesheim.sse.ivml.TypedefCompound compound, ModelElementTypeFinder.ModelElementDescription elementDescription)
-
isTypeDefClass
private boolean isTypeDefClass(ModelElementTypeFinder.ClassType type)
Checks whether the givenModelElementTypeFinder.ClassTypedescribes a type definition in IVML, e.g.: Enum OrderedEnum Compound Mapping- Parameters:
type- theModelElementTypeFinder.ClassTypeto check whether this is a class used in IVML to define a new type- Returns:
trueif the givenModelElementTypeFinder.ClassTypematches one of the types listed above.Falseotherwise.
-
getSpecificTypeDefs
private java.util.List<de.uni_hildesheim.sse.ivml.Typedef> getSpecificTypeDefs(java.util.List<de.uni_hildesheim.sse.ivml.Typedef> typeDefs, ModelElementTypeFinder.ClassType specificType)Creates a sub-list of the given list ofTypedefs in which only type definitions are included that provide the specific type definition described by the givenModelElementTypeFinder.ClassType.- Parameters:
typeDefs- the list ofTypedefs from which a subset of specific type definitions should be returnedspecificType- the specific type ofTypedefs to be included in a new list.- Returns:
- a sub-list of the given list of
Typedefs in which only type definitions are included that provide the specific type definition described by the givenModelElementTypeFinder.ClassType. May returnnullif the given list of type definitions isnullor empty. May return an empty list if the given list does not contain type definitions of the desired specific type.
-
notEmpty
private boolean notEmpty(ModelElementTypeFinder.ModelElementDescription elementDescription)
Checks whether the givenModelElementTypeFinder.ModelElementDescriptionis notnulland all information is available (the nestedStrings are notnullor empty).- Parameters:
elementDescription- theModelElementTypeFinder.ModelElementDescriptionto check- Returns:
trueif the givenModelElementTypeFinder.ModelElementDescriptionis notnulland all information is available.Falseotherwise.
-
getName
public java.lang.String getName(de.uni_hildesheim.sse.ivml.Project project)
Description copied from interface:IEcoreModelQueryReturns the name of the project.- Parameters:
project- the project- Returns:
- the name of
project
-
-