本文整理匯總了Java中org.eclipse.emf.ecore.util.EcoreUtil.getRootContainer方法的典型用法代碼示例。如果您正苦於以下問題:Java EcoreUtil.getRootContainer方法的具體用法?Java EcoreUtil.getRootContainer怎麽用?Java EcoreUtil.getRootContainer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.emf.ecore.util.EcoreUtil
的用法示例。
在下文中一共展示了EcoreUtil.getRootContainer方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: contentTypeMustBeDefined
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
private List<Diagnostic> contentTypeMustBeDefined(Body body) {
final List<Diagnostic> validationErrors = new ArrayList<>();
final EObject rootContainer = EcoreUtil.getRootContainer(body);
final boolean contentTypesDefined;
if (rootContainer instanceof Api) {
final Api api = (Api) rootContainer;
contentTypesDefined = api.getMediaType().size() > 0 || body.getContentTypes().size() > 0;
} else {
contentTypesDefined = body.getContentTypes().size() > 0;
}
if (!contentTypesDefined) {
validationErrors.add(error("Content type undefined", body));
}
return validationErrors;
}
示例2: getSingleElement
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
* Enhanced query-Method marking the originating import as used.
*
* @see org.eclipse.xtext.scoping.IScope#getSingleElement(org.eclipse.xtext.naming.QualifiedName)
*/
@Override
public IEObjectDescription getSingleElement(QualifiedName name) {
IEObjectDescription ret = delegatee.getSingleElement(name);
if (ret == null)
return null;
ImportSpecifier origin = origins.get(ret);
if (origin != null) {
EObject script = EcoreUtil.getRootContainer(origin);
if ((script instanceof Script) && ((Script) script).isFlaggedUsageMarkingFinished()) {
// do nothing as linking phase is over
} else {
markAsUsed(origin);
// TODO: Mark Twin-Ambiguous as well as used.
if (ret instanceof AmbiguousImportDescription) {
AmbiguousImportDescription ambiguousImportDescription = (AmbiguousImportDescription) ret;
for (ImportSpecifier ispec : ambiguousImportDescription.getOriginatingImports()) {
markAsUsed(ispec);
}
} else if (ret instanceof PlainAccessOfAliasedImportDescription) {
PlainAccessOfAliasedImportDescription plainAccess = (PlainAccessOfAliasedImportDescription) ret;
ImportSpecifier plainImport = origins.get(plainAccess.getDelegate());
if (plainImport != null)
markAsUsed(plainImport);
}
}
}
return ret;
}
示例3: getExtendedPackage
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
public String getExtendedPackage(EObject eObject) {
Extension extension = (Extension) EcoreUtil.getRootContainer(eObject);
String extensionFile = OcciRegistry.getInstance().getFileURI(extension.getScheme());
String[] args = extensionFile.split("\\/");
return args[args.length-3];
}