blob: 81d7305995df03e7488c1fe0e1f901640d74ac88 (
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
57
58
59
60
|
/**
* <copyright>
*
* Copyright (c) 2010,2011 E.D.Willink and others.
* 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:
* E.D.Willink - initial API and implementation
*
* </copyright>
*
* $Id: EnumCSAttribution.java,v 1.3 2011/04/25 09:50:02 ewillink Exp $
*/
package org.eclipse.qvtd.pivot.qvtcore.attributes;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.ocl.examples.pivot.scoping.AbstractAttribution;
import org.eclipse.ocl.examples.pivot.scoping.EnvironmentView;
import org.eclipse.ocl.examples.pivot.scoping.ScopeView;
import org.eclipse.qvtd.pivot.qvtbase.Transformation;
import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseUtil;
import org.eclipse.qvtd.pivot.qvtcore.Area;
import org.eclipse.qvtd.pivot.qvtcore.BottomPattern;
import org.eclipse.qvtd.pivot.qvtcore.CoreDomain;
import org.eclipse.qvtd.pivot.qvtcore.Mapping;
public class BottomPatternAttribution extends AbstractAttribution
{
public static final BottomPatternAttribution INSTANCE = new BottomPatternAttribution();
@Override
public ScopeView computeLookup(@NonNull EObject target, @NonNull EnvironmentView environmentView, @NonNull ScopeView scopeView) {
Area area = ((BottomPattern)target).getArea();
if (area instanceof Mapping) {
Mapping mapping = (Mapping)area;;
Transformation transformation = QVTbaseUtil.getContainingTransformation(mapping);
if (transformation != null) {
for (TypedModel typedModel : transformation.getModelParameter()) {
for (org.eclipse.ocl.examples.pivot.Package pPackage : typedModel.getUsedPackage()) {
environmentView.addNamedElement(pPackage);
environmentView.addNamedElements(pPackage.getOwnedType());
}
}
}
QVTcoreEnvironmentUtil.addMiddleBottomVariables(environmentView, mapping);
}
else {
CoreDomain domain = (CoreDomain)area;
TypedModel typedModel = domain.getTypedModel();
Mapping mapping = (Mapping) domain.getRule();
QVTcoreEnvironmentUtil.addSideBottomVariables(environmentView, mapping, typedModel);
}
return scopeView.getParent();
}
}
|