blob: c869d4e8b346ba1cbb0c26a94a94f1cc04c65e9b [file] [log] [blame]
/**
* Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Pirchner - Initial implementation
*/
package org.eclipse.osbp.ecview.uisemantics.scoping;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.xtext.resource.EObjectDescription;
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.scoping.IScope;
import org.eclipse.xtext.scoping.impl.AbstractScope;
public class EPackageContentScope extends AbstractScope {
private EPackage pkg;
protected EPackageContentScope(EPackage pkg) {
super(IScope.NULLSCOPE, true);
this.pkg = pkg;
}
@Override
protected Iterable<IEObjectDescription> getAllLocalElements() {
List<IEObjectDescription> result = new ArrayList<IEObjectDescription>();
if (pkg != null) {
for (EClassifier eClassifier : pkg.getEClassifiers()) {
if (eClassifier instanceof EClass) {
result.add(EObjectDescription.create(eClassifier.getName(),
eClassifier));
}
}
}
return result;
}
}