blob: 4e25e4ae28626b106ea22ea0bbb0debc0865fcdb [file] [log] [blame]
/**
* <copyright>
*
* Copyright (c) 2012 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>
*/
package org.eclipse.ocl.examples.xtext.essentialocl.attributes;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.ocl.examples.pivot.ConstructorExp;
import org.eclipse.ocl.examples.pivot.Type;
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.ocl.examples.pivot.utilities.PivotUtil;
import org.eclipse.ocl.examples.xtext.essentialocl.essentialoclcs.ConstructorExpCS;
import org.eclipse.ocl.examples.xtext.essentialocl.essentialoclcs.EssentialOCLCSPackage;
public class ConstructorPartCSAttribution extends AbstractAttribution
{
public static final @NonNull ConstructorPartCSAttribution INSTANCE = new ConstructorPartCSAttribution();
@Override
public ScopeView computeLookup(@NonNull EObject target, @NonNull EnvironmentView environmentView, @NonNull ScopeView scopeView) {
EStructuralFeature containmentFeature = scopeView.getContainmentFeature();
if (containmentFeature == EssentialOCLCSPackage.Literals.CONSTRUCTOR_PART_CS__PROPERTY) {
ConstructorExpCS targetElement = (ConstructorExpCS)target.eContainer();
ConstructorExp pivot = PivotUtil.getPivot(ConstructorExp.class, targetElement);
if (pivot != null) {
Type type = pivot.getType();
if (type != null) {
environmentView.addAllProperties(type, false);
}
}
return null;
}
return scopeView.getParent();
}
}