Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: cc554452b16214b7b2e530465359b3928f045cec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright (c) 2007, 2008 Borland Software Corporation
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Alexander Shatalin (Borland) - initial API and implementation
 */

import "http://www.eclipse.org/gmf/2008/GenModel";
import "http://www.eclipse.org/emf/2002/Ecore";
import "http://www.eclipse.org/emf/2002/GenModel";

boolean isTypeLink(gmfgen::GenLink link) :
	{link.modelFacet}.typeSelect(gmfgen::TypeLinkModelFacet).size() > 0
;

boolean isRefLink(gmfgen::GenLink link) :
	{link.modelFacet}.typeSelect(gmfgen::FeatureLinkModelFacet).size() > 0
;

boolean canBeSource(gmfgen::GenLink link, gmfgen::TypeModelFacet modelFacet) :
	canBeSource(link, modelFacet.metaClass)
;

boolean canBeSource(gmfgen::GenLink link, genmodel::GenClass metaClass) :
	null != link.modelFacet && canBeLinkEnd(link.modelFacet.getSourceType(), metaClass)
;

boolean canBeTarget(gmfgen::GenLink link, gmfgen::TypeModelFacet modelFacet) :
	canBeTarget(link, modelFacet.metaClass)
;

boolean canBeTarget(gmfgen::GenLink link, genmodel::GenClass metaClass) :
	null != link.modelFacet && canBeLinkEnd(link.modelFacet.getTargetType(), metaClass)
;

boolean canBeContainer(gmfgen::GenLink link, genmodel::GenClass metaClass) :
	null != link.modelFacet && canBeLinkEnd(getContainerClass(link.modelFacet), metaClass)
;

private genmodel::GenClass getContainerClass(gmfgen::LinkModelFacet modelFacet) : null  /* Should not be called */ ;

private genmodel::GenClass getContainerClass(gmfgen::TypeLinkModelFacet modelFacet) :
	// can't use getSourceType() here as it respects sourceMetaFeature, which is irrelevant for containment
	modelFacet.childMetaFeature != modelFacet.containmentMetaFeature ? modelFacet.childMetaFeature.genClass : modelFacet.containmentMetaFeature.genClass
;

private genmodel::GenClass getContainerClass(gmfgen::FeatureLinkModelFacet modelFacet) : modelFacet.getSourceType() ;

private boolean canBeLinkEnd(genmodel::GenClass endType, genmodel::GenClass metaClass) :
	null != endType && endType.ecoreClass.isSuperTypeOf(metaClass.ecoreClass)
;

Back to the top